1

I follow the instruction in this post, using the command

dd if=/dev/sda1 | gzip > disk.img.gz

but the imaging does not seem to stop. Is it because the disk.img is being put (as default) in my Home folder, which is on the same /dev/sda1 partition that I am imaging? (The size of /dev/sda1 is 24GB, but the img file is 32 GB and counting)

 Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   484491263   242244608   83  Linux
/dev/sda2       484493310   488396799     1951745    5  Extended
/dev/sda5       484493312   488396799     1951744   82  Linux swap / Solaris

If so, given my partition scheme, to solution is to cd to an external hard drive then use the above command?

EDIT: Added the output of lsblk

 NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
 sda      8:0    0 232.9G  0 disk 
 ├─sda1   8:1    0   231G  0 part /
 ├─sda2   8:2    0     1K  0 part 
 └─sda5   8:5    0   1.9G  0 part [SWAP]
  • Please run the lsblk command and edit your post with the output. – errikos Oct 23 '13 at 8:35
4
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   484491263   242244608   83  Linux

1 block is 512 bytes. 242244608 blocks is 115.5 GiB, not 24 as you mentioned. The dd command (refered by you as "imaging") keeps writing data to the same partition that you are cloning. This does not cause any loops, but it may yield a corrupt filesystem image (disk.img.gz).

What you should do is:

  1. Reboot to a Live CD.
  2. Ensure that your source partition is not mounted.
  3. Mount a different target partition (e.g. your external hard disk).
  4. Use dd to write the image to your second partition.

Even better, if you do not need to have an identical filesystem copy, just use rsync to copy your files and metadata (permissions). For this you need your backup target to have the same filesystem type (ext4) such that permissions and ACLs are preserved. See https://wiki.archlinux.org/index.php/Full_System_Backup_with_rsync for details on using rsync.

  • Yes, the total size of sda1 is 115 GB, but the used space is 24 GB. Thanks! – Heisenberg Oct 23 '13 at 16:10
0

Yes, you are correct, you are creating an infinite loop by making a backup of the disk the backup is written to!

What you need to do is write the image to a other device; attach an external USB or SATA hard drive, mount it, and run dd if=/dev/sda1 | gzip > /<mountpoint>/disk.img.gz

You may also use dd, gzip and ssh to dump the disk to a machine on your LAN.

  • There is no infinite loop, the maximum size of the image is the available space of the Home partition. – Lekensteyn Oct 23 '13 at 13:25
  • Ahh, I see. I was looking at the numbers, not the partition-size. 32GB > 24GB, hence the loop answer. – Sitron_NO Oct 23 '13 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.