How to Mount a Windows Network Drive On Boot as Systemd Service on Ubuntu

Assuming you want to mount to /home/username/files, create a file matching the name of your local directory where you want to mount to as below:

sudo nano /etc/systemd/system/home-username-files.mount

Its content should be the following with the remote (assuming you want 755 file permissions):

Description=Mount Files



Then create another file with the same name but with automount extension:

sudo nano /etc/systemd/system/home-username-files.automount

Add this content in it:

Description=Mount Files



Reload services and enable your new service:

sudo systemctl daemon-reload
sudo systemctl enable home-username-files.automount

You will see it mounted automatically after reboot. You can start and see the status of your new service by running:

sudo systemctl start home-username-files.automount
sudo systemctl status home-username-files.automount

If you want to mount the drive and assign it to a user and set file permissions, you’ll need something like this at the end of the options line:


See all options that can be set here.