Check-in [afc876941b]
Overview
Comment:Updated to use an initramfs to allow more flexible mounting options
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1:afc876941bda07800052b59758d82b65322ed87e
User & Date: rkeene on 2020-06-29 14:58:52
Other Links: manifest | tags
Context
2020-06-29
14:58
Updated to use an initramfs to allow more flexible mounting options Leaf check-in: afc876941b user: rkeene tags: trunk
2020-06-28
20:05
Do not include root directory in the cache/data fs check-in: 2d622e681b user: rkeene tags: trunk
Changes

Modified .fossil-settings/ignore-glob from [3fdd9f1f14] to [44e2bffff6].

     6      6   pki.tcl.h
     7      7   pki.tcl.new
     8      8   pki.tcl
     9      9   CA
    10     10   build/qemu/root/lib/modules
    11     11   build/qemu/appfs.img
    12     12   build/qemu/boot/vmlinuz
           13  +build/qemu/boot/initrd
    13     14   build/qemu/init
    14     15   build/qemu/root/bin/appfs-cache
    15     16   build/qemu/root/bin/appfs-mkfs
    16     17   build/qemu/root/bin/appfsd
    17     18   build/qemu/root/bin/init
    18     19   build/qemu/root/bin/mount.appfs
    19     20   build/qemu/root/bin/tclkit

Modified build/qemu/assemble from [1e459fa032] to [7557bdba83].

     1      1   #! /usr/bin/env bash
     2      2   
     3      3   set -e
     4      4   
     5      5   # Not included:
     6      6   #  1. Downloading huge.s from Slackware64 kernels (into boot/)
     7      7   #  2. Downloading kernel modules package from Slackware64 (into root/)
     8         -#  3. Downloading a static Tclkit with TUAPI
     9         -#  4. Downloading a static AppFS
            8  +#  3. Running "depmod" within the chroot root/
            9  +#  4. Downloading a static Tclkit with TUAPI
           10  +#  5. Downloading a static AppFS
           11  +
           12  +image_file="$(pwd)/appfs.img"
           13  +old_loop_dev="$(losetup --noheadings --output name --associated "${image_file}")" || old_loop_dev=''
           14  +extlinux_mbr_bin='/usr/lib/EXTLINUX/mbr.bin'
    10     15   
    11     16   make init LDFLAGS=-static
    12     17   cp init root/bin
    13     18   
    14         -rm -f appfs.img
    15         -truncate --size 1024M appfs.img
    16         -sfdisk --no-tell-kernel --no-reread ./appfs.img <<<'label: dos
    17         -size=16M type=83 bootable
    18         -size=239M type=83
           19  +rm -f boot/initrd
           20  +(
           21  +	cd root || exit 1
           22  +	find . ! -name '.' -print0 | sort --zero-terminated --dictionary-order | cpio -o -0 --owner 0:0 --dot -H newc
           23  +) | gzip -1c > boot/initrd
           24  +
           25  +rm -f "${image_file}"
           26  +truncate --size 1024M "${image_file}"
           27  +sfdisk --no-tell-kernel --no-reread "${image_file}" <<<'label: dos
           28  +size=128M type=83 bootable
    19     29   type=83'
    20     30   
    21         -sudo umount x-boot || :
    22         -sudo losetup -d /dev/loop3 || :
    23         -sudo losetup --partscan /dev/loop3 $(pwd)/appfs.img
    24         -sudo chown "$(id -u):$(id -g)" /dev/loop3 /dev/loop3p1 /dev/loop3p2
           31  +if [ -d 'x-boot' ]; then
           32  +	sudo umount x-boot || :
           33  +fi
           34  +if [ -n "${old_loop_dev}" ]; then
           35  +	sudo losetup -d "${old_loop_dev}" || :
           36  +fi
           37  +sudo losetup --partscan --find "${image_file}"
           38  +loop_dev="$(losetup --noheadings --output name --associated "${image_file}")"
           39  +if [ -z "${loop_dev}" ]; then
           40  +	echo "No loop device found" >&2
           41  +	exit 1
           42  +fi
           43  +sudo chown "$(id -u):$(id -g)" "${loop_dev}" "${loop_dev}p1" "${loop_dev}p2"
    25     44   
    26         -sudo mke2fs \
           45  +mke2fs \
    27     46     -L 'BOOT' \
    28     47     -N 0 \
    29     48     -O ^64bit \
    30     49     -d boot \
    31     50     -m 5 \
    32     51     -r 1 \
    33     52     -t ext4 \
    34         -  /dev/loop3p1
           53  +  "${loop_dev}p1"
    35     54   
    36         -sudo mke2fs \
    37         -  -L 'ROOT' \
    38         -  -N 0 \
    39         -  -O ^64bit \
    40         -  -d root \
    41         -  -m 5 \
    42         -  -r 1 \
    43         -  -t ext4 \
    44         -  /dev/loop3p2
    45         -
    46         -sudo mke2fs \
           55  +mke2fs \
    47     56     -L 'DATA' \
    48     57     -N 0 \
    49     58     -O ^64bit \
    50     59     -m 5 \
    51     60     -r 1 \
    52     61     -t ext4 \
    53         -  /dev/loop3p3
           62  +  "${loop_dev}p2"
    54     63   
    55     64   mkdir x-boot || :
    56         -sudo mount /dev/loop3p1 x-boot
           65  +sudo mount "${loop_dev}p1" x-boot
    57     66   sudo extlinux --install $(pwd)/x-boot
    58     67   sudo umount x-boot
    59         -dd if=/usr/lib/EXTLINUX/mbr.bin of=appfs.img conv=notrunc
           68  +dd if="${extlinux_mbr_bin}" of="${image_file}" conv=notrunc
    60     69   rmdir x-boot
    61     70   
    62         -losetup -d /dev/loop3
           71  +losetup -d "${loop_dev}"
           72  +
           73  +exit 0

