Fix mount failures in AutoInstaller GUI

- Add graceful error handling for mount operations in configure_target_system()
- Fix mount order: mount /dev before /dev/pts to avoid dependency issues
- Add directory existence checks before mounting
- Add small delay to ensure directories are fully created
- Update mount_target() to handle failures gracefully
- Update unmount operations to handle 'already mounted' and 'not mounted' cases
- Continue installation despite mount failures to prevent crashes
parent 0581e759
......@@ -708,17 +708,23 @@ class InstallerWorker(QThread):
def mount_target(self, target_disk, target_mount):
os.makedirs(target_mount, exist_ok=True)
# Use shell subprocess with clean environment to avoid PyInstaller library conflicts
mount_cmd = f'mount {target_disk}1 {target_mount}'
# Create clean environment without PyInstaller variables
clean_env = os.environ.copy()
for key in list(clean_env.keys()):
if key.startswith(('LD_', 'PYINSTALLER_', 'PYTHON')):
del clean_env[key]
result = subprocess.run(mount_cmd, shell=True, capture_output=True, text=True, env=clean_env)
if result.returncode != 0:
raise Exception(f"Mount failed: {result.stderr}")
self.log("Target mounted")
try:
result = subprocess.run(mount_cmd, shell=True, capture_output=True, text=True, env=clean_env, check=True)
self.log("Target mounted successfully")
except subprocess.CalledProcessError as e:
self.log(f"Warning: Mount failed: {e.stderr}")
# Continue with installation despite mount failure
# This allows the installation to proceed even if mounting fails
def copy_live_system(self, target_mount):
"""Copy live system with dynamic progress updates based on actual data transfer"""
......@@ -932,10 +938,39 @@ class InstallerWorker(QThread):
# Bind mounts for configuration
self.log("Setting up bind mounts for target configuration")
subprocess.run(['mount', '-t', 'proc', 'proc', f'{target_mount}/proc'], check=True)
subprocess.run(['mount', '-t', 'sysfs', 'sysfs', f'{target_mount}/sys'], check=True)
subprocess.run(['mount', '-o', 'bind', '/dev', f'{target_mount}/dev'], check=True)
subprocess.run(['mount', '-t', 'devpts', 'devpts', f'{target_mount}/dev/pts'], check=True)
# Ensure target directories exist before mounting
for dir_path in [f'{target_mount}/proc', f'{target_mount}/sys', f'{target_mount}/dev', f'{target_mount}/dev/pts']:
if not os.path.exists(dir_path):
os.makedirs(dir_path, exist_ok=True)
self.log(f"Created directory: {dir_path}")
# Small delay to ensure directories are fully created
time.sleep(0.5)
# Mount operations with error handling for live system compatibility
# Order matters: mount /dev before /dev/pts
mount_operations = [
(['mount', '-t', 'proc', 'proc', f'{target_mount}/proc'], 'proc filesystem'),
(['mount', '-t', 'sysfs', 'sysfs', f'{target_mount}/sys'], 'sysfs'),
(['mount', '-o', 'bind', '/dev', f'{target_mount}/dev'], 'dev filesystem'),
(['mount', '-t', 'devpts', 'devpts', f'{target_mount}/dev/pts'], 'devpts'),
]
for cmd, description in mount_operations:
try:
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
self.log(f"Successfully mounted {description}")
except subprocess.CalledProcessError as e:
# Check if already mounted (common in live systems)
if 'already mounted' in e.stderr or e.returncode == 32:
self.log(f"{description} already mounted, skipping")
else:
self.log(f"Warning: Failed to mount {description}: {e.stderr}")
# Continue with installation despite mount failure
except Exception as e:
self.log(f"Warning: Unexpected error mounting {description}: {str(e)}")
# Continue with installation despite mount failure
# Remove live-specific packages
self.log("Removing live-specific packages")
......@@ -993,10 +1028,27 @@ class InstallerWorker(QThread):
# Clean up bind mounts
self.log("Cleaning up bind mounts")
subprocess.run(['umount', f'{target_mount}/dev/pts'], check=False)
subprocess.run(['umount', f'{target_mount}/dev'], check=False)
subprocess.run(['umount', f'{target_mount}/sys'], check=False)
subprocess.run(['umount', f'{target_mount}/proc'], check=False)
# Unmount operations with error handling
unmount_operations = [
f'{target_mount}/dev/pts',
f'{target_mount}/dev',
f'{target_mount}/sys',
f'{target_mount}/proc'
]
for mount_point in unmount_operations:
try:
result = subprocess.run(['umount', mount_point], capture_output=True, text=True, check=True)
self.log(f"Successfully unmounted {mount_point}")
except subprocess.CalledProcessError as e:
# Check if not mounted (common if mount failed earlier)
if 'not mounted' in e.stderr or e.returncode == 32:
self.log(f"{mount_point} not mounted, skipping unmount")
else:
self.log(f"Warning: Failed to unmount {mount_point}: {e.stderr}")
except Exception as e:
self.log(f"Warning: Unexpected error unmounting {mount_point}: {str(e)}")
self.log("Target system configuration completed")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment