BSD FileSystem

From wikinotes


For the most part BSD uses the same system locations as linux. There are some differences though. Here is a list of notable locations in the FreeBSD filesystem.

/etc Generic system-specific configuration information.
/etc/defaults Default versions of system configuration files.
/etc/mail Extra sendmail(8) configuration and other MTA configuration files.
/etc/ppp Configuration for both user- and kernel-ppp programs.
/etc/namedb Default location for named(8) data. Normally named.conf and zone files are stored here.
/usr/local/etc Configuration files for installed applications. May contain per-application subdirectories.
/usr/local/etc/rc.d rc(8) scripts for installed applications.
/var/db Automatically generated system-specific database files, such as the package database and the locate(1) database.

FileSystem Types

FreeBSD primarily uses the UFS filesystem, but other filesystems are also available (ex: ext2, zfs). FreeBSD uses a very different partition table from linux, having a disk work on both can be tricky.

UFS can be mounted readonly on linux, exfat works everywhere but needs drivers.

This is just a list of common filesystem types. See Programs: filesystems for many more filesystems.



procfs (native)

FreeBSD doesn't mount procfs by default.
If you'd like to use it, you can mount it yourself.

mount -t procfs proc /proc

or dump it in your fstab

# /etc/fstab

proc /proc procfs rw 0 0

linprocfs (Linux Emulation)

FreeBSD also ships with linprocfs, which emulates a subset of linux procfs.

mount -t linprocfs linproc /compat/linux/proc
# /etc/fstab

linproc /compat/linux/proc linprocfs rw 0 0

File Permissions

See unix filesystem permissions.

Partition Management

BSD's partition management is a little different from linux, and it's setup varies depending on if you're using a GUID partition table or a MBR partition table.

If you're using MBR, you first set up a partition, and then slices of that partition for BSD to occupy. This is a means of sidestepping the MBR limit of 4 logical partitions before dividing it into extended partitions. I'm not entirely sure why this is necessary, but GUID is a cleaner, and superior solution and worth moving towards.

If you're using GPT, you don't need to worry about partitions at all. You simple create slices in your GUID partition table.

A typical freeBSD install has at least 3 partitions with the three following types:

  • freebsd-boot
  • freebsd-ufs
  • freebsd-swap



Create GUID table

## list all disks
sudo gpart list
sudo camcontrol devlist (to see windows labels)

## wipe disk mbr, and set up mbr:
sudo gpart destroy -F da1            ## destroy mbr
gpart create -s gpt da1              ## alternatively you could use mbr

Dividing Disk into Slices

You will need to create slices(partitions) in multiples of your sector size You may only use freebsd-boot and freebsd-ufs with newer boot schemes like gpt (vs mbr) for mbr your boot type should be freebsd

  • There are 1048576 kilobytes in 1 gb
  • List sector size with 'gpart list'
gpart add -t freebsd-boot -l gpboot -b 40 -s 512K da1
gpart add -s 160G -t freebsd-ufs da1

gpart show da1

If you need anything fancier:

  • -b = starting block (not byte on filesystem)
  • -s = size of partition in half kilobytes
  • -t = partition type

Create FileSystem

Gpart creates partitions, and newfs will automatically update your disklabel. no need for the disklabel command. You are now ready to create a filesystem.

sudo newfs -U /dev/gpt/gprootfs da1p1
sudo newfs -U da1p2