lvm_init
This commit is contained in:
+30
-17
@@ -11,6 +11,7 @@ IMG_FILE="PBX.img3.lz4"
|
||||
NO_WRITE=false
|
||||
NO_RETABLE=false
|
||||
NO_USB=false
|
||||
NO_CLEANUP=false
|
||||
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
@@ -26,6 +27,10 @@ for arg in "$@"; do
|
||||
NO_USB=true
|
||||
shift
|
||||
;;
|
||||
--nocleanup)
|
||||
NO_CLEANUP=true
|
||||
shift
|
||||
;;
|
||||
-h)
|
||||
printf "%-20s %s\n" "Flags:" "Description:"
|
||||
echo
|
||||
@@ -61,21 +66,13 @@ main() {
|
||||
else
|
||||
rewrite_gpt_table
|
||||
make_filesystem
|
||||
lvm_init
|
||||
fi
|
||||
|
||||
if [[ $NO_WRITE == true ]]; then
|
||||
echo -e "${YELLOW}--nowrite is specified. No need for Img no disks will be written to${RESET}"
|
||||
fi
|
||||
|
||||
# Resize physical volume
|
||||
echo "Resizing physical volume..."
|
||||
pvresize $(get_partition $disk_name "3") || true
|
||||
|
||||
# Resize swap and root logical volumes
|
||||
echo "Resizing swap and root volumes..."
|
||||
#lvresize -L +7G PBX-vg/swap_1
|
||||
lvresize -l +100%FREE --resizefs PBX-vg/root
|
||||
|
||||
echo "Generating fstab..."
|
||||
boot_uuid=$()
|
||||
|
||||
@@ -94,6 +91,18 @@ update-grub
|
||||
echo -e "${GREEN}Restore and resize complete!${RESET}"
|
||||
}
|
||||
|
||||
rewrite_gpt_table() {
|
||||
sgdisk -Z $disk_name
|
||||
|
||||
sgdisk -c $disk_name
|
||||
|
||||
sgdisk -n 1:1MiB:+512M -t 1:ef00 -c 1:"EFI System" $disk_name
|
||||
sgdisk -n 2:0:+1G -t 2:8300 -c 2:"boot" $disk_name
|
||||
sgdisk -n 3:0:0 -t 3:8e00 -c 3:"Linux LVM" $disk_name
|
||||
|
||||
partprobe || true
|
||||
}
|
||||
|
||||
write_img() {
|
||||
img_file_dir="null"
|
||||
|
||||
@@ -107,20 +116,19 @@ write_img() {
|
||||
|
||||
echo "Writing image to $(get_partition $disk_name "3")..."
|
||||
|
||||
lz4 -dc ${img_file_dir} | dd of=$(get_partition $disk_name "3") status=progress
|
||||
lz4 -dc ${img_file_dir} | partclone.ext4 -r -o $(get_partition $disk_name "3")
|
||||
partprobe || true
|
||||
}
|
||||
|
||||
rewrite_gpt_table() {
|
||||
sgdisk -Z $disk_name
|
||||
lvm_init() {
|
||||
pvcreate $(get_partition $disk_name "3")
|
||||
|
||||
sgdisk -c $disk_name
|
||||
vgcreate PBX-vg $(get_partition $disk_name "3")
|
||||
|
||||
sgdisk -n 1:1MiB:+512M -t 1:ef00 -c 1:"EFI System" $disk_name
|
||||
sgdisk -n 2:0:+1G -t 2:8300 -c 2:"boot" $disk_name
|
||||
sgdisk -n 3:0:0 -t 3:8e00 -c 3:"Linux LVM" $disk_name
|
||||
vgchange -ay PBX-vg
|
||||
|
||||
partprobe || true
|
||||
lvcreate -L 4G PBX-vg -n swap_1
|
||||
lvcreate -l 100%FREE PBX-vg -n root
|
||||
}
|
||||
|
||||
make_filesystem() {
|
||||
@@ -136,6 +144,11 @@ root_check() {
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ $NO_CLEANUP = true ]]; then
|
||||
echo -e "${YELLOW}No cleanup specified. Make sure to manually clean mounts." 1>&2
|
||||
exit 100
|
||||
fi
|
||||
|
||||
echo "Cleaning Mounts"
|
||||
|
||||
umount -lf /mnt/ventoy 2>/dev/null || true
|
||||
|
||||
Reference in New Issue
Block a user