to dd or not to dd


Forum: HD Install
Topic: to dd or not to dd
started by: robh

Posted by robh on Oct. 31 2005,01:59
well, i have finally got to a place where i am happy with my hdd install. i know u all think i'm mad not going for a frugal install, but i just want to turn on the machine and have all of my apps installed as i like them.

any hoo, there are enough posts dealing with the pro's and con's of frugal, but i have a hdd install related question.

does anyone have any strong opinions on whether it is best to use th "dd if=* of=*" command to take an image of my shiny new hd install of dsl, or whether it is best to go the "g4l" or some similar prog. route.

let's here your opinions then... ;-)

i will be imaging my only partition on my only disk (apart from swap partition) to a usb external hdd. it will be no bigger than 2.9G uncompressed and the usb drive is working well in my current dsl setup.

Posted by robh on Oct. 31 2005,02:05
oops, sorry about the double post.
Posted by SaidinUnleashed on Oct. 31 2005,03:56
Easiest, most efficient way to image a drive in Linux.

This creates the image...
Code Sample
bzip2 -1c < /dev/hda > myhdimage.img.bz2


And this restores the image to the HD...
Code Sample
bzip2 -dc < myhdimage.img.bz2 > /dev/hda


Happy imaging.

~J.P.

Posted by robh on Oct. 31 2005,04:48
so, could you just clarify for me....
the first operation creates a bzip2'd image of my drive, which i can save to my ext. hdd.
then to restore the image do i need to boot into a live cd environment and issue the second command?
do i need to do cfdisk to recreate the partitions prior to unziping?
and i assume i need to perform the unzip action from within the dir that contains the bzip2'd image... i.e. my ext hd (sda8)

could i ask u to be slightly more "-v" as i am a noob of the first order.

thanks

Posted by cbagger01 on Oct. 31 2005,17:52
FYI,

If you are going to use "dd", make sure that you install the "Upgrade to GNU utilities" first.

The built-in busybox "dd" command does not work with files larger than 2GB so you need the GNU "dd" command.

Also, before doing a backup, I suggest that you blank out any unused disk space with a bunch of zeros.  This will result in a smaller sized backup file.

1) Boot DSL livecd
2) Upgrade GNU utils
3) Mount your hard drive partition.

Then open a terminal (this example assumes hard drive partition located at /dev/hda1) and type:

sudo su
dd if=/dev/zero of=/mnt/hda1/file_of_zeros.bin bs=1M
rm /mnt/hda1/file_of_zeros.bin

Then you can go ahead and do your image backup.

Posted by SaidinUnleashed on Oct. 31 2005,19:39
the bzip command I gave you will create a bit-for-bit copy of your hdd, minus the empty space, and compress it, so that it is a lot smaller than it is expanded on the hd.

Since the copy will contain the master boot record, in addition to all your data, you will not need to repartition to restore it.

It also works independently of the filesystem of the partition you are imaging. You could image a Mac hd with these commands on an x86 box, and restore it later, and it would work perfectly. So don't worry about killing some ntfs partitions, or other exotic filesystems. It's all good.

~J.P.

Posted by brianw on Nov. 02 2005,02:26
Quote (SaidinUnleashed @ Oct. 30 2005,22:56)
Easiest, most efficient way to image a drive in Linux.

This creates the image...
Code Sample
bzip2 -1c < /dev/hda > myhdimage.img.bz2


And this restores the image to the HD...
Code Sample
bzip2 -dc < myhdimage.img.bz2 > /dev/hda


Happy imaging.

~J.P.

Just a couple quick questions that I am not clear on when creating an image of your hard drive.

1) Does the image file need to be on another partition when you create it or will bzip know not to copy it?

2) Do you need to boot from another media (livecd, etc...) to perform this?

3) When you restore obviously you are booting from another media (livecd, etc...),  but you can restore from a file on another media (i.e. another cd, usb drive, etc...), correct?

Posted by robh on Nov. 02 2005,21:31
thanks for your advice ~J.P.

unfortunately, as i said, i'm a big noob and i think i may have stuffed up, i just tried to make an image using the line

bzip2 -1c < /dev/hda > myhdimage.img.bz2

but i did it after booting up from my hd install not the live cd...

this is bad, no??

Posted by robh on Nov. 02 2005,22:38
so i stopped the above operation and deleted the 0 byte file that had been created, then rebooted with the live cd and tried to create the image file once more.

this time i got an error after a few moments...
bzip2: I/O or other error, bailing out. Possible reason follows.
bzip2: no space left on device
          Input file = (stdin), output file = (stdout)


what is this newbie doing wrong....
should i be doing this operation from the live cd, and if so can i specify to save the file i am creating to either the hd partition i am imaging or to my ext hdd directly?

sorry to be such a dill ~J.P.

Posted by robh on Nov. 03 2005,01:39
well i figure 2.5 hrs should have been enough time to bzip2 a 971MB partition, but it is still sitting there with 100% cpu usage and 50% swap used.

i don't think it is working...

Posted by brianw on Nov. 03 2005,05:18
Quote (robh @ Nov. 02 2005,20:39)
well i figure 2.5 hrs should have been enough time to bzip2 a 971MB partition, but it is still sitting there with 100% cpu usage and 50% swap used.

i don't think it is working...

robh,

I suspect you will need to do the following.  

Boot from livecd
sudo mount <your external hdd> <mount Point>
cd <mount point>
bzip2 -1c < /dev/hda > myhdimage.img.bz2

Posted by robh on Nov. 03 2005,20:08
thats it, i've had it with backing up my install. i think i'm gonna just fly solo and damn the consequences.

thanks for your slightly more verbose help brianw, but it seems that i'm not yet understanding the syntax/code enough to perform this task. i followed your above advice and the cpu has been maxed out for an hour now, with no sign of my compressed drive image coming out the other end.

i can wipe this 3.2 GB drive with all zeros in about 10 mins, so i reckon that an hour should be plenty of time to wait.

SaidinUnleashed described this as the "most efficient way" of imaging, but i'm on day 3 of trying now and still no luck. The man page for bzip2 is as dry and uninformative to a newbie, who is trying to learn the concepts of linux, as ~J.P.'s advice. Sorry J.P. but i want to know what the command is doing and what the operands are doing to further understand. i tried the one liner that you gave me to no avail, maybe i'm just not up to the skill level required for using linux.

ah well...

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.