2

我制作了一个 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
  1. 按上述顺序退出 initrd.img 后,我的 ram 是否被释放?

  2. 如果我不在 linuxrc 的末尾做 switch_root 而只是退出怎么办?不会从我的旧 initrd img 中释放我的 ram

.

4

0 回答 0