【问题标题】:mkdir and mount in initramfsmkdir 并挂载到 initramfs
【发布时间】:2020-07-10 08:05:29
【问题描述】:

我正在编写一个 initramfs,在 busybox 中执行,我在其中使用这些命令挂载一个分区:

/bin/busybox mount -n -t proc proc /proc
mount -n -t devtmpfs devtmpfs /dev
mount -n -t sysfs sysfs /sys
mount -n -t tmpfs inittemp /mnt
mkdir /mnt/saved
mount -n -t "${rootfstype}" -o "${rootflags}" ${device} /mnt/saved

但是当系统启动时,我有这个错误:

mount: mounting /dev/mmcblk0p2 on /mnt/saved failed: No such file or directory

我知道当找不到设备时,会有类似Device does not exist的消息,所以我认为问题出在尚未正确创建的目录/mnt/saved上。

我尝试在mkdir 之后添加ls -l /mnt 以检查目录是否正确创建,但大多数情况下,如果我这样做,错误就会消失。所以我认为问题可能是同步问题(tmpfs,很奇怪!)所以我尝试了一些其他的事情,比如在目录中创建一个虚拟文件来强制一种同步。这可行,但这是一个肮脏的解决方法,我想找到问题的真正原因以构建一个干净的解决方案。

【问题讨论】:

    标签: mount mkdir busybox initramfs


    【解决方案1】:

    到我写问题的时候,我终于自己找到了解决方案……我还是发布了它,以防有人像我一样被卡住。

    实际上,busyboxmount命令并没有显示关于设备的消息,如果找不到它,但总是显示No such file or directory

    我的问题实际上来自尚未准备好的根设备,因此还没有在/dev 目录中。为了让它正常工作,我只是在mount之前添加了这一行:

    while ${rootwait} && ! [ -b "${device}" ]; do sleep 1; done
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-11
      • 1970-01-01
      • 2020-01-26
      • 1970-01-01
      • 2013-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多