When a System Dies; Getting back in operation again.
jerrymc at msu.edu
Fri May 1 20:44:27 UTC 2009
On Fri, May 01, 2009 at 12:07:22PM -0500, Martin McCormick wrote:
> Let's say we have a system that is backed up regularly and it
> vanishes in a puff of smoke one day. One can get FreeBSD
> installed on a new drive in maybe half an hour or so but we also
> need to get back to the right patch level and then we can say we
> are back where we started. If you do not have hot-swappable
> drives which we mostly do not, What is the best way to restore
> the full system?
> Can I use the FreeBSD installation disk in rescue mode?
> The idea would be to boot the CDROM, go in to rescue mode, mount
> the new drive which may be blank right now, and then use restore
> based on the last dump of the system we are trying to revive.
By the way, dump/restore are the best for backup/recovery because
they handle the odd situations best - such as you replace the old
failed disk with a newer either larger or smaller (but still big
enough to hold everything) disk. Other utilities cannot handle
that gracefully. Dump/restore does. There are a few other odd
cases as well.
I think you want what is called 'fixit' mode. You can select
that when you boot from it. I am not absolutely sure all sets
of disks are populated identically. Check now that your CD has
the fixit and if it is on a different image, download that one,
burn it and stash it somewhere safe.
What you want to do is use the fixit image to set up the disk.
That means fdisk and bsdlabel and newfs it. You can actually
use sysinstall to do this as well. Just let the installer come
up and do the disk stuff, choose minimal install and then after
it finishes making the disks, kill the rest of the install (or
just let it finish and then overwrite it.
But, I find it actually easier to do the fdisk, bsdlabel and newfs-s
myself. But, then I am used to it.
Right after you get done making sure where your fixit is living,
then use fdisk and bsdlabel to check for the way you have the disk
set up currently. Write it down or print it out and keep it
near that installation/fixit disk.
If you do fdisk ad0 or fdisk da0 (depending on IDE/SATA or SCSI/SAS
respectively) without any other parameters, it will print out what it
thinks the disk is currently like. Of course, if it is other
than disk 0, use the correct number.
Then do a similar thing with bsdlabel. bsdlabel -e ad0s1
or bsdlabel da0s1. If you have more than one slice and FreeBSD
is not on slice 1, then use the correct slice identifier here.
So, if it is the second SATA drive and the third slice on it
that might look like bsdlabel -e ad1s3.
Note that drives number from 0, but slices number from 1.
Anyway, then copy the information it shows in the table down or
print it out. Ignore the stuff on top - anything above where
it says: '8 partitions:' You are just interested in the
partition identifiers and the sizes and offsets, types
and the fsize, bsize and bps/cpg. Actually, you can normally
just take whatever defaults it gives you for fsize, bsize and bps/cpg
unless you are doing something extra exotic.
Then just get out of the edit session without writing/saving.
just type ESC :q!
Those numbers don't have to be the exact same on the new disk and
probably will not be, but you will want to have the information
handy rather than have to recalculate it at a bad time.
NOTE, I am mostly writing this presuming that you have the machine
only running FreeBSD. If you have it dual booted, you will want
the information on the other OS slices too. fdisk will give you
what you need to know. The FreeBSD fdisk is smart enough to report
on all slices -(what MS calls primary partitions) even if they are
not FreeBSD slices. It does not report on extended partitions, but
it does not need to. You only need to know about the primaries/slices.
You let those other OSen deal with 'extended' stuff.
If you have an MS or Lunix OS on it, then those should be put back first.
Whatever you did to divide the old disk will have to be done to make
the slices on the new disk. Maybe Partition Magic or Gparted was used.
Once you have it divided in those major divisions (slices/primary partitions)
then use fdisk to make at least the FreeBSD slice boodable. Those
other OSen will probably take care of it for theirs.
The easy thing is if the whole disk is being used by FreeBSD.
Then just do:
fdisk -BI da0
That will make the whole disk FreeBSD and bootable.
Then do two bsdlabels. The first sets up the label and the
second edits it to have the partitions you want.
bsdlabel -w -B da0s1
bsdlabel -e da0s1
You will see an edit session about like the one you saw when you
collected the information to stash away, except it will only show
a 'c' partition.
Leave that c partition alone, but make the other ones similar
to what you had on the old disk. You only need to put in
the '0' value for the offset on the first (a) partition and then
put '*' in for the rest of the offsets.
Make the rest of the sizes what you want - remember the values
are in 512 byte block numbers by default. That can be changed, but
just learn to use the blocks. The number of blocks should come out
to be good round multiples of powers of 2. So for 500 Megabytes,
use 512*1024*1024 bytes - which is 1024*1024 blocks, etc.
For the last partition, use '*' for the size as well as the offset
and it will put all the remaining usable space in that partition.
Do the ESC :wq to get out of the edit session and write the
Now all you have to do is newfs each partition. Just take the
defaults. Remember that newfs wants the full device spec, not
just the drive identifier.
Do not newfs the swat partition.
Now make mount points such as
etc for whatever you need
Then mount the partitions
mkdir /dev/da0s1a /newroot
mkdir /dev/da0s1e /newusr
etc NOTE, that it is very unusual to restore /tmp - not necessary.
Then do the restores from whatever media they are on.
restore -r /dev/nsa0
If it is on tape.
If it is on another disk, such as a large external USB, you
will need to find out its device name, mount it and restore from there.
mount /dev/da1s1a /usbbak
restore -r /usbbak/rootbak
or whatever you named it.
Do that for each backed up file system and then reboot.
Should work jsut fine.
> Martin McCormick WB5AGZ Stillwater, OK
> Systems Engineer
> OSU Information Technology Department Telecommunications Services Group
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions