Let systemd automount NTFS partitions to ensure successful booting

On my laptop I use a dual-boot setup with a NTFS partition shared between Windows and Linux, containing eg. music. Because the Windows version installed is Windows 10, it could sometimes happen that, in spite of having turned off hybrid shutdown, ntfs-3g would refuse to mount the shared data partition because it was in an unclean state.

When I had a static fstab entry such as

/dev/disk/by-id/scsi-0ATA_Samsung_SSD_850_S246NWAG302024T-part3  /data  ntfs-3g    auto,user,users,gid=users,fmask=000,dmask=000,locale=de_DE.UTF-8 0 0

this could mean that the system’s boot sequence would be interrupted because that partition could not be mounted…

First I just used noauto as a remedy but of course I always forgot to manually mount the partition when I needed it (watching Rhythmbox removing its media library entries can be fun…). Plus this required root privileges because I didn’t want to make the ntfs-3g binary setuid.

systemd to the rescue! With an entry such as this

/dev/disk/by-id/scsi-0ATA_Samsung_SSD_850_S246NWAG302024T-part3  /data  ntfs-3g    noauto,x-systemd.automount,user,users,gid=users,fmask=000,dmask=000,locale=de_DE.UTF-8 0 0

you get what systemd calls a mount unit, in this case an automount unit. Meaning that the partition won’t be mounted until first access while still not possibly interrupting the boot sequence. Nice! :)

See systemd.automount(5) for more options.

Leave a Reply