update scripts. relative directories. boot to ubuntu noble command line.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "$0")"
|
||||
dir=$(dirname "$0")
|
||||
qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -drive format=raw,file='./boot_image.img' -usbdevice tablet -m 4G -smp 2 -vga std -enable-kvm -machine type=pc-q35-3.1,accel=kvm,kernel_irqchip=on
|
||||
cd ..
|
||||
disk="./outputs/boot_image.img"
|
||||
qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -drive format=raw,file=$disk -usbdevice tablet -m 4G -smp 2 -vga std -enable-kvm -machine type=pc-q35-3.1,accel=kvm,kernel_irqchip=on
|
||||
|
||||
@@ -3,8 +3,11 @@ set -e
|
||||
dir=$(dirname "$0")
|
||||
echo $dir
|
||||
cd $dir
|
||||
./install_dependencies.sh
|
||||
./build_kernel.sh
|
||||
./build_filesystem.sh
|
||||
sudo ./create_image.sh
|
||||
./build_initramfs.sh
|
||||
./build_image.sh
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
#!/bin/bash
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "switching from $(id -un) to root"
|
||||
exec sudo "$0" "$@"
|
||||
fi
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
echo $PWD
|
||||
mkdir -p outputs/root
|
||||
cat ./config/filesystem_containerfile | /usr/bin/podman build -f - -t patronagefs:latest .
|
||||
podman run --rm -it --volume ./outputs/root:/tmp/rootfs/:exec --name patronagefs patronagefs:latest
|
||||
echo 'exported.'
|
||||
rm -rf ./outputs/root/
|
||||
mkdir -p ./outputs/root/
|
||||
debootstrap noble ./outputs/root http://archive.ubuntu.com/ubuntu
|
||||
echo 'root filesystem created.'
|
||||
|
||||
|
||||
|
||||
@@ -5,21 +5,20 @@ if [ "$(id -u)" -ne 0 ]; then
|
||||
fi
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
dir=$(dirname "$0")
|
||||
echo "${dir}"
|
||||
cd ..
|
||||
echo "$PWD"
|
||||
sync
|
||||
if mountpoint -q "$dir/mnt/efi"; then
|
||||
umount "$dir/mnt/efi"
|
||||
if mountpoint -q "./outputs/efi"; then
|
||||
umount "./outputs/efi"
|
||||
fi
|
||||
if mountpoint -q "$dir/mnt/sys"; then
|
||||
umount "$dir/mnt/sys"
|
||||
if mountpoint -q "./outputs/sys"; then
|
||||
umount "./outputs/sys"
|
||||
fi
|
||||
echo 'creating image..'
|
||||
disk="boot_image.img"
|
||||
mnt="/mnt"
|
||||
disk="./outputs/boot_image.img"
|
||||
efi_part="1"
|
||||
root_part="2"
|
||||
dd if=/dev/zero of=boot_image.img count=6000 bs=1M
|
||||
dd if=/dev/zero of="$disk" count=6000 bs=1M
|
||||
parted -s "$disk" mklabel gpt
|
||||
parted -s --align=optimal "$disk" mkpart ESP fat32 1MiB 50Mib
|
||||
parted -s "$disk" set "$efi_part" esp on
|
||||
@@ -29,57 +28,52 @@ parted -s "$disk" print
|
||||
kpartx -d "$disk"
|
||||
kpartx -avs "$disk"
|
||||
echo 'mounting image as loopback device..'
|
||||
loop="$(kpartx -l boot_image.img | grep -ow 'loop[0-9]*' | head -n 1)"
|
||||
loop="$(kpartx -l $disk | grep -ow 'loop[0-9]*' | head -n 1)"
|
||||
disk_efi="${loop}p1"
|
||||
disk_sys="${loop}p2"
|
||||
echo 'formatting image partitions..'
|
||||
mkfs.fat -F32 -n EFI /dev/mapper/${disk_efi}
|
||||
mkfs.ext4 -L ROOT /dev/mapper/${disk_sys}
|
||||
echo 'creating mount points..'
|
||||
rm -rf $dir/mnt/
|
||||
mkdir -p $dir/mnt/
|
||||
mkdir -p $dir/mnt/{efi,sys,grub}
|
||||
rm -rf ./outputs/{efi,sys,grub}
|
||||
mkdir -p ./outputs/
|
||||
mkdir -p ./outputs/{efi,sys,grub}
|
||||
echo 'mounting loopback devices..'
|
||||
mount -t vfat /dev/mapper/${disk_efi} $dir/mnt/efi
|
||||
mount -t ext4 /dev/mapper/${disk_sys} $dir/mnt/sys
|
||||
mount -t vfat /dev/mapper/${disk_efi} ./outputs/efi
|
||||
mount -t ext4 /dev/mapper/${disk_sys} ./outputs/sys
|
||||
echo 'installing grub..'
|
||||
echo "loop dev: ${loop}"
|
||||
echo "efi loop: ${disk_efi}"
|
||||
echo "sys loop: ${disk_sys}"
|
||||
grub-install -s --compress=gz --target=x86_64-efi --recheck --no-floppy --efi-directory=$dir/mnt/efi --boot-directory=$dir/mnt/efi --root-directory=$dir/mnt/sys --bootloader-id=patronage /dev/$loop
|
||||
grub-install -s --compress=gz --target=x86_64-efi --recheck --no-floppy --efi-directory=./outputs/efi --boot-directory=./outputs/efi --root-directory=./outputs/sys --bootloader-id=patronage /dev/$loop
|
||||
echo 'copying filesystem to mounted image..'
|
||||
tar -xf ./patronagefs.tar --directory $dir/mnt/sys/
|
||||
sudo rsync -av './outputs/root/' './outputs/sys/'
|
||||
#tar -xf ./patronagefs.tar --directory ./mnt/sys/
|
||||
echo 'copied..'
|
||||
echo 'copying boot files..'
|
||||
mkdir -p $dir/mnt/efi/boot/
|
||||
cp $dir/initramfs.cpio.gz $dir/mnt/efi/
|
||||
mkdir -p $dir/mnt/efi/EFI/patronage/
|
||||
cp $dir/linux/arch/x86_64/boot/bzImage $dir/mnt/efi/EFI/patronage/bzImage
|
||||
cp $dir/initramfs.cpio.gz $dir/mnt/efi/EFI/patronage/
|
||||
#cp $dir/linux/arch/x86/boot/compressed/vmlinux $dir/mnt/efi/
|
||||
#cp $dir/linux/arch/x86/boot/vmlinux.bin $dir/mnt/efi/
|
||||
#cp $dir/initramfs.cpio.gz $dir/mnt/sys/
|
||||
#cp $dir/linux/arch/x86_64/boot/bzImage $dir/mnt/sys/
|
||||
#cp $dir/linux/arch/x86/boot/compressed/vmlinux $dir/mnt/sys/
|
||||
#cp $dir/linux/arch/x86/boot/vmlinux.bin $dir/mnt/sys/
|
||||
mkdir -p ./outputs/efi/boot/
|
||||
cp ./outputs/initramfs.cpio.gz ./outputs/efi/
|
||||
mkdir -p ./outputs/efi/EFI/patronage/
|
||||
cp ./outputs/bzImage ./outputs/efi/EFI/patronage/bzImage
|
||||
cp ./outputs/initramfs.cpio.gz ./outputs/efi/EFI/patronage/
|
||||
|
||||
cp $dir/grub.cfg $dir/mnt/efi/EFI/patronage/
|
||||
cp ./config/grub.cfg ./outputs/efi/EFI/patronage/
|
||||
#cp $dir/grub.cfg $dir/mnt/sys/boot/grub/
|
||||
cp $dir/grub.cfg $dir/mnt/efi/EFI/BOOT/
|
||||
cp ./config/grub.cfg ./outputs/efi/EFI/BOOT/
|
||||
echo 'unmounting..'
|
||||
|
||||
if mountpoint -q "$dir/mnt/efi"; then
|
||||
if mountpoint -q "./outputs/efi"; then
|
||||
sync
|
||||
#fuser -kmv "$dir/mnt/efi"
|
||||
umount -lf "$dir/mnt/efi"
|
||||
umount -lf "./outputs/efi"
|
||||
fi
|
||||
|
||||
if mountpoint -q "$dir/mnt/sys"; then
|
||||
if mountpoint -q "./outputs/sys"; then
|
||||
sync
|
||||
#fuser -kmv "$dir/mnt/sys"
|
||||
umount -lf "$dir/mnt/sys"
|
||||
umount -lf "./outputs/sys"
|
||||
fi
|
||||
|
||||
kpartx -d boot_image.img
|
||||
chmod 777 ./boot_image.img
|
||||
kpartx -d "$disk"
|
||||
chmod 777 "$disk"
|
||||
echo 'image built..'
|
||||
|
||||
@@ -7,11 +7,9 @@ rootdir=$(dirname "$0")
|
||||
dir=./$(dirname "$0")
|
||||
cd dependencies
|
||||
[[ -d ./linux ]] || git clone --depth 1 https://github.com/torvalds/linux.git ./linux
|
||||
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
cd ..
|
||||
echo $PWD
|
||||
cat ./config/build_containerfile | /usr/bin/podman build --volume /lib/modules:/lib/modules:z -f - -t patronagekernel:latest .
|
||||
nice -n 20 /usr/bin/podman run -it --volume /lib/modules:/lib/modules:z --volume ./dependencies/linux:/linux patronagekernel:latest
|
||||
|
||||
cp ./dependencies/linux/arch/x86_64/boot/bzImage ./outputs/bzImage
|
||||
|
||||
11
scripts/install_dependencies.sh
Executable file
11
scripts/install_dependencies.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#install dependencies
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "switching from $(id -un) to root"
|
||||
exec sudo "$0" "$@"
|
||||
fi
|
||||
set -e
|
||||
list="kpartx podman debootstrap"
|
||||
apt update
|
||||
for item in $list; do
|
||||
apt list --installed $item 2>/dev/null || sudo apt-get install -y $item
|
||||
done
|
||||
Reference in New Issue
Block a user