Files
SimpleLinux/scripts/installer.sh
T

31 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
set -ex
mkdir -pv installer
cd installer
dd if=/dev/zero of=installer.img bs=1M count=100
sudo modprobe nbd
sudo qemu-nbd --connect /dev/nbd0 installer.img && sync
printf "o\nn\np\n\n\n\nw\n" | sudo fdisk /dev/nbd0 && sync
sudo mkfs.ext4 /dev/nbd0p1 && sync
sudo mount /dev/nbd0p1 /mnt
cd ../build/rootfs
tar -czvf /tmp/rootfs.tar.gz.tmp .
cd ../../installer
sudo tar -xvf /tmp/rootfs.tar.gz.tmp -C /mnt && sync
sudo grub-install --target=i386-pc --root-directory=/mnt /dev/nbd0 && sync
sudo cp ../grub/grub.cfg /mnt/boot/grub/grub.cfg && sync
rawuuid=$(echo $(sudo blkid /dev/nbd0p1 | echo $(awk '{print $2}')))
echo $rawuuid
uuidIN=(${rawuuid//=/ })
uuid=${uuidIN[1]}
echo $uuid
sudo sed -i "s/ROOTUUID/$uuid/g" /mnt/boot/grub/grub.cfg && sync
sudo sed -i "s/\/dev\/sda/UUID=$uuid/g" /mnt/etc/fstab && sync
sudo cp -v ../build/kernel/linux-6.1.91/arch/x86_64/boot/bzImage /mnt/boot/vmlinuz-6.1.91 && sync
sudo cp -v ../build/initramfs.img /mnt/boot && sync
sudo cp -v /tmp/rootfs.tar.gz.tmp /mnt/rootfs.tar.gz && sync
sudo umount /mnt
sudo qemu-nbd --disconnect /dev/nbd0