The FreeBSD Diary |
(TM) | Providing practical examples since 1998If you buy from Amazon USA, please support us by using this link. |
Swapping boot drives around
13 August 1999
|
The NZ FreeBSD User Group was given a
box which was destined to become the cvsup and www mirror. The first thing I did was
swap the two 500MB drives out and put in three 1GB drives. This articles documents
how I did that.
You may wish to first read about a couple of other methods as supplied by other readers. |
Overview
|
The following steps will be performed:
This procedure assumes you have enough disk space for the backup. I'm sure there must be an easier way to do this. If you know, please let us know your comments. This article also assumes you know how to add a new drive to a box, set up the primary/secondary stuff (if using IDE) or set device IDs (if using SCSI). The main thing this article shows you is how I backed up and restored the boot drive. |
The backup
|
For this exercise, I had three drives. You could get away with just two. I
mounted the spare drive in /mnt.mkdir /mnt mount /dev/da1s1e /mnt The first step was to backup each file system on the boot drive. This is slightly more complex that I first thought. If you look at the existing mount points, you'll see what I mean: # mount /dev/da0s1a on / (local, writes: sync 14 async 215) /dev/da0s1f on /usr (local, writes: sync 3 async 95) /dev/da0s1e on /var (local, writes: sync 91 async 237) procfs on /proc (local) In this example, you'll see three mount points we must deal with: /, /usr, and /var. Each mount point represents a different file system. I decided to backup each separately. I'm not sure why. But I did. I used the tar command for this. tar cvlf /mnt/root.tar / tar cvlf /mnt/var.tar /var tar cvlf /mnt/usr.tar /usr Here is a brief explanation of each option:
Then I did a "shutdown -h now" and powered off the box once the shutdown was complete (see the console messages for this). |
Create a new boot drive
|
I removed the existing boot drive from the box and installed a new blank drive in it's
place. Then I went through the normal FreeBSD install process for that drive.
Actually, it wasn't a normal install as I need a custom kernel for this box because the
GENERIC kernel won't work. See Installing 3.2-release [the
hard way] for details on that. Otherwise, the install was pretty much the same
as Installing FreeBSD to replace Windows 95. Then I did a "shutdown -h now" and powered off the box once the shutdown was complete (see the console messages for this). |
Restoring the old to the new
|
The next step was to reinstall the original boot drive but retain the new boot drive.
You must be careful to avoid conflicts. In my case, I merely changed the SCSI
ID on the new boot drive from 0 to 2. I mounted the spare drive: mount /dev/da1s1e /mnt I mounted the new boot drive. You'll remember that we had three file system to backup. So that requires three mount points. mkdir /newboot mount /dev/da2s1a /newboot mount /dev/da2s1f /newboot/usr mount /dev/da2s1e /newboot/var Then I started restoring from /mnt to drive to the new boot drive: tar xvpf /mnt/root.tar -C /newboot tar xvpf /mnt/usr.tar -C /newboot tar xvpf /mnt/var.tar -C /newboot The -C option tells tar to change to the /newboot directory before untar'ing any files. Then I did a "shutdown -h now" and powered off the box once the shutdown was complete (see the console messages for this). |
Out with the old and in with the new
|
After shutting down the machine, I swapped the SCSI IDs of the new and old boot drives. The old one became 2 and the new one became 0. I powered on the machine, and it booted up straight away. No problems. |
Wait! All my permissions are gone!
|
If you find that the permissions on your files are messed. Perhaps everything is either root or wheel. Well, you probably haven't restored your users from the tar file. Try that. |
People have responded to my query regarding easier ways to do these things. Thanks to those that have helped. |
Duncan Barclay <dmlb@ragnet.demon.co.uk> supplied this information. Thanks.
|
All you need to do to use another drive as a boot drive is the following:
This is the scheme Duncan uses to have FreeBSD booted from his scsi drives in a mixed ide/scsi setup. |
Dean <madscientist@thegrid.net> supplied this. Cheers.
|
No re-install required. You also don't have to make sure you have enough space lying around to hold the tarball. Hope that helps, |
Was this efficient?
|
I'm sure there are simpler ways of doing this. For example, I think I could have done this with a single tarball. And I think I could have created a boot drive without actually having to install FreeBSD on the new drive. If you know of an easier way, please add your comments. |