The procedure to add a new partition in FreeBSD 9.1 is similar to the one described here: Create and extend an LVM Logical Volume in Ubuntu 12.04. But there are a few differences in the procedures. Warning: I have little confidence with FreeBSD, so I'm going to write any findings I think as interesting or useful.
Warning 2: as always, all commands are intended as preceded with sudo.
Warning 3: you need bash to run most of this commands, it seems. By default, I have sh as FreeBSD shell. In case you don't know, type /bin/bash if you see "#" instead of "[user@pcname /folder]"
CODE
First you have to add the new disk to your machine (virtual or physical). Once you connected the new disk, you can start the procedure. Here we go.
First, check which devices are already active:
ls -l /dev/
and keep them signed somewhere (maybe open another shell if you can). Suggestion: if you mount your disk in SCSI, in FreeBSD they are called with a name like da1, da2, da3, etc; while the partitions are called like da1p1, da1p2, da2p1, da2p2 etc.
Note: I found in internet that even in FreeBSD you can use "cat /proc/partitions", but in my case /proc was empty, so I had to look directly at /dev
To let FreeBSD recognize the new SCSI disk you have to force recheck of the SCSI bus:
camcontrol rescan all
Check again for the devices:
ls -l /dev/
and look for a different device from the previous list (I always check the last modified date). Let's say we found da4.
Now, create and format (in UFS in this case) a new partition:
gpart create -s GPT da4
gpart add -t freebsd-ufs da4
where -t is the partition type and -s is the scheme (let's say a format) of the partition.
Then, create the filesystem:
newfs -U /dev/da4p1
-U mark the file system to use Soft Updates. Soft Updates are a technique to guarantee consistency of the file system in case of crash, at the price of a slighly increased memory consumption and to lose the data to be written within 30-60 seconds before the crash. (For more informations, see FreeBSD - Configuring Disks, see paragraphs 12.13.2 and 12.13.2.1).
We're near the end. Let's create the mount point of the new partition:
mkdir /media/zakkwilde
Then edit /etc/fstab and add a new line:
echo "/dev/da4p1 /media/zakkwilde ufs rw 2 2" >> "/etc/fstab"
To remember, the order of the parameters is: partition, mount point, partition type, mode/option (read-write, read-only, etc), partition dumpable, order of fsck checks. To gather more information, see Ubuntu Help - Fstab. It's the ubuntu help, but the configuration is the same.
At last, mount the missing partition:
mount /dev/da4p1 /media/zakkwilde
If you prefere you can remount all partitions:
mount -a
The option -a remounts all the partitions present in the /etc/fstab file.
Well, we should be done! Let's just check if the file is rightly mounted:
df -h
If it's all right, the output should be similar to this:
Filesystem Size Used Avail Capacity Mounted on
/dev/da4p1 15G 8.0k 14G 0% /media/zakkwilde
Finished!
REFERENCES
- FreeBSD adding a new disk -.The main FreeBSD documentation, this section explains how to add a disk
- man newfs: freebsd manual of newfs
- man gpart: freebsd manual of gpart
- man camcontrol: freebsd manual of camcontrol
- Mounting partitions in FreeBSD - the main reference to the use of cat /proc/partitionsLabels: bash, linux