Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->Linux技术 ->Linux安全 ->正文

利用BusyBox定制Linux Live CD

来源:Linux时代 作者:Mike Chirico  时间:2007-04-22 点击: [收藏] [投稿]

Since there are a lot of files, and you may want to rebuild you "_install", it is recommended that these be put in a file. Below the file createdev is created with the following contents:

  #!/bin/bash
  # put this in a file called createdev
  #
  cp -avp /dev/console   dev
  cp -avp /dev/core   dev
  cp -avp /dev/fd0   dev
  cp -avp /dev/null   dev
  cp -avp /dev/ptmx   dev
  cp -avp /dev/pts   dev
  cp -avp /dev/ram0   dev
  cp -avp /dev/ram1   dev
  cp -avp /dev/ram2   dev
  cp -avp /dev/ram3   dev
  cp -avp /dev/random   dev
  cp -avp /dev/stderr   dev
  cp -avp /dev/stdin   dev
  cp -avp /dev/stdout   dev
  cp -avp /dev/tty   dev
  cp -avp /dev/tty0   dev
  cp -avp /dev/tty1   dev
  cp -avp /dev/tty2   dev
  cp -avp /dev/tty3   dev
  cp -avp /dev/tty4   dev
  cp -avp /dev/tty5   dev
  cp -avp /dev/tty6   dev
  cp -avp /dev/tty7   dev
  cp -avp /dev/tty8   dev
  cp -avp /dev/tty9   dev
  cp -avp /dev/urandom   dev
  cp -avp /dev/vcs   dev
  cp -avp /dev/zero dev

Now run the command, as root, in "_install"

  $ su
  # pwd
  /home/chirico/busybox/busybox-1.00/_install

  # chmod 700 createdev
  # ./createdev

The "ls -al" command now shows the following contents.

  # ls -l dev
  total 4
  crw-------    1 root     root       5,   1 Feb 17 14:49 console
  crw-------    1 root     root       1,   6 Jan 30  2003 core
  brw-rw----    1 root     floppy     2,   0 Jan 30  2003 fd0
  crw-rw-rw-    1 root     root       1,   3 Jan 30  2003 null
  crw-rw-rw-    1 root     root       5,   2 Mar  5 17:16 ptmx
  drwxr-xr-x    2 root     root         4096 Feb 17 09:48 pts
  brw-rw----    1 root     disk       1,   0 Jan 30  2003 ram0
  brw-rw----    1 root     disk       1,   1 Jan 30  2003 ram1
  brw-rw----    1 root     disk       1,   2 Jan 30  2003 ram2
  brw-rw----    1 root     disk       1,   3 Jan 30  2003 ram3
  crw-r--r--    1 root     root       1,   8 Jan 30  2003 random
  lrwxr-xr-x    1 root     root           17 Mar  5 17:16 stderr -> ../proc/self/fd/2
  lrwxr-xr-x    1 root     root           17 Mar  5 17:16 stdin -> ../proc/self/fd/0
  lrwxr-xr-x    1 root     root           17 Mar  5 17:16 stdout -> ../proc/self/fd/1
  crw-rw-rw-    1 root     root       5,   0 Mar  3 21:20 tty
  crw--w----    1 root     root       4,   0 Jan 30  2003 tty0
  crw-------    1 root     root       4,   1 Feb 17 14:49 tty1
  crw-------    1 root     root       4,   2 Feb 17 14:49 tty2
  crw-------    1 root     root       4,   3 Feb 17 14:49 tty3
  crw-------    1 root     root       4,   4 Feb 17 14:49 tty4
  crw-------    1 root     root       4,   5 Feb 17 14:49 tty5
  crw-------    1 root     root       4,   6 Feb 17 14:49 tty6
  crw--w----    1 root     root       4,   7 Oct 24  2003 tty7
  crw--w----    1 root     root       4,   8 Jan 30  2003 tty8
  crw--w----    1 root     tty        4,   9 Jan 30  2003 tty9
  crw-r--r--    1 root     root       1,   9 Feb 17 14:49 urandom
  crw--w----    1 vcsa     tty        7,   0 Jan 30  2003 vcs
  crw-rw-rw-    1 root     root       1,   5 Jan 30  2003 zero

These files could all have been created with the "mknod" command. Taking a look at "tty" above, about half way down, it is a character device with a major number of 5 and a minor number of 0. It has rights rw-rw-rw. So the "tty" device could have been created with the command "mknod -m 666 dev/tty c 5 0" . But, you ask, where can you get a listing of all the major and minor numbers for both block and character devices? This can be found in "/Documentation/devices.txt" in the kernel source. Or, you can see them all here: http://souptonuts.sourceforge.net/devices.txt

So, if you want to mount disk drives, ide (hda) and scsi (sda) consider executing the following commands:

  mknod -m 660 dev/hda  b 3 0
  mknod -m 660 dev/hda1 b 3 1
  mknod -m 660 dev/hda2 b 3 2
  mknod -m 660 dev/hda3 b 3 3
  mknod -m 660 dev/hda4 b 3 4
  chown root.disk  dev/hda*

  mknod -m 660 dev/sda  b 8 0
  mknod -m 660 dev/sda1  b 8 1
  mknod -m 660 dev/sda2  b 8 2
  mknod -m 660 dev/sda2  b 8 3
  mknod -m 660 dev/sda2  b 8 4
  chown root.disk  dev/sda*

After the PC is booted from the CD, you can mount these devices after creating a directory as the mount point "mkdir /h", then, it gets mounted as "mount -t ext2 /dev/hda2 /h".

It is also possible to create volume groups

  mkdir -p dev/mapper
  mknod -m 600 dev/mapper/VolGroup00-LogVol00 b 253 0
  mknod -m 600 dev/mapper/VolGroup00-LogVol01 b 253 1
  chown -R root.root dev/mapper

Create a directory "/v1"

  mkdir -p /v1

The VolGroup would be mounted as ext3, most likely by doing the following after creating a mount point "/v1", then, "mount -t ext3 /dev/VolGroup00/LogVol01 /v1". But, would require the proper device drivers to be loaded in the kernel module, and the needed configuration in "/etc/rc.sysinit", notably the section under "# LVM2 initializtion". All of this will be discussed in a future update of this article.

 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇:基于FreeBSD5.4全能服务器安装v1.01   下一篇:使用 Perl 自动化 UNIX 系统管理

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
Power by linux-cn.com 粤ICP备05006655号