diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/build.sh b/build.sh index 88f34ad..6c5c176 100755 --- a/build.sh +++ b/build.sh @@ -4,6 +4,7 @@ dir=$(dirname "$0") echo $dir cd $dir ./build_kernel.sh +./build_filesystem.sh sudo ./create_image.sh diff --git a/containerfile b/build_containerfile old mode 100644 new mode 100755 similarity index 100% rename from containerfile rename to build_containerfile diff --git a/build_filesystem.sh b/build_filesystem.sh index 464895c..f744c4f 100755 --- a/build_filesystem.sh +++ b/build_filesystem.sh @@ -3,8 +3,9 @@ set -e cd "$(dirname "$0")" dir=$(dirname "$0") echo $dir -podman run --rm -d --name ubuntu ubuntu:latest /bin/bash -c "while true; do sleep 1; done" -podman export -o ./ubuntu.tar ubuntu +cat ./filesystem_containerfile | /usr/bin/podman build -f - -t patronagefs:latest +podman run --rm -d --name patronagefs patronagefs:latest /bin/bash -c "while true; do sleep 1; done" +podman export -o ./patronagefs.tar patronagefs echo 'exported.' -podman stop ubuntu +podman stop patronagefs diff --git a/build_kernel.sh b/build_kernel.sh index 7c1d38f..e28a2cc 100755 --- a/build_kernel.sh +++ b/build_kernel.sh @@ -5,9 +5,9 @@ dir=$(dirname "$0") echo $dir #mkdir -p /tmp/linux [[ -d ./linux ]] || git clone --depth 1 https://github.com/torvalds/linux.git ./linux -cat ./containerfile | /usr/bin/podman build --volume /lib/modules:/lib/modules:z -f - -t kernelbuild:latest . +cat ./build_containerfile | /usr/bin/podman build --volume /lib/modules:/lib/modules:z -f - -t patronagekernel:latest . #rsync -av ./linux /mnt/tmpfs -nice -n 20 /usr/bin/podman run -it --volume /lib/modules:/lib/modules:z --volume ./linux:/linux kernelbuild:latest +#nice -n 20 /usr/bin/podman run -it --volume /lib/modules:/lib/modules:z --volume ./linux:/linux patronagekernel:latest cd $dir rm -rf initram/ mkdir -p initram @@ -26,6 +26,7 @@ cp $dir/init.sh $dir/initram/init cp $dir/linux/arch/x86_64/boot/bzImage $dir/bzImage.efi chmod +x $dir/initram/init cd $dir/initram/ -find . +echo $dir find . -print0 | cpio --null -ov --format=newc | gzip -9 > $dir/initramfs.cpio.gz +echo "created iniramfs" diff --git a/busybox b/busybox old mode 100644 new mode 100755 diff --git a/container_cmd.sh b/container_cmd.sh old mode 100644 new mode 100755 diff --git a/create_image.sh b/create_image.sh index a29eeaf..c89876d 100755 --- a/create_image.sh +++ b/create_image.sh @@ -17,34 +17,38 @@ disk="boot_image.img" mnt="/mnt" efi_part="1" root_part="2" -dd if=/dev/zero of=boot_image.img count=1024 bs=1M +dd if=/dev/zero of=boot_image.img 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 -parted -s --align=optimal "$disk" mkpart ext2 100MiB 100% +parted -s --align=optimal "$disk" mkpart ext4 100MiB 100% parted -s "$disk" set "$root_part" boot on parted -s "$disk" print kpartx -d "$disk" kpartx -avs "$disk" + loop="$(kpartx -l boot_image.img | grep -ow 'loop[0-9]*' | head -n 1)" disk_efi="${loop}p1" disk_sys="${loop}p2" -echo "${loop}" -echo "${disk_efi}" -echo "${disk_sys}" + mkfs.fat -F32 -n EFI /dev/mapper/${disk_efi} -mkfs.ext2 -L ROOT /dev/mapper/${disk_sys} +mkfs.ext4 -L ROOT /dev/mapper/${disk_sys} rm -rf $dir/mnt/ mkdir -p $dir/mnt/ mkdir -p $dir/mnt/{efi,sys,grub} mount -t vfat /dev/mapper/${disk_efi} $dir/mnt/efi mount -t ext4 /dev/mapper/${disk_sys} $dir/mnt/sys -tar -xvf ./ubuntu.tar --directory ./mnt/sys/ -rm ./ubuntu.tar +echo 'copying filesystem to mounted image' +tar -xvf ./patronagefs.tar --directory $dir/mnt/sys/ +echo 'copied...' +echo "${loop}" +echo "${disk_efi}" +echo "${disk_sys}" + #--grub-mkdevicemap=$dir/mnt/device.map #echo "(hd0) /dev/${disk_grub}" > $dir/mnt/device.map #--efi-directory=$dir/mnt/efi --boot-directory=$dir/mnt/grub --root-directory=$dir/mnt/sys -grub-install --target=x86_64-efi --recheck --no-floppy --efi-directory=$dir/mnt/efi --root-directory=$dir/mnt/sys --bootloader-id=patronage /dev/$loop +grub-install --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 #umount $dir/mnt/image #lsblk -f mkdir -p $dir/mnt/efi/boot/ diff --git a/filesystem_containerfile b/filesystem_containerfile new file mode 100755 index 0000000..8312d7e --- /dev/null +++ b/filesystem_containerfile @@ -0,0 +1,19 @@ +from ubuntu:latest +run apt-get update +run apt-get upgrade -y +run apt-get install -y python3 htop opensnitch +run apt-get install -y qemu-system python3-bpfcc python3-pip bpfcc-tools ipset +run pip install --break-system-packages dnslib psutil +run apt-get install -y ufw ubuntu-gnome-desktop ubuntu-gnome-default-settings +run apt-get install -y doas lm-sensors gnome-shell-extension-prefs gnome-software-plugin-flatpak gnome-tweaks flatpak snapd net-tools iputils-ping +run apt-get install -y bluetooth gnome-bluetooth pulseaudio-module-bluetooth pulseaudio +run apt-get install -y systemd-resolved +run flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo +run echo "permit persist :sudo as root" >> /etc/doas.conf +run usermod -a -G sudo ubuntu +run yes defaultpass | passwd ubuntu +#run systemctl start snapd.service +#run systemctl start flatpak.service +#run snap install brave +#run flatpak install flathub org.keepassxc.KeePassXC +cmd ["/usr/bin/bash"] diff --git a/grub.cfg b/grub.cfg old mode 100644 new mode 100755 index 749ab5f..f23bf51 --- a/grub.cfg +++ b/grub.cfg @@ -7,11 +7,10 @@ insmod gzio set root='(hd0,gpt1)' menuentry "PatronageOS" { ls (hd0,gpt1)/EFI/patronage/ - linux /EFI/patronage/bzImage quiet splash debug=yes ramdisk_size=500000,1 boot=/init + linux /EFI/patronage/bzImage boot=/init echo 'loaded kernel...' initrd /EFI/patronage/initramfs.cpio.gz echo 'loaded initial ramdisk...' - set debug=all boot echo 'done.' } diff --git a/init.sh b/init.sh old mode 100644 new mode 100755 index 99c85e8..8e3e16e --- a/init.sh +++ b/init.sh @@ -9,5 +9,5 @@ #depmod -a #/bin/busybox modprobe nbd max_part=2 -exec switch_root /newroot /bin/bash +exec switch_root /newroot /bin/systemd #exec /bin/busybox sh diff --git a/test_image.sh b/test_image.sh new file mode 100644 index 0000000..a9f968d --- /dev/null +++ b/test_image.sh @@ -0,0 +1 @@ +qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -drive format=raw,file='./boot_image.img' -usbdevice tablet -m 4G -smp 2 -vga virtio -enable-kvm -machine type=pc-q35-3.1,accel=kvm,kernel_irqchip=on