Go back to manually updating fstab because the new method didn't work.
This commit is contained in:
@@ -292,11 +292,14 @@ if [[ "$TARGET_DEVICE" =~ nvme|mmcblk ]]; then
|
||||
fi
|
||||
|
||||
# Find the actual root partition (might not be partition 1)
|
||||
echo "Searching for ext4 root partition..."
|
||||
for part in "${TARGET_DEVICE}"*; do
|
||||
if [[ "$part" != "$TARGET_DEVICE" ]]; then
|
||||
fstype=$(lsblk -no FSTYPE "$part" 2>/dev/null)
|
||||
echo "Checking $part: filesystem type = $fstype"
|
||||
if [[ "$fstype" == "ext4" ]]; then
|
||||
TARGET_ROOT_PART="$part"
|
||||
echo "Found root partition: $TARGET_ROOT_PART"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
@@ -304,7 +307,8 @@ done
|
||||
|
||||
# Regenerate partition UUIDs and labels to prevent boot conflicts with USB
|
||||
echo "Regenerating partition identifiers..."
|
||||
regenerate_partition_identifiers "$TARGET_DEVICE" > /dev/null
|
||||
mapfile -t uuid_mappings < <(regenerate_partition_identifiers "$TARGET_DEVICE")
|
||||
echo "Found ${#uuid_mappings[@]} UUID mappings to update"
|
||||
|
||||
# Mount and make final adjustments
|
||||
TEMP_MOUNT="/mnt/stormux_target"
|
||||
@@ -323,21 +327,34 @@ if sudo mount "$TARGET_ROOT_PART" "$TEMP_MOUNT" 2>/dev/null; then
|
||||
# Set immutable attribute to prevent accidental deletion
|
||||
sudo chattr +i "$TEMP_MOUNT/home/stormux/.baremetal" 2>/dev/null || echo "Warning: Could not set immutable attribute on .baremetal"
|
||||
|
||||
# Generate new fstab using genfstab
|
||||
echo "Generating new fstab with current UUIDs..."
|
||||
if command -v genfstab >/dev/null 2>&1; then
|
||||
# Update fstab with new UUIDs if any were generated
|
||||
if [[ ${#uuid_mappings[@]} -gt 0 ]]; then
|
||||
echo "Updating fstab with new UUIDs..."
|
||||
# Backup original fstab
|
||||
sudo cp "$TEMP_MOUNT/etc/fstab" "$TEMP_MOUNT/etc/fstab.backup" || echo "Warning: Could not backup fstab"
|
||||
|
||||
# Generate new fstab based on current mount points
|
||||
if genfstab -U "$TEMP_MOUNT" | sudo tee "$TEMP_MOUNT/etc/fstab" > /dev/null; then
|
||||
echo "fstab generated successfully with genfstab"
|
||||
else
|
||||
echo "Warning: genfstab failed, restoring backup"
|
||||
sudo cp "$TEMP_MOUNT/etc/fstab.backup" "$TEMP_MOUNT/etc/fstab" 2>/dev/null || true
|
||||
fi
|
||||
# Apply UUID updates to fstab
|
||||
temp_fstab=$(mktemp)
|
||||
sudo cp "$TEMP_MOUNT/etc/fstab" "$temp_fstab"
|
||||
|
||||
for mapping in "${uuid_mappings[@]}"; do
|
||||
if [[ "$mapping" =~ ^UUID_MAPPING:([^:]+):([^:]+)$ ]]; then
|
||||
old_uuid="${BASH_REMATCH[1]}"
|
||||
new_uuid="${BASH_REMATCH[2]}"
|
||||
|
||||
# Replace old UUID with new UUID in fstab
|
||||
sed -i "s/UUID=$old_uuid/UUID=$new_uuid/g" "$temp_fstab"
|
||||
echo "Updated fstab: $old_uuid -> $new_uuid"
|
||||
fi
|
||||
done
|
||||
|
||||
# Copy updated fstab back
|
||||
sudo cp "$temp_fstab" "$TEMP_MOUNT/etc/fstab"
|
||||
rm -f "$temp_fstab"
|
||||
echo "fstab updated successfully"
|
||||
else
|
||||
echo "Warning: genfstab not available - fstab may have incorrect UUIDs"
|
||||
echo "No UUID mappings found - keeping original fstab"
|
||||
sudo cp "$TEMP_MOUNT/etc/fstab" "$TEMP_MOUNT/etc/fstab.backup" || echo "Warning: Could not backup fstab"
|
||||
fi
|
||||
|
||||
echo "Unmounting target partition..."
|
||||
|
||||
Reference in New Issue
Block a user