fstab changes

This commit is contained in:
2026-07-13 13:44:25 -05:00
parent 581a827831
commit 3777d25662
2 changed files with 64 additions and 29 deletions
+45 -29
View File
@@ -11,7 +11,7 @@ NO_RETABLE=false
NO_USB=false NO_USB=false
NO_CLEANUP=false NO_CLEANUP=false
IMG_FILE="PBX-root.img.lz4" IMG_FILE="PBX-Image-*.tar.zst"
MOUNT_PATH="/mnt/debian" MOUNT_PATH="/mnt/debian"
MOUNT_POINTS=("/dev" "/dev/pts" "/proc" "/sys" "/run") MOUNT_POINTS=("/dev" "/dev/pts" "/proc" "/sys" "/run")
@@ -74,8 +74,10 @@ main() {
make_filesystem make_filesystem
fi fi
mount_chroot mount_partitions
write_img write_img
mount_chroot
gen_fstab gen_fstab
install_grub install_grub
@@ -121,9 +123,24 @@ dialogue() {
echo "Chose disk $disk_name" echo "Chose disk $disk_name"
echo echo
echo -e "${RED}WARNING: ALL DATA ON ${disk_name} WILL BE DESTROYED${RESET}"
lsblk $disk_name 2>/dev/null || true
echo
read -rp "Are you sure you want to continue? (yes/no): " confirm
if [[ "$confirm" != "yes" ]]; then
echo "Aborted."
exit 0
fi
echo "Chose disk $disk_name"
echo
} }
rewrite_gpt_table() { rewrite_gpt_table() {
vgchange -an $VGROUP 2>/dev/null || true
vgremove -f $VGROUP 2>/dev/null || true
pvremove -ff $ROOT_PART 2>/dev/null || true
sgdisk -Z $disk_name sgdisk -Z $disk_name
sgdisk -c $disk_name sgdisk -c $disk_name
@@ -159,10 +176,10 @@ lvm_init() {
} }
make_filesystem() { make_filesystem() {
mkfs.vfat -F 32 $EFI_PART mkfs.vfat -I -F 32 $EFI_PART
mkfs.ext4 $BOOT_PART mkfs.ext4 -F $BOOT_PART
mkfs.ext4 "${VG_PATH}${ROOT_LV}" mkfs.ext4 -F "${VG_PATH}${ROOT_LV}"
mkswap "${VG_PATH}${SWAP_LV}" mkswap -f "${VG_PATH}${SWAP_LV}"
echo -e "${GREEN}Make filesystems finished.${RESET}" echo -e "${GREEN}Make filesystems finished.${RESET}"
} }
@@ -172,22 +189,19 @@ write_img() {
return 0 return 0
fi fi
img_file_dir="null" local img_file_dir=$(ls -1 ./PBX-Image-*.tar.zst 2>/dev/null | head -n1)
if [[ -f "./${IMG_FILE}" ]]; then if [[ -z "$img_file_dir" ]]; then
img_file_dir="./${IMG_FILE}" img_file_dir=$(ls -1 ./Image/PBX-Image-*.tar.zst 2>/dev/null | head -n1)
elif [[ -f "./Image/${IMG_FILE}" ]]; then fi
img_file_dir="./Image/${IMG_FILE}" if [[ -z "$img_file_dir" ]]; then
elif [[ ! -f $img_file_dir ]]; then echo -e "${RED}NO TAR.ZST FILE FOUND${RESET}"
echo -e "${RED}NO IMG FILE FOUND${RESET}"
exit 100 exit 100
fi fi
echo "Writing image to ${VG_PATH}${ROOT_LV}..." echo "Writing image to ${VG_PATH}${ROOT_LV}..."
lz4 -dc ${img_file_dir} | partclone.ext4 -r -o "${VG_PATH}${ROOT_LV}" pv "${img_file_dir}" | tar -I zstd -x -C "${MOUNT_PATH}"
tar -I zstd -xvf "${img_file_dir}" -C "${MOUNT_PATH}"
echo -e "${GREEN}Finished writing image to disk${RESET}" echo -e "${GREEN}Finished writing image to disk${RESET}"
} }
@@ -208,25 +222,27 @@ get_partition() {
get_partuuid() { get_partuuid() {
local target_part="$1" local target_part="$1"
local part_uuid="$( blkid -s UUID -o value "$target_part"
lsblk -ln -o PATH,PARTUUID $disk_name | awk -v target_part="$target_part" '$1==target_part {print $2}' }
)"
printf "$part_uuid" mount_partitions() {
echo "Mounting partitions..."
vgchange -ay $VGROUP
mkdir -p "${MOUNT_PATH}"
mount "${VG_PATH}${ROOT_LV}" $MOUNT_PATH
mkdir -p "${MOUNT_PATH}/boot"
mount $BOOT_PART "${MOUNT_PATH}/boot"
mkdir -p "${MOUNT_PATH}/boot/efi"
mount $EFI_PART "${MOUNT_PATH}/boot/efi"
} }
mount_chroot() { mount_chroot() {
vgchange -ay $VGROUP
echo "Mounting restored system..." echo "Mounting restored system..."
mkdir -p "${MOUNT_PATH}/boot"
mkdir -p "${MOUNT_PATH}/boot/efi"
mount "${VG_PATH}${ROOT_LV}" $MOUNT_PATH
mount $BOOT_PART "${MOUNT_PATH}/boot"
mount $EFI_PART "${MOUNT_PATH}/boot/efi"
for i in "${MOUNT_POINTS[@]}"; do mount --bind -m "$i" "${MOUNT_PATH}${i}"; done for i in "${MOUNT_POINTS[@]}"; do mount --bind -m "$i" "${MOUNT_PATH}${i}"; done
echo -e "${GREEN}Mounts prepared for chroot.${RESET}" echo -e "${GREEN}Mounts prepared for chroot.${RESET}"
+19
View File
@@ -0,0 +1,19 @@
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mapper/SangomaPBX--vg-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/vda2 during installation
UUID=BOOT_UUID /boot ext4 defaults 0 2
# /boot/efi was on /dev/vda1 during installation
UUID=EFI_UUID /boot/efi vfat umask=0077 0 1
/dev/mapper/SangomaPBX--vg-swap_1 none swap sw 0 0