# Using a Solid State Drive with FreeBSD



## wblock@ (Jan 22, 2013)

Using a Solid State Drive with FreeBSD shows how to set up SSDs on FreeBSD.  This article is new and still being revised, but is now in a reasonable state to share with a larger group.  Feedback welcome.

PS: credit for the idea of using a swap file to take advantage of TRIM is due to forum member throAU.

PPS: A reference to most SSDs including information about controller and memory types and links to external reviews: http://www.johnnylucky.org/data-storage/ssd-database.html


----------



## Dies_Irae (May 14, 2013)

Thanks @wblock, I really appreciate your guides!

But there is something unclear to me in this passage:



> Following the root partition is a 2G partition for /var and the rest of the SSD for /usr. Actually, a 1G /var is often large enough. These are aligned to 1M increments, again an even multiple of the 4K block size. Salt to taste.
> 
> # gpart add -t freebsd-ufs -l ssdvarfs -a 1m -s 2g ada0
> # gpart add -t freebsd-ufs -l ssdusrfs -a 1m ada0
> # gpart add -t freebsd-ufs -l ssdrootfs -b 1m -s 2g ada0



First, you add 2 partitions aligned (-a) to 1 M, then you add the root partition starting (-b) at the 1 M boundary.
I think I misunderstood the meanings of the -a and -b flags.


----------



## vermaden (May 14, 2013)

I use SSD with FreeBSD just as any other regular drive, no special steps taken, as I have 8 GB RAM I did not even bother to enable swap.


----------



## kpa (May 14, 2013)

Dies_Irae said:
			
		

> Thanks @wblock, I really appreciate your guides!
> 
> But there is something unclear to me in this passage:
> 
> ...



The example is definitely wrong because the last command would try to create partition over an existing partition, the -b flag means an absolute sector number for the starting sector.


----------



## SirDice (May 14, 2013)

The order seems to be off, it probably should be something like this:

```
# 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
```

That would make the first the root file system, the second var and the rest for usr.


----------



## drhowarddrfine (May 14, 2013)

How can I check to see if I formatted my SSD with TRIM? I remember reading Warren's article but don't recall what I did. Is there any idea how much wear leveling helps increase longevity (I presume)? Is it worth reformatting my drive to do this?


----------



## kpa (May 14, 2013)

The utility to use to check for TRIM is tunefs(8), for example:


```
firewall ~ # tunefs -p /dev/ada0p2
tunefs: POSIX.1e ACLs: (-a)                                disabled
tunefs: NFSv4 ACLs: (-N)                                   disabled
tunefs: MAC multilabel: (-l)                               disabled
tunefs: soft updates: (-n)                                 enabled
tunefs: soft update journaling: (-j)                       disabled
tunefs: gjournal: (-J)                                     disabled
tunefs: trim: (-t)                                         enabled
tunefs: maximum blocks per file in a cylinder group: (-e)  4096
tunefs: average file size: (-f)                            16384
tunefs: average number of files in a directory: (-s)       64
tunefs: minimum percentage of free space: (-m)             8%
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)                                 
firewall ~ #
```

As you can see TRIM is a filesystem level feature, not for the full disk.


----------



## wblock@ (May 15, 2013)

Dies_Irae said:
			
		

> Thanks @wblock, I really appreciate your guides!



Thanks!



> First, you add 2 partitions aligned (-a) to 1 M, then you add the root partition starting (-b) at the 1 M boundary.
> I think I misunderstood the meanings of the -a and -b flags.



The example got moved around, probably an editing error on my part.  I'll fix it.  @SirDice has the right order.

-a is for Align, and -b is for Begin.


----------



## topcat (Oct 26, 2016)

I'm using this now to install 11.0 on an SSD. Thanks!!!


----------



## Birdy (Aug 22, 2021)

Is this 2016 document still up to date?


----------



## vermaden (Aug 22, 2021)

Birdy said:


> Is this 2016 document still up to date?


Yes.

But I would use ZFS and if that is a laptop then ZFS with GELI encryption.


----------



## mark_j (Aug 23, 2021)

I can't categorically say it's 100% up-to-date, but the information in it is still relevant, especially and ABSOLUTELY, the part about using dd on SSDs.
A quick perusal makes me think there's nothing written then that doesn't apply now.

I am not sure there's any SSDs on the market now that don't support trim. If there are, as the author states, stay away from them.
It's also worth noting nowadays that consensus is to only partition 80% of the capacity, leaving around 20% free and never used.


----------

