3

I have a question concerning the creation of an drive image with dd.

Normally i would simply type: "dd if=/dev/foo of=/dev/bar". But in this case i only have a fat32 formatted drive at hand, which should be used for the output. Fat32 only allows files up to 2GB (Or was that 4GB?). Anyway the image would be too big.

My question is, is it possible to create the image in a bunch of smaller files? And how would one restore the splitted image? I'm really not good at bash commands and would be happy for any suggestions. By the way, is there a good book concerning shell scripts, or are there some good tutorials you would recommend?

Kalpesh Soni
  • 88
  • 1
  • 2
Darokthar
  • 133
  • 1
  • 4
  • Are you copying the image between two different-size drives? Smaller to larger or larger to smaller? It is not clear! – Khaled Nov 24 '10 at 16:31
  • I can't copy it. I would like to shove the image with dd over "on the fly". My problem is, that i want to backup my an laptop hd to an external drive. Maybe the easiest solution would be to resize the external drive. But i fear the data loss. The external drive is 2TB without any backups... – Darokthar Nov 24 '10 at 21:58
  • 1
    I think i found the right commands thanks to google and the split hint from whitequark. It should be dd if=/dev/foo | gzip -9 | split -b 4000m > /mnt/bar I'll post tomorrow, if that worked. – Darokthar Nov 24 '10 at 22:31

5 Answers5

7

how about

http://michi-bs.blogspot.com/2008/06/hdd-or-partition-backup-with-dd.html

# dd if=/dev/hda1 | gzip -c | split -b 2000m - /mnt/hdc1/backup.img.gz.
Kalpesh Soni
  • 88
  • 1
  • 2
  • From the same post, to save the files: `cat /mnt/hdc1/backup.img.gz.* | gzip -dc | dd of=/dev/hda1` – M Smith Aug 30 '15 at 01:10
  • I used `dd if=/dev/sda4 | pv -s 54G | gzip -c | split -b 4000m - "/media/thatfile/os.image.gz."` for pv – zed Jul 09 '17 at 12:07
4

You cannot create a file greater than 4GiB (2^32-1 bytes) on FAT32 partition, period. So if you want to use that image file with some VM software, you are probably out of luck, as I known no VMs which can work around limitations of braindead filesystems.

But if you are just trying to store the image there temporarily, you can create it with dd by 4GiB chunks, or split an existing one with a command like this:

split -b 4095M /source/file /target/files

Note that I've used 4095M and not 4096M/4G, as the maximal size of file is one byte less.

This is a guide I learned bash with. (And manpages for everything other, of course. Bash manpage looks like it was deliberately obfuscated.)

whitequark
  • 474
  • 1
  • 3
  • 11
1

Look into using the 'split' command to split the files. I'm not sure if you are writing directly to the device (dd if=/dev/foo of=/dev/bar) or writing to an image on a mounted filesystem.

ksexton
  • 43
  • 4
1

My advice here would be to use gparted or similar partitioning or disk management software to resize the fat32 partition and create the space freed up as an ext2 or ntfs formatted partition. Get the best of both worlds.

bikedragon
  • 11
  • 1
-1

If the drive is empty ... reformat that drive to ext3! Unless you have other plans, just my 2pence

Mister IT Guru
  • 1,158
  • 3
  • 15
  • 35