# SSD Trim - fstab ext4 swap partitions

## gentian

Hi all,

So I just need to enable Trim. Do I just have to add the discard option next to ext4 and swap partitions in the fstab?

----------

## asturm

man mkfs.ext4:

```
       -E extended-options

                   discard

                          Attempt to discard blocks at mkfs time (discarding blocks initially is  useful  on  solid

                          state  devices  and  sparse  / thin-provisioned storage). When the device advertises that

                          discard also zeroes data (any subsequent read after the discard and before write  returns

                          zero),  then mark all not-yet-zeroed inode tables as zeroed. This significantly speeds up

                          filesystem initialization. This is set as default.
```

You actually don't have to do anything  :Wink: 

----------

## gentian

 *genstorm wrote:*   

> man mkfs.ext4:
> 
> ```
>        -E extended-options
> 
> ...

 

gentoo ftw!

----------

## EatMeerkats

```
Attempt to discard blocks at mkfs time
```

Actually, that's only at filesystem creation time… you do still have to include the "discard" option in fstab in order for TRIM to be run on newly deleted data.

----------

## gentian

 *EatMeerkats wrote:*   

> 
> 
> ```
> Attempt to discard blocks at mkfs time
> ```
> ...

 

So all I need to do is add the discard option next to swap and ext4 partitions in fstab right?

```
/dev/sda4      /      ext4      noatime,discard      0 1

/dev/sda3      none      swap      sw,discard      0 0
```

----------

## mbar

I'm almost sure swap subsystem uses SSD autodetection.

----------

## xtx

 *gentian wrote:*   

>  *EatMeerkats wrote:*   
> 
> ```
> Attempt to discard blocks at mkfs time
> ```
> ...

 

on a side note, why are you using swap with your ssd? i have recently purchased a laptop with a ssd and have disabled swap to preserve the life of the drive.

----------

## gentian

 *xtx wrote:*   

>  *gentian wrote:*    *EatMeerkats wrote:*   
> 
> ```
> Attempt to discard blocks at mkfs time
> ```
> ...

 

Sleep/Suspend to Ram?

----------

## EatMeerkats

You only need it for hibernation… sleep/suspend to ram does exactly that: suspends to RAM.

----------

## gentian

 *EatMeerkats wrote:*   

> You only need it for hibernation… sleep/suspend to ram does exactly that: suspends to RAM.

 

I'm on 3GB. I need paging.

----------

