Difference between revisions of "FreeBSD Format and Partition"

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search
m (Partition a SSD for FreeBSD)
m (Partition a SSD for FreeBSD)
Line 57: Line 57:
 
  tunefs -t enable /dev/gpt/ssdusrfs
 
  tunefs -t enable /dev/gpt/ssdusrfs
  
Now to deal with SSD specific things.  /etc/fstab must be changed to refer to the SSD. At the same time, the missing /tmp will be added.
+
Now to deal with SSD specific things.  /etc/fstab must be changed to refer to the SSD. At the same time, the missing /tmp will be added. Edit the /etc/fstab file.
 +
vi /etc/fstab
 +
Modify
 +
# Device                Mountpoint      FStype  Options        Dump    Pass#
 +
/dev/gpt/ssdrootfs      /              ufs    rw              1      1
 +
/dev/gpt/ssdvarfs      /var            ufs    rw              2      2
 +
tmpfs                  /tmp            tmpfs  rw,mode=01777  0      0
 +
/dev/gpt/ssdusrfs      /usr            ufs    rw              2      2
  
 +
Swap
 +
mkdir /usr/swap
 +
dd if=/dev/zero of=/usr/swap/swap bs=128k count=32768
 +
Edit /etc/fstab to use the swap file.
 +
vi /etc/fstab
 +
Modify
 +
# Device        Mountpoint      FStype  Options                        Dump    Pass#
 +
md99            none            swap    sw,file=/usr/swap/swap,late    0      0
 +
 +
Make sure the SSD is set as the first boot drive.
  
  

Revision as of 18:22, 5 December 2020

All FreeBSD 9.0 and later installations come with GPT. You can use gpart(8) instead of the classic fdisk(8) and disklabel(8).

AHCI - Advanced Host Controller Interface is a standard for disk drives and controllers. Enabling AHCI in the BIOS can give a 5-15% performance increase. Not all controllers offer AHCI.

For Solid State Computer Systems most SSD models support a feature called TRIM. TRIM is just a status update that triggers when the filesystem deletes a block, it also notifies the device that the block is no longer in use. The SSD firmware can then do some wear leveling functions. Without TRIM, it would not be able to tell whether that block was still in use. TRIM does not require AHCI.

Some Commands

To remove existing partitions from a drive

gpart delete


gpart show

gpart recover vtbd0

gpart add -t freebsd-ufs -b BEGIN -s SIZE GEOM

gpart add -t freebsd-ufs -b 20971682 -s 18874240 vtbd0

newfs -U /dev/vtbd0p4

mkdir /transip

mount /dev/vtbd0p4 /transip

mount /dev/vtbd0p4 /transip

Partition a SSD for FreeBSD

Applies to Solid State Computer Systems with FreeBSD 10.X and newer.

Do not enable TRIM unless the SSD supports it. Better yet, avoid SSDs that do not support TRIM.

Create the partition scheme. In the GPT partition scheme make a boot partition of the size 512K. Here we will use the new 4K-alignment which is what is advised for SSD drives. More information is on Hard Drive Logical Block Format Migration to 4K- Alignment.

gpart create -s gpt ada0
gpart add -t freebsd-boot -s 512k -a4k -l ssdboot ada0
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i1 ada0

Now create a root partition. 2GiG is recommended. Unique naming is recommended. The 1M location is 4K aligned and 1M aligned.

gpart add -t freebsd-ufs -l ssdrootfs -b 1m -s 2g ada0

2G partition for /var and the rest of the SSD for /usr.

gpart add -t freebsd-ufs -l ssdrootfs -b 1m -s 2g ada0
gpart add -t freebsd-ufs -l ssdvarfs -a 1m -s 2g ada0
gpart add -t freebsd-ufs -l ssdusrfs -a 1m ada0

Fresh installation of FreeBSD on a SSD may use the newfs(8) the filesystems without TRIM. Boot into single user mode and use tunefs(8) -t enable to re-enable it on each filesystem. FreeBSD’s UFS filesystem supports TRIM. That will be enabled with -t while formatting the filesystems.

Format these file systems with TRIM enabled

newfs -U -t /dev/gpt/ssdrootfs
newfs -U -t /dev/gpt/ssdvarfs
newfs -U -t /dev/gpt/ssdusrfs

The FreeBSD installer might format the file system without enabling TRIM. You can go in after the fact and enable TRIM by doing the following when booted into single user mode:

tunefs -t enable /dev/gpt/ssdrootfs
tunefs -t enable /dev/gpt/ssdvarfs
tunefs -t enable /dev/gpt/ssdusrfs

Now to deal with SSD specific things. /etc/fstab must be changed to refer to the SSD. At the same time, the missing /tmp will be added. Edit the /etc/fstab file.

vi /etc/fstab

Modify

# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/gpt/ssdrootfs      /               ufs     rw              1       1
/dev/gpt/ssdvarfs       /var            ufs     rw              2       2
tmpfs                   /tmp            tmpfs   rw,mode=01777   0       0
/dev/gpt/ssdusrfs       /usr            ufs     rw              2       2

Swap

mkdir /usr/swap
dd if=/dev/zero of=/usr/swap/swap bs=128k count=32768

Edit /etc/fstab to use the swap file.

vi /etc/fstab

Modify

# Device        Mountpoint      FStype  Options                         Dump    Pass#
md99            none            swap    sw,file=/usr/swap/swap,late     0       0

Make sure the SSD is set as the first boot drive.