image a disk/partition?

lists lists at dlfws.net
Thu Oct 23 01:00:38 PDT 2003


Dmitry Mityugov wrote:

>Hi,
>
>I am looking for a program that would let me image HDDs in my test lab and
>restore them, either completely or just a few first partitions. I don't mind
>buying it (although freeware would be preferred of course) but I don't want
>to buy an OS to host this program on, so I would like to use FreeBSD for
>this project. I have modest experience with versions 4.7, 4.8 and 5.1 of
>FreeBSD and no bandwidth to stay current with version 5.1, so 5.1 released
>on the CDs is the latest version that I have. It works reasonably well in my
>test lab; it panics on reboot (shutdown -r) when I enable MP support on a
>test server with two "server Tualatin" processors but I can live with the
>standard kernel just fine.
>
>The data I am going to image are just test servers that store no valuable
>data so strictly speaking this is not vital data to me, I need this program
>just to speed up the setup, not for backup purposes (and to get rid of the
>HDDs in removable racks with different versions of various operating systems
>lying everywhere in my lab). However, I would prefer not to use beta
>software in this project because I need to use the time I get because of the
>improvement in speed for purposes other than helping the author find and fix
>bugs in the software. The software should be able to image partitions of any
>type, not just DOS/NTFS/etc like most commercial software does, compress the
>image well, because a typical test server in my lab occupies 5-15 GB that
>need to be imaged, and be smart enough to not compress the remaining free
>space on the disks (the typical HDD sizes in my lab start at 80 GB so I'd
>definitely not want to image the free space). The current number of servers
>is about 20 and of course it tends to grow.
>
>It would be nice to be able to image SCSI disks as well but almost all my
>HDDs except 2 are IDE. It would also be nice to be able to restore not the
>entire disk but just several partitions from it (yes, I believe I understand
>the possible consequences) but this is not critical for me. I searched the
>Packages and Ports collections, the documentation and the Internet
>(including archives of these lists) but found nothing that would (a) work on
>FreeBSD, (b) is not in the beta state, (c) can image everything and (d)
>compresses the images and does not image the free space. I suspect that
>there is a simple approach that does not require a third-party program at
>all (why did I get so many links to DD command? <g>) but I cannot figure out
>how to image the first 15 GB off a 80 GB HDD with DD and restore it to
>another (larger or smaller) HDD. I don't mind performing some arithmetic
>like in Greg Lehey's "The Complete FreeBSD" in the chapter about disks, I
>think I just need some enlightenment.
>
>Thank you in advance for any help you can provide
>
>P.S. I am not on the list, don't forget to copy me.
>
>Dmitry
>
>_______________________________________________
>freebsd-questions at freebsd.org mailing list
>http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
>
>  
>
Hello Dmitry,

I don't know if my solution will fit your needs perfectly, but here is 
how I solved the same problem for my lab ...

I have eight machines, all running five flavors of Windows ( 98SE, Me, 
2000, XP Pro, XP Home ) on a single disc. Each OS is on it's own 
partition as follows:

ad0s1 = Win98SE
ad0s2 = WinMe
ad0s3 = Win2000
ad0s4 = Logical Partition
ad0s5 = Win XP Pro
ad0s6 = Win XP Home

First off, I use LiveCD ( http://livecd.sourceforge.net/ ) and I store 
my backups on a server running FreeBSD 4.8-RELEASE. The only downside to 
LiveCD is that the keyboard is not mapped to my US based keyboard. To 
fix this, the first command I enter is 'kbdcontrol -l 
../usr/share/syscons/keymaps/us.iso.kbd'.

To backup any of my partitions I use the following command, 'dd 
bs=2097152 if=/dev/ad0s? | gzip > /mounted/drive/os_name.gz'
To backup the entire drive I would use, 'dd bs=2097152 if=/dev/ad? | 
gzip > /mounted/drive/os_name.gz'

To restore any of my partitions I use the following command, 'cat 
os_name.gz | gunzip -c | dd bs=2097152 of=/dev/ad0s?'
To restore the entire drive I would use, 'cat os_name.gz | gunzip -c | 
dd bs=2097152 of=/dev/ad?'

One thing you must be careful about when restoring partitions. If you 
have OSes installed on the logical partitions as I do, you need to 
create /dev/ad0s5, /dev/ad0s6 and so on for each logical partition you 
have. A drive is only allowed 4 primary partitions but any number of 
logical partitions. To create /dev/ad0s5 and /dev/ad0s6 for WinXP Pro 
and WinXP Home I do the following;

cd /dev;
./MAKEDEV ad0s5;
./MAKEDEV ad0s6;

And just for yucks, before I create a new test machine I zero the drive 
so I don't backup useless data, 'dd bs=2097152 if=/dev/zero of=/dev/ad0 
count=??g'

This system allows me to refresh any partition in about 5 minutes. 
Creating the backups takes a little longer as I'm gziping the data over 
the network, but I create new machines far less than I break them and 
need to restore.

As for your specific requirements ...

I have not tried this setup with a scsi disk so I have no idea if it 
will work.

You can backup any type of file system as dd makes a block for block 
copy of the entire partition or disk. As well, backing up the entire 
drive also backs up the MBR, so any boot manager is intact after a full 
system restore.

The amount of empty space does not seem to make a difference on the size 
of the .gz file created. I have partitions ranging from 4 GB to 20 GB 
and the file size for a patched install of Win2000 is around 1.2GB. I 
believe this is because I zero the drives before turning them into test 
machines. If you have data on the disc, dd will back it up and your 
backup files size will be larger.

One of the flaws in my system is that I cannot restore to any other 
drive than the one I imaged. This is because drive geometry differs from 
drive to drive. I have never tried to restore to another drive, but my 
understanding is that it will probably not work. Anyone have data 
regarding this point?

I hope you find some of this information helpful.
If you have any specific questions regarding my setup that I have not 
covered here, let me know.

Good luck,
Thanatos
















More information about the freebsd-questions mailing list