Mount Partitions to Restore Backups
I’ve been asking myself what do I do if a partition gets corrupted? Yeah, I do dumps regularly to another disk, but when you boot from an OpenBSD install cd there’s no matching /dev/wd1d there. There are no devices with wd1, only wd0. There’s MAKEDEV but it says that the operation isn’t permitted when I type ./MAKEDEV wd1d. What’s going on here? I don’t have to worry about being root, this is an installation cd. Actually I’ve shelled out of the install routine. Let’s do ls -l and see what we get. I’ll be darned, MAKEDEV is not executable. chmod +x MAKEDEV and that solves that problem.
Once again, I type ./MAKEDEV wd1d and hit enter. This time there’s no error message. Another quick ls -l shows all kinds of wd1 listings now including wd1d. Now I mount -r /dev/wd1d /mnt and no error message. Let’s see what mount shows. Cool, wd1d is mounted. I do a ls -l on it and sure enough, there’s my /data partition on the hard drive where all the dumps are stored.
Now if a partition gets corrupted, all I have to do is boot up on the cd, make the device, run newfs on the corrupted partition, mount the partition with the backups on it as shown above, mount the newly formatted partition in write mode, change directory into it and restore the appropriate dump. Life is good!
Someone may say you don’t need the cd to boot from, you just boot the bsd.rd kernel, and that’s okay, that is if your / partition isn’t the corrupted one. Also, remember, restore is in /sbin. I don’t think there’s anything wrong with using the cd to work from. That is, unless you didn’t install off a cd and don’t have one. I think it’s a good idea to keep one one hand.
This is probably kindergarden stuff for most of the guys on the OpenBSD mailing list, but for me it’s like when the apple hit old Isaac on the head! It’s a revelation!
I’m putting this up here in hopes someday some poor newbie having the same problem googles around and finds it. That’d be cool.
Everytime I do a fresh install of OpenBSD, I create a wd1a partition on a 2nd hard drive the same size as my root partition on the primary hard drive and label it altroot. In root’s crontab, right below my env settings SHELL, PATH, and HOME, I enter ROOTBACKUP=1. That way, every day the system will backup /root to /altroot. Alternately, you can edit /etc/daily.local and enter the same ROOTBACKUP=1 line.
In either case, you also have to remember to enter the partition info in /etc/fstab. The format is a little different too, than the format the others partitions use: /dev/wd1a /altroot ffs xx 0 0
Experimenting for Newbies
I thought it might help newbies to write about a learning strategy
I’ve usedsince I started out trying to learn the BSD’s. I’ve got this
old PIII 800 I’m working on running OpenBSD, an ancient PII 300
dual-processor HP Netserver running OpenBSD, a Toshiba Satellite
4015 (another relic) running OpenBSD, and a PIII 667 home-built
box running XP. I installed cygwin on the XP box, setup a vanilla
bash prompt so neither FreeBSD or OpenBSD, which has a different
term code and didn’t like the flashy default bash prompt in cygwin.
I also setup Microsoft Services for Unix Administration on the XP
box. I setup ficticious users on all the different boxes, and then I
taught myself how to do automated cronjob rsync backups across
the LAN, setup LAN file shares on on the XP box and NFS on the
BSD boxes, taught myself about ssh and scp along with authorized
keyfiles to eliminate typing passwords, and setup cvsup in root’s
crontab to keep all sources up to date. Forgot to mention a friend
gave me a very ancient Prioris P90 box given to him after Hurricane
Katrina, setup an IDE drive and 5 1GB scsi drives in it left over from
the storm and still working, installed OpenBSD 3.8 on it, set termcap
for serial port usage, hooked up a null modem cable bought locally,
and taught myself how to control it remotely from this box. While I was
out of town, I was told it wasn’t working properly, and was able to ssh
into this box and work on the ailing box from 700 miles away. All I
need to do, I guess, is set up the NIC for wake-on-lan and I could
even wake it up from somewhere else.
Whole point of this tirade is that you can use a bunch of old hardware
as your classroom. All of these boxes I have would be laughed at by
someone using the hot hardware that’s coming out these days, but
they have been a great help at relatively very low costs.
Just a thought!