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.
newfs /dev/rwd1a
after that:
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)
By Anonymous Coward (165.228.157.146) on
Comments
By Anonymous Coward (24.22.214.92) on
Suppose he wasn't in a scenario where it was possible (or simple) to have two hard disks in a machine at once. Many mini-desktops from big-name OEMs are like this.
Comments
By Lennie (82.75.29.106) on
>
> Suppose he wasn't in a scenario where it was possible (or simple) to have two hard disks in a machine at once. Many mini-desktops from big-name OEMs are like this.
You mean to tell me it doesn't even allow for that when it's lying open ?
It's not just a case problem ? Is it the power-spply ?
Well, if you have an other machine, you could use the NFS method as shown above, but if you have enough memory, I could also suggest rsync.
Comments
By Anonymous Coward (68.148.116.122) on
Yep. I've seen machines with just one ATA port and two molex connectors - just enough to run a disk and a CD/DVD. Not saying that's a good idea, but for some users, it's good enough.
Comments
By Marc Espie (213.41.185.88) espie@openbsd.org on
>
> Yep. I've seen machines with just one ATA port and two molex connectors - just enough to run a disk and a CD/DVD. Not saying that's a good idea, but for some users, it's good enough.
So you just disconnect the CD drive temporarily and plug-in both disks. Like wow, difficult idea.
By Anonymous (82.204.30.143) on
Comments
By Anonymous Coward (151.145.232.92) on
Oh, Stewie, you're such a cutie.
By Anonymous Coward (213.221.123.174) on
Expanded your memory? To what? 4GB is the limit, isn't it?
So what "expansion"? :-]]
By Pierre Riteau (82.240.212.223) on
And you forget your hidden files in your home with the wildcard, at least on ksh.
Comments
By Andrei GUDIU (andreig) on http://www.openbsd-box.org
> And you forget your hidden files in your home with the wildcard, at least on ksh.
I'm using zsh and it worked OK for me.
Comments
By Anonymous Coward (192.61.201.164) on
> > And you forget your hidden files in your home with the wildcard, at least on ksh.
>
> I'm using zsh and it worked OK for me.
You have hidden files in /home ?
Comments
By Andrei GUDIU (andreig) on http://www.openbsd-box.org
> > > And you forget your hidden files in your home with the wildcard, at least on ksh.
> >
> > I'm using zsh and it worked OK for me.
>
> You have hidden files in /home ?
of course I have, all my configs are in hidden files in my home and they are all there. Hidden files and hidden directories.
By Pierre Riteau (82.65.36.204) on
> > > And you forget your hidden files in your home with the wildcard, at least on ksh.
> >
> > I'm using zsh and it worked OK for me.
>
> You have hidden files in /home ?
Sorry, it's /home but I thought /home/user... my mistake.
By Anonymous Coward (24.37.242.64) on
By Anonymous Coward (204.80.187.5) on
I would have just done the fdisk, disklabel, newfs, and then:
(cwd is irrelevant here since absolute paths are specified):
tar cXf - / | (cd /mnt; tar xpf -)
tar cXf - /home | ( cd /mnt; tar xpf -)
tar cXf - /var | ( cd /mnt; tar xpf -)
tar cXf - /usr | ( cd /mnt; tar xpf -)
/usr/mdec/installboot -v /mnt/boot /usr/mdec/biosboot wd1
(where wd1 is the new disk)
Comments
By Andrei GUDIU (andreig) on http://www.openbsd-box.org
>
> I would have just done the fdisk, disklabel, newfs, and then:
>
> (cwd is irrelevant here since absolute paths are specified):
>
> tar cXf - / | (cd /mnt; tar xpf -)
> tar cXf - /home | ( cd /mnt; tar xpf -)
> tar cXf - /var | ( cd /mnt; tar xpf -)
> tar cXf - /usr | ( cd /mnt; tar xpf -)
> /usr/mdec/installboot -v /mnt/boot /usr/mdec/biosboot wd1
>
> (where wd1 is the new disk)
I just found that soultion to be easiest to follow for me, and I guess I have also a good backup image (never had one before). Btw, my old hdd died yesterday evening. The box won't start with it plugged in anymore. Lucky me I got my new one 2 days ago.
Comments
By Anonymous Coward (204.80.187.5) on
> I just found that soultion to be easiest to follow for me, and I guess I have also a good backup image (never had one before). Btw, my old hdd died yesterday evening. The box won't start with it plugged in anymore. Lucky me I got my new one 2 days ago.
Well using the network with dump/restore and then using tar for the rest of it makes no sense, and is really a big waste of time. If you just use tar or dump/restore locally between the disks then you could have done the whole thing in like 10-15 minutes (with the write cache enabled on wd1)
Comments
By Andrei GUDIU (andreig) on http://www.openbsd-box.org
> > I just found that soultion to be easiest to follow for me, and I guess I have also a good backup image (never had one before). Btw, my old hdd died yesterday evening. The box won't start with it plugged in anymore. Lucky me I got my new one 2 days ago.
>
> Well using the network with dump/restore and then using tar for the rest of it makes no sense, and is really a big waste of time. If you just use tar or dump/restore locally between the disks then you could have done the whole thing in like 10-15 minutes (with the write cache enabled on wd1)
>
>
I will keep that in mind for my next hdd switch (which will be in 10 years from now I guess :)). Thank you for your suggestions and good intentions (unlike some others around).
By Anonymous Coward (24.37.242.64) on
> >
> > I would have just done the fdisk, disklabel, newfs, and then:
> >
> > (cwd is irrelevant here since absolute paths are specified):
> >
> > tar cXf - / | (cd /mnt; tar xpf -)
> > tar cXf - /home | ( cd /mnt; tar xpf -)
> > tar cXf - /var | ( cd /mnt; tar xpf -)
> > tar cXf - /usr | ( cd /mnt; tar xpf -)
> > /usr/mdec/installboot -v /mnt/boot /usr/mdec/biosboot wd1
> >
> > (where wd1 is the new disk)
>
> I just found that soultion to be easiest to follow for me, and I guess I have also a good backup image (never had one before). Btw, my old hdd died yesterday evening. The box won't start with it plugged in anymore. Lucky me I got my new one 2 days ago.
I think your posting was great and I always like to see new articles. It shows how you did it and even how others do it in different ways which means it's educational for many, one way or another. It shows how versatile things can be and gives people the 'choice' to do things how they like, and in a variety of ways.
I'll be posting a few articles myself soon, just after 4.2 is out.
Glad to see your effort, unlike some others... ;-)
By Anonymous Coward (204.80.187.5) on
cd /mnt/dev
./MAKEDEV all
and, at this point, you could reboot and use the new drive as primary.....
By Anonymous Coward (204.80.187.5) on
> tar cXf - / | (cd /mnt; tar xpf -)
> tar cXf - /home | ( cd /mnt; tar xpf -)
> tar cXf - /var | ( cd /mnt; tar xpf -)
> tar cXf - /usr | ( cd /mnt; tar xpf -)
> /usr/mdec/installboot -v /mnt/boot /usr/mdec/biosboot wd1
This assumes that wd1 is mounted to /mnt and that wd0 has 4 partitions: / /home /var /usr but your article says that your 15gb disk was only one partition so all you need to do is the first tar cXf - / | (cd /mnt; tar xpf -) between the disks and then run installboot.
By tuyosi (210.253.226.156) on
i Changed the harddisk from 80GB(wd0) to 20GB(wd1) by following methods .
i attach new 20GB harddisk drive
1. boot with "OpenBSD CD"
2. chose install
3. select wd1 as "install hard disk"
4.when formatting is done , press " ctrl+C ".
( this brings you shell prompt .)
5. umount /mnt
6. mkdir /m0
mkdir /m1
7. mount  /dev/wd0a /m0
mount  /dev/wd1a /m1
8. ( cd /m0 ; tar cf - . )|(cd /m1 ; tar xvpf - )
9. fdisk -i wd1
/usr/mdec/installboot -v /m1/boot /usr/mdec/biosboot wd1
umount /m0
umount /m1
halt
10. remove 80GB hard disk , and boot OpenBSD with 20GB hard disk .
Comments
By tuyosi (125.215.108.74) on
>7. mount  /dev/wd0a /m0
> mount  /dev/wd1a /m1
7. mount /dev/wd0a /m0
mount /dev/wd1a /m1
By Anonymous Coward (12.217.228.139) on
Comments
By spikeysnack (12.45.63.191) spikeysnack@gmail.com on
just for clarification --
from growfs (8) :
As always, Consult the man pages carefully before messing around with potentially destructive procedures -- (Duh!)[OpenBSD user since 2.1]