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
powered by performancing firefox