Auto-mount drives at boot

Just want to ask how I can have two data partitions auto-mount at boot?

Include them in /etc/fstab.

See fstab - ArchWiki for correct syntax.

thanks.

EDIT: I might just put up with it I think - there is WAY too much in all of that for me to muck up and break. Thanks again though!

If you use KDE there is a built-in auto mount tool in the settings

4 Likes

That looks useful - I’m on xfce though :frowning:


In the worst case, you badly defined to automatic mount in fstab and your system refuses to start. Just keep a LiveUSB ready in that case, so you can boot from it and revert/comment your modifications, and you’ll be fine.
Alternatively, try the systemd mount as detailed above, as that will simply ignore mount failure rather than block on it.

While not exactly the same - you get an idea of how simple it is using systemd

In your case (you won’t need the automount) create two files - one for each partition

So proceed to create a file data-part1.mount

/etc/systemd/system/data-part1.mount

with content (use lsblk -o PATH,UUID to get UUID) and replace $UUID with the actual UUID

[Unit]
Description=Data partition 1

[Mount]
What=/dev/disk/by-uuid/$UUID
Where=/data/part1
Type=auto
Options=rw,noatime

[Install]
WantedBy=multi-user.target

Create one more and name it data-part2.mount

/etc/systemd/system/data-part2.mount

with content (use lsblk -o PATH,UUID to get UUID) and replace $UUID with the actual UUID

[Unit]
Description=Data partition 2

[Mount]
What=/dev/disk/by-uuid/$UUID
Where=/data/part2
Type=auto
Options=rw,noatime

[Install]
WantedBy=multi-user.target

Then start and enable to units

sudo systemctl enable --now data-part1.mount data-part2.mount

Set permissions on the mount points as needed

sudo chmod ugo+rw /data/part1 /data/part2
4 Likes

Thanks linux-aarhus, I will try that and let you know how I go. If I do it correctly I imagine it will work so once I get to that stage I’ll post it as the solution :slight_smile:

Sorry, got stuck at the very first line /etc/systemd/system/data-part1.mount - it gave the response: “No such file or directory”

I have used this for years - it works - so I reckon you have made a spelling error or a wrong uuid.

did you put the correct uuid in the respective files?

How did you try to create this file exactly?
Through terminal or your file manager?

I cannot create it in ETC (it is a system file) and not sure how to create it in terminal…do I use the nano editor perhaps?

I don’t really know Thunar as I never really played with XFCE. Dolphin in KDE, you cannot indeed perform actions in root folders.
In Cinnamon or in Gnome, you can with Nemo and Nautilus.

In terminal, you can create a file with sudo touch /etc/systemd/system/data-part1.mount then sudo nano to edit the file.
Or directly sudo nano etc/systemd/system/data-part1.mount to create and edit directly the file.

edit : obvisously as you create/edit a file in /etc, you have to use sudo

1 Like

thanks, I’ll try that now…

EDIT: Ok now we’re cooking that worked - sorry I cannot post it as the solution I think the post from linux-aarhus will be that, but thanks so much for the assist. I’ll go back to his (her?) instructions now and try again!

1 Like

ok, I think I got the first one correct, but the second one (even though I did it exactly the same) didn’t.

Second one is an NTFS drive, does that make a difference?

here is the terminal message:
Created symlink /etc/systemd/system/multi-user.target.wants/data-part1.mount → /etc/systemd/system/data-part1.mount.
Created symlink /etc/systemd/system/multi-user.target.wants/data-part2.mount → /etc/systemd/system/data-part2.mount.
Failed to start data-part2.mount: Unit data-part2.mount has a bad unit file setting.
See system logs and ‘systemctl status data-part2.mount’ for details. that then shows:
○ data-part2.mount - Data partition 1
Loaded: bad-setting (Reason: Unit data-part2.mount has a bad unit file setting.)
Active: inactive (dead)
Where: /data/part1
What: /dev/disk/by-uuid/$809A1AD69A1AC894

Oct 09 08:48:39 NUC-1 systemd[1]: data-part2.mount: Where= setting doesn’t match unit name.>

Could you paste here the content you placed in your second mount file?

I’d rather put Type=ntfs instead of auto

However, NTFS being a Windows extension, maybe that’d explain why…

1 Like

[Unit]
Description=Data partition 1

[Mount]
What=/dev/disk/by-uuid/$809A1AD69A1AC894
Where=/data/part1
Type=auto
Options=rw,noatime

[Install]
WantedBy=multi-user.target

But I noticed in the first one, the Description is part 4 but in the Where it still has part 1 - is that the mismatch perhaps?

Try with replacing auto and launch the commands again.

Don’t forget to reload the system daemon.

1 Like

ok - it takes me a while as this is still pretty new :slight_smile: so sorry for the delay…

Ok so it was a mismatch between the where which was still set to part1 - fixed that and re-ran the ```
sudo systemctl enable --now data-part1.mount data-part2.mount

Then the terminal hung for ages then came up with this:

Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░ 
░░ A start job for unit dev-disk-by\x2duuid-\x24ac007462\x2d356e\x2d4d54\x2d9bed\x2dc2f10defcd81.device has finished with a failur>
░░ 
░░ The job identifier is 1851 and the job result is timeout.
Oct 09 09:17:04 NUC-1 systemd[1]: Dependency failed for Data partition 4.
░░ Subject: A start job for unit data-part1.mount has failed
░░ Defined-By: systemd
░░ Support: https://forum.manjaro.org/c/support
░░ 
░░ A start job for unit data-part1.mount has finished with a failure.
░░ 
░░ The job identifier is 1847 and the job result is dependency.
Oct 09 09:17:04 NUC-1 systemd[1]: data-part1.mount: Job data-part1.mount/start failed with result 'dependency'.
Oct 09 09:17:04 NUC-1 systemd[1]: dev-disk-by\x2duuid-\x24ac007462\x2d356e\x2d4d54\x2d9bed\x2dc2f10defcd81.device: Job dev-disk-by>
Oct 09 09:17:04 NUC-1 sudo[8012]: pam_unix(sudo:session): session closed for user root
Oct 09 09:17:04 NUC-1 audit[8012]: USER_END pid=8012 uid=1000 auid=1000 ses=1 subj==unconfined msg='op=PAM:session_close grantors=>
Oct 09 09:17:04 NUC-1 audit[8012]: CRED_DISP pid=8012 uid=1000 auid=1000 ses=1 subj==unconfined msg='op=PAM:setcred grantors=pam_f>
Oct 09 09:17:04 NUC-1 kernel: kauditd_printk_skb: 18 callbacks suppressed
Oct 09 09:17:04 NUC-1 kernel: audit: type=1106 audit(1633731424.736:293): pid=8012 uid=1000 auid=1000 ses=1 subj==unconfined msg='>
Oct 09 09:17:04 NUC-1 kernel: audit: type=1104 audit(1633731424.736:294): pid=8012 uid=1000 auid=1000 ses=1 subj==unconfined msg='>
Oct 09 09:17:25 NUC-1 kernel: [UFW BLOCK] IN=eno1 OUT= MAC=01:00:5e:00:00:01:bc:30:d9:f9:72:12:08:00 SRC=192.168.0.1 DST=224.0.0.1>
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
lines 1133-1155/1155 (END)