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
7
8
9
10
11
12

13
14
15
16
17
18
19
pki.tcl.h
pki.tcl.new
pki.tcl
CA
build/qemu/root/lib/modules
build/qemu/appfs.img
build/qemu/boot/vmlinuz

build/qemu/init
build/qemu/root/bin/appfs-cache
build/qemu/root/bin/appfs-mkfs
build/qemu/root/bin/appfsd
build/qemu/root/bin/init
build/qemu/root/bin/mount.appfs
build/qemu/root/bin/tclkit







>







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

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

1
2
3
4
5
6
7

8
9




10
11
12
13
14






15
16
17
18
19
20

21


22

23





24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62


#! /usr/bin/env bash

set -e

# Not included:
#  1. Downloading huge.s from Slackware64 kernels (into boot/)
#  2. Downloading kernel modules package from Slackware64 (into root/)

#  3. Downloading a static Tclkit with TUAPI
#  4. Downloading a static AppFS





make init LDFLAGS=-static
cp init root/bin

rm -f appfs.img






truncate --size 1024M appfs.img
sfdisk --no-tell-kernel --no-reread ./appfs.img <<<'label: dos
size=16M type=83 bootable
size=239M type=83
type=83'


sudo umount x-boot || :


sudo losetup -d /dev/loop3 || :

sudo losetup --partscan /dev/loop3 $(pwd)/appfs.img





sudo chown "$(id -u):$(id -g)" /dev/loop3 /dev/loop3p1 /dev/loop3p2

sudo mke2fs \
  -L 'BOOT' \
  -N 0 \
  -O ^64bit \
  -d boot \
  -m 5 \
  -r 1 \
  -t ext4 \
  /dev/loop3p1

sudo mke2fs \
  -L 'ROOT' \
  -N 0 \
  -O ^64bit \
  -d root \
  -m 5 \
  -r 1 \
  -t ext4 \
  /dev/loop3p2

sudo mke2fs \
  -L 'DATA' \
  -N 0 \
  -O ^64bit \
  -m 5 \
  -r 1 \
  -t ext4 \
  /dev/loop3p3

mkdir x-boot || :
sudo mount /dev/loop3p1 x-boot
sudo extlinux --install $(pwd)/x-boot
sudo umount x-boot
dd if=/usr/lib/EXTLINUX/mbr.bin of=appfs.img conv=notrunc
rmdir x-boot

losetup -d /dev/loop3









>
|
|
>
>
>
>




|
>
>
>
>
>
>
|
|
|
<


>
|
>
>
|
>
|
>
>
>
>
>
|

|







|

|
<
<
<
<
<
<
<
<
<
<






|


|


|


|
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55










56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#! /usr/bin/env bash

set -e

# Not included:
#  1. Downloading huge.s from Slackware64 kernels (into boot/)
#  2. Downloading kernel modules package from Slackware64 (into root/)
#  3. Running "depmod" within the chroot root/
#  4. Downloading a static Tclkit with TUAPI
#  5. Downloading a static AppFS

image_file="$(pwd)/appfs.img"
old_loop_dev="$(losetup --noheadings --output name --associated "${image_file}")" || old_loop_dev=''
extlinux_mbr_bin='/usr/lib/EXTLINUX/mbr.bin'

make init LDFLAGS=-static
cp init root/bin

rm -f boot/initrd
(
	cd root || exit 1
	find . ! -name '.' -print0 | sort --zero-terminated --dictionary-order | cpio -o -0 --owner 0:0 --dot -H newc
) | gzip -1c > boot/initrd

rm -f "${image_file}"
truncate --size 1024M "${image_file}"
sfdisk --no-tell-kernel --no-reread "${image_file}" <<<'label: dos
size=128M type=83 bootable

type=83'

if [ -d 'x-boot' ]; then
	sudo umount x-boot || :
fi
if [ -n "${old_loop_dev}" ]; then
	sudo losetup -d "${old_loop_dev}" || :
fi
sudo losetup --partscan --find "${image_file}"
loop_dev="$(losetup --noheadings --output name --associated "${image_file}")"
if [ -z "${loop_dev}" ]; then
	echo "No loop device found" >&2
	exit 1
fi
sudo chown "$(id -u):$(id -g)" "${loop_dev}" "${loop_dev}p1" "${loop_dev}p2"

mke2fs \
  -L 'BOOT' \
  -N 0 \
  -O ^64bit \
  -d boot \
  -m 5 \
  -r 1 \
  -t ext4 \
  "${loop_dev}p1"

