Explanation of dd commands in CentOS
Dd: The biggest feature is backup.
[Root @ linux ~] # Dd if = "input_file" of = "outptu_file" bs = "block_size "\
Count = "number"
Parameters:
If: input file ~ It can also be a device!
Of: output file ~ It can also be a device;
Bs: the size of a planned block. If no value is set, the default value is 512 bytes.
Count: the number of bs.
Example:
Example 1: back up/etc/passwd to/tmp/passwd. back
[Root @ linux ~] # Dd if =/etc/passwd of =/tmp/passwd. back
3 + 1 records in
3 + 1 records out
[Root @ linux ~] # Ll/etc/passwd/tmp/passwd. back
-Rw-r -- 1 root 1746 Aug 25 14:16/etc/passwd
-Rw-r -- 1 root 1746 Aug 29 16:57/tmp/passwd. back
# Take a closer look, my/etc/passwd file size is 1746 bytes, because I have not set bs,
# Therefore, the default value is 512 bytes. Therefore, the above 3 + 1 indicates three complete
#512 bytes, and another block under 512 bytes!
# In fact, it seems like the cp command ~
Example 2: backup/dev/hda MBR
[Root @ linux ~] # Dd if =/dev/hda of =/tmp/mbr. back bs = 512 count = 1
1 + 0 records in
1 + 0 records out
# You need to know about it ~ We know that the MBR of the entire hard disk is 512 bytes,
# It is the first sector on the hard disk. Therefore, I can use this method
# All data in the MBR is recorded. It's really amazing! Pai_^
Example 3: Back up the entire/dev/hda1 partition.
[Root @ linux ~] # Dd if =/dev/hda1 of =/some/path/filenaem
# This command is amazing! Back up all the content of the entire partition ~
# The following of must not be in the/dev/hda1 directory ~ Otherwise, you cannot finish reading ~
# This action is very useful. If you need to complete the content of the entire partition in the next day,
# You can use dd if =/some/file of =/dev/hda1 to write data to the hard disk.
# If you want to back up the entire hard disk, it is similar to Norton's ghost software,
# From disk to disk, hey ~ You can use dd ~ Amazing!