In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to make Linux U disk boot disk". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to make Linux U disk startup disk".
USB flash memory devices (flash drives) are generally only the size of a keychain, and the storage capacity is mostly 32MB and 64MB. Because it has the advantages of light and delicate, easy to use and easy to carry, especially compared with floppy disk, which has the characteristics of large capacity, safety and reliability, fast reading speed, more and more people use this device to replace floppy drive and floppy disk to exchange files between PC. At present, the new motherboard BIOS supports the boot mode of USB floppy disk and hard disk, which is more and more convenient for the system maintenance and installation of Windows 98. However, the manufacturer only provides the tools to make the Windows 98 boot disk, not the linux boot disk. Setting up a Linux boot disk on a flash drive has more practical significance for system maintenance personnel. You can use Linux to build a compact kernel, establish a network environment, quickly judge and troubleshoot network problems and transfer files. In this paper, taking Red Hat 8.0 as an example, the Linux boot disk of USB disk is established by using Ranko's dual-startup flash drive.
Download the related software: e3tech bvije Liuux kernel.
Compile the kernel
First of all, the motherboard of the computer must support the boot mode of the USB hard drive, and the flash drive used is a startup flash drive.
Let me take Linux-2.4.20 as an example. When compiling, you must be careful not to compile unnecessary modules, such as sound card drivers, so as to make the compiled kernel as small as possible. To support USB boot, SCSI devices, usbcore, usb-storage, Loopback device support, RAM disk support, and initrd must be compiled into the kernel.
Many people will ask, why build initrd.img files when the usb-storage module is already included in the kernel? This is because the initialization process of the flash drive is slower than the execution of / sbin/init, so the kernel has been booted and the flash drive has not been initialized, so the root file system has not been loaded, so the execution of the / sbin/init command must not be successful. By creating the initrd.img file, load the initrd.img file into memory when the kernel is started, wait 3 seconds for the USB drive to complete initialization, and then execute the / sbin/init instruction. The specific operation steps are as follows.
1. Create an initrd.img file
# mkdir-p / mnt/initrd
# cd / tmp
# mkinitrd / tmp/initrd.gz 2.4.20-usb
two。 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
Because the initrd file created by default is relatively large (4MB), it must be reduced in order to speed up the startup of the flash drive. 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.img
4. Test whether the compiled kernel starts properly
Test whether the compiled kernel starts properly and whether the flash drive can be seen during the startup process.
Create a flash drive
1. Divide the flash drive into two partitions
The capacity left for the Linux partition 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 using a USB flash drive, the sector size must be set to 63 sectors, and the heads, sectors, and cylinders parameters can be modified through the fdisk x command extension.
two。 Create and generate ext2 partitions
# mke2fs-m 0 / dev/sda2
# mkdir-p / mnt/sda2
# mount / dev/sda2 / mnt/sda2
# cd / mnt/sda2
3. Set up a boot directory
Copy the compiled kernel and initrd-2.4.20-usb.img file to the boot directory, the compiled module to the lib/modules directory, and the / boot/grub file to the boot directory, and edit the boot/grub/menu.lst file, 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. Set up a bin directory
Copy system maintenance tools, such as insmod, fsck, and mkdosfs utilities, as needed for self-work. Be sure to check those shared library files using the ldd command, which need to be copied to the lib directory in 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 (such as cat, init, ifconig, route) to establish symbolic joins of these files with ln-s busybox. You can recompile busybox according to your individual needs, including commands such as vi, or you can use the small e3 instead of vi.
In addition, if you use bash, you must also edit and cut / 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. Set up a dev directory
Use the cp-a command to copy common device files, including console, tty1, tty2, tty3sda, sda1, sda2, hda, hdb, and hda1.
6. Edit etc/init.d/rcS
The contents are 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 the etc/fstab file
The contents are as follows:
/ dev/sda2 / ext2 defaults 1 1
None / proc proc defaults 0 0
Application example
Give an example of transferring files. Execute on a functioning Linux machine A (IP=192.168.100.5):
$tar cf-win98 | nc-l-p 5555
Note: you can use a flash drive to start the machine on machine B, and telnet logs in to machine A to execute the above command.
Start the execution using a flash drive on machine B:
# 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 the format / s command cannot be used to create the Windows 98 boot disk of the USB disk, you can use a flexible method, as follows:
# mkdosfs-F 16 / dev/sda1
# xxd-c 16 / dev/sda1 | less
At this time, record the 32'35 bytes of Boot Record (in this case, 60 91 01 00, these 4 bytes record the total number of sectors of the FAT partition), then use the tools provided by Longco to make the boot disk Windows 98 boot disk, and then use bvi under Linux or the tool that can edit binary files to modify the 32 bytes of Boot Record to the original content. In this way, it is possible to achieve a veritable three boot mode (Windows double boot + Linux boot).'
Thank you for your reading, the above is the content of "how to make Linux U disk boot disk". After the study of this article, I believe you have a deeper understanding of how to make Linux U disk startup disk, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.