mke2fs \










  -L 'DATA' \
  -N 0 \
  -O ^64bit \
  -m 5 \
  -r 1 \
  -t ext4 \
  "${loop_dev}p2"

mkdir x-boot || :
sudo mount "${loop_dev}p1" x-boot
sudo extlinux --install $(pwd)/x-boot
sudo umount x-boot
dd if="${extlinux_mbr_bin}" of="${image_file}" conv=notrunc
rmdir x-boot

losetup -d "${loop_dev}"

exit 0

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

1
2
3
4
5

6
DEFAULT appfs
SERIAL 0 9600 0x003

LABEL appfs
	KERNEL vmlinuz

	APPEND root=/dev/vda2 console=tty0 console=ttyS0 consoleblank=0 loglevel=8





>
|
1
2
3
4
5
6
7
DEFAULT appfs
SERIAL 0 9600 0x003

LABEL appfs
	KERNEL vmlinuz
	INITRD initrd
	APPEND rdinit=/bin/init console=tty0 console=ttyS0 consoleblank=0 loglevel=8

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

41
42
43
44
45
46
47


48











49
50




51

























52
53
54
55
56
57
58
..
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
..
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

	execv(path, argv);

	exit(EXIT_FAILURE);
}

int main(int argc, char **argv) {


	/*











	 * Remount root filesystem read-write
	 */




	mount("/dev/vda2", "/", "ext4", MS_REMOUNT, NULL);


























	/*
	 * Mount needed filesystems
	 */
	mkdir("/dev", 0755);
	mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);

................................................................................
	mkdir("/sys", 0755);
	mount("sysfs", "/sys", "sysfs", 0, NULL);

	/*
	 * Setup networking
	 */
	run("/bin/init-networking", "init-networking", NULL);
	run("/bin/init-fuse", "init-fuse", NULL);

	mkdir("/etc", 0755);
	mkdir("/bin", 0755);
	mkdir("/lib", 0755);
	mkdir("/opt", 0755);
	mkdir("/opt/appfs", 0755);

	mkdir("/var", 0755);
	mkdir("/var/cache", 0755);
	mkdir("/var/cache/appfs", 0755);
	mount("/dev/vda3", "/var/cache/appfs", "ext4", 0, NULL);

	run("/bin/appfsd", "appfsd", "/var/cache/appfs", "/opt/appfs", NULL);

	symlink(".", "/usr");
	symlink("lib", "/lib64");

	symlink("/proc/self/mounts", "/etc/mtab");
................................................................................
	run("/bin/appfs-cache", "appfs-cache", "install", "-lib", "core.appfs.rkeene.org", "glibc", NULL);
	run("/bin/appfs-cache", "appfs-cache", "install", "core.appfs.rkeene.org", "coreutils", NULL);
	run("/bin/appfs-cache", "appfs-cache", "install", "core.appfs.rkeene.org", "procps-ng", NULL);
	setenv("PATH", "/bin", 1);

	run("/bin/sh", "sh", NULL);

	/*
	 * Remount root filesystem read-only
	 */
	umount("/dev");
	umount("/tmp");
	umount("/proc");
	umount("/sys");
	umount("/opt/appfs");
	umount("/var/cache/appfs");
	mount("/dev/vda2", "/", "ext4", MS_REMOUNT | MS_RDONLY, NULL);
	sync();

	return(0);
}







>
>

>
>
>
>
>
>
>
>
>
>
>
|

>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<










<







 







<
<
<
<
<
<
<
<
<
<




41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
107
108
109
110
111
112
113

114
115
116
117
118
119
120
121
122
123

124
125
126
127
128
129
130
...
138
139
140
141
142
143
144










145
146
147
148

	execv(path, argv);

	exit(EXIT_FAILURE);
}

