In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to create USB boot disk under Linux", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "How to create a USB boot disk under Linux"!
Download related software: e3, bvi, Linux kernel.
compile the kernel
First of all, the motherboard of the computer must support the boot mode of the USB hard disk, and the flash drive used is a boot flash drive.
I'll take Linux-2.4.20 as an example. Compile must be careful not to compile unnecessary modules, such as driver modules such as sound card drivers, so that the compiled kernel as small as possible. SCSI devices, usbcore, usb-storage, Loopback device support, RAM disk support, and initrd must be compiled into the kernel to support USB boot.
Many people ask why create the initrd.img file when the usb-storage module is already included in the kernel. This is because the initialization process of the flash drive is slower than executing/sbin/init, resulting in the kernel has been started and the flash drive has not completed the initialization work, so the root file system has not been loaded. At this time, executing the/sbin/init command must not succeed. By creating an initrd.img file, load the initrd.img file into memory at kernel startup, wait 3 seconds for flash drive initialization to complete, and then execute the/sbin/init command. The specific operation steps are as follows.
1. Create the initrd.img file
# mkdir -p /mnt/initrd # cd /tmp # mkinitrd /tmp/initrd.gz 2.4.20-usb
2. Extract the initrd.img file and modify the startup script 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
Add the following:
echo 'wait 3 seconds..... ' /bin/sleep 3
3. Regenerate the initrd.img file
Since the default initrd file is large (4MB), it must be reduced in order to speed up the USB drive boot. The specific operation is 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.img
4. Test whether the compiled kernel starts properly
Test whether the compiled kernel boots properly and whether the relevant information of USB drive can be seen during startup.
Create USB flash drive boot drive
1. Divide USB drive into two partitions
The size of the partition reserved for Linux depends entirely on which system maintenance tools are installed, and the results are as follows:
# modprobe usb-storage # 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
Note: If you need to boot Windows 98 with a USB flash drive, the sector size must be set to 63 sectors, and the heads, sectors, and cylinders parameters can be modified via the x command extension of fdisk.
2. Create and generate ext2 partition
# mke2fs -m 0 /dev/sda2 # mkdir -p /mnt/sda2 # mount /dev/sda2 /mnt/sda2 # cd /mnt/sda2
3. Create boot directory
Copy the compiled kernel and initrd-2.4.20-usb.img file to the boot directory, copy the compiled modules to the lib/modules directory, copy the/boot/grub file to the boot directory, edit the boot/grub/menu.lst file, and the contents are as follows:
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/vmlinuz-2.4.20-usb ro root=/dev/sda2 initrd /boot/initrd-2.4.20-usb.img
Install grub, as follows:
grub> root (hd1,1) grub> setup (hd1)
4. Create bin directory
Copy system maintenance tools such as insmod, fsck, and mkdosfs as needed for your own work. Be sure to check for shared library files using ldd, which need to be copied to the lib directory following the original path. Due to disk space constraints, busybox commands are used instead of some common Linux commands, mainly because busybox files are very small and statically linked, including many common Linux commands (cat, init, ifconig, route) using ln -s busybox to establish symbolic links between these files. Busybox can be recompiled according to personal needs, including vi commands, or you can use the small e3 instead of vi.
In addition, if bash is used, you must edit and trim/etc/termcap and the following files:
/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. Create dev directory
Use cp -a to copy common device files, including console, tty1, tty2, tty3sda, sda1, sda2, hda, hdb, and hda1.
6. Edit etc/init.d/rcS
It reads as follows:
#!/ 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
7. Edit etc/fstab file
It reads as follows:
/dev/sda2 / ext2 defaults 1 1 none /proc proc defaults 0 0
application examples
Take an example of transferring files. On a working Linux machine A(IP=192.168.100.5) execute:
$ tar cf - win98 | nc -l -p 5555
Note: You can use USB flash drive to boot the machine on machine B, telnet login to machine A and execute the above command. Start execution on machine B using USB flash drive:
# mount -t vfat -o codepage=938,iocharset=cp936 /dev/hda5 /mnt/2dos # cd /mnt/2dos # modprobe eepro00 # ifconfig eth0 192.168.1.10 # route add default gw 192.168.1.1 # ping 192.168.10.5 # nc 192.168.10.5 5555 | tar xf -
If you cannot create a USB flash drive Windows 98 boot disk using the format /s command at this time, you can use alternative methods, as follows:
# mkdosfs -F 16 /dev/sda1 # xxd -c 16 /dev/sda1 | less
At this time, record the 32~35 bytes of the Boot Record (in this example, 60 91 01 00, these 4 bytes record the total number of sectors in the FAT partition), and then use the tools for making boot disks provided by Langke to make Windows 98 boot disks, and then use bvi under Linux or tools that can edit binary files to modify the 32~35 bytes of the Boot Record to the original contents. In this way, you can achieve a veritable three-boot mode (Windows dual boot +Linux boot)
At this point, I believe that everyone has a deeper understanding of "how to create a USB boot disk under Linux," so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.