how to add a drive to a FreeBSD installation September 16th, 2007 (as amended)
This procedure details how to add a hard disk to an existing FreeBSD installation. I had a spare drive, I wanted to install it so I could cd to it, make directories, copy files to it, etc.
install hard drive into the computer (ensure to set jumpers correctly)
ensure BIOS can see the drive correctly
boot FreeBSD
login as root
run dmesg
note the devicename given to the new drive - it should be visible at the end of the dmesg output (eg. ad1)
create a mountpoint for the new drive (eg. mkdir /mnt/ad1)
(optional) to see the existing partitions on the drive, run fdisk devicename (eg. fdisk /dev/ad1)
run sysinstall
select Configure, then select Fdisk
from the drive selection menu, select the drive to work with (the devicename noted earlier will be listed here)
press A to erase all existing partitions and allocate all the space to FreeBSD
press W to write the new partition table to the disk (NOTE: all existing data on the drive will be lost at this point!) [accept warning if prompted]
press Esc to select None - leave MBR untouched (unless you have reasons for doing otherwise)
press Q, then select OK to quit Fdisk
press Esc to exit the drive selection menu
select Label
press C to create a new FreeBSD slice
define the size of the slice (press Enter to accept the default maximum size)
select FS (filesystem)
specify the mountpoint for the new drive made earlier (eg. /mnt/ad1) - this is the path to the new drive, created earlier
press W to write the slice to disk [accept warning if prompted]
Note: if you do not see newfs format the slice, and/or you get an 'unable to write' message, repeat this step. When successful, a file called ".snap" should be visible in the root of the drive.
press Q to quit the label editor
press Esc, Esc, and Esc to exit back to the command prompt
The drive will then be available for use, in /mnt/ad1. It will also be listed in the output of the df command.
Notes:
The drive will NOT be automatically re-mounted after a reboot. To auto-mount the drive at boot, add something like this to /etc/fstab:
/dev/ad1s1d /mnt/ad1 ufs rw 0 0
You may wish to change group ownership and permissions, if other users will be using the drive. Use syntax like this:
chgrp -R usergroup /mnt/ad1
chmod -R 775 /mnt/ad1
Those two commands will give write access to all users in the group "usergroup".
To mount the volume manually, use a command similar to:
mount /dev/ad1s1d /mnt/ad1
Substitute the correct name of your device and mountpoint.