# [SOLVED] Recommended mount options for SSD

## Troopo

Hi,

I got lost trying to create an updated fstab file, could use some help.

SDB - SSD

SDC - HDD

16GB RAM

Here is what i've got:

```

/dev/sdb1               /boot           vfat            defaults,noatime,discard        1 2     

/dev/sdb2               /               ext4            defaults,noatime,discard        0 1

```

Boot is vfat as per the handbook and root is ext4 since it's stable and i need brtfs.

Do i need the boot partition mounted?

I kinda got lost in realtime vs noatime, probably noatime is better since i'm not aware of anything needing that info.

Then moved on to TRIM, so discard makes it do trim automatically but for every delete so it's less recommended per my understanding.

What's better running cron (assuming the machine is up at that time) or having a daemon do it manually every few hours?

The info i found said once a week is the recommended runtime

Do i need to specify defaults or is default?

I also have tmpfs and a few hdd's, this is the setup for them at the moment:

```

/dev/sdc1              /mnt/windows     ntfs-3g         defaults,uid=1000,gid=100       0 0

tmpfs                   /tmp            tmpfs           rw,nosuid,noatime,nodev,size=8G,mode=1777 0 0

```

Searching around got me to tmpfs size is half the physical size which for me is 16GB so i made it 8, i put noatime on everything but the rest i got from the internet so i'm not sure it's needed and how does it help if at all.

Also as you can see tmpfs is just for /tmp while i did find some suggestions to add /var/tmp as well.

As for the windows HDD, that's what i got after searching for NTFS mount options i think.

Yes i know i'm missing swap and i'm adding it to the new installation as:

```

none swap defaults 0 0

```

Anyway my question is what is recommended\missing or what do you use out there for this.Last edited by Troopo on Sat Jun 19, 2021 10:08 am; edited 1 time in total

----------

## salahx

Don't use the "discard" option on a SATA SSD. TRIM is an unqueued command, and can slow things down, especially if you start deleting losts of small files. Use a cronjob or systemd timer to "bulk trim" weekly (util-linux provides a systemd timer unit automatically, You just need to enable it)

----------

## Banana

is the TRIM really needed anymore?

I thought it is implemented in the drives and the OS already so a manual trim is not needed anymore

----------

## NeddySeagoon

Troopo,

Beware the discard option.

discard is supposed to tell the SSD to make a note of freed blocks so it can erase them whenever it wants. It is not supposed to be a command to do the erase now.

Some badly designed SSD firmware treats it as a command. That leads to a lot oy wire amplification, which is bad for drive life.

fstrim in a cron job or every update will be more than enough unless your SSD is almost full.

Some background ...

SSDs have a 4k read and write block size but the erase block size is bigger. The drive can read/write 4k blocks but to erase a single 4k free block, it has to move all the used 4k blocks out of the erase block its about to erase.

This moving of data is called write amplification.

The idea is to erase free space in time before you want to reuse it but not as soon as it's free.

How often you need to run fstrim depends on how fast you use the free space on the drive.

That's the whole drive, not any partition. Your drive will do wear levelling, so even things you never free will be moved around.

It also has spare blocks to cover for failed blocks. They are included in the wear levelling too.

The concept of a partition being a contiguous sequence of physical blocks does not exist for SSDs.

The drive remaps erase blocks as part of every day use. Much like a normal hard drive remaps failed blocks. 

You can't tell if you drive does discard properly or not but its safe to not use it.

----------

## Troopo

 *salahx wrote:*   

> Don't use the "discard" option on a SATA SSD. TRIM is an unqueued command, and can slow things down, especially if you start deleting losts of small files. Use a cronjob or systemd timer to "bulk trim" weekly (util-linux provides a systemd timer unit automatically, You just need to enable it)

 

Thanks, so once a week is fine or should it be based on my actual usage?

 *Banana wrote:*   

> is the TRIM really needed anymore?
> 
> I thought it is implemented in the drives and the OS already so a manual trim is not needed anymore

 

It's still give the drive more accuracy i think

 *NeddySeagoon wrote:*   

> Troopo,
> 
> Beware the discard option.
> 
> discard is supposed to tell the SSD to make a note of freed blocks so it can erase them whenever it wants. It is not supposed to be a command to do the erase now.
> ...

 

Wow, thanks for all the info it was very insightful  :Smile: 

I was already under the impression discard was bad just didn't know exactly why will go with the cron job, weekly isn't too excessive is it?

Also everyone, anything to say regarding my mount options apart from discard?

----------

## NeddySeagoon

Troopo,

I have a liberal helping of nosuid,nodev,noexec too.

Don't just blindly add them, you can make your system unusable.

The idea is to make it hard for anyone to do anything useful if they do break in.

/tmp can have nosuid,nodev,noexec since nobody should be doing any of those things in /tmp

Your users may hate you if you mount /home noexec since they won't be able to run anything from their home dirs.

