[plug] Images
Leon Brooks
leon at brooks.smileys.net
Sat Aug 12 20:45:43 WST 2000
Jonathon Bates wrote:
> I am just wondering how I go about creating an image of an installed
> machine? Do I simply tar up everything or what?
You are usually better off doing a partition at a time because it allows
you to restore to different sized disks. If this disk is larger, you can
make a temporary partition of the correct size, restore (usually /home)
into it, then "cp -a" the restored partition into the real one and
delete the temp, restore the other partitions. If the disk is slightly
smaller (e.g. same model with more badblocks) you can leave out
something like /tmp and make it by hand. Remember to fudge a
/etc/lilo.conf (or similar for grub) on the new disk and install a boot
sector for it before putting it aside.
Disk-to-disk imaging, both disks the same size exactly.
dd if=/dev/hdX of=/dev/hdY
X and Y as appropriate (typcally a and c respectively). The disk device
may also vary (sd for SCSI disks instead of hd for IDE).
Disk-to-file (X is drive letter):
dd if=/dev/hdX of=filename
Partition-to-file (X is drive, N is partition):
dd if=/dev/hdXN of=filename
...with compression...
dd if=/dev/hdXN | bzip2 >filename
...to another machine...
mkfifo wormhole
scp wormhole username at nodename:/path/to/dir/hdXN.image.bz2 &
dd if=/dev/hdXN | bzip2 >wormhole
rm -f wormhole
...to someone you hate...
dd if=/dev/hdXN | crypt | mail -s "Latest Mars image" enemy at hostname
...elaborate on this as necessary.
In Real Life, making a Kickstart disk during installation is a safer way
of duplicating an install. If you want to change some config, say "touch
marker.temp", then make your changes and copy them off separately like
this:
tar cvzf changes.tar.gz \
$(find / -name -newer marker.temp -o -cnewer marker.temp)
Note that this does not track deletions, only modifications and
additions. I suggest editing the results of this to track deletions:
history | sed -ne "/ rm /s/^ +[0-9]+ +//p" >deletions.sh
If your version of sed down't recognise the + regex operator, double the
argument and use * instead, so:
history | sed -ne "/ rm /s/^ *[0-9][0-9]* *//p" >deletions.sh
These instructions work on bash, and probably fail miserably on csh.
Some other shells will require replacing $(...) with `...` to work. Matt
can probably better this in PERL. (-:
--
If life is merely a joke, the question remains: for whose amusement?
More information about the plug
mailing list