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
|
fi
|
||||||
|
|
||||||
# Find the actual root partition (might not be partition 1)
|
# Find the actual root partition (might not be partition 1)
|
||||||
|
echo "Searching for ext4 root partition..."
|
||||||
for part in "${TARGET_DEVICE}"*; do
|
for part in "${TARGET_DEVICE}"*; do
|
||||||
if [[ "$part" != "$TARGET_DEVICE" ]]; then
|
if [[ "$part" != "$TARGET_DEVICE" ]]; then
|
||||||
fstype=$(lsblk -no FSTYPE "$part" 2>/dev/null)
|
fstype=$(lsblk -no FSTYPE "$part" 2>/dev/null)
|
||||||
|
echo "Checking $part: filesystem type = $fstype"
|
||||||
if [[ "$fstype" == "ext4" ]]; then
|
if [[ "$fstype" == "ext4" ]]; then
|
||||||
TARGET_ROOT_PART="$part"
|
TARGET_ROOT_PART="$part"
|
||||||
|
echo "Found root partition: $TARGET_ROOT_PART"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -304,7 +307,8 @@ done
|
|||||||
|
|
||||||
# Regenerate partition UUIDs and labels to prevent boot conflicts with USB
|
# Regenerate partition UUIDs and labels to prevent boot conflicts with USB
|
||||||
echo "Regenerating partition identifiers..."
|
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
|
# Mount and make final adjustments
|
||||||
TEMP_MOUNT="/mnt/stormux_target"
|
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
|
# 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"
|
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
|
# Update fstab with new UUIDs if any were generated
|
||||||
echo "Generating new fstab with current UUIDs..."
|
if [[ ${#uuid_mappings[@]} -gt 0 ]]; then
|
||||||
if command -v genfstab >/dev/null 2>&1; then
|
echo "Updating fstab with new UUIDs..."
|
||||||
# Backup original fstab
|
# Backup original fstab
|
||||||
sudo cp "$TEMP_MOUNT/etc/fstab" "$TEMP_MOUNT/etc/fstab.backup" || echo "Warning: Could not backup 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
|
# Apply UUID updates to fstab
|
||||||
if genfstab -U "$TEMP_MOUNT" | sudo tee "$TEMP_MOUNT/etc/fstab" > /dev/null; then
|
temp_fstab=$(mktemp)
|
||||||
echo "fstab generated successfully with genfstab"
|
sudo cp "$TEMP_MOUNT/etc/fstab" "$temp_fstab"
|
||||||
else
|
|
||||||
echo "Warning: genfstab failed, restoring backup"
|
for mapping in "${uuid_mappings[@]}"; do
|
||||||
sudo cp "$TEMP_MOUNT/etc/fstab.backup" "$TEMP_MOUNT/etc/fstab" 2>/dev/null || true
|
if [[ "$mapping" =~ ^UUID_MAPPING:([^:]+):([^:]+)$ ]]; then
|
||||||
fi
|
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
|
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
|
fi
|
||||||
|
|
||||||
echo "Unmounting target partition..."
|
echo "Unmounting target partition..."
|
||||||
|
|||||||
Reference in New Issue
Block a user