Compare commits

..

2 Commits

Author SHA1 Message Date
poslop 1e608196a5 partclone in extract script 2026-04-27 16:01:27 -05:00
poslop 4e3f5a158e Remove USB support 2026-04-27 15:26:47 -05:00
2 changed files with 22 additions and 43 deletions
+12 -28
View File
@@ -7,6 +7,7 @@ YELLOW='\e[33m'
RESET='\e[0m'
MOUNT_POINTS=("/dev" "/dev/pts" "/proc" "/sys" "/sys/firmware/efi/efivars" "/run")
IMG_FILE="PBX.img3.lz4"
NO_WRITE=false
NO_RETABLE=false
NO_USB=false
@@ -93,38 +94,21 @@ update-grub
echo -e "${GREEN}Restore and resize complete!${RESET}"
}
write_image() {
if [[ $NO_USB == true ]]; then
echo "Writing image to $(get_partition $disk_name "3")..."
lz4 -dc ./Image/PBX.img3.lz4 | dd of=$(get_partition $disk_name "3") status=progress
partprobe || true
write_img() {
img_file_dir="null"
if [[ -f "./${IMG_FILE}" ]]; then
img_file_dir="./${IMG_FILE}"
elif [[ ! -f "./Image/${IMG_FILE}" ]]; then
img_file_dir="./Image/${IMG_FILE}"
else
read -rp "Enter the name of the usb partition in /dev/mapper (e.g., sda1): " disk_suffix
usb_name="/dev/mapper/${disk_suffix}"
user_response="n"
read -rp "$(echo -e "${RED}You are about to WRITE and ERASE disk ${disk_name} | Are you sure? y/N: ${RESET}")" user_response
if [[ $user_response != y ]]; then
echo "Exiting script"
exit
fi
echo "Mounting Ventoy..."
mkdir -p /mnt/ventoy
mount $usb_name /mnt/ventoy
cd /mnt/ventoy/Images
echo "Writing image to $(get_partition $disk_name "3")..."
lz4 -dc PBX.img.lz4 | dd of=$(get_partition $disk_name "3") status=progress
partprobe || true
img_file_dir="null"
fi
echo "Writing image to $(get_partition $disk_name "3")..."
lz4 -dc ${img_file_dir} | dd of=$(get_partition $disk_name "3") status=progress
partprobe || true
}
rewrite_gpt_table() {
+10 -15
View File
@@ -1,33 +1,28 @@
#!/bin/bash
set -e
# THE RAINBOW HAHAHAH
RED='\e[31m'
GREEN='\e[32m'
YELLOW='\e[33m'
RESET='\e[0m'
# root check
img_file="PBX-Test.img"
if [[ $EUID -ne 0 ]]; then
echo -e "${RED}You must be root to do this." 1>&2
exit 100
echo -e "${RED}You must be root to do this." 1>&2
exit 100
fi
echo "Converting to IMG"
qemu-img convert -f qcow2 -O raw PBX.qcow2 PBX.img
losetup -fP PBX.img
loop_device=$(losetup -l | grep "PBX.img" | cut -d ' ' -f1)
losetup -fP $img_file
loop_device=$(losetup -l | grep $img_file | cut -d ' ' -f1)
echo $loop_device
vgchange -a y PBX-vg
lvreduce -L 14G -r PBX-vg/root
lvreduce -L 976M PBX-vg/swap_1
sgdisk --delete=3 $loop_device
sgdisk --new=3:+0:+15G --typecode=3:8e00 --change-name=3:"Linux LVM" $loop_device
lvreduce -L 12G -r PBX-vg/root
partclone.ext4 -c -s /dev/mapper/PBX--vg-root | lz4 -z >./PBX-root.img.lz4
vgchange -a n PBX-vg
dd if=/dev/loop0p3 bs=64M conv=sync status=progress | lz4 -z > ./PBX3.img.lz4
losetup -D