The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Article Feedback - Swapping boot drives around
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 dump/restore
Author: Henry 
Date:   28-10-01 19:23

(posted by Dan Langille)


I came across your article while researching disk and controller issues and
thought I would pass along the method I regularly use to replace disks in
FBSD, in fact I just got done with a boot disk swap on a 3.4 RELEASE system
about an hour ago on one of my development machines.

I use dump and restore to copy the filesystems in one operation.

The first thing I do is install and prep the disks using the "Dangerously
dedicated method" described in the FreeBSD Handbook. Methodology doesn't
matter as long as you can newfs and mount the disks and access their
filesystems. If your new disk will be a boot disk you must make sure it is
bootable using sysinstall's "partition" utility or via the -B option to
"disklabel."

"newfs" your new filesystems and "mount" them up.

"cd" to the new filesystem, here we'll build a new root on /slash:

# /slash

Now dump the root FS to it:

dump -0b 512 -f - / | buffer -S 2048K -p 75 | restore -rb 512 -f -

If you don't have the "buffer" utility remove "buffer -S 2048K -p 75 | " and
pipe dump directly to restore.

In the above dump command I specify a Level 0 full dump with a 512k blocksize
for speed, your mileage may vary, experimenting with the blocksize is
necessary to determine an optimal value. I use the "-f -" option to dump to
stdout and "/" is the filesystem to dump to stdout. I am piping the dump to
"buffer" to speed up the I/O a tad and that pipes to restore which uses the -r
option to "rebuild a filesystem", -b to specify my 512k blocksize, and "-f -"
once again to specify that it is restoring from stdin. I frequently clone
disks with gigabytes of data on them so maximum speed is desirable and the use
of the "-S 2048" has buffer spitting out the progress for every two megs
through the pipe. "-p 75" instructs buffer to start a write when the 75% of
the internal queue is full. "buffer" is available through the misc FreeBSD
ports collection. "team" is another nifty buffering utility which can be used.

Follow the same procedure for each filesystem on the hard disk and when
finished you will have a perfect copy which is ready to replace the old drive
about as fast as is possible.

When I'm finished cloning the disk I set whatever jumpers may be necessary for
its new position on the SCSI or IDE daisy chain and remove the old drive.

If replacing an IDE boot drive with a SCSI drive you'll want to build a new
kernel specifying "kernel root on dax" or "kernel root on sdx" in the conf
file where "x" is the unit number of the boot disk and da or sd as the disk
IS as approriate. Your SCSI controller must be able to be used for booting,
consult your hardware documentation for more information. When trying to
diagnose strange system bootstrapping preferences take some time to examine
your /boot/ directory's files and read the boot(8) manpage. FreeBSD will boot
from the first bootable device it can figure out how to boot from and it can
be quite confusing to initially boot from a kernel on one disk and then have
your root filesystem mounted from another disk which has your new and
still _unused_ kernel on it! If you will no longer have IDE drives in the
system and your SCSI controller hijack's the bios on its own then you
shouldn't even need to modify the kernel, it should just pick up the ball and
run with it all on its own.

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org