私の root ディスクおよび utility ディスクのディレクトリ一覧です。 このリストはシステムを作る際、あくまで例として利用して下さい。有益と思 えるコメントをいくつか書き込んであります。
total 18 drwxr-xr-x 2 root root 1024 Jul 29 21:16 bin/ drwxr-xr-x 2 root root 9216 Jul 28 16:21 dev/ drwxr-xr-x 3 root root 1024 Jul 29 20:25 etc/ drwxr-xr-x 2 root root 1024 Jul 28 19:53 lib/ drwxr-xr-x 2 root root 1024 Jul 24 22:47 mnt/ drwxr-xr-x 2 root root 1024 Jul 24 22:47 proc/ drwxr-xr-x 2 root root 1024 Jul 28 19:07 sbin/ drwxr-xr-x 2 root root 1024 Jul 29 20:57 tmp/ drwxr-xr-x 4 root root 1024 Jul 29 21:35 usr/ drwxr-xr-x 3 root root 1024 Jul 28 19:52 var/ bin: total 713 -rwxr-xr-x 1 root bin 7737 Jul 24 22:16 cat* -rwxr-xr-x 1 root bin 9232 Jul 24 22:48 chmod* -rwxr-xr-x 1 root bin 8156 Jul 24 22:48 chown* -rwxr-xr-x 1 root bin 19652 Jul 24 22:48 cp* -rwxr-xr-x 1 root root 8313 Jul 29 21:16 cut* -rwxr-xr-x 1 root bin 12136 Jul 24 22:48 dd* -rwxr-xr-x 1 root bin 9308 Jul 24 22:48 df* -rwxr-xr-x 1 root root 9036 Jul 29 20:24 dircolors* -rwxr-xr-x 1 root bin 9064 Jul 24 22:48 du* -rwxr-x--- 1 root bin 69252 Jul 24 22:51 e2fsck* -rwxr-xr-x 1 root bin 5361 Jul 24 22:48 echo* -rwxr-xr-x 1 root bin 5696 Jul 24 22:16 hostname* -rwxr-xr-x 1 root bin 6596 Jul 24 22:49 kill* -rwxr-xr-x 1 root bin 10644 Jul 24 22:17 ln* -rwxr-xr-x 1 root bin 13508 Jul 24 22:17 login* -rwxr-xr-x 1 root bin 26976 Jul 24 22:17 ls* -rwxr-xr-x 1 root bin 7416 Jul 24 22:49 mkdir* -rwxr-x--- 1 root bin 34596 Jul 24 22:51 mke2fs* -rwxr-xr-x 1 root bin 6712 Jul 24 22:49 mknod* -rwxr-xr-x 1 root bin 20304 Jul 24 22:17 more* -rwxr-xr-x 1 root bin 24704 Jul 24 22:17 mount* -rwxr-xr-x 1 root bin 12464 Jul 24 22:17 mv* -rwxr-xr-x 1 root bin 20829 Jul 24 22:50 ps* -rwxr-xr-x 1 root bin 9424 Jul 24 22:50 rm* -rwxr-xr-x 1 root bin 4344 Jul 24 22:50 rmdir* -rwxr-xr-x 1 root root 299649 Jul 27 14:12 sh* -rwxr-xr-x 1 root bin 9853 Jul 24 22:17 su* -rwxr-xr-x 1 root bin 380 Jul 27 14:12 sync* -rwxr-xr-x 1 root bin 13620 Jul 24 22:17 umount* -rwxr-xr-x 1 root root 5013 Jul 29 20:03 uname* dev: total 0 lrwxrwxrwx 1 root root 10 Jul 24 22:34 cdrom -> /dev/sbpcd crw--w--w- 1 root tty 4, 0 Jul 24 21:49 console brw-rw---- 1 root floppy 2, 0 Apr 28 1995 fd0 lrwxrwxrwx 1 root root 4 Jul 24 22:34 ftape -> rft0 crw-rw-rw- 1 root sys 10, 2 Jul 18 1994 inportbm crw-rw---- 1 root kmem 1, 2 Jul 28 16:21 kmem crw-rw---- 1 root kmem 1, 1 Jul 18 1994 mem lrwxrwxrwx 1 root root 4 Jul 24 22:34 modem -> cua0 lrwxrwxrwx 1 root root 4 Jul 24 22:34 mouse -> cua1 crw-rw-rw- 1 root sys 1, 3 Jul 18 1994 null brw-rw---- 1 root disk 1, 1 Jul 18 1994 ram crw-rw---- 1 root disk 27, 0 Jul 18 1994 rft0 brw-rw---- 1 root disk 25, 0 Jul 19 1994 sbpcd
*** ここでは SCSI パーティションのためのデバイスを置いています。 IDE *** を使っている場合は代わりに /dev/hdxx を使って下さい。 brw-rw---- 1 root disk 8, 0 Apr 29 1995 sda brw-rw---- 1 root disk 8, 6 Apr 29 1995 sda6 brw-rw---- 1 root disk 8, 7 Apr 29 1995 sda7 brw-rw---- 1 root disk 8, 8 Apr 29 1995 sda8 lrwxrwxrwx 1 root root 7 Jul 28 12:56 systty -> console
***この systty から console へのリンクは必要です。 crw-rw-rw- 1 root tty 5, 0 Jul 18 1994 tty crw--w--w- 1 root tty 4, 0 Jul 18 1994 tty0 crw--w---- 1 root tty 4, 1 Jul 24 22:33 tty1 crw--w---- 1 root tty 4, 2 Jul 24 22:34 tty2 crw--w--w- 1 root root 4, 3 Jul 24 21:49 tty3 crw--w--w- 1 root root 4, 4 Jul 24 21:49 tty4 crw--w--w- 1 root root 4, 5 Jul 24 21:49 tty5 crw--w--w- 1 root root 4, 6 Jul 24 21:49 tty6 crw-rw-rw- 1 root tty 4, 7 Jul 18 1994 tty7 crw-rw-rw- 1 root tty 4, 8 Jul 18 1994 tty8 crw-rw-rw- 1 root tty 4, 9 Jul 19 1994 tty9 crw-rw-rw- 1 root sys 1, 5 Jul 18 1994 zero etc: total 20 -rw-r--r-- 1 root root 2167 Jul 29 20:25 DIR_COLORS -rw-r--r-- 1 root root 20 Jul 28 12:37 HOSTNAME -rw-r--r-- 1 root root 109 Jul 24 22:57 fstab -rw-r--r-- 1 root root 271 Jul 24 22:21 group -rw-r--r-- 1 root root 2353 Jul 24 22:27 inittab -rw-r--r-- 1 root root 0 Jul 29 21:02 issue -rw-r--r-- 1 root root 2881 Jul 28 19:38 ld.so.cache
*** ブート時に ld.so.cache がないと、動かなくなるものがたくさん出ます。 *** このファイルをアップデートする ldconfig が rc.x スクリプトから実行 *** されるようになっていることも確認して下さい。 -rw-r--r-- 1 root root 12 Jul 24 22:22 motd -rw-r--r-- 1 root root 606 Jul 28 19:25 passwd -rw-r--r-- 1 root root 1065 Jul 24 22:21 profile drwxr-xr-x 2 root root 1024 Jul 29 21:01 rc.d/ -rw-r--r-- 1 root root 18 Jul 24 22:21 shells -rw-r--r-- 1 root root 774 Jul 28 13:43 termcap -rw-r--r-- 1 root root 126 Jul 28 13:44 ttys -rw-r--r-- 1 root root 0 Jul 24 22:47 utmp etc/rc.d: total 5
*** shutdown スクリプトは使いません。 RAM ディスクでしか使っていません *** から、特にシャットダウンに気を使う必要はありません。 -rwxr-xr-x 1 root root 1158 Jul 24 22:23 rc.K* -rwxr-xr-x 1 root root 1151 Jul 28 19:08 rc.M* -rwxr-xr-x 1 root root 507 Jul 29 20:25 rc.S* lib: total 588
*** 私は ELF システムを使っていますから ELF のローダである ld-linux.so *** を置いてあります。まだ a.out のシステムを使っている方は ld.so が必 *** 要になります。ライブラリがどちらのものかを調べるには file コマンド *** を使います。 lrwxrwxrwx 1 root root 17 Jul 24 23:36 ld-linux.so.1 -> ld-linux.so.1.7.3* -rwxr-xr-x 1 root root 20722 Aug 15 1995 ld-linux.so.1.7.3* lrwxrwxrwx 1 root root 13 Jul 24 23:36 libc.so.5 -> libc.so.5.0.9* -rwxr-xr-x 1 root root 562683 May 19 1995 libc.so.5.0.9*
*** libtermcap は必須です。 lrwxrwxrwx 1 root root 19 Jul 28 19:53 libtermcap.so.2 -> libtermcap.so.2.0.0* -rwxr-xr-x 1 root root 11360 May 19 1995 libtermcap.so.2.0.0* mnt: total 0 proc: total 0 sbin: total 191
*** 私は Slackware なので agetty が使われています。他の多くのシステム *** は getty を使っています。 /etc/inittab を見て、どちらが使われてい *** るか調べて下さい。ブート後に何をするにしても (a)getty と login は *** 必ず必要ですから忘れないように。 -rwxr-xr-x 1 root bin 11309 Jul 24 22:54 agetty* -rwxr-xr-x 1 root bin 5204 Jul 24 22:19 halt*
*** これが無いとブートしません -rwxr-xr-x 1 root bin 20592 Jul 24 22:19 init* -rwxr-xr-x 1 root root 86020 Jul 28 19:07 ldconfig* -rwxr-xr-x 1 root bin 5329 Jul 27 14:10 mkswap* -rwxr-xr-x 1 root root 5204 Jul 24 22:20 reboot* -rwxr-xr-x 1 root bin 12340 Jul 24 22:20 shutdown* -rwxr-xr-x 1 root root 5029 Jul 24 22:20 swapoff* -rwxr-xr-x 1 root bin 5029 Jul 24 22:20 swapon* -rwxr-xr-x 1 root root 20592 Jul 27 18:18 telinit* -rwxr-xr-x 1 root root 7077 Jul 24 22:20 update* tmp: total 0 usr: total 2 drwxr-xr-x 2 root root 1024 Jul 29 21:00 adm/ drwxr-xr-x 2 root root 1024 Jul 29 21:16 lib/ usr/adm: total 0 usr/lib: total 0 var: total 1
*** 私のシステムでは、このディレクトリを作って /etc/rc.S に *** /var/run/utmp を作る行を入れるまでは、文句を言うコマンドがいくつか *** ありました。しかし他のシステムでは不要かもしれません。 drwxr-xr-x 2 root root 1024 Jul 28 19:52 run/ var/run: total 0
total 579 -rwxr-xr-x 1 root root 42333 Jul 28 19:05 cpio* -rwxr-xr-x 1 root root 103560 Jul 29 21:31 elvis* -rwxr-xr-x 1 root root 56401 Jul 28 19:06 find* -rw-r--r-- 1 root root 128254 Jul 28 19:03 ftape.o -rwxr-xr-x 1 root root 64161 Jul 29 20:47 grep* -rwxr-xr-x 1 root root 45309 Jul 29 20:48 gzip* -rwxr-xr-x 1 root root 23560 Jul 28 19:04 insmod* -rwxr-xr-x 1 root root 118 Jul 28 19:04 lsmod* lrwxrwxrwx 1 root root 5 Jul 28 19:04 mt -> mt-st* -rwxr-xr-x 1 root root 9573 Jul 28 19:03 mt-st* lrwxrwxrwx 1 root root 6 Jul 28 19:05 rmmod -> insmod* -rwxr-xr-x 1 root root 104085 Jul 28 19:05 tar* lrwxrwxrwx 1 root root 5 Jul 29 21:35 vi -> elvis*
これらのシェルスクリプトはあくまで例として挙げたものです。私はこれらの スクリプトを自分のシステムでレスキュー用フロッピーを作るときに用いてい ます。読者の皆さんにも便利に使っていただけるかもしれませんが、その場合 でも説明を注意して読んで下さい。例えばスワップデバイスを間違えて指定す ると、ルートファイルシステムは徹底的に、そして永久に消え去ってし まいます。ですから使う前に設定が正しいかどうか、何度も何度も確認 して下さい。
これらのスクリプトを用いると、レスキュー用ディスクのセットを手早く作る ことができます。
シェルスクリプトは 2 つあります。
現在のところ両者はそれぞれ boot_disk、util_disk の親ディレクトリで起動 するようになっています。各ディレクトリには各々のフロッピーにコピーする ものを全部入れておきます。これらのシェルスクリプトは自動的に必要なファ イルを選んで上記ディレクトリにコピーしてくれるわけではありません。どの ファイルが必要かは自分で決めて、これらのディレクトリにコピーする必要が あります。ここで紹介するのはディレクトリの内容をフロッピーにコピーする シェルスクリプトの例です。ここで紹介するシェルスクリプトは原始的なもの で、初心者向けの物ではないことに注意して下さい。
それぞれのシェルスクリプトの先頭部では、設定用の変数を指定しています。 この値を変えれば boot_disk や util_disk 以外のディレクトリでこれらのス クリプトを使用できます。まずディレクトリ名を決めてそのディレクトリを作 成し、必要なファイルを全てそこにコピーして下さい。必要なディレクトリや ファイルに関しては、先の節で示したディレクトリ一覧を見て下さい。
シェルスクリプト中で設定に用いている変数をチェックして、お望みの通りに 書き換えてからスクリプトを実行して下さい。
# mkroot: make a root disk - creates a root diskette # by building a file system on it, then mounting it and # copying required files from a model. # Note: the model to copy from from must dirst be set up, # then change the configuration variables below to suit # your system. # # usage: mkroot [ -d swap | ram ] # where swap means use $SWAPDEV swap device # and ram means use $RAMDISKDEV ramdisk device # Copyright (c) Graham Chapman 1996. All rights reserved. # Permission is granted for this material to be freely # used and distributed, provided the source is acknowledged. # No warranty of any kind is provided. You use this material # at your own risk. # Configuration variables - set these to suit your system # #### set the device to use to build the root filesystem on. #### ramdisk is safer - swap is ok only if you have plenty of #### free memory. If linux can't swap then things get nasty. USEDEVICE="ramdisk" # set to either "ramdisk" or "swap" RAMDISKDEV="/dev/ram" # ramdisk device <==== CHANGE if using ramdisk SWAPDEV="/dev/sda7" # swap device <==== CHANGE if using swap FSBLOCKS=3072 # desired filesystem size in blocks # #### set name or directory where you have set up your rootdisk #### model ROOTDISKDIR="./root_disk" # name of root disk directory MOUNTPOINT="/mnt" # temporary mount point for diskette DISKETTEDEV="/dev/fd0" # device name of diskette drive LOGFL="`pwd`/mkroot.log" # log filename TEMPROOTFS="/tmp/mkrootfs.gz" # temp file for compressed filesystem # End of Configuration variables # Internal variables ROOTDISKDEV= case $USEDEVICE in swap|ramdisk) :;; *) echo "Invalid setting for USEDEVICE variable" exit;; esac clear echo " ***************** W A R N I N G ****************** Use this script with care. If you don't understand it, then exit NOW!" if [ "$USEDEVICE" = "swap" ] then ROOTDISKDEV=$SWAPDEV echo -e "\nThis script will temporarily remove the swap file $SWAPDEV" echo "and use the space to build a compressed root filesystem from" echo "the files in the directory tree below $ROOTDISKDIR. To do this" echo "safely you must have 8Mb or more of memory, and you should" echo "switch to single user mode via 'init 1'." echo -e "\nIf you have used a ramdisk since the last reboot, then" echo "reboot NOW before using this script." echo -e "\nIf the script fails, you may not have a swap partition. Run 'free'" echo "and check the total size to see if it is correct. If the swap" echo "partition $SWAPDEV is missing, do the following:" echo " umount $MOUNTPOINT" echo " mkswap $SWAPDEV" echo " swapon $SWAPDEV" echo "to restore the swap partition $SWAPDEV." else ROOTDISKDEV=$RAMDISKDEV echo -e "\nThis script will use a ramdisk of $FSBLOCKS Kb. To do this safely" echo "you must have at least 8Mb of memory. If you have only 8Mb you should" echo "ensure nothing else is running on the machine." echo -e "\nWhen the script is complete, the ramdisk will still be present, so" echo "you should reboot to reclaim the memory allocated to the ramdisk." fi echo -e " Do you want to continue (y/n)? \c" read ans if [ "$ans" != "Y" -a $ans != "y" ] then echo "not confirmed - aborting" exit fi echo "Starting mkroot at `date`" > $LOGFL if [ "$USEDEVICE" = "swap" ] then echo "Unmounting swap device $SWAPDEV" | tee -a $LOGFL swapoff $SWAPDEV >> $LOGFL 2>&1 fi echo "Zeroing device $ROOTDISKDEV" | tee -a $LOGFL dd if=/dev/zero of=$ROOTDISKDEV bs=1024 count=$FSBLOCKS >> $LOGFL 2>&1 if [ $? -ne 0 ] then echo "dd zeroing $ROOTDISKDEV failed" | tee -a $LOGFL exit 1 fi echo "Creating filesystem on device $ROOTDISKDEV" | tee -a $LOGFL mke2fs -m0 $ROOTDISKDEV $FSBLOCKS >> $LOGFL 2>&1 echo "Mounting $ROOTDISKDEV filesystem at $MOUNTPOINT" | tee -a $LOGFL mount -t ext2 $ROOTDISKDEV $MOUNTPOINT >> $LOGFL 2>&1 if [ $? -ne 0 ] then echo "mount failed" exit 1 fi # copy the directories containing files echo "Copying files from $ROOTDISKDIR to $MOUNTPOINT" | tee -a $LOGFL currdir=`pwd` cd $ROOTDISKDIR find . -print | cpio -dpumv $MOUNTPOINT >> $LOGFL 2>&1 if [ $? -ne 0 ] then echo "cpio step failed." cd $currdir exit 1 fi cd $currdir fssize=`du -sk $MOUNTPOINT|cut -d" " -f1` echo "Uncompressed root filesystem size is $fssize Kb" | tee -a $LOGFL echo "Unmounting filesystem from $ROOTDISKDEV" | tee -a $LOGFL umount $MOUNTPOINT >> $LOGFL 2>&1 echo "Compressing filesystem from $ROOTDISKDEV into $TEMPROOTFS This may take a few minutes..." | tee -a $LOGFL # We don't bother with gzip -9 here - takes more than twice as long # and saves less than 1% in space on my root disk... dd if=$ROOTDISKDEV bs=1024 count=$FSBLOCKS 2>>$LOGFL | gzip -c > $TEMPROOTFS fssize=`du -k $TEMPROOTFS|cut -d" " -f1` echo "Compressed root filesystem size is $fssize Kb" | tee -a $LOGFL echo -e "Insert diskette in $DISKETTEDEV and press any key *** Warning: data on diskette will be overwritten!\c" read ans echo "Copying compressed filesystem from $TEMPROOTFS to $DISKETTEDEV" | tee -a $LOGFL dd if=$TEMPROOTFS of=$DISKETTEDEV >>$LOGFL 2>&1 if [ $? -ne 0 ] then echo "copy step failed." exit 1 fi if [ "$USEDEVICE" = "swap" ] then echo "Reinitialising swap device $SWAPDEV" | tee -a $LOGFL mkswap $SWAPDEV >> $LOGFL 2>&1 echo "Starting swapping to swap device $SWAPDEV" | tee -a $LOGFL swapon $SWAPDEV >> $LOGFL 2>&1 fi echo "Deleting $TEMPROOTFS" | tee -a $LOGFL rm $TEMPROOTFS echo "mkroot completed at `date`" >> $LOGFL echo "Root diskette creation complete - please read log file $LOGFL"
# mkutil: make a utility diskette - creates a utility diskette # by building a file system on it, then mounting it and # copying required files from a model. # Note: the model to copy from from must first be set up, # then change the configuration variables below to suit # your system. # Copyright (c) Graham Chapman 1996. All rights reserved. # Permission is granted for this material to be freely # used and distributed, provided the source is acknowledged. # No warranty of any kind is provided. You use this material # at your own risk. # Configuration variables... UTILDISKDIR=./util_disk # name of directory containing model MOUNTPOINT=/mnt # temporary mount point for diskette DISKETTEDEV=/dev/fd0 # device name of diskette drive echo $0: create utility diskette echo Warning: data on diskette will be overwritten! echo Insert diskette in $DISKETTEDEV and and press any key... read anything mke2fs $DISKETTEDEV if [ $? -ne 0 ] then echo mke2fs failed exit fi # Any file system type would do here mount -t ext2 $DISKETTEDEV $MOUNTPOINT if [ $? -ne 0 ] then echo mount failed exit fi # copy the directories containing files cp -dpr $UTILDISKDIR/* $MOUNTPOINT umount $MOUNTPOINT echo Utility diskette complete