How to make a bootable img/iso image file on a Linux system

  
                

The img/iso file is an image file. Sometimes you need to create an image file in Linux system operation. What are the methods for making an image file? The following small series will introduce you how to make a bootable img/iso file under Linux.

There are three methods of making image file, cp, cat, dd, and other special tools. Cp , cat , and dd both copy files from the device to create a mirror. The dd command is more powerful, and you can create a mirror directly by specifying the block size and the number of blocks.

IMG file:

Because cp, cat can only make images from the device, but there is no special tool to do IMG files, so use the dd command to make IMG files.

1, make

dd if=/dev/zero of=fdimage.img count=2880

or

dd if=/dev/zero Of=fdimage.img bs=1024 count=1440

2, format

mkfs.msdos fdimage.img

3, modify

can be used After the following command mount, you can directly modify

mount -o loop *.img /mnt

4, can start

Because making a bootable image will definitely use virtual Machine, it is recommended to use Virtualbox, first go to the next DOS boot disk on the network to boot. Pass the system with the DOS sys command. It is recommended to use FreeDOS, which is free software. You can also use the dd command to pass boot boot information and copy the files needed to start the boot to make the boot disk. Take FreeDOS as an example, pass the startup information with the following command, where the downloaded boot disk is balder10.img file

dd if=balder10.img of=fdimage.img bs=512 count=1 conv=notrunc

Multi-system with grub4dos,

1), use grub.exe to boot multiple systems

2), install grub to MBR, use grldr to boot multiple systems. Of course, you can also use dd to write the boot information directly in the same way as above.

bootlace.com --floppy --chs 0x00

Note: I found that I can only copy from the logical sector with the dd command. I thought I could use dd to write grldr.mbr. I entered the u disk, I tried it with my U disk, and the result could not be opened. Because my U disk is in fat16 format, the logical sector starts with OBR, then the FAT table. The result is that the FAT1 table is covered. At that time, I didn't think there was FAT2. It was just right. Now I think it is depressed, a lot. Nothing is gone.

Why is a floppy disk possible because it does not have the first 63 sectors, starting directly from the logical 0 sector.

ISO file:

Because of the file system relationship, you can't use dd to do ISO image directly (of course, it can still make an ISO image from the device). There are special tools for making ISO files,

1, making

mkisofs -r -o cdimage.iso /home/XXX/cddir

2, formatting

iso made with mkiso file system iso9660

3, can be started

Whether it is booting a single system or booting multiple systems, it still uses the mkisofs tool, just loaded to the CD. The boot loader is different. Of course, you can also put the DOS bootloader (that is, its boot sector) or the Windows bootloader (XP system's ntldr) into the bootable CD. The following only discusses the use of grub4dos

1), booting multiple systems with grub.exe

loading grub.exe with DOS to boot multiple systems

2), installing grub to CD MBR

The following command can be used to generate a bootable image directly, where grldr, menu.lst should be placed in the cddir directory, that is, in the cd root directory.

mkisofs -R -b grldr -no-emul-boot -boot-load-seg 0x1000 -o cdimage.iso cddir

mkisofs -R -b grldr -no-emul-boot - Boot-load-size 4 -o cdimage.iso cddir

PS, the dd command and mkisofs parameter description are given below

dd (convert and copy files)

dd is A very useful command under Linux/UNIX to copy a file with a block of the specified size and perform the specified conversion while copying.

The main options for dd:

If you specify a number, multiply the corresponding number by the following character:

b=512, c=1, k=1024, w=2, xm=number m

if=file

Enter the file name, which defaults to standard input.

of=file

Output file name, defaults to standard output.

ibs=bytes

Read bytes bytes at a time (that is, one block size is bytes bytes).

obs=bytes

Write bytes bytes at a time (that is, one block size is bytes bytes).

bs=bytes

Set the read and write block size to bytes at the same time, instead of ibs and obs.

cbs=bytes

Converts bytes bytes at a time, which is the conversion buffer size.

skip=blocks

Skip blocks from the beginning of the input file before starting copying.
Previous12Next Total 2 Pages

Copyright © Windows knowledge All Rights Reserved