----------

## Troopo

 *NeddySeagoon wrote:*   

> Troopo,
> 
> I have a liberal helping of nosuid,nodev,noexec too.
> 
> Don't just blindly add them, you can make your system unusable.
> ...

 

Thanks!

However i should mention this is a home machine without any other users or public access so apart from the added security to indulge any paranoia i don't find any of those flags needed here.

As for /tmp i guess i could add it since it's the temp folder anyway but it doesn't feel needed you know?

----------

## Troopo

BTW if i don't specify "defaults" what is the default used?

----------

## sdauth

```
man mount
```

defaults : rw, suid, dev, exec, auto, nouser and async.

edit : oops, I misread, sorry.Last edited by sdauth on Thu Jun 17, 2021 12:20 am; edited 1 time in total

----------

## Troopo

 *sdauth wrote:*   

> 
> 
> ```
> man mount
> ```
> ...

 

Thanks but that's not what i asked, i asked if i don't specify the defaults option what would be the default.

----------

## freke

I believe you get the default wether or not you specify it?

Also orders of options matters; So when you use rw,nosuid,nodev,exec,users in your fstab, the last option, users, sets noexec,nosuid,nodev, thus disabling your exec (and also making your nosuid,nodev redundant).

The result, as expected, is rw,noexec,nosuid,nodev.

Also most non-no????? options are not listed when doing 

```
mount
```

ie. for me on / I get

```
/dev/sda1 on / type ext4 (rw,noatime)
```

with a

```
/dev/sda1               /                       ext4    noatime                                                 0 1
```

mountpoint.

----------

## Troopo

 *freke wrote:*   

> I believe you get the default wether or not you specify it?
> 
> Also orders of options matters; So when you use rw,nosuid,nodev,exec,users in your fstab, the last option, users, sets noexec,nosuid,nodev, thus disabling your exec (and also making your nosuid,nodev redundant).
> 
> The result, as expected, is rw,noexec,nosuid,nodev.
> ...

 

I feel the same way but I'm not sure about the default and i couldn't find an answer so i asked.

Also i'm aware of the ordering importance but thanks for bringing it up.

----------

## Goverp

 *Troopo wrote:*   

> ...
> 
> Thanks but that's not what i asked, i asked if i don't specify the defaults option what would be the default.

 

Why not do an experiment and find out?  For extra marks, share your results.

----------

## Troopo

 *Goverp wrote:*   

>  *Troopo wrote:*   ...
> 
> Thanks but that's not what i asked, i asked if i don't specify the defaults option what would be the default. 
> 
> Why not do an experiment and find out?  For extra marks, share your results.

 

For me, having defaults:

```

/dev/sdb2               /               ext4            defaults,noatime        0 1

```

Mounts root as:

```

/dev/sdb2 / ext4 rw,noatime 0 0

```

So i don't think it works since it's missing suid, dev, exec, auto, nouser

That makes the default just rw

----------

## sdauth

Indeed, this can be confusing but apparently this is normal although it is not explicitely said in man pages.

See :

https://unix.stackexchange.com/questions/525787/how-do-i-see-that-a-device-is-mounted-with-exec-option-using-either-mount-or

 *Quote:*   

> /proc/mounts and mount don’t show settings which are included in the default settings, so you can assume that an entry which doesn’t show the contrary is using the defaults (see the documentation there for defaults):
> 
>     rw, suid, dev, exec, auto, nouser, and async.
> 
> If /proc/mounts doesn’t list noexec, then the file system is mounted with the exec permission.

 

I use defaults for my storage mounts and it only shows rw as well.

----------

## Troopo

 *sdauth wrote:*   

> Indeed, this can be confusing but apparently this is normal although it is not explicitely said in man pages.
> 
> See :
> 
> https://unix.stackexchange.com/questions/525787/how-do-i-see-that-a-device-is-mounted-with-exec-option-using-either-mount-or
> ...

 

So back to the original question, if i see rw listed there after removing defaults is it safe to assume it's already using the default therefore i don't need to specify defaults?

If so then what's the point in using defaults in a modern kernel system?

----------

## Hu

Due to the format of the fstab file, you cannot have an empty options field, since it is defined as the fourth non-whitespace field.  Therefore, you must write something there.  If you have nothing specific to say about a mount, you can say defaults, which is a valid token, is not whitespace, and will get you reasonable defaults.  It may also be legal to write rw and omit the defaults, but some people might find defaults to be clearer.

----------

## Troopo

 *Hu wrote:*   

> Due to the format of the fstab file, you cannot have an empty options field, since it is defined as the fourth non-whitespace field.  Therefore, you must write something there.  If you have nothing specific to say about a mount, you can say defaults, which is a valid token, is not whitespace, and will get you reasonable defaults.  It may also be legal to write rw and omit the defaults, but some people might find defaults to be clearer.

 

Got it, thank you

----------

