[Reprint] image your hard drive using dd

Source: Internet
Author: User

I have backed up my system to an external ximeta Drive Using "DD" and the well-known Linux Live CD distribution, knoppix to boot from. Below are the steps in brief:

  1. Boot from the live CDROM distribution.
  2. Switch to root.
  3. Make sure no partitions are mounted from the source hard drive.
  4. Mount the external HD.
      # mount -t vfat /dev/sda1 /mnt/sda1
  5. Backup the drive.
      # dd if=/dev/hda conv=sync,noerror bs=64K | gzip -c  > /mnt/sda1/hda.img.gz

    "DD" is the command to make a bit-by-bit copy of "If =/dev/hda" as
    "Input file" to "of =/mnt/sda1/hda.img.gz" as the "output file ".
    Everything from the partition will go into an "output file" named
    "Hda.img.gz". "Conv = sync, noerror" tells dd that if it can't read
    Block due to a read error, then it shoshould at least write something
    Its output of the correct length. Even if your hard disk exhibits no
    Errors, remember that DD will read every single block, including any
    Blocks which the OS avoids using because it has marked them as bad.
    "BS = 64 K" is the block size of 64x1024 bytes. Using this large of Block
    Size speeds up the copying process. The output of DD is then piped
    Through gzip to compress it.

  6. To restore your system:
      # gunzip -c /mnt/sda1/hda.img.gz | dd of=/dev/hda conv=sync,noerror bs=64K 
  7. Store
    Extra information about the drive geometry necessary in order
    Interpret the Partition Table stored within the image. The most
    Important of which is the cylinder size.

      # fdisk -l /dev/hda > /mnt/sda1/hda_fdisk.info

Notes:

One of the disadvantages of the DD method over software specifically
Designed for the job such as ghost or partimage is that DD will store
The entire partition, including blocks not currently used to store
Files, whereas the likes of ghost understand the filesystem and don't
Store these unallocated blocks. The overhead isn't too bad as long
You compress the image and the unallocated blocks have low entropy. In
General this will not be the case because the emtpy blocks contain
Random junk from bygone files. To rectify this, it's best to blank all
Unused blocks before making the image. after doing that,
Unallocated blocks will contain mostly zeros and will therefore
Compress down to almost nothing.

Mount the partition, then create a file of zeros which fills the entire disk, then delete it again.

# dd if=/dev/zero of=/tmp/delete.me bs=8M; rm delete.me

References:

  1. Backup-hard-disk-partitions
  2. Linux_loopback
  3. Imagedrive

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.