Skip to content

Commit 29203eb

Browse files
authored
Merge pull request #81 from bobuhiro11/fix_rdinit
busybox: clean up files under /dev and startup script
2 parents 3d6bb87 + 5102b90 commit 29203eb

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ initrd: busybox.config busybox.tar.bz2 busybox.inittab busybox.passwd busybox.rc
3838
mkdir -p _busybox/_install/etc/init.d
3939
mkdir -p _busybox/_install/proc
4040
mkdir -p _busybox/_install/sys
41+
mkdir -p _busybox/_install/dev
42+
[ -e _busybox/_install/dev/null ] || mknod _busybox/_install/dev/null c 1 3
43+
[ -e _busybox/_install/dev/zero ] || mknod _busybox/_install/dev/zero c 1 5
44+
[ -e _busybox/_install/dev/vda ] || mknod _busybox/_install/dev/vda b 254 0
4145
rm -f _busybox/_install/usr/bin/lspci
4246
cp _pciutils/lspci _busybox/_install/usr/bin/lspci
4347
cp _pciutils/pci.ids _busybox/_install/usr/local/share/pci.ids
@@ -47,7 +51,6 @@ initrd: busybox.config busybox.tar.bz2 busybox.inittab busybox.passwd busybox.rc
4751
cp busybox.rcS _busybox/_install/etc/init.d/rcS
4852
sed -i -e 's|{{ GUEST_IPV4_ADDR }}|$(GUEST_IPV4_ADDR)|g' _busybox/_install/etc/init.d/rcS
4953
cd _busybox/_install && find . | cpio -o --format=newc > ../../initrd
50-
rm -rf _busybox
5154

5255
linux.tar.xz:
5356
curl --retry 5 https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-$(LINUX_VERSION).tar.xz \

busybox.rcS

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
#!/bin/sh
22
mount -t proc none /proc
33
mount -t sysfs none /sys
4-
5-
mknod /dev/vda b 254 0
4+
mount -t tmpfs tmpfs /run
5+
mount --bind /dev /dev
6+
mount --bind /dev/pts /dev/pts
7+
/sbin/mdev -s
68

79
ip link set eth0 up
810
ip addr add {{ GUEST_IPV4_ADDR }} dev eth0
9-
10-
# DIRTY HACK:
11-
#
12-
# Forcing /linuxrc to stop processing here and start /bin/sh. Without it,
13-
# kernel will try to mount the disk provided by virtio-blk as rootfs and
14-
# finally panic.
15-
#
16-
# [ 559.258478][ T1] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
17-
# [ 559.258478][ T1] Kernel Offset: disabled
18-
# [ 559.258478][ T1] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---
19-
exec /bin/sh

flag/flag.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func ParseArgs(args []string) (string, string, string, string, int, error) {
1414
params := flag.String("p", `console=ttyS0 earlyprintk=serial noapic noacpi notsc `+
1515
`debug apic=debug show_lapic=all mitigations=off lapic tsc_early_khz=2000 `+
1616
`dyndbg="file arch/x86/kernel/smpboot.c +plf ; file drivers/net/virtio_net.c +plf" pci=realloc=off `+
17-
`virtio_pci.force_legacy=1 rdinit=/linuxrc`, "kernel command-line parameters")
17+
`virtio_pci.force_legacy=1 rdinit=/sbin/init`, "kernel command-line parameters")
1818

1919
flag.Parse()
2020

linux.config

+3-1
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,9 @@ CONFIG_BLK_DEV=y
908908
# CONFIG_BLK_DEV_DRBD is not set
909909
# CONFIG_BLK_DEV_NBD is not set
910910
# CONFIG_BLK_DEV_SX8 is not set
911-
# CONFIG_BLK_DEV_RAM is not set
911+
CONFIG_BLK_DEV_RAM=y
912+
CONFIG_BLK_DEV_RAM_COUNT=16
913+
CONFIG_BLK_DEV_RAM_SIZE=4096
912914
# CONFIG_CDROM_PKTCDVD is not set
913915
# CONFIG_ATA_OVER_ETH is not set
914916
CONFIG_VIRTIO_BLK=y

machine/machine_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestNewAndLoadLinux(t *testing.T) { // nolint:paralleltest
2020
}
2121

2222
param := `console=ttyS0 earlyprintk=serial noapic noacpi notsc ` +
23-
`lapic tsc_early_khz=2000 pci=realloc=off virtio_pci.force_legacy=1 rdinit=/linuxrc`
23+
`lapic tsc_early_khz=2000 pci=realloc=off virtio_pci.force_legacy=1 rdinit=/sbin/init`
2424

2525
if err = m.LoadLinux("../bzImage", "../initrd", param); err != nil {
2626
t.Fatal(err)

0 commit comments

Comments
 (0)