how to upgrade a drive in a FreeBSD system July 2nd, 2008 (as amended)
This procedure details how to upgrade a hard disk in an existing FreeBSD installation. It assumes you already
have an existing drive, which contains data that you wish to migrate. This procedure is suitable for data drives
only - do NOT use this to upgrade your boot drive!
Below, it's assumed that the drive to be replaced is called /mnt/ad0 and the new drive is called /mnt/ad2
to begin, follow the instuctions under adding a disk
ensure you can see both the old and new drives when you run the df command
ensure you're logged in as root
Now to copy the data. If you're brave, you can migrate all your data at once, however this is not recommended
as it will stress your hardware. It's recommended to migrate one directory at a time, leaving some time between
directories. This will allow your hardware time to cool. It will also minimise the damage, if you copy the wrong
thing to the wrong place. Use this command to copy the "example" directory, and all its subdirectories, from the
old drive to the new drive:
cp -Rpv /mnt/ad0/example /mnt/ad2
repeat the above command for each directory to copy
(optional) test the copied data somehow, if there's a large ZIP file this can be tested for errors
remove the old drive from the system
Notes:
Note the lack of a trailing slash (/) on the above paths. Do not add a trailing slash to the paths.
The above copy command uses the -p switch, this preserves file permissions and timestamps. See the cp manpage
for more information.
The above copy command also uses the -v switch (verbose) - this shows what is being copied. Note that the name
of the file being copied is not shown until AFTER it is copied, not before.
The above copy command also uses the -R switch, that means recursive (eg. will copy the contents of all subdirectories as well).
Be careful with FreeBSD's drive numbering scheme. If you add a disk which causes a change in the drive
number of your boot drive, your system won't boot. Have a read of FreeBSD and ATA disks
before proceeding (note, this may also be applicable to SCSI-based systems).
If you wanted to copy a single file, rather than an entire directory (as above), use syntax like this: