extract partitions
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
PBX.img
|
PBX.img
|
||||||
PBX.qcow2
|
PBX.qcow2
|
||||||
PBX-Test.qcow2
|
PBX-Test.qcow2
|
||||||
|
*.snapshot*
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
IMAGE="PBX.img"
|
|
||||||
|
|
||||||
fdisk -l ./PBX.img | grep 'PBX\.img[0-9]'
|
|
||||||
33
Image/extract_partition.sh
Executable file
33
Image/extract_partition.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# THE RAINBOW HAHAHAH
|
||||||
|
RED='\e[31m'
|
||||||
|
GREEN='\e[32m'
|
||||||
|
YELLOW='\e[33m'
|
||||||
|
RESET='\e[0m'
|
||||||
|
|
||||||
|
# root check
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
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)
|
||||||
|
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
|
||||||
|
vgchange -a n PBX-vg
|
||||||
|
|
||||||
|
dd if=/dev/loop0p3 bs=64M conv=sync status=progress | lz4 -z > ./PBX3.img.lz4
|
||||||
|
|
||||||
|
losetup -D
|
||||||
Reference in New Issue
Block a user