update scripts. relative directories. boot to ubuntu noble command line.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
dir=$(dirname "$0")
|
cd ..
|
||||||
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
|
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")
|
dir=$(dirname "$0")
|
||||||
echo $dir
|
echo $dir
|
||||||
cd $dir
|
cd $dir
|
||||||
|
./install_dependencies.sh
|
||||||
./build_kernel.sh
|
./build_kernel.sh
|
||||||
./build_filesystem.sh
|
./build_filesystem.sh
|
||||||
sudo ./create_image.sh
|
./build_initramfs.sh
|
||||||
|
./build_image.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
echo "switching from $(id -un) to root"
|
||||||
|
exec sudo "$0" "$@"
|
||||||
|
fi
|
||||||
set -e
|
set -e
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
cd ..
|
cd ..
|
||||||
echo $PWD
|
echo $PWD
|
||||||
mkdir -p outputs/root
|
rm -rf ./outputs/root/
|
||||||
cat ./config/filesystem_containerfile | /usr/bin/podman build -f - -t patronagefs:latest .
|
mkdir -p ./outputs/root/
|
||||||
podman run --rm -it --volume ./outputs/root:/tmp/rootfs/:exec --name patronagefs patronagefs:latest
|
debootstrap noble ./outputs/root http://archive.ubuntu.com/ubuntu
|
||||||
echo 'exported.'
|
echo 'root filesystem created.'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,21 +5,20 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||||||
fi
|
fi
|
||||||
set -e
|
set -e
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
dir=$(dirname "$0")
|
cd ..
|
||||||
echo "${dir}"
|
echo "$PWD"
|
||||||
sync
|
sync
|
||||||
if mountpoint -q "$dir/mnt/efi"; then
|
if mountpoint -q "./outputs/efi"; then
|
||||||
umount "$dir/mnt/efi"
|
umount "./outputs/efi"
|
||||||
fi
|
fi
|
||||||
if mountpoint -q "$dir/mnt/sys"; then
|
if mountpoint -q "./outputs/sys"; then
|
||||||
umount "$dir/mnt/sys"
|
umount "./outputs/sys"
|
||||||
fi
|
fi
|
||||||
echo 'creating image..'
|
echo 'creating image..'
|
||||||
disk="boot_image.img"
|
disk="./outputs/boot_image.img"
|
||||||
mnt="/mnt"
|
|
||||||
efi_part="1"
|
efi_part="1"
|
||||||
root_part="2"
|
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 "$disk" mklabel gpt
|
||||||
parted -s --align=optimal "$disk" mkpart ESP fat32 1MiB 50Mib
|
parted -s --align=optimal "$disk" mkpart ESP fat32 1MiB 50Mib
|
||||||
parted -s "$disk" set "$efi_part" esp on
|
parted -s "$disk" set "$efi_part" esp on
|
||||||
@@ -29,57 +28,52 @@ parted -s "$disk" print
|
|||||||
kpartx -d "$disk"
|
kpartx -d "$disk"
|
||||||
kpartx -avs "$disk"
|
kpartx -avs "$disk"
|
||||||
echo 'mounting image as loopback device..'
|
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_efi="${loop}p1"
|
||||||
disk_sys="${loop}p2"
|
disk_sys="${loop}p2"
|
||||||
echo 'formatting image partitions..'
|
echo 'formatting image partitions..'
|
||||||
mkfs.fat -F32 -n EFI /dev/mapper/${disk_efi}
|
mkfs.fat -F32 -n EFI /dev/mapper/${disk_efi}
|
||||||
mkfs.ext4 -L ROOT /dev/mapper/${disk_sys}
|
mkfs.ext4 -L ROOT /dev/mapper/${disk_sys}
|
||||||
echo 'creating mount points..'
|
echo 'creating mount points..'
|
||||||
rm -rf $dir/mnt/
|
rm -rf ./outputs/{efi,sys,grub}
|
||||||
mkdir -p $dir/mnt/
|
mkdir -p ./outputs/
|
||||||
mkdir -p $dir/mnt/{efi,sys,grub}
|
mkdir -p ./outputs/{efi,sys,grub}
|
||||||
echo 'mounting loopback devices..'
|
echo 'mounting loopback devices..'
|
||||||
mount -t vfat /dev/mapper/${disk_efi} $dir/mnt/efi
|
mount -t vfat /dev/mapper/${disk_efi} ./outputs/efi
|
||||||
mount -t ext4 /dev/mapper/${disk_sys} $dir/mnt/sys
|
mount -t ext4 /dev/mapper/${disk_sys} ./outputs/sys
|
||||||
echo 'installing grub..'
|
echo 'installing grub..'
|
||||||
echo "loop dev: ${loop}"
|
echo "loop dev: ${loop}"
|
||||||
echo "efi loop: ${disk_efi}"
|
echo "efi loop: ${disk_efi}"
|
||||||
echo "sys loop: ${disk_sys}"
|
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..'
|
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 'copied..'
|
||||||
echo 'copying boot files..'
|
echo 'copying boot files..'
|
||||||
mkdir -p $dir/mnt/efi/boot/
|
mkdir -p ./outputs/efi/boot/
|
||||||
cp $dir/initramfs.cpio.gz $dir/mnt/efi/
|
cp ./outputs/initramfs.cpio.gz ./outputs/efi/
|
||||||
mkdir -p $dir/mnt/efi/EFI/patronage/
|
mkdir -p ./outputs/efi/EFI/patronage/
|
||||||
cp $dir/linux/arch/x86_64/boot/bzImage $dir/mnt/efi/EFI/patronage/bzImage
|
cp ./outputs/bzImage ./outputs/efi/EFI/patronage/bzImage
|
||||||
cp $dir/initramfs.cpio.gz $dir/mnt/efi/EFI/patronage/
|
cp ./outputs/initramfs.cpio.gz ./outputs/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/
|
|
||||||
|
|
||||||
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/sys/boot/grub/
|
||||||
cp $dir/grub.cfg $dir/mnt/efi/EFI/BOOT/
|
cp ./config/grub.cfg ./outputs/efi/EFI/BOOT/
|
||||||
echo 'unmounting..'
|
echo 'unmounting..'
|
||||||
|
|
||||||
if mountpoint -q "$dir/mnt/efi"; then
|
if mountpoint -q "./outputs/efi"; then
|
||||||
sync
|
sync
|
||||||
#fuser -kmv "$dir/mnt/efi"
|
#fuser -kmv "$dir/mnt/efi"
|
||||||
umount -lf "$dir/mnt/efi"
|
umount -lf "./outputs/efi"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if mountpoint -q "$dir/mnt/sys"; then
|
if mountpoint -q "./outputs/sys"; then
|
||||||
sync
|
sync
|
||||||
#fuser -kmv "$dir/mnt/sys"
|
#fuser -kmv "$dir/mnt/sys"
|
||||||
umount -lf "$dir/mnt/sys"
|
umount -lf "./outputs/sys"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kpartx -d boot_image.img
|
kpartx -d "$disk"
|
||||||
chmod 777 ./boot_image.img
|
chmod 777 "$disk"
|
||||||
echo 'image built..'
|
echo 'image built..'
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ rootdir=$(dirname "$0")
|
|||||||
dir=./$(dirname "$0")
|
dir=./$(dirname "$0")
|
||||||
cd dependencies
|
cd dependencies
|
||||||
[[ -d ./linux ]] || git clone --depth 1 https://github.com/torvalds/linux.git ./linux
|
[[ -d ./linux ]] || git clone --depth 1 https://github.com/torvalds/linux.git ./linux
|
||||||
|
|
||||||
|
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
cd ..
|
cd ..
|
||||||
echo $PWD
|
echo $PWD
|
||||||
cat ./config/build_containerfile | /usr/bin/podman build --volume /lib/modules:/lib/modules:z -f - -t patronagekernel:latest .
|
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
|
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