Break up a dd image into multiple files
Solution 1:
You probably want to consider using tar
, as KPWINC says, but to answer your question directly, you want to use dd
's "skip" option.
If your first command, as stated, is:
sudo dd if=/dev/sdf1 bs=4096 count=150GB | gzip > img1.gz
Then your second would be:
sudo dd if=/dev/sdf1 bs=4096 skip=150GB count=40GB | gzip > img2.gz
and third:
sudo dd if=/dev/sdf1 bs=4096 skip=190GB count=120GB | gzip > img3.gz
That said, I'm not sure that the "GB" suffix does what you're intending. I think it just does raw math on the root number it follows, not figure out how to get that many gigabytes from the block size you've given. I would do something like this:
dd if=/dev/sdf1 bs=`expr 10 * 1024 * 1024` count=`expr 15 * 1024 * 1024 * 1024`
just to be sure of the math.
Oh, and make sure that your device isn't changing underneath you as you copy it. That would be bad.
Solution 2:
It is my command line:
dd if=/dev/sda bs=4M | gzip -c | split -b 2G - /mnt/backup_sda.img.gz
It will create 2GB files in this fashion:
backup_sda.img.gz.aa
backup_sda.img.gz.ab
backup_sda.img.gz.ac
Restore:
cat /mnt/UDISK1T/backup_sda.img.gz.* | gzip -dc | dd of=/dev/sda bs=4M
Hope it helps.
Solution 3:
A simple solution might be to just use "/usr/bin/split". It just breaks files up into pieces. You can use "-" as the input file name to read from standard input. The nice thing about split is that it is simple, it doesn't affect the toolchain in any real way and you can "join" the files by just using "cat" to glob them back together (or pipe them to another app).
Solution 4:
tar
I tar might solve your issue. It has the ability to break up files into multiple volumes.
Check out this link:
http://paulbradley.tv/44/
From the page:
The two extra command line options you need to use over and above the standard syntax are -M (--multi-volume) which tells Tar you want to split the file over multiple media disks. You then need to tell Tar how big that media is, so that it can create files of the correct size. To do this you use the --tape-length option, where the value you pass is number x 1024 bytes.
The example below shows the syntax used. Lets say the largefile.tgz is 150 Meg and we need to fit the file on two 100 Meg Zip drives.
tar -c -M --tape-length=102400 --file=disk1.tar largefile.tgz
The value 102400 is 1024 x 100, which will create a 100 Meg file called disk1.tar and then Tar will prompt for volume 2 like below :-
Prepare volume #2 for disk1.tar and hit return:
In the time of tape drives you would have taken the first tape out of the machine and inserted a new tape, and pressed return to continue. As we want Tar to create the remaining 50 Meg in a separate file, we issue the following command :-
n disk2.tar
This instructs Tar to continue writing the remaining 50 Meg of largefile.tgz to a file named disk2.tar. You will then be prompted with the line below, and you can now hit return to continue.
Prepare volume #2 for disk2.tar and hit return:
You would repeat this process until your large file has been completely processed, increasing the disk number in the filename each time you are prompted.