我创建了一个ext2文件系统,复制了静态构建的busybox及其所有软链接。 busybox有点粘性。( - rwsr-sr-x权限)。我有/ linuxrc,我在/ etc /目录中没有多少。我使用以下命令从ext2文件系统创建映像。
mkimage -C gzip -A ppc -O linux -T ramdisk -a 0x2000000 -n "ramdisk" -d initrd-ext2 initrd.img
我将initrd.img作为/ boot /中的单独文件保留,并且不是内核的一部分。
linuxrc的内容是
#!/bin/sh (Also tried #!/bin/busybox sh)
mkdir -p /proc /dev /sys /mnt /tmp
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mknod /dev/misc/rtc0 c 254 0
mdev -s
mkdir -p /new_root
mount /dev/mmcblk0p2 /new_root
exec switch_root -c /dev/console /new_root /sbin/init
我的内核被正确加载并且initrd.img也被加载并且linuxrc被执行但最后switch_root提供了使用帮助。
然后我的系统继续启动并加载新的rootfs。以下是序列。
RAMDISK: ext2 filesystem found at block 0
RAMDISK: Loading 10240KiB [1 disk] into ram disk... done.
VFS: Mounted root (ext2 filesystem) on device 1:0.
Starting initramfs boot...
Waiting 5 seconds for devices to settle...
kjournald starting. Commit interval 5 seconds
EXT3 FS on mmcblk0p2, internal journal
EXT3-fs: mounted filesystem with writeback data mode.
BusyBox v1.21.0.git (2012-10-17 00:34:21 PDT) multi-call binary.
Usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT [ARGS]
Free initramfs and switch to another root fs:
chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,
execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.
-c DEV Reopen stdio to DEV after switch
VFS: Mounted root (ext3 filesystem) on device 179:2.
Trying to move old root to /initrd ... /initrd does not exist. Ignored.
Unmounting old root
Trying to free ramdisk memory ... okay
Freeing unused kernel memory: 200k init
INIT: version 2.86 booting
Please wait: booting...
mount: sysfs already mounted or /sys busy
mount: according to mtab, sysfs is already mounted on /sys
Starting udev
udev: starting version 154
Root filesystem already rw, not remounting
Caching udev devnodes
在上述序列中退出initrd.img后,我的ram是否已释放?
如果我不在linuxrc的末尾执行switch_root并且只是放入 出口?不要从我的旧initrd img释放我的ram