Improve the install to disk script.
This commit is contained in:
@@ -54,6 +54,83 @@ get_disk_info() {
|
||||
echo "$size - $model"
|
||||
}
|
||||
|
||||
# Function to rename partition labels to prevent boot conflicts
|
||||
rename_partition_labels() {
|
||||
local target_device="$1"
|
||||
echo "Renaming partition labels to prevent boot conflicts..."
|
||||
|
||||
# Get all partitions on the target device
|
||||
local partitions=()
|
||||
while IFS= read -r partition; do
|
||||
if [[ "$partition" != "$target_device" ]]; then
|
||||
partitions+=("$partition")
|
||||
fi
|
||||
done < <(lsblk -lpno NAME "$target_device" 2>/dev/null | grep "^${target_device}")
|
||||
|
||||
# Rename each partition based on filesystem type
|
||||
for partition in "${partitions[@]}"; do
|
||||
local fstype
|
||||
local current_label
|
||||
fstype=$(lsblk -no FSTYPE "$partition" 2>/dev/null)
|
||||
current_label=$(lsblk -no LABEL "$partition" 2>/dev/null)
|
||||
|
||||
# Skip if no filesystem or no current label
|
||||
[[ -z "$fstype" || -z "$current_label" ]] && continue
|
||||
|
||||
# Determine new label based on current label and add -HDD suffix
|
||||
local new_label=""
|
||||
case "$current_label" in
|
||||
"STORMUX"|"stormux")
|
||||
new_label="STORMUX-HDD"
|
||||
;;
|
||||
"BOOT"|"boot"|"ESP")
|
||||
new_label="BOOT-HDD"
|
||||
;;
|
||||
*)
|
||||
# For any other label, just add -HDD suffix, truncate if too long
|
||||
new_label="${current_label}-HDD"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Truncate label if too long (filesystem limits)
|
||||
case "$fstype" in
|
||||
"vfat"|"fat32"|"fat16")
|
||||
# FAT32 has 11 character limit
|
||||
new_label="${new_label:0:11}"
|
||||
if command -v fatlabel >/dev/null 2>&1; then
|
||||
sudo fatlabel "$partition" "$new_label" 2>/dev/null || echo "Warning: Could not rename FAT partition $partition"
|
||||
fi
|
||||
;;
|
||||
"ext2"|"ext3"|"ext4")
|
||||
# ext* has 16 character limit
|
||||
new_label="${new_label:0:16}"
|
||||
if command -v tune2fs >/dev/null 2>&1; then
|
||||
sudo tune2fs -L "$new_label" "$partition" 2>/dev/null || echo "Warning: Could not rename ext partition $partition"
|
||||
fi
|
||||
;;
|
||||
"ntfs")
|
||||
# NTFS has 32 character limit
|
||||
new_label="${new_label:0:32}"
|
||||
if command -v ntfslabel >/dev/null 2>&1; then
|
||||
sudo ntfslabel "$partition" "$new_label" 2>/dev/null || echo "Warning: Could not rename NTFS partition $partition"
|
||||
fi
|
||||
;;
|
||||
"xfs")
|
||||
# XFS has 12 character limit
|
||||
new_label="${new_label:0:12}"
|
||||
if command -v xfs_admin >/dev/null 2>&1; then
|
||||
sudo xfs_admin -L "$new_label" "$partition" 2>/dev/null || echo "Warning: Could not rename XFS partition $partition"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Info: Skipping unknown filesystem type '$fstype' on $partition"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Renamed partition $partition: '$current_label' -> '$new_label'"
|
||||
done
|
||||
}
|
||||
|
||||
# Welcome message
|
||||
clear
|
||||
echo "Stormux Gaming Image - USB to Disk Installer"
|
||||
@@ -179,17 +256,15 @@ if sudo mount "$TARGET_ROOT_PART" "$TEMP_MOUNT" 2>/dev/null; then
|
||||
# Remove any USB-specific markers
|
||||
sudo rm -f "$TEMP_MOUNT/home/stormux/.firstboot" 2>/dev/null || true
|
||||
|
||||
# Remove STORMUX label from filesystem to prevent false USB detection
|
||||
if command -v tune2fs >/dev/null 2>&1; then
|
||||
sudo tune2fs -L "" "$TARGET_ROOT_PART" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Update any USB-specific configurations if needed
|
||||
|
||||
sudo umount "$TEMP_MOUNT"
|
||||
fi
|
||||
sudo rmdir "$TEMP_MOUNT"
|
||||
|
||||
# Rename all partition labels to prevent boot conflicts with USB
|
||||
rename_partition_labels "$TARGET_DEVICE"
|
||||
|
||||
# Success message
|
||||
echo
|
||||
echo "Installation completed successfully!"
|
||||
|
||||
Reference in New Issue
Block a user