Want to support HowtoForge? Become a subscriber!


1. Get yourself two hardives setup your first drive (HDA) with the your perfek system.
2. Power up your second drive (HDC)
3. Slice HDC up by using cfdisk (command is cfdisk /dev/hdc)

Hda1 - primary boot begining Label [ / ]
Hda5 - logical beginning [ /usr ]
Hda6 - logical beginning [ /var ]
Hda7 - logical beginning [ swap ]
Hda8 - logical beginning [ /tmp ]
Hda9 - logical beginning [ /home ]

To Setup your filesystem and your labels

Mkfs -t ext3 -L / dev/hdc1
Mkfs -t ext3 -L /usr dev/hdc5
Mkfs -t ext3 -L /var dev/hdc6
Mkfs -t ext3 -L /tmp dev/hdc8
Mkfs -t ext3 -L /home dev/hdc9

okay so you have sliced HDC and setup your filesystems with Labels.

Vi and copy the below script save a file called clone, make it chmod 777 and run it.

once copied run Grub
#grub --no-floppy
# device (hd0) /dev/hdc
# root (hd0,0)
# setup (hd0)
# quit

Clone Script"make sure nothing is mounted in /mnt!"
echo "going to unmount /mnt"
/bin/umount /mnt

mount /dev/hdc1 /mnt
cd /
cp -ax / /mnt

mount /dev/hdc5 /mnt/usr
cd /usr
tar lcpBf - /usr | (cd /mnt; tar xBf -)

mount /dev/hdc9 /mnt/home
cd /home
tar lcpBf - /home | (cd /mnt; tar xBf -)

mount /dev/hdc8 /mnt/tmp
cd /tmp
tar lcpBf - /tmp | (cd /mnt; tar xBf -)

#Stop crtical services
/etc/init.d/mysql stop

mount /dev/hdc6 /mnt/var
cd /var
tar lcpBf - /var | (cd /mnt; tar xBf -)

#start all the services again
/etc/init.d/mysql start

echo "all copied"
exit 0

Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Sun, 2005-11-13 21:42.

in case it's useful, a simpler way to duplicate the partitions from /dev/hda to /dev/hdc is the following:

sfdisk -d /dev/hda | sfdisk /dev/hdc

or in two steps:

sfdisk -d /dev/hda >hda.txt

sfdisk /dev/hdc <hda.txt

as for copying, i like to mount both the source and dest fs's in subdirectories of /mnt - avoids having to worry about not copying stuff like /proc - and then use rsync. something like this:

cd /mnt

mkdir sys1 sys2

mount /dev/hda1 sys1

mount /dev/hda5 sys1/usr

mount /dev/hda6 sys1/var

mount /dev/hda9 sys1/home

mount /dev/hdc1 sys2

mkdir sys2/usr sys2/var sys2/home

mount /dev/hdc5 sys2/usr

mount /dev/hdc6 sys2/var

mount /dev/hdc9 sys2/home

rsync -avuSHl --delete sys1/ sys2

the "/" after "sys1/" in the above matters. you can add a "-n" to the above and pipe it into less if you want to preview what it'll do.

ya gotta love 'nix - so many ways to get stuff done.