¡¡¡¡ÕªÒª
¡¡¡¡±¾ÎÄÃèÊöÁËÈçºÎÔÚUSB´æ´¢É豸ÉϽ¨Á¢LinuxÆô¶¯ÏµÍ³µÄ¹ý³Ì¡£
¡¡¡¡Ê×ÏÈÈÃÎÒÃÇÏÈÁ˽âÒ»ÏÂLINUXÏÂUSBÉ豸, Linux USB Çý¶¯³ÌÐòÓÐÈýÖÖ²»Í¬µÄ USB Ö÷¿ØÖÆÆ÷Ñ¡Ïî,ÕâÊÇÒòΪÔÚÖ÷°åºÍ PCI ¿¨ÉÏÓÐÈýÖÖ²»Í¬ÀàÐ굀 USB оƬ¡£"EHCI"Çý¶¯³ÌÐòÉè¼Æ³ÉΪʵÏÖеĸßËÙ USB 2.0 ÐÒéµÄоƬÌṩ֧³Ö¡£"OHCI"Çý¶¯³ÌÐòÓÃÀ´Îª·Ç PC ϵͳÉϵģ¨ÒÔ¼°´øÓÐ SiS ºÍ ALi оƬ×éµÄ PC Ö÷°åÉϵģ©USB оƬÌṩ֧³Ö¡£"UHCI"Çý¶¯³ÌÐòÓÃÀ´Îª´ó¶àÊýÆäËü PC Ö÷°å£¨°üÀ¨ Intel ºÍ Via£©É쵀 USB ʵÏÖÌṩ֧³Ö¡£Ö»ÐèÑ¡ÔñÓëÏ£ÍûÆôÓÃµÄ USB Ö§³ÖµÄÀàÐͶÔÓ¦µÄ"?HCI"Çý¶¯³ÌÐò¼´¿É¡£
¡¡¡¡ÆôÓÃÁË"USB support"ºÍÊʵ±µÄ"?HCI"USB Ö÷¿ØÖÆÆ÷Çý¶¯³ÌÐòºó£¬Ê¹ USB Æô¶¯²¢ÔËÐÐÖ»ÐèÔÙ½øÐм¸¸ö²½Öè¡£Ó¦¸ÃÆôÓÃ"Preliminary USB device filesystem"£¬SCSI¼ÆËã»ú±ê×¼½Ó¿Ú,ÒòΪͨ³£ÎÒÃǵÄUSB´æ´¢É豸£¬Ä£ÄâΪSCSIÓ²Å̶ø½øÐзÃÎÊ
Ò»¡¢¹ØÓÚÄÚºË
¡¡¡¡usb-storageÄ£¿é°üÀ¨ÔÚÄں˵«ÊÇÓÉÓÚUÅ̵ijõʼ»¯¹ý³Ì±ÈÖ´ÐÐ/sbin/initÂý,µ¼ÖÂÄÚºËÒѾÆô¶¯Íê³ÉÁË£¬ÓÅÅÌ»¹Ã»ÓÐÍê³É³õʼ»¯¹¤×÷£¬Òò´Ë¸ùÎļþϵͳûÓмÓÔØ£¬ÕâʱִÐÐ/sbin/initÃüÁî¿Ï¶¨²»³É¹¦¡£ËùÒÔÒª¶ÔϵͳÄں˳õʼ»¯´úÂë×÷ÐÞ¸ÄÈçÏÂ:
/init/do_mounts.c
¡¡
* Allow the user to distinguish between failed open
* and bad superblock on root device.
*/
- printk ("VFS: Cannot open root device "%s" or %s",
+ printk ("VFS: Cannot open root device "%s" or %s,
retrying in 1 second.", root_device_name, kdevname (ROOT_DEV));
- printk ("Please append a correct "root=" boot option");
- panic("VFS: Unable to mount root fs on %s",
- kdevname(ROOT_DEV));
+ printk ("You may need to append a correct "root=" boot option");
+ printk ("or wait for the root device to become ready.");
+
+ /* wait 1 second and try again,
+ * allowing time for hubs/devices to become ready */
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(HZ);
+ goto retry;
}
panic("VFS: Unable to mount root fs on %s", kdevname(ROOT_DEV));
out:
¡¡
¡¡¡¡°´ÕÕÐèÒªÖØбàÒëÄںˡ£
¡¡¡¡ÄúÒ²¿ÉÒÔÔÚÆô¶¯ÄÚºËʱ¼ÓÔØinitrd.imgÎļþµ½ÄÚ´æÖУ¬µÈ´ý3ÃëʹÓÅÅÌÍê³É³õʼ»¯¹¤×÷£¬ÔÙÖ´ÐÐ/sbin/initÖ¸Áî¡£
1¡¢½¨Á¢initrd.imgÎļþ
# mkdir -p /mnt/initrd
# cd /tmp
# mkinitrd /tmp/initrd.gz 2.4.20-usb
2¡¢½âѹinitrd.imgÎļþ£¬ÐÞ¸ÄÆô¶¯½Å±¾linuxrc
# gunzip initrd.gz
# mount -o loop /tmp/initrd /mnt/initrd
# cp /sbin/busybox /mnt/initrd/bin
# cd /mnt/initrd/bin
# ln -s busybox sleep
# vi /mnt/initrd/linuxrc
¡¡¡¡¼ÓÈëÈçÏÂÄÚÈÝ£º
echo 'wait 3 seconds.....'
/bin/sleep 3
3¡¢ÖØÐÂÉú³Éinitrd.imgÎļþ
¡¡¡¡ÓÉÓÚȱʡ½¨Á¢µÄinitrdÎļþ±È½Ï´ó(Ϊ4MB)£¬ÎªÁ˼ӿìÓÅÅ̵ÄÆô¶¯£¬±ØÐë¼õСËü¡£¾ßÌå²Ù×÷ÈçÏ£º
# mkdir -p /mnt/initrdusb
# cd /tmp
# dd if =/dev/zero of= /tmp/initrdusb bs=1M count=1
# mke2fs -m 0 initrdusb
# mount -o loop /tmp/initrdusb /mnt/initrdusb
# cp -a /mnt/initrd/* /mnt/initrdusb
# umount /mnt/initrd
# umount /mnt/initrdusb
# cd /tmp
# gzip -9 initrdusb
# cp initrdusb.gz /boot/initrd-2.4.20-usb.img
¶þ¡¢½¨Á¢ÓÅÅÌÆô¶¯ÅäÖÃÓëĿ¼½á¹¹
(/dev, /proc, /bin, /etc, /lib, /usr, /tmp, /var)
1¡¢½«ÓÅÅÌ·Ö³ÉÁ½¸ö·ÖÇø
¡¡¡¡Áô¸øLinux·ÖÇøÈÝÁ¿´óСÍêÈ«È¡¾öÓÚ°²×°ÄÄЩϵͳά»¤¹¤¾ß£¬½á¹ûÈçÏ£º
¡¡¡¡# fdisk -l /dev/sda
¡¡¡¡Disk /dev/sda: 16 heads, 63 sectors, 126 cylinders
¡¡¡¡Units = cylinders of 1008 * 512 bytes
¡¡¡¡Device Boot Start End Blocks Id System
¡¡¡¡/dev/sda1 1 102 51376+ 6 FAT16
¡¡¡¡/dev/sda2 103 126 12096 83 Linux
¡¡¡¡×¢Ò⣺Èç¹ûÐèҪʹÓÃÓÅÅÌÒýµ¼Windows 98£¬ÉÈÇø´óС±ØÐëÉèÖÃΪ63¸öÉÈÇø£¬¿ÉÒÔͨ¹ýfdiskµÄxÃüÁîÀ©Õ¹ÐÞ¸Äheads¡¢sectorsºÍcylinders²ÎÊý¡£×îºÃ»¹ÊÇÀûÓÃUÅÌÏàÓ¦¹¤¾ß½¨Á¢.
2¡¢½¨Á¢ÓëÉú³Éext2·ÖÇø
# mke2fs -m 0 /dev/sda2
# mkdir -p /mnt/sda2
# mount /dev/sda2 /mnt/sda2
# cd /mnt/sda2
3¡¢½¨Á¢bootĿ¼
¡¡¡¡½«±àÒëºÃµÄÄÚºËÓëinitrd.imgÎļþ¿½±´µ½bootĿ¼¡¢±àÒëºÃµÄÄ£¿é¿½±´µ½lib/modulesĿ¼,ÒÔ¼°½«/boot/grubµÄÎļþ¿½±´µ½bootĿ¼,±à¼boot/grub/menu.lstÎļþ,ÄÚÈÝÈçÏÂ:
timeout 10
color 0x17 0x70
default 0
title Windows 98
rootnoverify (hd0,0)
makeactive
chainloader +1
title GNU/Linux Redhat 8.0 (2.4.20-usb)
root (hd0,1)
kernel /boot/bzImage ro root=/dev/sda2
initrd /boot/ initrd.img //Èç¹ûûÓÐinitrd.img,Õâ¾ä¾Í²»ÒªÁË
¡¡¡¡°²×°grub,¾ßÌå²Ù×÷ÈçÏ£º
grub> root (hd1,1)
grub> setup (hd1)
4¡¢½¨Á¢binĿ¼
¡¡¡¡¸ù¾Ý×Ô¹¤×÷µÄÐèÒª¿½±´ÏµÍ³Î¬»¤¹¤¾ß£¬Èçinsmod¡¢fsckºÍmkdosfsµÈʵÓóÌÐò¡£
¡¡¡¡¶ÔÓÚ³£ÓõŤ¾ß,½¨ÒéʹÓÃtinylogin http://tinylogin.busybox.net »òÕßbusybox http://www.busybox.net,ËüÃÇ¿ÉÒÔÈÏÄú½ÚÔ¼²»Ê¡µÄ¿Õ¼ä.
¡¡¡¡ÁíÍ⣬Èç¹ûʹÓÃbash£¬»¹±ØÐë±à¼Óë²Ã¼õ/etc/termcap¼°ÈçÏÂÎļþ£º
/bin/bash
/etc/termcap
/usr/share/terminfo/l/linux
/usr/share/terminfo/k/klone+acs
/usr/share/terminfo/k/klone+color
/usr/share/terminfo/k/klone+sgr
5¡¢½¨Á¢dev proc usr sbinĿ¼
¡¡¡¡Ê¹ÓÃcp -aÃüÁ±´³£ÓõÄÉ豸Îļþ,°üÀ¨console¡¢tty1¡¢tty2¡¢tty3sda¡¢sda1¡¢sda2¡¢hda¡¢hdbºÍhda1µÈÉ豸Îļþ¡£Èç¹ûÄúµÄÄÚºËʹÓÃDevfs, Ö»Òª½¨Á¢Õâ¸öĿ¼¼´¿É.
¡¡¡¡½¨Á¢proc usr sbinĿ¼,ÄãÁË¿ÉÒÔln -s bin sbin½¨Á¢sbinµÄÁ¬½Ó.
6¡¢½¨Á¢libĿ¼
¡¡¡¡Ò»¶¨Òª×¢ÒâʹÓÃlddÃüÁî¼ì²éÄÇЩ¹²Ïí¿âÎļþ,ÕâЩÎļþÐèÒª°´ÕÕÔÀ´µÄ·¾¶¿½±´µ½libĿ¼¡£
¡¡¡¡Ò»°ãÓ¦ÓÐÈçÏÂÎļþ:
/lib:
-rwxr-xr-x 1 root root 45415 Nov 1 15:39 ld-2.0.7.so
lrwxrwxrwx 1 root root 11 Nov 1 15:39 ld-linux.so.2 ->
ld-2.0.7.so
-rwxr-xr-x 1 root root 731548 Nov 1 15:39 libc-2.0.7.so
lrwxrwxrwx 1 root root 13 Nov 1 15:39 libc.so.6 ->
libc-2.0.7.so
lrwxrwxrwx 1 root root 17 Nov 1 15:39 libcom_err.so.2 ->
libcom_err.so.2.0
-rwxr-xr-x 1 root root 6209 Nov 1 15:39 libcom_err.so.2.0
-rwxr-xr-x 1 root root 153881 Nov 1 15:39 libcrypt-2.0.7.so
lrwxrwxrwx 1 root root 17 Nov 1 15:39 libcrypt.so.1 ->
libcrypt-2.0.7.so
-rwxr-xr-x 1 root root 12962 Nov 1 15:39 libdl-2.0.7.so
lrwxrwxrwx 1 root root 14 Nov 1 15:39 libdl.so.2 ->
libdl-2.0.7.so
lrwxrwxrwx 1 root root 14 Nov 1 15:39 libpam.so.0 ->
libpam.so.0.64
-rwxr-xr-x 1 root root 26906 Nov 1 15:39 libpam.so.0.64
lrwxrwxrwx 1 root root 19 Nov 1 15:39 libpam_misc.so.0 ->
libpam_misc.so.0.64
-rwxr-xr-x 1 root root 7086 Nov 1 15:39 libpam_misc.so.0.64
-r-xr-xr-x 1 root root 35615 Nov 1 15:39 libproc.so.1.2.6
lrwxrwxrwx 1 root root 19 Nov 1 15:39 libtermcap.so.2 ->
libtermcap.so.2.0.8
-rwxr-xr-x 1 root root 12041 Nov 1 15:39 libtermcap.so.2.0.8
-rwxr-xr-x 1 root root 12874 Nov 1 15:39 libutil-2.0.7.so
lrwxrwxrwx 1 root root 16 Nov 1 15:39 libutil.so.1 ->
libutil-2.0.7.so
drwx--x--x 3 root root 1024 Nov 1 15:39 modules
drwx--x--x 2 root root 1024 Nov 1 15:39 security
/lib/modules:
drwx--x--x 4 root root 1024 Nov 1 15:39 2.0.35
/lib/modules/2.0.35:
drwx--x--x 2 root root 1024 Nov 1 15:39 block
drwx--x--x 2 root root 1024 Nov 1 15:39 cdrom
/lib/modules/2.0.35/block:
drwx------ 1 root root 7156 Nov 1 15:39 loop.o
/lib/modules/2.0.35/cdrom:
drwx------ 1 root root 24108 Nov 1 15:39 cdu31a.o
/lib/security:
-rwx--x--x 1 root root 8771 Nov 1 15:39 pam_permit.so
Èý¡¢½¨Á¢ÅäÖÃÎļþ
1¡¢±à¼etc/init.d/rcS ?ÎļþÃû¾ö¶¨ÓÚetc/inittab
¡¡¡¡ÄÚÈÝÈçÏ£º
#!/bin/sh
PATH=/sbin:/bin
export PATH
mount -n -t proc none /proc
umount /initrd
mount -n -o remount,rw /
mount -n -o remount,rw -t proc none /proc
ifconfig lo 127.0.0.1
hostname UsbBoot
2¡¢±à¼etc/fstabÎļþ
¡¡¡¡ÄÚÈÝÈçÏ£º
/dev/sda2 / ext2 defaults 1 1
none /proc proc defaults 0 0
3¡¢½¨Á¢etc/inittabÎļþ£¬Èç¹ûÓÃbusyboxÉú³ÉµÄinitÕâ¸öÎļþ¿ÉÒÔ²»Òª¡£
id:2:initdefault:
si::sysinit:/etc/rcS
1:2345:respawn:/sbin/getty 9600 tty1
2:23:respawn:/sbin/getty 9600 tty2
4¡¢½¨Á¢nsswitch.confÎļþ
passwd: files
shadow: files
group: files
hosts: files
services: files
networks: files
protocols: files
rpc: files
ethers: files
netmasks: files
bootparams: files
automount: files
aliases: files
netgroup: files
publickey: files
5¡¢½¨Á¢/etc/pam.confÎļþ
OTHER auth optional /lib/security/pam_permit.so
OTHER account optional /lib/security/pam_permit.so
OTHER password optional /lib/security/pam_permit.so
OTHER session optional /lib/security/pam_permit.so
6¡¢½¨Á¢passwd,group,shadowÎļþ
¡¡¡¡×î¼òµ¥µÄ·½·¨¾ÍÊǸ´ÖÆÔϵͳµÄÎļþÔٱ༡£
hongkeyin ÓÚ 2006-12-16 11:17:26·¢±í:
¿´Ìû²»ÅÂÉÙ
¾µä²ÅÖØÒª
´ó¼Ò¶¼¿´¿´°Éhighing