Best way to automount ext4 SSD

I just added a new SSD to my system (for games) and created a ext4 Filesystem on it. I now wonder what is the best way to automount the drive. Should i use discard? On the Arch-Wiki i read it could cause Issues? Any recommendation?

Highly recommended read ā€“

1 Like
sudo blkid

Then use the UUID to add to your /etc/fstab file at your desired mount point, like so:

UUID=d2f4d267-7412-4279-868d-f00742e1ff25      /data      ext4      defaults      0 2
1 Like

Oh PLEASE stop with the advise with fstabā€¦
:point_down:

If you read carefully, I canā€™t quote cause its been a while since i read that page, it should tell you what file systems can cause problems with discardā€¦


Example: for the OP how easy it is:

$ sc-cat mnt-LutrisGames.{,auto}mount | xc

# /etc/systemd/system/mnt-LutrisGames.mount
[Unit]
Description=Lutris-Gamelib
Documentation=man:systemd.mount(5)
Documentation=man:systemd.automount(5)
After=dev-disk-by\x2dlabel-Backups.device
BindsTo=dev-disk-by\x2dlabel-Backups.device
RefuseManualStart=yes
RefuseManualStop=yes

[Mount]
What=/dev/disk/by-label/Backups
Type=btrfs
Options=noatime,subvol=/@LutrisGames

# /etc/systemd/system/mnt-LutrisGames.automount
[Unit]
Description=Lutris-Gamelib
Documentation=man:systemd.mount(5)
Documentation=man:systemd.automount(5)
PartOf=Gameing-Mounts.service

[Automount]
TimeoutIdleSec=5min

# Autostarted by Gameing-Mounts.service
# [Install]
# WantedBy=graphical.target

The above uses Filesystem LABEL but you can use UUIDā€™s also ofcourse.
Plus the above is started using a service that pulls in other automount units also, just to make it easy to start/stop related mounts for gaming in my exampleā€¦

As for the options (regardless of if you choose fstab or systemd to mount), from all have read,

discard

makes not much difference most of the time, makes things slower in some cases, and even breaks things in some very rare cases.
So for me it is a clear decision against it.
Which is the default. Also, by default, trimming is done once a week. You can change the timer, or run

sudo fstrim -v /dev/nvme0

Manually after deletion of many gigabytes at once.

Iā€™ll use the topic to ask something myself: at the beginning of the ssd times, i thought

Noatime

Is a must. But i do not see it in the defaults in the manjaro fstab? Should i add it to reduce writes or nowadays it is somewhere else.

I use noatime as option in my systemd.mount units for SSD, yes.
It reduces writes due to reads and thus makes the live span longerā€¦

Why?

Convention and systemd docs, etc, still consider fstab the ā€˜properā€™ way.

configuring mount points through /etc/fstab is the preferred approach

I know that post calls the statement ā€˜contradictoryā€™ ā€¦ but Iā€™m not entirely sure I agree.

3 Likes

Whatā€¦? Thatā€™s what I do. Well, except I use GNOME Disks to make the fiddly stuff easier. :grin:

Indeed.

Please donā€™t assume everyone uses BTRFS. They donā€™t.

2 Likes

Examples are examples for a reasonā€¦

The should burn that line, and im sure they will in due timeā€¦

Noatime Is a must. But i do not see it in the defaults in the manjaro fstab?

Sorry, it is actually the default. I just checked my fstab

UUID=....................  /              ext4    defaults,noatime 0 1

That is done automatically by manjaro Calamares installer, i did not touch anything. Calamares detected it was a nvme drive.

Sure, examples are just that.

Donā€™t get me wrong, both the tutorial linked twice above and your advice are helpful.

1 Like

OK ā€¦ but still ā€¦ whats your reasoning?

Personally I find adding a single intelligible line to a single file a whole lot easier than fiddling with multiple systemd units (especially for an internal drive that isnt going anywhere).

3 Likes

Getting rid of advise using fstab is like getting rid of advise using cronā€¦
Sure they both work, but you know what the future is and whats better by now donā€™t you?
Reason why systemd ā€œstillā€ supports fstab, which is actually translated by it self into units, is because of prehistoric ppl still hanging to old stuff :stuck_out_tongue:

Where is the future where fstab disappears?
Is it some time in 2030 and you have seen it in your crystal ball?
I havent heard one iota about such a thing.
Maybe I missed it. But still ā€¦ wheres such an adamant position coming from?

It is not fair to compare to cron ā€¦
cron is legacy software one must install and attempt to use instead of systemd units.
This is the opposite.
/etc/fstab exists in the filesystem, is expected, and used, by default. You must go out of your way to use systemd units to mount otherwise.

2 Likes

Uhmmm sorry, yes it is actually super secret and top secret info to tell you, which means i have to kill you 30s after you reading this:
ā€œI am from the future yesā€
:woman_facepalming: :rofl:

One of my ancestors was named ā€œChatGPTā€ :stuck_out_tongue_winking_eye:

Ok ā€¦ so no evidence or support ā€¦ just something you started saying for some reason. Got it.

EDIT: you can facepalm/emoji me ā€¦ but its a pretty simple proposition.
You make a claim ā€¦ I ask for evidence ā€¦ you do not produce it ā€¦ I discount claim.

1 Like

ā€¦it will self-destructā€¦

Self-destruction sequence pausedā€¦

Hey, weā€™re here to help out a user who asked a question, remember?

No fighting, no biting.

1 Like

Sorry youā€™re absolutely right, please just delete all thos off-topic replies :wink:

Itā€™s a little late for that.

Unless you want me to delete everything after @cscsā€™s first reply here? I donā€™t think that would be fair, because then it would bulldozer @Teoā€™s reply as well.

Answering the question

fstab example

UUID=some-long-uuid    /ext4    /data/games    defaults,rw,noatime    0 0
mkdir -p /data/games
sudo mount -a

unit example
naming convention: data-games.mount (mountpoint-path converted to filename)
file location: /etc/systemd/system

[Unit]
Description=Games partition

[Mount]
What=/dev/disk/by-uuid/some-long-uuid
Where=/data/games
Type=ext4
Options=defaults,rw,noatime

[Install]
WantedBy=multi-user.target
sudo systemctl enable --now data-games.mount

In both cases you need to set permissions and/or ownership to be able to actually use it.

sudo chown $USER:$USER /data/games -R

That is just my logic that doesnā€™t compute fstab is preferred and converting to units into a logical meaning.

I completely agree that for internal devices - always on - fstab is the best documented method - no doubt about that - but making a system mount unit for it is just as simple.

Many systemd unit flags for network and automount can be added to fstab - making it extremely confusing for those new to Linux and then it gets error prone.

When you need network mounts and removable device mount - the extra work put into the mount units is well paid off.

2 Likes