Modified build/qemu/boot/extlinux.conf from [16eb016414] to [4580fa2068].

     1      1   DEFAULT appfs
     2      2   SERIAL 0 9600 0x003
     3      3   
     4      4   LABEL appfs
     5      5   	KERNEL vmlinuz
     6         -	APPEND root=/dev/vda2 console=tty0 console=ttyS0 consoleblank=0 loglevel=8
            6  +	INITRD initrd
            7  +	APPEND rdinit=/bin/init console=tty0 console=ttyS0 consoleblank=0 loglevel=8

Modified build/qemu/init.c from [e11582ede8] to [c6b18551fb].

    41     41   
    42     42   	execv(path, argv);
    43     43   
    44     44   	exit(EXIT_FAILURE);
    45     45   }
    46     46   
    47     47   int main(int argc, char **argv) {
           48  +	int mount_ret;
           49  +
           50  +	/*
           51  +	 * Load kernel modules (drivers)
           52  +	 */
           53  +	mkdir("/sys", 0755);
           54  +	mount("sysfs", "/sys", "sysfs", 0, NULL);
           55  +
           56  +	run("/bin/init-modules", "init-modules", NULL);
           57  +
           58  +	umount("/sys");
           59  +	rmdir("/sys");
           60  +
    48     61   	/*
    49         -	 * Remount root filesystem read-write
           62  +	 * Mount root filesystem
    50     63   	 */
    51         -	mount("/dev/vda2", "/", "ext4", MS_REMOUNT, NULL);
           64  +	mkdir("/dev", 0755);
           65  +	mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);
           66  +
           67  +	mkdir("/new-root", 0755);
           68  +	mount_ret = mount("/dev/vda2", "/new-root", "ext4", 0, NULL);
           69  +	if (mount_ret != 0) {
           70  +		mount_ret = mount("/dev/sda2", "/new-root", "ext4", 0, NULL);
           71  +	}
           72  +	if (mount_ret != 0) {
           73  +		mount_ret = mount("/dev/hda2", "/new-root", "ext4", 0, NULL);
           74  +	}
           75  +	umount("/dev");
           76  +	rmdir("/dev");
           77  +
           78  +	if (mount_ret == 0) {
           79  +		mkdir("/new-root/initramfs", 0755);
           80  +		mkdir("/new-root/bin", 0755);
           81  +		mkdir("/new-root/lib", 0755);
           82  +		symlink("../initramfs/bin/appfsd", "/new-root/bin/appfsd");
           83  +		symlink("../initramfs/bin/init", "/new-root/bin/init");
           84  +		symlink("../initramfs/bin/init-modules", "/new-root/bin/init-modules");
           85  +		symlink("../initramfs/bin/init-networking", "/new-root/bin/init-networking");
           86  +		symlink("../initramfs/bin/appfs-cache", "/new-root/bin/appfs-cache");
           87  +		symlink("../initramfs/bin/tclkit", "/new-root/bin/tclkit");
           88  +		symlink("../initramfs/lib/modules", "/new-root/lib/modules");
           89  +		chdir("/new-root");
           90  +		mount("/", "/new-root/initramfs", "bind", MS_BIND, NULL);
           91  +		chroot("/new-root");
           92  +		chdir("/");
           93  +	}
    52     94   
    53     95   	/*
    54     96   	 * Mount needed filesystems
    55     97   	 */
    56     98   	mkdir("/dev", 0755);
    57     99   	mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);
    58    100   
