-
Notifications
You must be signed in to change notification settings - Fork 1
/
extract-disk
executable file
·33 lines (27 loc) · 990 Bytes
/
extract-disk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
mkdir cache -p
ISOPATH="cache/lubuntu-desk.iso"
if [ ! "$(getFileSize $ISOPATH)" -gt "0" ]; then
ISO=`zenity --file-selection --title="Select the ISO image" 2>/dev/null`
echo "Copying $ISO..."
rsync --info=progress2 "$ISO" "$ISOPATH"
fi
if [ ! -d disk/ ] || [ ! -d cache/extract-cd/ ]; then
echo "Mounting file .iso in 'mnt' folder."
mkdir mnt -p
sudo mount -o loop $ISOPATH mnt >/dev/null 2>&1
if [ ! -d disk/ ]; then
echo "Extracting files from system"
sudo unsquashfs mnt/casper/filesystem.squashfs
sudo mv squashfs-root disk
fi
if [ ! -d cache/extract-cd/ ]; then
echo "Extracting files from .iso in 'extract-cd' folder"
mkdir cache/extract-cd/ -p
sudo rsync --exclude=/casper/filesystem.squashfs -a mnt/ cache/extract-cd/ >/dev/null 2>&1
echo "Extract the isohybrid MBR isohdpfx.bin from ISO using dd"
sudo dd if=$ISOPATH bs=512 count=1 of=cache/extract-cd/isolinux/isohdpfx.bin >/dev/null 2>&1
fi
sudo umount mnt
rmdir mnt
fi