assemble_image.sh 2.75 KB
Newer Older
1 2 3 4 5 6
#!/bin/bash

set -x

image_size="3G"
iso_file="ubuntu-18.04.1-desktop-amd64.iso"
7
workspace="/workspace/"
8 9

# mtools, ddrescure, fdisk, grub, 7z
10 11 12
rm -rf "$workspace/part_files"
mkdir -p "$workspace/part_files"
git -C "$workspace/part_files" clone -b tardis https://git.fsmpi.rwth-aachen.de/osak/lipstick.git .
13 14 15
#rsync -av /usr/lib/grub/x86_64-efi part_files/grub
#mkdir -p part_files/efi/ubuntu
#rsync -av /usr/lib/grub/x86_64-efi part_files/efi/ubuntu
16 17 18 19 20
rsync -av /usr/lib/grub/i386-efi "$workspace/part_files"/grub
rsync -av /usr/lib/grub/i386-pc "$workspace/part_files"/grub
rsync -av /usr/share/grub/themes "$workspace/part_files"/grub
mkdir -p "$workspace/part_files"/grub/fonts/
rsync -av /usr/share/grub/unicode.pf2 "$workspace/part_files"/grub/fonts/
21

22 23
7z x "$iso_file" -o"$workspace/part_files" EFI/
7z x "$iso_file" -o"$workspace/part_files" boot/grub/x86_64-efi
24

25 26
mv "$workspace/part_files"/grub/* "$workspace/part_files"/boot/grub/
rm -rf "$workspace/part_files"/grub
27 28

#wget -O part_files/gparted-live-i686.iso https://sourceforge.net/projects/gparted/files/gparted-live-stable/0.28.1-1/gparted-live-i686.iso
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#wget -O part_files/gparted-live-i686.iso https://sourceforge.net/projects/gparted/files/gparted-live-stable/0.28.1-1/gparted-live-x86_64.iso
#ln "$iso_file" part_files/kubuntu.iso

# cdrtools
rm -rf "$workspace/iso_files"
mkdir -p "$workspace/iso_files"
7z x "$iso_file" -o"$workspace/iso_files"
echo 'd-i preseed/early_command string echo TARDIS > /dev/kmsg' >> "$workspace/iso_files/preseed/ubuntu.seed"
echo 'd-i preseed/early_command string touch /TARDIS' >> "$workspace/iso_files/preseed/ubuntu.seed"
echo 'd-i debian-installer/language string en' >> "$workspace/iso_files/preseed/ubuntu.seed"
echo 'd-i debian-installer/country string NL' >> "$workspace/iso_files/preseed/ubuntu.seed"
echo 'd-i keyboard-configuration/xkb-keymap select us' >> "$workspace/iso_files/preseed/ubuntu.seed"
cp "$workspace/iso_files/preseed/ubuntu.seed" "$workspace/iso_files/preseed/kubuntu.seed"
mkisofs -J -r -o "$workspace/part_files"/kubuntu.iso -l "$workspace/iso_files"

#echo "d-i preseed/early_command string touch /TARDIS" > preseed.cfg

rm "$workspace/part.img"
truncate -s "$image_size" "$workspace/part.img"
mkfs.vfat -n "LIPSTICK" "$workspace/part.img"
MTOOLS_SKIP_CHECK=1 mcopy -i "$workspace/part.img" -b -s -v "$workspace/part_files"/* ::
grub-mkimage --prefix "(hd0,msdos1)/boot/grub" --output "$workspace/grub.i386-pc.img" --format "i386-pc" part_msdos fat ext2 biosdisk
dd if=/usr/lib/grub/i386-pc/boot.img of="$workspace/output.img" bs=446 count=1
dd if="$workspace/grub.i386-pc.img" of="$workspace/output.img" bs=512 seek=1
ddrescue --output-position=2048s --sparse "$workspace/part.img" "$workspace/output.img"
printf "label: dos\nunit: sectors\n2048,+,b,*\n" | sfdisk "$workspace/output.img"