................................................................................
    65    107   	mkdir("/sys", 0755);
    66    108   	mount("sysfs", "/sys", "sysfs", 0, NULL);
    67    109   
    68    110   	/*
    69    111   	 * Setup networking
    70    112   	 */
    71    113   	run("/bin/init-networking", "init-networking", NULL);
    72         -	run("/bin/init-fuse", "init-fuse", NULL);
    73    114   
    74    115   	mkdir("/etc", 0755);
    75    116   	mkdir("/bin", 0755);
    76    117   	mkdir("/lib", 0755);
    77    118   	mkdir("/opt", 0755);
    78    119   	mkdir("/opt/appfs", 0755);
    79    120   
    80    121   	mkdir("/var", 0755);
    81    122   	mkdir("/var/cache", 0755);
    82    123   	mkdir("/var/cache/appfs", 0755);
    83         -	mount("/dev/vda3", "/var/cache/appfs", "ext4", 0, NULL);
    84    124   
    85    125   	run("/bin/appfsd", "appfsd", "/var/cache/appfs", "/opt/appfs", NULL);
    86    126   
    87    127   	symlink(".", "/usr");
    88    128   	symlink("lib", "/lib64");
    89    129   
    90    130   	symlink("/proc/self/mounts", "/etc/mtab");
................................................................................
    98    138   	run("/bin/appfs-cache", "appfs-cache", "install", "-lib", "core.appfs.rkeene.org", "glibc", NULL);
    99    139   	run("/bin/appfs-cache", "appfs-cache", "install", "core.appfs.rkeene.org", "coreutils", NULL);
   100    140   	run("/bin/appfs-cache", "appfs-cache", "install", "core.appfs.rkeene.org", "procps-ng", NULL);
   101    141   	setenv("PATH", "/bin", 1);
   102    142   
   103    143   	run("/bin/sh", "sh", NULL);
   104    144   
   105         -	/*
   106         -	 * Remount root filesystem read-only
   107         -	 */
   108         -	umount("/dev");
   109         -	umount("/tmp");
   110         -	umount("/proc");
   111         -	umount("/sys");
   112         -	umount("/opt/appfs");
   113         -	umount("/var/cache/appfs");
   114         -	mount("/dev/vda2", "/", "ext4", MS_REMOUNT | MS_RDONLY, NULL);
   115    145   	sync();
   116    146   
   117    147   	return(0);
   118    148   }

Deleted build/qemu/root/bin/init-fuse version [3ac2dd4f3a].

     1         -#! /bin/tclkit
     2         -
     3         -package require tuapi
     4         -
     5         -::tuapi::modprobe fuse

Added build/qemu/root/bin/init-modules version [a758608fd7].

            1  +#! /bin/tclkit
            2  +
            3  +package require tuapi
            4  +
            5  +::tuapi::scan_and_load_kernel_modules
            6  +
            7  +::tuapi::modprobe fuse

Modified build/qemu/root/bin/init-networking from [be0f1f2714] to [19614066f2].

     1      1   #! /bin/tclkit
     2      2   
     3      3   package require tuapi
     4      4   
     5         -::tuapi::scan_and_load_kernel_modules
     6         -
     7      5   ::tuapi::ifconfig eth0 address 10.0.2.15 netmask 255.255.255.0 flags {BROADCAST MULTICAST UP}
     8      6   ::tuapi::syscall::route add 0.0.0.0 0.0.0.0 gateway 10.0.2.2 dev eth0
     9      7   
    10      8   file mkdir /etc   
    11      9   set fd [open /etc/resolv.conf w]
    12     10   puts $fd "nameserver 10.0.2.3"
    13     11   close $fd

Modified build/qemu/run from [4b861ef3b6] to [a48cd7e079].

     1      1   #! /usr/bin/env bash
     2      2   
     3      3   sudo chown $(id -u) /dev/kvm
     4      4   qemu-system-x86_64  \
     5      5   	-display none -vga none -serial stdio \
     6      6   	-m 2048 -enable-kvm -cpu host -smp 2 \
     7      7   	-net nic -net user \
     8         -	-drive file=appfs.img,if=virtio,cache=unsafe
            8  +	-drive file=appfs.img,if=virtio,format=raw