Re: "auto mount"

Francis Montagnac via users <[email protected]>
Newsgroups gmane.linux.redhat.fedora.general
Message-ID <20260531075031.6973abaf@fmpc>
On Sat, 30 May 2026 11:26:26 -0400 None via users <[email protected]> wrote:

> You can use systemd mount and automount files for this. 

Yes, and this has the advantage of not being dependent of the Desktop.

> You need to make a pair of files for each partition you wish to mount. 
 
> Here is an example of the files I use to mount my NFS shares from my NAS: 

> <code>
> [Unit]  
> Description=Mount ZimaOS Quick-Storage  
> After=network-online.target  
> Wants=network-online.target  
> 
> [Mount]  
> What=192.168.50.4:/media/nvme0n1p1   
> Where=/mnt/storage_server/NVMe  
> Type=nfs  
> Options=defaults,noatime,nodiratime,rsize=1048576,wsize=1048576,timeo=14,soft  
> 
> [Install]  
> WantedBy=multi-user.target
> </code>

This should be written in the file:

  /etc/systemd/system/mnt-storage_server-NVMe.mount

but it is better IMO to not enable this unit, and thus the [Install]
section is not needed, nor the ordering After=, but enable only the
.automount unit.

Here is an example to mount sde8 (that has the pdupre label).

/run/media should not be used because it is managed by the
Desktop. Use instead /mnt/SOME_NAME.

---------- /etc/systemd/system/mnt-pdupre.mount ----------
[Unit]
Description=%n

[Mount]
What=LABEL=pdupre
Where=/mnt/pdupre
----------------------------------------------------------

---------- /etc/systemd/system/mnt-pdupre.autmount -------
[Unit]
Description=%n

[Automount]
Where=/mnt/pdupre

[Install]
WantedBy=multi-user.target
----------------------------------------------------------

Then, enable the .automount unit:

  sudo systemctl enable mnt-pdupre.autmount

To test before rebooting:

  sudo systemctl start mnt-pdupre.autmount
  ls -l /mnt/pdupre
  findmnt /mnt/pdupre

findmnt should give here (after the access done by ls) something like:

  TARGET   SOURCE    FSTYPE OPTIONS
  /mnt/pdupre systemd-1 autofs rw,relatime,fd=130,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=118033
  /mnt/pdupre /dev/sde8 ext4   rw,relatime,seclabel

-- 
francis
-- 
_______________________________________________
users mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/[email protected]
Do not reply to spam, report it: https://forge.fedoraproject.org/infra/tickets/issues/new
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.