開機時根目錄用aufs, move mount - Linux

Table of Contents

(1):
今天原本的目標是在initramfs時,把root fs用aufs包起來(像live CD)
所以從 kernel cmdline開始:

linux vmlinuz break=mountroot ...

(initramfs) mkdir /root/ro /root/rw
(initramfs) mount -t ext4 -r /dev/sda1 /root/ro
(initramfs) insmod /root/ro/lib/modules/.../kernel/fs/aufs/aufs.ko
(initramfs) mount -t tmpfs /root/rw
(initramfs) mount -t aufs -o br:/root/rw:/root/ro /root
(initramfs) ls /root
/bin .....
這時writeable root看起來弄好了
(initramfs) >/root/root/test
(initramfs) ls /root/root
test
(Ctrl-D)
..........

login:
可是在登入後,/root底下沒有東西,也變成唯讀的了


(2)在平常的shell下
# chroot /bin/ /busybox
chroot: failed to run command `/busybox': No such file or directory

不知到為什麼會這樣,static linked binary也會有dependency?
strace看到的結果是:
chroot("/bin/") = 0
chdir("/") = 0
execve("/busybox", ["/busybox"], [/* 15 vars */]) =
-1 ENOENT (No such file or directory)

又是很怪的問題了,謝謝大家

--

All Comments

Franklin avatarFranklin2012-10-23
我學長改完initrd的script是mount aufs後直接pivot chroot
Zanna avatarZanna2012-10-24
我的作法更暴力,進去系統時在mountall前先做aufs mount
James avatarJames2012-10-28
在修掉kernel中squashfs對mount會強制加上ro flag,這樣就
Lucy avatarLucy2012-10-29
可以不經initrd直接掛起squashfs後進系統,apt-get也不會因
Lauren avatarLauren2012-10-30
/是ro就不給我"暫時"的安裝package在aufs的系統下。
Mason avatarMason2012-11-02
你的意思是:改掉ro flag就可以讓kernel把東西暫時放到buffer?
Catherine avatarCatherine2012-11-06
如果kernel不做patch,掛squashfs當/的話,/一定是ro
apt-get跟dpkg在安裝的時候如果看到/是ro就直接出錯了