View previous topic :: View next topic |
Author |
Message |
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Sun Jun 13, 2021 10:41 pm Post subject: [SOLVED] Recommended mount options for SSD |
|
|
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 |
|
|
salahx Guru
Joined: 12 Mar 2005 Posts: 530
|
Posted: Mon Jun 14, 2021 12:55 am Post subject: |
|
|
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 |
|
|
Banana Veteran
Joined: 21 May 2004 Posts: 1392 Location: Germany
|
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Mon Jun 14, 2021 8:55 am Post subject: |
|
|
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 |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Mon Jun 14, 2021 10:02 pm Post subject: |
|
|
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 |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Mon Jun 14, 2021 10:14 pm Post subject: |
|
|
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 |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Wed Jun 16, 2021 5:05 pm Post subject: |
|
|
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 |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Wed Jun 16, 2021 5:15 pm Post subject: |
|
|
BTW if i don't specify "defaults" what is the default used? |
|
Back to top |
|
|
sdauth Guru
Joined: 19 Sep 2018 Posts: 569 Location: Ásgarðr
|
Posted: Wed Jun 16, 2021 5:41 pm Post subject: |
|
|
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 |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Wed Jun 16, 2021 7:05 pm Post subject: |
|
|
sdauth wrote: |
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 |
|
|
freke l33t
Joined: 23 Jan 2003 Posts: 977 Location: Somewhere in Denmark
|
Posted: Wed Jun 16, 2021 8:18 pm Post subject: |
|
|
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
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 |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Wed Jun 16, 2021 8:58 pm Post subject: |
|
|
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
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 |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2007
|
Posted: Thu Jun 17, 2021 8:21 am Post subject: |
|
|
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 |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Thu Jun 17, 2021 8:48 am Post subject: |
|
|
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 |
|
|
sdauth Guru
Joined: 19 Sep 2018 Posts: 569 Location: Ásgarðr
|
Posted: Thu Jun 17, 2021 5:19 pm Post subject: |
|
|
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 |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Thu Jun 17, 2021 10:54 pm Post subject: |
|
|
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 |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Fri Jun 18, 2021 1:22 am Post subject: |
|
|
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 |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Sat Jun 19, 2021 10:07 am Post subject: |
|
|
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 |
|
|
|
|
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
|
|