More fixes to install to disk
This commit is contained in:
@@ -19,9 +19,23 @@ log_error() {
|
|||||||
echo "[ERROR] $*" | tee -a "$LOGFILE" >&2
|
echo "[ERROR] $*" | tee -a "$LOGFILE" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup_mounts() {
|
||||||
|
# Clean up any leftover mounts
|
||||||
|
local mount_point="${1:-/mnt/stormux_target}"
|
||||||
|
if [[ -d "$mount_point" ]]; then
|
||||||
|
sudo umount "$mount_point/boot" 2>/dev/null || true
|
||||||
|
sudo umount "$mount_point/proc" 2>/dev/null || true
|
||||||
|
sudo umount "$mount_point/sys" 2>/dev/null || true
|
||||||
|
sudo umount "$mount_point/dev" 2>/dev/null || true
|
||||||
|
sudo umount "$mount_point" 2>/dev/null || true
|
||||||
|
sudo rmdir "$mount_point" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
error_exit() {
|
error_exit() {
|
||||||
log_error "$1"
|
log_error "$1"
|
||||||
echo "Installation failed. Log file: $LOGFILE"
|
echo "Installation failed. Log file: $LOGFILE"
|
||||||
|
cleanup_mounts
|
||||||
restore_speech
|
restore_speech
|
||||||
echo
|
echo
|
||||||
read -rp "Press enter to continue..."
|
read -rp "Press enter to continue..."
|
||||||
@@ -102,6 +116,8 @@ detect_partitions() {
|
|||||||
part=$(echo "$line" | awk '{print $1}')
|
part=$(echo "$line" | awk '{print $1}')
|
||||||
# Remove lsblk tree characters that break mount commands
|
# Remove lsblk tree characters that break mount commands
|
||||||
part="${part//[├─└│]/}"
|
part="${part//[├─└│]/}"
|
||||||
|
# Add /dev/ prefix if not present
|
||||||
|
[[ "$part" != /dev/* ]] && part="/dev/$part"
|
||||||
fstype=$(echo "$line" | awk '{print $2}')
|
fstype=$(echo "$line" | awk '{print $2}')
|
||||||
label=$(echo "$line" | awk '{print $3}')
|
label=$(echo "$line" | awk '{print $3}')
|
||||||
|
|
||||||
@@ -440,7 +456,8 @@ log "Syncing data to disk..."
|
|||||||
sudo sync
|
sudo sync
|
||||||
|
|
||||||
log "Refreshing partition table..."
|
log "Refreshing partition table..."
|
||||||
sudo partprobe "$TARGET_DEVICE" 2>&1 | tee -a "$LOGFILE" || log "Warning: partprobe reported issues"
|
# Use -s flag for script mode, pipe 'Fix' response for GPT expansion
|
||||||
|
echo "Fix" | sudo partprobe -s "$TARGET_DEVICE" 2>&1 | tee -a "$LOGFILE" || log "Warning: partprobe reported issues"
|
||||||
sudo udevadm settle --timeout=10 || log "Warning: udevadm settle timeout"
|
sudo udevadm settle --timeout=10 || log "Warning: udevadm settle timeout"
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
@@ -461,6 +478,17 @@ log " BIOS: ${target_partitions[bios]:-none}"
|
|||||||
log " EFI: ${target_partitions[efi]:-none}"
|
log " EFI: ${target_partitions[efi]:-none}"
|
||||||
log " Root: ${target_partitions[root]}"
|
log " Root: ${target_partitions[root]}"
|
||||||
|
|
||||||
|
# Regenerate UUIDs and labels BEFORE mounting
|
||||||
|
log "Regenerating partition identifiers..."
|
||||||
|
mapfile -t uuid_mappings < <(regenerate_partition_identifiers "$TARGET_DEVICE" target_partitions)
|
||||||
|
log "Generated ${#uuid_mappings[@]} UUID mappings"
|
||||||
|
|
||||||
|
# Trigger udev to update with new UUIDs
|
||||||
|
log "Updating system device database..."
|
||||||
|
sudo udevadm trigger --subsystem-match=block
|
||||||
|
sudo udevadm settle --timeout=10 || log "Warning: udevadm settle timeout"
|
||||||
|
sleep 1
|
||||||
|
|
||||||
# Mount root partition
|
# Mount root partition
|
||||||
TEMP_MOUNT="/mnt/stormux_target"
|
TEMP_MOUNT="/mnt/stormux_target"
|
||||||
sudo mkdir -p "$TEMP_MOUNT"
|
sudo mkdir -p "$TEMP_MOUNT"
|
||||||
@@ -472,11 +500,6 @@ fi
|
|||||||
|
|
||||||
log "Root partition mounted successfully"
|
log "Root partition mounted successfully"
|
||||||
|
|
||||||
# Regenerate UUIDs and labels
|
|
||||||
log "Regenerating partition identifiers..."
|
|
||||||
mapfile -t uuid_mappings < <(regenerate_partition_identifiers "$TARGET_DEVICE" target_partitions)
|
|
||||||
log "Generated ${#uuid_mappings[@]} UUID mappings"
|
|
||||||
|
|
||||||
# Update fstab with new UUIDs
|
# Update fstab with new UUIDs
|
||||||
if ! update_fstab "$TEMP_MOUNT" "${uuid_mappings[@]}"; then
|
if ! update_fstab "$TEMP_MOUNT" "${uuid_mappings[@]}"; then
|
||||||
error_exit "Failed to update fstab"
|
error_exit "Failed to update fstab"
|
||||||
@@ -501,16 +524,9 @@ if ! validate_installation "$TEMP_MOUNT"; then
|
|||||||
error_exit "Installation validation failed"
|
error_exit "Installation validation failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Unmount EFI partition if mounted
|
# Clean up all mounts
|
||||||
if [[ -n "${target_partitions[efi]:-}" ]] && mountpoint -q "$TEMP_MOUNT/boot"; then
|
log "Unmounting filesystems..."
|
||||||
log "Unmounting EFI partition..."
|
cleanup_mounts "$TEMP_MOUNT"
|
||||||
sudo umount "$TEMP_MOUNT/boot"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Unmount root partition
|
|
||||||
log "Unmounting root partition..."
|
|
||||||
sudo umount "$TEMP_MOUNT"
|
|
||||||
sudo rmdir "$TEMP_MOUNT"
|
|
||||||
|
|
||||||
# Restore speech
|
# Restore speech
|
||||||
restore_speech
|
restore_speech
|
||||||
|
|||||||
Reference in New Issue
Block a user