10005. Making Linux's USB flash drive

xiaoxiao2021-03-06  84

USB flash storage (USD) typically only has a keychain size, storage capacity is 32MB and 64MB. Due to the advantages of light and exquisite, easy to use, easy to carry, especially the comparison floppy disk has large capacity, safe and reliable, and the speed is faster, and more and more people use this device to replace the floppy drive and floppy disk, in PC Switching between files. The new motherboard BIOS is currently supported by USB floppy disk and hard drives, so that the system maintenance and installation work for Windows 98 is increasingly convenient. However, manufacturers only provide production tools for making Windows 98 boot disks, do not provide Linux boot disk making tools. Establishing a Linux boot disk on a USB flash drive, which has more practical meaning for system maintenance personnel, you can use Linux to create a small core, establish a network environment, quickly judge and exclude network failures and transfer files. This paper uses Red Hat 8.0 as an example, using Ranco's dual-activated USB flash drive to establish a Linux boot disk. Download Related Software: E3, BVI, LiUux kernel. Compile the kernel First Computer motherboard must support the starting mode of the USB hard drive, and the USB flash drive is the start-type USB flash drive. I will explain with Linux-2.4.20. Be careful when compiling do not compile unnecessary modules, such as sound card driver, etc., so that the compiled kernel is small as possible. Because you want to support the USB flash drive, you must compile SCSI devices, USBCORE, USB-Storage, Loopback Device Support, Ram Disk Support, and InitRD to the kernel. Many people will ask, the USB-Storage module has included why I have to build the initrd.img file? This is because the initialization process of the USB flash drive is slower than the execution / sbin / init, causing the kernel that has been completed, the USB flash drive has not completed the initialization work, so the root file system is not loaded, and the execution / sbin / init command is not successful. By establishing the init.img file, load the initrd.img file to the memory when the kernel is started, wait for 3 seconds to make the USB flash drive complete the initialization work, then execute / sbin / init instruction. The specific steps are as follows. 1. Establishing the initrd.img file # mkdir -p / mnt / initrd # cd / tmp # mkinitrd /tmp/initrd.gz 2.4.20-usb2. Unzip the initrd.img file, modify the startup script Linuxrc # Gunzip Initrd.gz # mount -o loop / tmp / initrd / mnt / initrd # cp / sbin / busybox / mnt / initrd / bin # l-t it it s le # VI / MNT / INITRD / LinuxRC Add to: echo 'Wait 3 Seconds .....' / bin / sleep 33. Reconstruction of initrd.img files Due to the default initrd file is relatively large (4MB), in order to speed up the startup of the USB flash drive, it must be reduced.

The specific operations are as follows: # 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.img4. Test whether the compiled kernel is normal to start the test compiled kernel is normal start, and whether the relevant information of the USB flash drive can be seen during the startup process. Create a USB flash drive 1. Divide the USD to the two partitions to the Linux partition capacity is completely dependent on which system maintenance tools are installed. The results are as follows: # modprobe usb-storage # fdisk -l / dev / sdadisk / dev / sda: 16 heads , 63 Sectors, 126 cylindersunits = cyclinders of 1008 * 512 BYTESDEVICE BOOT START END Blocks ID System / DEV / SDA1 1 102 51376 6 FAT16 / DEV / SDA2 103 126 12096 83 Linux Note: You need to boot Windows 98, sector The size must be set to 63 sectors, which can extend the HEADS, SECTORS and CYLINDERS parameters via FDisk X command. 2. Establish and generate EXT2 partition # mke2fs -m 0 / dev / sda2 # mount / dev / sda2 / mnt / sda2 # CD / MNT / SDA23. Establishing Boot Directory to compile the kernel and Initrd-2.4.20-usb.img file copy to the boot directory, compile the module to the lib / modules directory, and copy / boot / grub's file to the boot directory, edit boot / grub / menu.lst file, content as follows: timeout 10color 0x17 0x70default 0title Windows 98 (hd0,0) rootnoverify makeactivechainloader 1title GNU / Linux redhat 8.0 (2.4.20-usb) root (hd0,1) kernel /boot/vmlinuz-2.4.20-usb ro root = / dev / sda2 initrd /boot/initrd-2.4.20-usb.img Installing GRUB, the specific operations are as follows: GRUB> root (hd1, 1) GRUB> Setup (HD1) 4. Establish a bin directory according to self-work requirement copy system Maintenance tools such as INSMOD, FSCK, and MKDOSFS. Be sure to use the LDD command to check those shared library files, these files need to copy to the lib directory according to the original path. Due to the restrictions of disk space, use the busybox command replace some common Linux commands, the main reason is that the busybox file is very small, and is static link, including many common Linux commands (such as CAT, INIT, IFCONIG, ROUTE) LN - S Busybox is built in the symbol of these files. You can re-compile BUSYBOX according to your individual, including a command or other commands, or use a small E3 instead of VI.

转载请注明原文地址:https://www.9cbs.com/read-106073.html

New Post(0)