Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Recommended mount options for SSD
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Sun Jun 13, 2021 10:41 pm    Post subject: [SOLVED] Recommended mount options for SSD Reply with quote

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:

Code:

/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:
Code:

/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:
Code:

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
Back to top
View user's profile Send private message
salahx
Guru
Guru


Joined: 12 Mar 2005
Posts: 530

PostPosted: Mon Jun 14, 2021 12:55 am    Post subject: Reply with quote

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)
Back to top
View user's profile Send private message
Banana
Veteran
Veteran


Joined: 21 May 2004
Posts: 1392
Location: Germany

PostPosted: Mon Jun 14, 2021 7:03 am    Post subject: Reply with quote

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
_________________
My personal space
My delta-labs.org snippets do expire

PFL - Portage file list - find which package a file or command belongs to.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Mon Jun 14, 2021 8:55 am    Post subject: Reply with quote

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.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Mon Jun 14, 2021 10:02 pm    Post subject: Reply with quote

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.
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.


Wow, thanks for all the info it was very insightful :)
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?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Mon Jun 14, 2021 10:14 pm    Post subject: Reply with quote

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.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Wed Jun 16, 2021 5:05 pm    Post subject: Reply with quote

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.
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.


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?
Back to top
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Wed Jun 16, 2021 5:15 pm    Post subject: Reply with quote

BTW if i don't specify "defaults" what is the default used?
Back to top
View user's profile Send private message
sdauth
Guru
Guru


Joined: 19 Sep 2018
Posts: 569
Location: Ásgarðr

PostPosted: Wed Jun 16, 2021 5:41 pm    Post subject: Reply with quote

Code:
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
Back to top
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Wed Jun 16, 2021 7:05 pm    Post subject: Reply with quote

sdauth wrote:
Code:
man mount


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


Thanks but that's not what i asked, i asked if i don't specify the defaults option what would be the default.
Back to top
View user's profile Send private message
freke
l33t
l33t


Joined: 23 Jan 2003
Posts: 977
Location: Somewhere in Denmark

PostPosted: Wed Jun 16, 2021 8:18 pm    Post subject: Reply with quote

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
Code:
mount


ie. for me on / I get
Code:
/dev/sda1 on / type ext4 (rw,noatime)
with a
Code:
/dev/sda1               /                       ext4    noatime                                                 0 1
mountpoint.
Back to top
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Wed Jun 16, 2021 8:58 pm    Post subject: Reply with quote

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.

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


ie. for me on / I get
Code:
/dev/sda1 on / type ext4 (rw,noatime)
with a
Code:
/dev/sda1               /                       ext4    noatime                                                 0 1
mountpoint.


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.
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2007

PostPosted: Thu Jun 17, 2021 8:21 am    Post subject: Reply with quote

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.
_________________
Greybeard
Back to top
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Thu Jun 17, 2021 8:48 am    Post subject: Reply with quote

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:
Code:

/dev/sdb2               /               ext4            defaults,noatime        0 1


Mounts root as:
Code:

/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
Back to top
View user's profile Send private message
sdauth
Guru
Guru


Joined: 19 Sep 2018
Posts: 569
Location: Ásgarðr

PostPosted: Thu Jun 17, 2021 5:19 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Thu Jun 17, 2021 10:54 pm    Post subject: Reply with quote

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

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.


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?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21633

PostPosted: Fri Jun 18, 2021 1:22 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Sat Jun 19, 2021 10:07 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum