Documentation/
% cat -n /usr/src/linux/Documentation/filesystems/ramfs-rootfs-initramfs.txt
1 ramfs, rootfs and initramfs
2 October 17, 2005
3 Rob Landley
4 =============================
5
6 What is ramfs?
7 --------------
8
9 Ramfs is a very simple filesystem that exports Linux's disk caching
...
このファイルは以前,
このファイルでは,
そして,
70 What is rootfs?
71 ---------------
72
73 Rootfs is a special instance of ramfs (or tmpfs, if that's enabled), which is
74 always present in 2.6 systems. You can't unmount rootfs for approximately the
75 same reason you can't kill the init process; rather than having special code
76 to check for and handle an empty list, it's smaller and simpler for the kernel
77 to just make sure certain lists can't become empty.
78
79 Most systems just mount another filesystem over rootfs and ignore it. The
80 amount of space an empty instance of ramfs takes up is tiny.
81
rootfsはramfsで実現されたカーネル内蔵のファイルシステムで,
もう少し読み進めていくと,
114 - When switching another root device, initrd would pivot_root and then
115 umount the ramdisk. But initramfs is rootfs: you can neither pivot_root
116 rootfs, nor unmount it. Instead delete everything out of rootfs to
117 free up the space (find -xdev / -exec rm '{}' ';'), overmount rootfs
118 with the new root (cd /newmount; mount --move . /; chroot .), attach
119 stdin/stdout/stderr to the new /dev/console, and exec the new init.
以前,
initrdの場合はメモリ上に割りあてたram diskをrootfs上にマウントしているので,
実のところ,
実際にinitrd形式ならpivot_
# dd if=/dev/zero of=miniroot bs=1M count=4
4+0 records in
4+0 records out
4194304 bytes (4.2 MB) copied, 0.0188857 s, 222 MB/s
# mke2fs -i1024 -m0 miniroot
mke2fs 1.41.4 (27-Jan-2009)
initrd is not a block special device.
Proceed anyway? (y,n) y
...
# mount miniroot /loop -o loop
# ( cd ./initramfs ; tar cvf - * ) | ( cd /loop ; tar xf -)
bin/
bin/busybox
bin/sh
...
# umount /loop
# gzip -c miniroot > initrd.gz
まずddコマンドでinitrd用に固定サイズのファイルをあらかじめ確保しておきます。この例では4Mバイト分,
そのファイルをmke2fsでフォーマットし,
このinitrd.
起動直後はinitrdが/dev/
この状態で,
/ # cd /put_old
/put_old # /sbin/pivot_root . put_old
/ # ls /
bin etc loop proc shutdown
cdrom init lost_found put_old sys
dev lib new_root sbin
pivot_
今回はinitramfsでpivot_
前回のpmountもそうでしたが,
さて,