[linux] linux uses dd command to make hard disk image

Production environment

System: linux

Make

  1. Use the lsblkcommand to view the serial number of the hard disk mirrored
lsblk
  1. Make a hard disk image
sudo dd bs=512 count=117229568 if=/dev/sdc | gzip -9 > image-os.gz

Description ::
countThe size of the hard disk to be mirrored needs to be calculated according to the size of the hard disk
bs: the size of a write block
sdc: the serial number of the hard disk to be mirrored, check the hard disk according to lsblk to modify this

Image compression split and decompression merge

  1. Compression and splitting
    The image obtained by dd is generally relatively large and cannot be stored on the CD. The image can be split by the following command, and the split image file can be obtained in the current directory
mkdir image
mv image-os.gz image
tar cjf - image |split -b 3800m - image-os.tar.bz2.

Description ::
-bSplit by file size

  1. Unzip and merge
    execute the following command in the directory where the image file is located, you can get the unzipped and merged image file in the current directory
cat  image-os.tar.bz2.a* |tar xj

Mirror installation

  1. Use the lsblkcommand to view the hard disk serial number of the installed image
lsblk
  1. Mirror installation
gzip -c -d image-os-os.gz | sudo dd of=/dev/sdc

sdc: The serial number of the hard disk to be installed mirrored, according to lsblk to view the hard disk to modify this

Guess you like

Origin blog.csdn.net/macaiyun0629/article/details/108436338