Generating a full filesystem remotely
2021-10-06 [ systems-deployment ]Expected result
|| mbr | grub | part1 | part2 ||
Generate disk layout
$ parted .. 50% 100%
Generate part1
Create partition
$ dd if=.. of=.. count= bs/..
$ mkfs.xfs image
# mount image tmp_dst
Create partition contents
FROM centos:7.9.2009
RUN yum install -y systemd kernel
Put contents into partition
docker build -f centos7.9 -t 7.9 .
$ CONTAINER_ID=$(docker run -itd 7.9 /bin/sh)
$ docker export $CONTAINER_ID > data.tar
# sudo tar -C tmp_dst data.tar # keep uid
$ docker stop $CONTAINER_ID
Write grub/MBR
dd if=/usr/lib/grub/i386-pc/boot.img of=$DISK bs=446 count=1 conv=notrunc
dd if=core.img of=$DISK bs=512 seek=1 conv=notrunc
This leaves me with a generic image, per-host customization at install time
Installer/Delivering to a system
needs another image! as a cdrom
Debugging
kvm -nographic -serial mon:stdio with 'console=ttyS0' as kernel logs
Writing image to disk
https://wiki.gentoo.org/wiki/CustomInitramfs#Staticvs.dynamicbinaries https://wiki.gentoo.org/wiki/CustomInitramfs#Jobcontrol utilities
Generate initrd
find . -print0 | cpio --null --create --verbose --format=newc > ../iso_src/initrd.img
Busybox
setsid cttyhack sh
Isolinux
pacakge into iso
genisoimage -f -q -o out.iso -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat iso_src/