Linux dd command burning boot USB flash drive detailed
DD command to make USB boot disk is very convenient, only need: sudo dd if=xxx.iso of=/dev/sdb bs=1m
Before using the above command must unload U disk, SDB is your u disk, bs=1m is the size of the block, behind the value of large, write speed relative to a bit, but also not unlimited, I generally choose 2M, note, the execution of the command after a block complete, but the U disk is still flashing, and so on, safe removal.
Note: Your image needs to support the DD command.
The interpretation of the DD command.
Defined
DD is a very useful command under Linux/unix, which is to copy a file with a block of the specified size and make the specified conversion at the same time as the copy.
Parameters
1. if= file name: Enter a file name, default to standard input. The source file is specified. < If=input file >
2. of= file name: Output file name, default is standard output. That is, the specified destination file. < Of=output file >
3. Ibs=bytes: Reads a bytes byte at a time, that is, specifies a block size of bytes bytes.
Obs=bytes: Outputs bytes bytes at a time, that is, specifying a block size of bytes bytes.
Bs=bytes: Set the read/output block size to bytes bytes at the same time.
4. Cbs=bytes: Converts bytes bytes at a time, that is, specifies the conversion buffer size.
5. Skip=blocks: Skips blocks blocks from the beginning of the input file before copying begins.
6. Seek=blocks: Skips blocks blocks from the beginning of the output file before copying begins.
Note: Usually only works when the output file is a disk or tape, that is, when backing up to disk or tape.
7. Count=blocks: Copy only blocks blocks, the block size equals the number of bytes specified by IBS.
8. Conv=conversion: Convert the file with the specified parameters.
ASCII: convert EBCDIC to ASCII
EBCDIC: convert ASCII to EBCDIC
IBM: Convert ASCII to alternate EBCDIC
Block: Converts each row to a CBS length, with less space padding
Unblock: Make each line the length of the CBS, the less part filled with spaces
LCase: Converting uppercase characters to lowercase characters
UCase: Converting lowercase characters to uppercase characters
Swab: Swap each byte of the input
NoError: Do not stop when error occurs
Notrunc: Output File not truncated
Sync: Fills each input block into IBS bytes, and the less part is padded with empty (NUL) characters.
Edit this section of the DD application instance.
1. Back up the local/dev/hdb full disk to the/DEV/HDD
DD If=/dev/hdb OF=/DEV/HDD
2. Back up the/DEV/HDB full data to the image file of the specified path
DD If=/dev/hdb Of=/root/image
3. Restore the backup file to the specified disk
DD If=/root/image OF=/DEV/HDB
4. Back up the/DEV/HDB full data and compress it with the Gzip tool to save to the specified path
DD If=/dev/hdb | gzip >/root/image.gz
5. Restore the compressed backup file to the specified disk
gzip-dc/root/image.gz | DD Of=/dev/hdb
6. Backup disk starts with 512 byte-sized MBR information to the specified file
DD If=/dev/hda of=/root/image count=1 bs=512
Count=1 refers to copying only one block; bs=512 refers to a block size of 512 bytes.
Recovery: DD If=/root/image Of=/dev/hda
7. Backup floppy disk
DD if=/dev/fd0 of=disk.img count=1 bs=1440k (i.e. block size 1.44M)
8. Copy the memory contents to the hard disk
DD If=/dev/mem Of=/root/mem.bin bs=1024 (Specify block size 1k)
9. Copy the contents of the disc to the specified folder and save it as a Cd.iso file
DD If=/dev/cdrom (HDC) Of=/root/cd.iso
10. Increase the size of the swap partition file
The first step: Create a file of size 256M:
DD If=/dev/zero of=/swapfile bs=1024 count=262144
Step Two: Turn this file into a swap file:
Mkswap/swapfile
Step three: Enable this swap file:
Swapon/swapfile
Fourth step: Edit the/etc/fstab file to automatically load swap files at each boot:
/swapfile Swap swap default 0 0
11. Destroying disk data
DD If=/dev/urandom OF=/DEV/HDA1
Note: Populating the hard disk with random data can be used to destroy the data in some necessary situations.
12. Test the read/write speed of the hard drive
DD If=/dev/zero bs=1024 count=1000000 of=/root/1gb.file
DD If=/root/1gb.file bs=64k | DD Of=/dev/null
With the command execution time of the above two commands output, the read and write speed of the hard disk can be calculated.
13. Determine the optimal block size for your hard drive:
DD If=/dev/zero bs=1024 count=1000000 of=/root/1gb.file
DD If=/dev/zero bs=2048 count=500000 of=/root/1gb.file
DD If=/dev/zero bs=4096 count=250000 of=/root/1gb.file
DD If=/dev/zero bs=8192 count=125000 of=/root/1gb.file
By comparing the execution time of the command shown in the above command output, you can determine the optimal block size for the system.
14. Repairing the hard drive
DD IF=/DEV/SDA OF=/DEV/SDA
When the hard disk is not used for a long time (for example, 1, 2 years), magnetic fluxpoint will be generated on the disk. When the heads read these areas, they encounter difficulties and can cause I/O errors. When this condition affects the first sector of the hard disk, it may cause the hard disk to retire. The above command may bring the data back to the dead. And the process is safe and efficient.
Linux DD Command Practical explanation