[Skip to content](#main)

[→](/)

[![Avunu](/brand/avunu-logo.svg)![Avunu](/brand/avunu-logo-light.svg)](/)[Services](/services/)[Consulting](/services/consulting/)[ERP](/services/erp/)[Odoo](/services/erp/odoo/)[ERPNext](/services/erp/erpnext/)[Custom software](/services/custom-software/)[Devices & IoT](/services/devices-iot/)[Websites](/services/websites/)[Infrastructure](/services/infrastructure/)[Partners](/partners/)

[Work](/work/)[Open source](/open-source/)[Knowledge base](/kb/)[About](/about/)

[About Avunu](/about/)[Team](/about/team/)[Insights](/insights/)[Contact](/contact/)

[Client portal](https://erp.avunu.net/projects)[Start a project](/start/)

- [Services](/services/)[Consulting](/services/consulting/)
- [ERP](/services/erp/)
- [Odoo](/services/erp/odoo/)
- [ERPNext](/services/erp/erpnext/)
- [Custom software](/services/custom-software/)
- [Devices & IoT](/services/devices-iot/)
- [Websites](/services/websites/)
- [Infrastructure](/services/infrastructure/)
- [Partners](/partners/)

[Work](/work/)[Open source](/open-source/)[Knowledge base](/kb/)[About](/about/)

- [About Avunu](/about/)
- [Team](/about/team/)
- [Insights](/insights/)
- [Contact](/contact/)

[Client portal](https://erp.avunu.net/projects)[Start a project](/start/)

[Knowledge base](/kb/)[Linux](/kb/linux/)Mount a Drive with a systemd Mount Unit

Search the knowledge basePress/

ESC

Jump to

[Browse the knowledge base](/kb/)[Frappe](/kb/frappe/)[ERPNext](/kb/erpnext/)[Odoo](/kb/odoo/)[WordPress](/kb/wordpress/)[NixOS](/kb/nixos/)[Email](/kb/email/)[Linux](/kb/linux/)[Databases](/kb/databases/)[Containers](/kb/containers/)[Proxmox](/kb/proxmox/)[Git & Dev Tools](/kb/git-and-dev-tools/)

↵select↑↓navigateescclose

Search the knowledge base

[Skip to the article](#kb-article)[Linux](/kb/linux/)9 articles

- [Overview](/kb/linux/)
- [Clean Up Stale nginx Unix Sockets with a systemd Drop-in](/kb/linux/nginx-socket-cleanup-drop-in/)
- [Intel GPU Kernel Parameters](/kb/linux/intel-gpu-kernel-parameters/)
- [Media Conversion Recipes](/kb/linux/media-conversion-recipes/)
- [Mount a Drive with a systemd Mount Unit](/kb/linux/systemd-mount-units/)
- [Release Stuck Messages in the Postal Mail Server Queue](/kb/linux/postal-release-queued-messages/)
- [Set Up a WireGuard VPN Host](/kb/linux/wireguard-host-setup/)
- [Shell One-Liners](/kb/linux/shell-one-liners/)
- [Swap Configuration](/kb/linux/swap-configuration/)
- [Switch Commands with update-alternatives and sudo-rs](/kb/linux/sudo-rs-and-update-alternatives/)

Other sections[Frappe](/kb/frappe/)[ERPNext](/kb/erpnext/)[Odoo](/kb/odoo/)[WordPress](/kb/wordpress/)[NixOS](/kb/nixos/)[Email](/kb/email/)[Databases](/kb/databases/)[Containers](/kb/containers/)[Proxmox](/kb/proxmox/)[Git & Dev Tools](/kb/git-and-dev-tools/)

In Linux: 9 articles

[Overview](/kb/linux/)[Clean Up Stale nginx Unix Sockets with a systemd Drop-in](/kb/linux/nginx-socket-cleanup-drop-in/)[Intel GPU Kernel Parameters](/kb/linux/intel-gpu-kernel-parameters/)[Media Conversion Recipes](/kb/linux/media-conversion-recipes/)[Mount a Drive with a systemd Mount Unit](/kb/linux/systemd-mount-units/)[Release Stuck Messages in the Postal Mail Server Queue](/kb/linux/postal-release-queued-messages/)[Set Up a WireGuard VPN Host](/kb/linux/wireguard-host-setup/)[Shell One-Liners](/kb/linux/shell-one-liners/)[Swap Configuration](/kb/linux/swap-configuration/)[Switch Commands with update-alternatives and sudo-rs](/kb/linux/sudo-rs-and-update-alternatives/)

Other sections[Frappe](/kb/frappe/)[ERPNext](/kb/erpnext/)[Odoo](/kb/odoo/)[WordPress](/kb/wordpress/)[NixOS](/kb/nixos/)[Email](/kb/email/)[Databases](/kb/databases/)[Containers](/kb/containers/)[Proxmox](/kb/proxmox/)[Git & Dev Tools](/kb/git-and-dev-tools/)

LinuxMount a Drive with a systemd Mount Unit

Write systemd .mount and .automount units to mount a disk by UUID at boot or on first access, as an alternative to fstab.

UpdatedOct 1, 2026

Applies toUbuntu 24.04Ubuntu Core 24systemd 255

Tagssystemdlinuxstorageubuntu

Reading time3 min

On this page[1. Find the Partition's UUID](#1-find-the-partitions-uuid)[2. Name the Unit After the Mount Point](#2-name-the-unit-after-the-mount-point)[3. Write the Mount Unit](#3-write-the-mount-unit)[Filesystem-Specific Options](#filesystem-specific-options)[4. Start and Enable the Mount](#4-start-and-enable-the-mount)[Mount on First Access Instead](#mount-on-first-access-instead)[Make Services Wait for the Mount](#make-services-wait-for-the-mount)

systemd can mount filesystems from unit files instead of `/etc/fstab`. This is the only option on systems where `/etc/fstab` is read-only or managed for you, such as Ubuntu Core, and it's handy anywhere you want a mount with dependencies, ordering, or on-demand mounting. Run the commands as root.

## 1. Find the Partition's UUID

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">blkid</span>
```

```text
/dev/sdb1: LABEL="data" UUID="<PARTITION_UUID>" TYPE="ext4" PARTUUID="..."
```

Mount by UUID (`/dev/disk/by-uuid/...`) rather than `/dev/sdX`, which can change between boots.

## 2. Name the Unit After the Mount Point

A mount unit's file name must be the escaped mount path. `systemd-escape` produces it:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">systemd-escape</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">-p</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">--suffix=mount</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">/media/data</span>
```

```text
media-data.mount
```

Paths with dashes or spaces escape differently (for example `/mnt/my-disk` becomes `mnt-my\x2ddisk.mount`), so always generate the name rather than guessing.

## 3. Write the Mount Unit

Create `/etc/systemd/system/media-data.mount`:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">[Unit]</span>
<span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">Description</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">=Data drive</span>

<span style="--shiki-dark:#FFA657;--shiki-light:#953800">[Mount]</span>
<span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">What</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">=/dev/disk/by-uuid/<PARTITION_UUID></span>
<span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">Where</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">=/media/data</span>
<span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">Type</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">=ext4</span>
<span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">Options</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">=defaults,noatime,nofail</span>

<span style="--shiki-dark:#FFA657;--shiki-light:#953800">[Install]</span>
<span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">WantedBy</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">=multi-user.target</span>
```

`Where=` must match the unit's file name exactly, or systemd refuses to load it.

`nofail` lets the system finish booting if the drive is missing, which matters for removable or external disks.

systemd creates the mount point directory if it doesn't exist.

### Filesystem-Specific Options

| Filesystem                            | `Type=`                | Typical `Options=`                   |
| ------------------------------------- | ---------------------- | ------------------------------------ |
| ext4, XFS, Btrfs                      | `ext4`, `xfs`, `btrfs` | `defaults,noatime,nofail`            |
| NTFS (kernel driver, Linux 5.15+)     | `ntfs3`                | `uid=1000,gid=1000,umask=022,nofail` |
| NTFS (FUSE driver, `ntfs-3g` package) | `ntfs-3g`              | `uid=1000,gid=1000,umask=022,nofail` |
| exFAT                                 | `exfat`                | `uid=1000,gid=1000,umask=022,nofail` |

NTFS and exFAT have no Unix permissions, so `uid`, `gid`, and `umask` decide who owns the files. Replace `1000` with the user and group IDs from `id <USER>`. Avoid `umask=0000`, which makes every file world-writable.

## 4. Start and Enable the Mount

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">systemctl</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">daemon-reload</span>
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">systemctl</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">start</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">media-data.mount</span>
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">systemctl</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">enable</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">media-data.mount</span>
```

Check it with `systemctl status media-data.mount` and `findmnt /media/data`.

## Mount on First Access Instead

To mount the drive only when something first touches the mount point (and optionally unmount it when idle), add an automount unit with the same base name, `/etc/systemd/system/media-data.automount`:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">[Unit]</span>
<span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">Description</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">=Automount data drive</span>

<span style="--shiki-dark:#FFA657;--shiki-light:#953800">[Automount]</span>
<span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">Where</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">=/media/data</span>
<span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">TimeoutIdleSec</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">=10min</span>

<span style="--shiki-dark:#FFA657;--shiki-light:#953800">[Install]</span>
<span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">WantedBy</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">=multi-user.target</span>
```

Enable the automount unit instead of the mount unit. Remove the `[Install]` section from the `.mount` file, or disable it, so only the automount triggers it:

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">systemctl</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">daemon-reload</span>
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">systemctl</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">disable</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">media-data.mount</span>
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">systemctl</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">enable</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#79C0FF;--shiki-light:#0550AE">--now</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328"> </span><span style="--shiki-dark:#A5D6FF;--shiki-light:#0A3069">media-data.automount</span>
```

## Make Services Wait for the Mount

If a service stores data on the drive, make it depend on the mount so it never starts against an empty mount point. In the service's drop-in (`systemctl edit <SERVICE>`):

```
<span style="--shiki-dark:#FFA657;--shiki-light:#953800">[Unit]</span>
<span style="--shiki-dark:#FF7B72;--shiki-light:#CF222E">RequiresMountsFor</span><span style="--shiki-dark:#E6EDF3;--shiki-light:#1F2328">=/media/data</span>
```

Sources

- [www.freedesktop.org/software/systemd/man/latest/systemd.mount.html](https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html)
- [www.freedesktop.org/software/systemd/man/latest/systemd.automount.html](https://www.freedesktop.org/software/systemd/man/latest/systemd.automount.html)
- [www.freedesktop.org/software/systemd/man/latest/systemd-escape.html](https://www.freedesktop.org/software/systemd/man/latest/systemd-escape.html)

Need help with Linux servers?

Our notes can take you a long way, but sometimes you'd rather have someone who's done it before.

[Managed infrastructure](/services/infrastructure/)

[← PreviousMedia Conversion Recipes](/kb/linux/media-conversion-recipes/)[Next →Release Stuck Messages in the Postal Mail Server Queue](/kb/linux/postal-release-queued-messages/)

CC0This article is in the public domain ([CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/)), code samples included. Use it however helps you.

On this page

- [1. Find the Partition's UUID](#1-find-the-partitions-uuid)
- [2. Name the Unit After the Mount Point](#2-name-the-unit-after-the-mount-point)
- [3. Write the Mount Unit](#3-write-the-mount-unit)
- [Filesystem-Specific Options](#filesystem-specific-options)
- [4. Start and Enable the Mount](#4-start-and-enable-the-mount)
- [Mount on First Access Instead](#mount-on-first-access-instead)
- [Make Services Wait for the Mount](#make-services-wait-for-the-mount)

[Back to top↑](#top)

Services

- [ERP implementation](/services/erp/)
- [Odoo](/services/erp/odoo/)
- [ERPNext](/services/erp/erpnext/)
- [Custom software](/services/custom-software/)
- [Devices & IoT](/services/devices-iot/)
- [Websites](/services/websites/)
- [Infrastructure](/services/infrastructure/)

Resources

- [Our work](/work/)
- [Open source](/open-source/)
- [Knowledge base](/kb/)
- [Insights](/insights/)

Company

- [About](/about/)
- [Team](/about/team/)
- [Partners](/partners/)
- [Contact](/contact/)

Clients

- [Project portal](https://erp.avunu.net/projects)
- [Invoices](https://erp.avunu.net/)
- [Support](https://erp.avunu.net/)

[![Avunu](/brand/avunu-logo-light.svg)](/)[\<av-icon data-jx-static>\<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor" stroke="none" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">\<path d="M20.400 20.500h-3.600v-5.600c0-1.300 0-3-1.800-3s-2.100 1.400-2.100 2.900v5.700H9.400V9h3.400v1.600c.5-.9 1.600-1.900 3.400-1.900 3.600 0 4.300 2.400 4.300 5.500v6.300zM5.300 7.400a2.100 2.100 0 1 1 0-4.100 2.100 2.100 0 0 1 0 4.100zm1.800 13.100H3.600V9h3.500v11.500zM22.200 0H1.800C.8 0 0 .8 0 1.700v20.600c0 .9.800 1.700 1.800 1.700h20.400c1 0 1.800-.8 1.800-1.700V1.700C24 .8 23.200 0 22.200 0z">\</path>\</svg>\</av-icon>](https://www.linkedin.com/company/avunu)[\<av-icon data-jx-static>\<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor" stroke="none" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">\<path d="M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.6-1.4-1.4-1.8-1.4-1.8-1-.7.1-.7.1-.7 1.2.1 1.8 1.2 1.8 1.2 1 1.8 2.8 1.3 3.5 1 .1-.8.4-1.3.7-1.6-2.7-.3-5.5-1.3-5.5-5.9 0-1.3.5-2.4 1.2-3.2-.1-.3-.5-1.5.1-3.2 0 0 1-.3 3.3 1.2a11.500 11.500 0 0 1 6 0c2.300-1.500 3.300-1.200 3.300-1.200.6 1.700.2 2.900.1 3.200.8.8 1.200 1.900 1.200 3.200 0 4.600-2.800 5.600-5.500 5.900.4.400.8 1.100.8 2.200v3.300c0 .3.2.7.8.6A12 12 0 0 0 12 .3">\</path>\</svg>\</av-icon>](https://github.com/Avunu)[Client portal](https://erp.avunu.net/projects)[Start a project](/start/)

Avunu LLC · 948 East Philadelphia Street, York, PA 17403 · (717) 814-8540Knowledge base articles are in the public domain[Privacy](/privacy/)[Terms](/terms/)
