Use the dd command in linux

Source: Internet
Author: User

Use the dd command in linux
 
In linux, the dd command is used to perform hard disk engraving and clone the hard disk. in linux, all devices are represented as a file, dd commands are used to copy and convert file streams, so they can be used to clone hard disks....
Use dd commands in linux to perform hard disk engraving and hard disk cloning
 
In linux, all devices are represented as a file,
 
Dd commands are used to copy and convert file streams, so they can be used to clone hard disks.
 
The method is as follows:
 
Connect the source disk with the target disk to your computer and start linux,
Determine the device name (/dev/sd * Or/dev/hd *) of the source and target disks *),
Run the command: dd if = source disk of = target disk conv = noerror, sync
After completion, you can.
 
Function of parameters in conv:
Noerror
If an error occurs during copy, skip and continue to execute
Sync
An error occurs during copy. skipping this block may change the overall position of the subsequent data. You can add this parameter to fill the part of the target file with the same location as the wrong block with empty data, ensure the file system structure is stable.
Linux disk management command -- dd
 
Dd command
 
Function: Copies the specified input file to the specified output file, and supports format conversion during the copy process. You can use this command to implement the diskcopy command in DOS. Use the dd command to write the data on the floppy disk as a storage file on the hard disk, and then write the storage file to the second disk to complete the diskcopy function. Note that you should delete the storage file on the hard disk with the rm command. Standard input files and standard output files are used by default.
 
Syntax: dd [Option]
 
If = input file (or device name ).
 
Of = output file (or device name ).
 
Ibs = bytes: the number of bytes read from the buffer zone.
 
Skip = blocks skip the ibs * blocks block at the beginning of the read buffer.
 
Obs = bytes: the number of bytes written to the buffer zone.
 
Bs = bytes: set the number of bytes in the read/write buffer at the same time (equal to setting ibs and obs ).
 
Cbs = byte: bytes are converted once.
 
Count = blocks only copies the input blocks block.
 
Conv = ASCII converts the EBCDIC code to the ASCIl code.
 
Conv = ebcdic converts an ASCIl code to an EBCDIC code.
 
Conv = IBM converts an ASCIl code to an alternate EBCDIC code.
 
Conv = block converts a variable bit to a fixed character.
 
Conv = ublock converts a fixed bit to a variable bit.
 
Conv = ucase converts lowercase letters to uppercase letters.
 
Conv = lcase converts uppercase letters to lowercase letters.
 
Conv = notrunc: the output file is not truncated.
 
Conv = swab exchange each pair of input bytes.
 
Conv = do not stop processing when noerror occurs.
 
Conv = sync adjusts the size of each input record to the ibs size (filled with NUL ).
 
 
 
Example 1: copy the content of a floppy disk to another floppy disk and use/tmp as the temporary storage area. Insert the source disk into the drive and enter the following command:
 
$ Dd if =/dev/fd0 of =/tmp/tmpfile
 
After the copy is complete, extract the source disk from the drive and insert the target disk. Enter the following command:
 
$ Dd if =/tmp/tmpfile of =/dev/fd0
 
After the floppy disk is copied, delete the temporary file:
 
$ Rm/tmp/tmpfile
 
 
 
Example 2: Write the net. I file to a floppy disk and set the number of read/write buffers.
 
(Note: The content in the floppy disk will be completely overwritten)
 
$ Dd if = net. I of =/dev/fd0 bs = 16384
 
 
 
Example 3: copy the sfile to the dfile.
 
$ Dd if = sfile of = dfile
 
 
 
========================================================== ========================================================== ====================
The size of the original disk is the same as that of the target disk.
Dd if =/dev/hda of =/dev/hdb conv-noerror, sync
 
========================================================== ========================================================== ======================

Author: "linux"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.