U disk installation Linux skills

  
                  

There are two ways to boot the system from a USB drive. The first is to install completely over the network. The second is to copy the CD image to the USB drive as the source of the package and can be combined with other images. The second way is more common.

For the first installation, you need to download the installation image from the netboot directory and copy the file to the U disk according to the "Flexible Method" described below.

The installation image of the second installation method is placed in the hd-media directory, which can be copied to the USB flash drive using the "Easy Method" or "Flexible Method". You will also need to download a CD image for this installation. The installation image and CD image should be the same debian-installer distribution. If it is different, an error will occur in the installation.

In order to prepare the USB flash drive, you need a running GNU/Linux system that supports USB. The current GNU/Linux system will automatically recognize when you insert a USB drive. If not, you should verify that the usb-storage kernel module has been loaded. Once the USB drive is inserted, it will be mapped to a device named /dev/sdX where “X” is the letter of a-z. You can confirm that it is mapped correctly by inserting a USB flash drive by running dmesg. To write a message, first turn on the write-protect switch on it.

Warnings

Using this method will destroy anything that is already on the device! Make sure you are using the correct U disk device name. If you make a mistake, such as writing a hard disk, all the information on the device will be lost.

Note that the USB flash drive must have at least 256MB capacity (a smaller size installation is also possible, see Section 2 “ Copying Files — Flexible Method”).

1 Copy files — Easy way

There is a file collection hd-media/boot.img.gz that contains all the installer files (including the kernel) and syslinux and corresponding configuration files .

It should be noted that although convenient, this method has one major drawback: Even if the USB flash drive is large, the logical size of the device is limited to 256 MB. If you want to use the U

disk for other purposes, you need to repartition it to create a new file system for the rest of the capacity. A minor disadvantage is that you cannot copy a full CD image to a USB drive, only a smaller

businesscard or netinst CD image.

To use this image, just unzip it directly to the USB flash drive:

# zcat boot.img.gz > /dev/sdX

Then mount U Disk (mount /dev/sdX /mnt), now has a FAT file system, copy the Debian netinst or businesscard ISO image into it. Uninstalling the U disk (umount /mnt) is complete.

2 Copying files — Flexible methods

If you need more flexibility, or just want to know what's going on, you should use the following method to put the file into the U disk. .

2.1 Partitioning a USB Disk

We will show how to use the first partition of a USB stick instead of the entire device.

Note

Since most USB sticks have a separate FAT16 partition set up, you may not need to repartition or format the USB stick. If you have to do it, use cfdisk or another partitioning tool to create a FAT16 partition and then create a file system:

# mkdosfs /dev/sdX1

Note, please use the correct U disk Device name. The mkdosfs command is included in Debian's dosfstools package.

In order to boot the kernel after the U disk is booted, we need to put a boot loader on the USB flash drive. Although any boot loader (like lilo) should work, it's more convenient to use syslinux. The main reason is that it can use the FAT16 partition and it can be configured by simply editing a text file. Any operating system that supports the FAT file system can be used to change the boot loader's configuration file.

To put syslinux on the FAT16 partition of the USB drive, install the syslinux and mtools packages on your system and execute:

# syslinux /dev/sdX1

Remind again, please confirm that you are using the correct device name. The partition cannot be mounted when syslinux is started, because the process writes data to the boot sector of the partition and creates an ldlinux.sys file containing the boot loader code.

2.2 Add the installer image

Mount the partition (mount /dev/sdX1 /mnt) and copy the following installer image file to the USB flash drive:

vmlinuz ( Kernel binary)

initrd.gz (initial ramdisk image)

You can choose to use the text interface or the graphical installation interface to install the program. The latter can be obtained from the gtk subdirectory. If you need to change the file name, please note that syslinux only follows the DOS (8.3) naming method.

Next, you need to create a syslinux.cfg configuration file with at least the following two lines:

default vmlinuz

append initrd=initrd.gz

For the graphical installer, you need to add video=vesa:ywrap, mtrr vga=788 to the end of the second line.

If you use the hd-media image, you should now copy the Debian ISO image (businesscard, netinst, or full CD image; confirm the appropriate one) to the USB drive. Then, unmount the U disk (umount /mnt).

3 Booting from a USB drive

Warning

If your system refuses to boot from a USB drive, it may be because it contains an invalid primary boot sector record (MBR) . You can fix this by using the install-mbr command from the mbr package:

# install-mbr /dev/sdX

Copyright © Windows knowledge All Rights Reserved