int main(int argc, char **argv) {
	int mount_ret;

	/*
	 * Load kernel modules (drivers)
	 */
	mkdir("/sys", 0755);
	mount("sysfs", "/sys", "sysfs", 0, NULL);

	run("/bin/init-modules", "init-modules", NULL);

	umount("/sys");
	rmdir("/sys");

	/*
	 * Mount root filesystem
	 */
	mkdir("/dev", 0755);
	mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);

	mkdir("/new-root", 0755);
	mount_ret = mount("/dev/vda2", "/new-root", "ext4", 0, NULL);
	if (mount_ret != 0) {
		mount_ret = mount("/dev/sda2", "/new-root", "ext4", 0, NULL);
	}
	if (mount_ret != 0) {
		mount_ret = mount("/dev/hda2", "/new-root", "ext4", 0, NULL);
	}
	umount("/dev");
	rmdir("/dev");

	if (mount_ret == 0) {
		mkdir("/new-root/initramfs", 0755);
		mkdir("/new-root/bin", 0755);
		mkdir("/new-root/lib", 0755);
		symlink("../initramfs/bin/appfsd", "/new-root/bin/appfsd");
		symlink("../initramfs/bin/init", "/new-root/bin/init");
		symlink("../initramfs/bin/init-modules", "/new-root/bin/init-modules");
		symlink("../initramfs/bin/init-networking", "/new-root/bin/init-networking");
		symlink("../initramfs/bin/appfs-cache", "/new-root/bin/appfs-cache");
		symlink("../initramfs/bin/tclkit", "/new-root/bin/tclkit");
		symlink("../initramfs/lib/modules", "/new-root/lib/modules");
		chdir("/new-root");
		mount("/", "/new-root/initramfs", "bind", MS_BIND, NULL);
		chroot("/new-root");
		chdir("/");
	}

	/*
	 * Mount needed filesystems
	 */
	mkdir("/dev", 0755);
	mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);

................................................................................
	mkdir("/sys", 0755);
	mount("sysfs", "/sys", "sysfs", 0, NULL);

	/*
	 * Setup networking
	 */
	run("/bin/init-networking", "init-networking", NULL);


	mkdir("/etc", 0755);
	mkdir("/bin", 0755);
	mkdir("/lib", 0755);
	mkdir("/opt", 0755);
	mkdir("/opt/appfs", 0755);

	mkdir("/var", 0755);
	mkdir("/var/cache", 0755);
	mkdir("/var/cache/appfs", 0755);


	run("/bin/appfsd", "appfsd", "/var/cache/appfs", "/opt/appfs", NULL);

	symlink(".", "/usr");
	symlink("lib", "/lib64");

	symlink("/proc/self/mounts", "/etc/mtab");
................................................................................
	run("/bin/appfs-cache", "appfs-cache", "install", "-lib", "core.appfs.rkeene.org", "glibc", NULL);
	run("/bin/appfs-cache", "appfs-cache", "install", "core.appfs.rkeene.org", "coreutils", NULL);
	run("/bin/appfs-cache", "appfs-cache", "install", "core.appfs.rkeene.org", "procps-ng", NULL);
	setenv("PATH", "/bin", 1);

	run("/bin/sh", "sh", NULL);











	sync();

	return(0);
}

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

1
2
3
4
5
#! /bin/tclkit

package require tuapi

::tuapi::modprobe fuse
<
<
<
<
<










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















>
>
>
>
>
>
>
1
2
3
4
5
6
7
#! /bin/tclkit

package require tuapi

::tuapi::scan_and_load_kernel_modules

::tuapi::modprobe fuse

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

1
2
3
4
5
6
7
8
9
10
11
12
13
#! /bin/tclkit

package require tuapi

::tuapi::scan_and_load_kernel_modules

::tuapi::ifconfig eth0 address 10.0.2.15 netmask 255.255.255.0 flags {BROADCAST MULTICAST UP}
::tuapi::syscall::route add 0.0.0.0 0.0.0.0 gateway 10.0.2.2 dev eth0

file mkdir /etc   
set fd [open /etc/resolv.conf w]
puts $fd "nameserver 10.0.2.3"
close $fd




<
<







1
2
3
4


5
6
7
8
9
10
11
#! /bin/tclkit

package require tuapi



::tuapi::ifconfig eth0 address 10.0.2.15 netmask 255.255.255.0 flags {BROADCAST MULTICAST UP}
::tuapi::syscall::route add 0.0.0.0 0.0.0.0 gateway 10.0.2.2 dev eth0

file mkdir /etc   
set fd [open /etc/resolv.conf w]
puts $fd "nameserver 10.0.2.3"
close $fd

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

1
2
3
4
5
6
7
8
#! /usr/bin/env bash

sudo chown $(id -u) /dev/kvm
qemu-system-x86_64  \
	-display none -vga none -serial stdio \
	-m 2048 -enable-kvm -cpu host -smp 2 \
	-net nic -net user \
	-drive file=appfs.img,if=virtio,cache=unsafe







|
1
2
3
4
5
6
7
8
#! /usr/bin/env bash

sudo chown $(id -u) /dev/kvm
qemu-system-x86_64  \
	-display none -vga none -serial stdio \
	-m 2048 -enable-kvm -cpu host -smp 2 \
	-net nic -net user \
	-drive file=appfs.img,if=virtio,format=raw