-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.sh
executable file
·63 lines (53 loc) · 2.45 KB
/
create.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# **************************************************************************** #
# #
# ::: :::::::: #
# create.sh :+: :+: :+: #
# +:+ +:+ +:+ #
# By: agaley <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/11/21 21:00:58 by agaley #+# #+# #
# Updated: 2023/01/02 18:05:29 by agaley ### ########lyon.fr #
# #
# **************************************************************************** #
#!/bin/bash
# SIZE=8G
SIZE=31G
ISO=debian-11.6.0-amd64-netinst.iso
wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/$ISO
rm debian_11.qcow2
# Preseed iso files https://wiki.debian.org/DebianInstaller/Preseed/EditIso
7z x -oisofiles $ISO
chmod +w -R isofiles/install.amd/
gunzip isofiles/install.amd/initrd.gz
echo preseed.cfg | cpio -H newc -o -A -F isofiles/install.amd/initrd
gzip isofiles/install.amd/initrd
chmod -w -R isofiles/install.amd/
cp post_install.sh isofiles/
cp services_install.sh isofiles/
cp status.sh isofiles/
cp backup.sh isofiles/
cd isofiles
chmod +w md5sum.txt
# Warning is OK - find: File system loop detected;
# ‘./debian’ is part of the same file system loop as ‘.’ :
find -follow -type f ! -name md5sum.txt -print0 | xargs -0 md5sum > md5sum.txt
chmod -w md5sum.txt
cd ..
# Repack preseeded iso https://wiki.debian.org/RepackBootableISO
# isofiles/.disk/mkisofs with stripped Jigdo
xorriso -as mkisofs \
-r -V 'Debian 11.6.0 amd64 n' \
-o "preseeded-$ISO" -J -joliet-long -cache-inodes \
-b isolinux/isolinux.bin -c isolinux/boot.cat \
-boot-load-size 4 -boot-info-table -no-emul-boot \
-eltorito-alt-boot -e boot/grub/efi.img \
-no-emul-boot -isohybrid-gpt-basdat -isohybrid-apm-hfsplus \
isofiles
chmod +w -R isofiles
rm -r isofiles
# Launch unattended install
qemu-img create -f qcow2 debian_11.qcow2 "$SIZE"
qemu-system-x86_64 -hda debian_11.qcow2 -cdrom preseeded-$ISO -boot d -m 2048 \
--enable-kvm
echo "Debian installation complete, you can start your vm now ./start.sh"
echo "Launch ./services_install.sh when logged-in with your user"