在路上...

The development of life
我们一直都在努力,有您的支持,将走得更远...

站内搜索: Google

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

#!/bin/sh
echo "mount /etc as ramfs"
/bin/mount -n -t ramfs ramfs /etc         
/bin/cp -a /mnt/etc/* /etc

echo "re-create the /etc/mtab entries"
# re-create the /etc/mtab entries
/bin/mount -f -t cramfs -o remount,ro /dev/bon/2 /
/bin/mount -f -t ramfs ramfs /etc

1. /bin/mount -n -t ramfs ramfs /etc  

这句话的作用加载一个ramfs作为/etc目录。这样/etc就是一个可写目录。
看 这个脚本,得出你的根文件系统是一个cramfs,是一个只读文件系统中,而/etc作为系统运行配置文件的存放地点,可能会写一些运行状态在这里, linuxrc第一件事情就是将一个ramfs mount 到/etc只读目录中,使得/etc/目录可写,指定参数 -n的目的是告诉mount不要写/etc/mtab, 这个文件存放当前系统mount了的所有文件系统。 因为现在/etc/目录还是只读,所以这次mount不要写这个文件,否则会失败。

而你问到的 ramfs在哪里,这个在你的 /etc/fstab文件中应该有ramfs一项, mount 会去找这项,如果没有,mount会失败。后面就执行不下去。

2. /bin/cp -a /mnt/etc/* /etc
/etc成为可写目录后,将所有/mnt/etc中的配置文件拷贝到/etc/中,这说明你的ramfs可能是一个空的ramfs,没有配置文件,或者配置文件比较老。 同时也说明你这个系统是一个只读系统,每次系统运行中写入的配置不会保留。

将以前mount的那些信息重新写到/etc/mtab中,命令就是下面这些。
3. /bin/mount -f -t cramfs -o remount,ro /dev/bon/2 /
/bin/mount -f -t ramfs ramfs /etc

这些命令只是将这些mount信息写到/etc/mtab中,不会实际去mount这些block device,说明你的根文件系统依然是以前的那个/dev/bon/2

4. exec /sbin/init
执行根文件系统中的init执行程序,使其成为1号进程。shell正式运行。


你的shell运行不起来,可能是因为/etc/fstab有问题,注意看一下你的cramfs中的这个文件内容是否正确。
脚本不全,无法做出更进一步判断。最好把你的脚本和cramfs中的文件结构贴出来。

另外启动命令中noinitrd !=   no   ramdisk

mount命令参数:

       -n     Mount without writing in /etc/mtab. This is necessary for exam-
              ple when /etc is on a read-only file system.

       -f     Causes everything to be done except for the actual system call;
              if it's not obvious, this ``fakes'' mounting the file system.
              This option is useful in conjunction with the -v flag to deter-
              mine what the mount command is trying to do. It can also be used
              to add entries for devices that were mounted earlier with the -n
              option.

        remount
                     Attempt to remount an already-mounted file system.   This
                     is commonly used to change the mount flags for a file
                     system, especially to make a readonly file system write-
                     able. It does not change device or mount point.

         ro     Mount the file system read-only.

 

posted on 2009-08-31 20:54  palam  阅读(781)  评论(0编辑  收藏  举报