# drive imaging on gentoo

## niyogi

I wanted to spark a discussion on drive imaging on Gentoo installations.  

Here's the reason:  It takes >=5 hours to install Gentoo.   It could be the case that a sys admin either a)wants to install the same setup on dozens of identical machines or b)wants to be able to recover from a unrecoverable crash/setup.  Having a image of the hard drive and slapping on there would be much faster and intuitive then reinstalling everything.

The thing is: I don't know how to do this or better yet what the best way would be.  Any ideas?

-S

----------

## Jamon

Well.. you can try Partition Image for Linux!  I have not tried it, but let me know what you think.

	Jamon

http://www.partimage.org

----------

## Nitro

To create a real image one would use dd.  To create an image of an entire drive you'd do something like: 

```
dd if=/dev/hda of=/mnt/some/nfs/mount
```

Then to restore it try: 

```
 dd if=/mnt/some/nfs/mount of=/dev/hda
```

That should copy everything including bootsector (I think, correct me if I'm wrong).  I would imagine that you would only want to do this on a system running of a boot disk or boot cd so that when you make the image you don't copy session specific stuff like /etc/mtab, and you obviously can't apply an image to a drive that you have mounted.

----------

## Jamon

Of course that would work, but many would like to be able to use the image on a different size drive, and also compressing it would be nice!  (though bzip could do that..)

   Jamon

----------

## Guest

 *Jamon wrote:*   

> Of course that would work, but many would like to be able to use the image on a different size drive, and also compressing it would be nice!  (though bzip could do that..)
> 
>    Jamon

 

Well, we usually install one reference machine including a very stripped down package set and a tailored kernel. After that, we put the drive(s) in a different machine, mount everything short of the virtual filesystems (/dev, /proc ...) below /mnt and create a tar.bz2 from that. That tarball in turn is put onto our install server.

Now when a new machien has to be installed, we boot off the net, mount the install servers NFS share (which includes all tarballs), partition the drives etc. and untar the tarball from the NFS share. After that, a quick edit of fstab, and the network conf, a chroot plus updates (in case of a debian: apt-get update, apt-get dist-upgrade, gentoo works similar with emerge) and a lilo (or grub-install). Voila, machine done. And even this could be further simplified by using scripts+dialog (but hey, gotta think of job security  :Wink: )

----------

