Re: Some help with dd backing up into an iso
- Date: Tue, 07 Mar 2017 08:51:37 +0100
- From: "Thomas Schmitt" <scdbackup@xxxxxxx>
- Subject: Re: Some help with dd backing up into an iso
> > I used dd if=/dev/sdb of=usbfilename.iso
> > The resulting image was the full size of the disk.
That's the job of dd: Copying block by block.
As David stated, the file usbfilename.iso will not be an ISO 9660 filesystem
but rather a disk image.
David Christensen wrote:
> dd if=/dev/sda | gzip > myimage.img
The name suffix .img is more appropriate than .iso, indeed.
If your USB stick contains a lot of blocks with zeros, you may get even
better compression by using bzip2 instead of gzip:
dd if=/dev/sdb | bzip2 >usbfilename.img
Zeroing the unused blocks before running dd will normally improve the
compression ratio and thus yield an even smaller .img file.
When you put it back on the USB stick, you need to uncompress:
bunzip2 <usbfilename.img | dd of=/dev/sdb
This will recreate your two partitions and the filesystems which reside in
> To test the validity I restored reversing the order of the filenames
> if/of but that took for ever
By default dd copies chunks of 512 bytes.
Changing to 1 MiB chunks by dd option
might speed up copying substantially.
> I looked at the disk and
> it seemed complete with all files in tact, so maybe I killed it
> somewhere in the verification process.
There is no verification process with plain dd.
Probably you successfully copied the first partition and the directory
tree of the second one. It has to be expected that not all files in the
second partition bear their original content, because it was not copied.
> Is there someway one can avoid creating such a large iso for no reason,
> when the filesize is a fraction of the whole disk.
That's called backup and archiving.
While the filesystem is mounted but fewly busy, you let a program read
the files and pack them up in that program's archive format.
The classic archiver is called "tar". Caution: wrong arguments or wrong
sequence of arguments can easily shoot your foot.
Assumed you have your filesystems mounted as
you may pack them up gzip compressed by
tar cvzf usb_part1.tar.gz /mnt/usb_part1
tar cvzf usb_part2.tar.gz /mnt/usb_part2
The archive files usb_part1.tar.gz and usb_part2.tar.gz can be unpacked into
some directory by:
tar xzf /where/it/is/usb_part1.tar.gz
tar xzf /where/it/is/usb_part2.tar.gz
If the archive shall be an ISO 9660 filesystem, you may create it by
xorriso -for_backup \
-outdev usb_part1_and_2.iso \
-map /mnt/usb_part1 /part1 \
-map /mnt/usb_part2 /part2 \
The superuser will be able to mount the result for random access:
mount -o loop /where/it/is/usb_part1_and2.iso /mnt/usb_par1_and_2
The normal user will then see and be able to read two file trees
To unmount the .iso, the superuser later does:
Have a nice day :)