From fa72800ef3d31bf91e26b231ed9ec6a25bf1a3f3 Mon Sep 17 00:00:00 2001 From: David Marceau Date: Tue, 5 Dec 2023 22:45:10 -0500 Subject: [PATCH 1/5] Update build_rootfs.sh https://github.com/containers/podman/pull/4622/commits/8cb1af9afc84e1cdcf39fc93f0eee75cc2ec1c74 We cannot make nodes unless we are root. Tweaked to use sudo mknod. --- mnt/build_rootfs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mnt/build_rootfs.sh b/mnt/build_rootfs.sh index c88d982..ea5d863 100755 --- a/mnt/build_rootfs.sh +++ b/mnt/build_rootfs.sh @@ -14,7 +14,7 @@ make oldconfig make -j "$CORES" all install cd "$BBCONF" && cp inittab profile fstab passwd group shadow "$ROOTFS"/etc && cp rcS "$ROOTFS"/etc/init.d cd "$ROOTFS" && ln -s bin/busybox init -cd "$ROOTFS"/dev && mknod -m 666 console c 5 1 && mknod -m 666 null c 1 3 +cd "$ROOTFS"/dev && sudo mknod -m 666 console c 5 1 && sudo mknod -m 666 null c 1 3 #sudo chmod 777 -R * cd "$ROOTFS" && find . | cpio -o -H newc | gzip > ../rootfs.cpio.gz cd "$ROOTFS" && tar -Jcf ../rootfs.tar.xz . From 67e07ff32d1c349ba7847ced0a3b5e72c280d440 Mon Sep 17 00:00:00 2001 From: David Marceau Date: Thu, 7 Dec 2023 08:05:15 -0500 Subject: [PATCH 2/5] Update build_rootfs.sh fakeroot mknod passes without error --- mnt/build_rootfs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mnt/build_rootfs.sh b/mnt/build_rootfs.sh index ea5d863..b0809f9 100755 --- a/mnt/build_rootfs.sh +++ b/mnt/build_rootfs.sh @@ -14,7 +14,7 @@ make oldconfig make -j "$CORES" all install cd "$BBCONF" && cp inittab profile fstab passwd group shadow "$ROOTFS"/etc && cp rcS "$ROOTFS"/etc/init.d cd "$ROOTFS" && ln -s bin/busybox init -cd "$ROOTFS"/dev && sudo mknod -m 666 console c 5 1 && sudo mknod -m 666 null c 1 3 +cd "$ROOTFS"/dev && fakeroot mknod -m 666 console c 5 1 && fakeroot mknod -m 666 null c 1 3 #sudo chmod 777 -R * cd "$ROOTFS" && find . | cpio -o -H newc | gzip > ../rootfs.cpio.gz cd "$ROOTFS" && tar -Jcf ../rootfs.tar.xz . From 37fb4d1b899c98b2da632dec3c8a4dcd6dc09184 Mon Sep 17 00:00:00 2001 From: David Marceau Date: Thu, 7 Dec 2023 08:07:32 -0500 Subject: [PATCH 3/5] Update build_rootfs.sh needed fakeroot for the cpio and tar as well --- mnt/build_rootfs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mnt/build_rootfs.sh b/mnt/build_rootfs.sh index b0809f9..39bd94f 100755 --- a/mnt/build_rootfs.sh +++ b/mnt/build_rootfs.sh @@ -16,7 +16,7 @@ cd "$BBCONF" && cp inittab profile fstab passwd group shadow "$ROOTFS"/etc && cp cd "$ROOTFS" && ln -s bin/busybox init cd "$ROOTFS"/dev && fakeroot mknod -m 666 console c 5 1 && fakeroot mknod -m 666 null c 1 3 #sudo chmod 777 -R * -cd "$ROOTFS" && find . | cpio -o -H newc | gzip > ../rootfs.cpio.gz -cd "$ROOTFS" && tar -Jcf ../rootfs.tar.xz . +cd "$ROOTFS" && fakeroot find . | cpio -o -H newc | gzip > ../rootfs.cpio.gz +cd "$ROOTFS" && fakeroot tar -Jcf ../rootfs.tar.xz . cd /mnt && ls -l rootfs.* From a9f5e41ca08285baf0c968692ed91b27c59b46ca Mon Sep 17 00:00:00 2001 From: David Marceau Date: Thu, 7 Dec 2023 21:41:05 -0500 Subject: [PATCH 4/5] Update build_rootfs.sh Ensure the mknod, cpio, tar behave correctly by running everything entirely in this script in fakeroot. This also ensures cpio.gz and the tar.xz preserve the root:root afterwards. --- mnt/build_rootfs.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mnt/build_rootfs.sh b/mnt/build_rootfs.sh index 39bd94f..09c95ac 100755 --- a/mnt/build_rootfs.sh +++ b/mnt/build_rootfs.sh @@ -1,4 +1,9 @@ #!/bin/bash + +# ensure the mknod, cpio, tar behave correctly by running everything in this script in fakeroot +# and also ensures cpio.gz and the tar.xz preserve the root:root afterwards +fakeroot + CORES=$(nproc) ROOTFS=/mnt/rootfs BBCONF=/mnt/bb @@ -14,9 +19,8 @@ make oldconfig make -j "$CORES" all install cd "$BBCONF" && cp inittab profile fstab passwd group shadow "$ROOTFS"/etc && cp rcS "$ROOTFS"/etc/init.d cd "$ROOTFS" && ln -s bin/busybox init -cd "$ROOTFS"/dev && fakeroot mknod -m 666 console c 5 1 && fakeroot mknod -m 666 null c 1 3 +cd "$ROOTFS"/dev && mknod -m 666 console c 5 1 && mknod -m 666 null c 1 3 #sudo chmod 777 -R * -cd "$ROOTFS" && fakeroot find . | cpio -o -H newc | gzip > ../rootfs.cpio.gz -cd "$ROOTFS" && fakeroot tar -Jcf ../rootfs.tar.xz . +cd "$ROOTFS" && find . | cpio -o -H newc | gzip > ../rootfs.cpio.gz +cd "$ROOTFS" && tar -Jcf ../rootfs.tar.xz . cd /mnt && ls -l rootfs.* - From 21921255790064bb0c3f362a079c4fa30325c606 Mon Sep 17 00:00:00 2001 From: David Marceau Date: Thu, 7 Dec 2023 22:16:37 -0500 Subject: [PATCH 5/5] Update build_rootfs.sh ensure the mknod, cpio, tar behave correctly by invoking this script differently with ./podman_shell.sh fakeroot /bin/bash build_rootfs.sh The script itself has no sudo/fakeroot within it. --- mnt/build_rootfs.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mnt/build_rootfs.sh b/mnt/build_rootfs.sh index 09c95ac..195a62f 100755 --- a/mnt/build_rootfs.sh +++ b/mnt/build_rootfs.sh @@ -1,8 +1,8 @@ #!/bin/bash -# ensure the mknod, cpio, tar behave correctly by running everything in this script in fakeroot -# and also ensures cpio.gz and the tar.xz preserve the root:root afterwards -fakeroot +# ensure the mknod, cpio, tar behave correctly by invoking this script differently +# by doing so, it also ensures the cpio.gz and the tar.xz preserve the root:root afterwards +# ./podman_shell.sh fakeroot /bin/bash build_rootfs.sh CORES=$(nproc) ROOTFS=/mnt/rootfs