Contributed by sean on from the getting things done the puffy way dept.
This is my story of switching my 4.2 OpenBSD box from my old 15GB hard-disk to a new 160GB/7200/RPM one.
Lately I just frequently got "out of space" on my old 15GB hard-disk so I decided it's time to buy a new one. I got myself a 160GB IDE since my box only supports IDE hard-disks. So I started looking for a way to minimize my downtime and keep all my data and setup intact during and after the switch. I have to say that there was a single partition on my old 15GB hdd so this should be quite easy to dump and restore.
Read on for his solution.
Would you have solved this issue differently (how so)?
Andrei's submission as follows:
I browsed the OpenBSD FAQ and found that I could use dump(8) and restore(8) (http://www.openbsd.org/faq/faq14.html#Backup).What kinds of problems do you use OpenBSD to solve?
Note: I used a NFS mounted space for my system dump not a tape-drive. Throughout this story I will use /mnt/exported for my dump destination and source and /mnt/new for the new harddisk I mounted in.
1. First, the system dump. My single partition was wd0a so I started by dumping this partition into the NFS exported file-system.
/sbin/dump -0au -f /mnt/exported/systembackup /dev/rwd0aThis process took a long while (about an hour or so) since it all went through our LAN (which is a damn slow one).
2. Preparing the new hard-disk.
I got my new hard-disk in my box as primary slave. So now I have wd0 my old hdd and wd1 the new one. First I needed to initialize the new hdd for the use with OpenBSD (and only OpenBSD). For that I used:
$fdisk -e wd1 Enter 'help' for information fdisk: 1> reinit fdisk: 1> write fdisk: 1> quitAt the prompt I initialized the new hdd with the "reinit" command, then "write" and then "quit". After that I had to create the disklabel. I only needed to create one UFS slice so I choose my / slice to have 30GB of space.
disklabel -E wd1 # Inside MBR partition 1: type A6 start ## size ####### Treating sectors ##-####### as the OpenBSD portion of the disk. You can use the 'b' command to change this. Initial label editor (enter '?' for help at any prompt) > a a size: 30G FS type: [4.2BSD] > a f size: 1G FS type: [swap] > qAt the prompt I added the a 30GB slice and after that I created the swap space.
3. Next I got my new file system and mounted the new slice onto /mnt/new.*********************************************** *** DO NOT FORGET ABOUT THE SWAP PARTITION. *** ***********************************************
For that I used the newfs command to build a clean file-system in place.
mount /dev/wd1a /mnt/newNow I should have the new 30GB slice ready for the restore of my system backup.
cd /mnt/new restore -rs 1 -f /mnt/exported/systembackupThis also will take a long while. Note that the restore command is pretty silent so if you would like to see which files are being restored you should add the -v flag but keep in mind that verbosity steals from your precious time :)
4. Next I wanted my new hard-disk to be able to boot :)
I used the following commands to write a new MBR for my drive and install boot blocks.
fdisk -i wd1 cp /usr/mdec/boot /mnt/new/boot /usr/mdec/installboot -v /mnt/new/boot /usr/mdec/biosboot wd15. Unmounted and halt.
After all this was done, with my heart beating like a locomotive I turned my box down, switched the IDE cables and...
VOILA ! My 4.2-current booted like a charm from my new hard-disk. I have to say it booted more than twice faster since my old hdd was a 4200 or 5400 RPM old runner.
6. I created 3 more slices for /var /home and /usr. You can do this the same
way as described above with the 30GB partition. I mounted /mnt/var, /mnt/home and /mnt/usr and copied my old /var, /home and /usr there using tar.
cd /home tar cf - * | ( cd /mnt/home; tar xfp -) cd /var tar cf - * | ( cd /mnt/var; tar xfp -) cd /usr tar cf - * | ( cd /mnt/usr; tar xfp -)Now change /etc/fstab to use your new slices and... reboot. At least that's
what I did. Everything works like a charm and about 3 times faster :)
(Comments are closed)