dd empty space question
i made image of hda1...
there is some empty space on it... how to make image without that empty space?? dd if=/dev/hda1 of=/home/image bs=4096 conv=notrunc,noerror |
I believe that you cannot realistically do that because you cannot count on all of the free space being contiguous.
You can mount the partition and use dd if=<mount point> but then I doubt that it is any better than using tar. |
does tar copy all data...??
tar -cpf image.tar /dev/hda1 ?? |
tar won't copy to or from an unmounted disk partition but it will copy all of the files in a mounted file system.
What I meant was that if you want to dump a disk partition then you probably can't get rid of the free space. |
dd makes a bitwise copy of the drive (i.e., an image). The image must contain all data present on the original disk. tar, OTOH, works on the filesystem and you can create a tar file that contains all the files on the filesystem, but it will not be an 'exact copy' in the sense of an image.
|
howto to archive all dirs in "/" using tar
except "/home"? |
Use tar with the --exclude option to avoid /home. But you'll also want to avoid /sys, /dev, and /proc. You may also want to explore tar's 'l' option.
|
tar -cpf tt.tar * --exclude comics/
not working... tar -cpfl image.tar / how to exclude /sys, /dev, and /proc? |
I would suggest using partimage. You can download a live cd such as SystemRescueCD which has that on it already. That app ignores all empty space and does compression for you. I have used it to clone a linux hd. In fact I use it in an embedded application to clone linux from a compact flash so that reinstallation is not necessary. It is very fast compared with doing a dd.
|
compress the image
Quote:
I use this method here in the work to deal with MS_Windows images. The images are good for a fast restore of a windows machine. To deal with the large empty space in the image, I store the image in compressed mode with gzip. For a typical 40Gbytes image of an entire hard disk, the compressed image is just about 3G! I have a dozen of compressed images for several kinds of hardware and applications pre-loaded. |
!! 10 fold compression...
any1 knows how to exclude dirs using tar? |
dd copies MBR??
tar copies MBR?? |
Quote:
Quote:
|
how to copy MBR with dd?
|
dd does copy the mbr.
dd if=/hda of=hda.mbr bs=512 count=1 will copy it to the file hda.mbr. Here is a sample script for backing up and restoring using partimage but you can use dd instead if you like. #!/bin/sh # Backup master boot record (MBR) echo "Backing up master boot record" dd if=/dev/hda of=Image.mbr count=1 bs=512 # Backup partition table echo "Backing up partition table" /sbin/sfdisk -d /dev/hda > Image.sf # Create image echo "Backing up first partition" /usr/sbin/partimage -z1 -c -d -o -b save /dev/hda1 ImageP0 echo "Backing up second partition" /usr/sbin/partimage -z1 -c -d -o -b save /dev/hda2 ImageP1 echo "Backing up third partition" /usr/sbin/partimage -z1 -c -d -o -b save /dev/hda3 ImageP2 echo "Backup complete!" Here is another one for restore #!/bin/sh # Write master boot record (MBR) echo "Writing master boot record" dd if=Image.mbr of=/dev/hda count=1 bs=512 # Write partition table echo "Writing parition table" /sbin/sfdisk /dev/hda < Image.sf # Write images echo "Writing first partition" /usr/sbin/partimage -b restore /dev/hda1 ImageP0.000 echo "Writing second parition" /usr/sbin/partimage -b restore /dev/hda2 ImageP1.000 echo "Writing third partition" /usr/sbin/partimage -b restore /dev/hda3 ImageP2.000 echo "Clone complete!" |
combined backup:
dd if=/dev/hda of=Image.mbr count=1 bs=512 tar -cvpf image.tar --exclude=/dir --exclude=/dir1 / |
All times are GMT -5. The time now is 11:35 PM. |