automatically mount USB drive on boot/power loss

I have been using my Dietpi box to host a samba shared drive so that I can easily access files from around the house, the only problem is that if I lose power when the pi and USB drive power back up they are no longer mounted which means I have to log into the dietpi box and manually mount them again using drive manager.

Is there a way to set the USB drive to automatically be assigned to a mount point? I’ve read some people use fstab to do this on linux, but when I run fstab in dietpi I get command not found error.


fstab isn’t a command that can be xecuted. It’s a file containing mount information about drives to be mounted. It located at /etc/fstab

many thanks for your message. How do yoou mount your USB drive? do you use DietPi drive manager? Usually drive manager will set an option to mount the external drive as soon as someone is trying to access it.

Yes I am using drive manager each time I mount it, and then I have the mount point for it shared with Samba. I don’t see any options to set it to auto-mount after a power or connection loss.

can you share your /etc/fstab. Usually drive manager will set automatic mount automatically

cat /etc/fstab

So the shares show up just fine in fstab, but when I lose power they are gone. I want to try and set it up so that they are always there.

Please use “dietpi-drive_manager” to setup mounts






tmpfs /tmp tmpfs size=1938M,noatime,lazytime,nodev,nosuid,mode=1777
tmpfs /var/log tmpfs size=50M,noatime,lazytime,nodev,nosuid,mode=1777


MISC: ecryptfs, vboxsf (VirtualBox shared folder), gluster, bind mounts







PARTUUID=907af7d0-02 / ext4 noatime,lazytime,rw 0 1
PARTUUID=907af7d0-01 /boot vfat noatime,lazytime,rw 0 2
UUID=406CED016CECF298 /mnt/samba/backup ntfs noatime,lazytime,rw,permissions,big writes,nofail,noauto,x-systemd.automount
UUID=825AE4125AE4052F /mnt/samba/share ntfs noatime,lazytime,rw,permissions,big

both devices are set with x-systemd.automount flag. Means, on a reboot these devices are mounted automatically as soon as someone is trying to access them. Could be you don’t see them after a reboot. They will be mounted just in case you or an application is going inside the folder. Usually there is no need to mount them manually after a reboot.

Btw: what do you mean with power loss? Is that a reboot on your DietPi device or on the external HDD?

Power loss meaning my kid or dog hit’s the power strip and turns off my HDD and my diet pi. When that happens, or I have a normal power outage, when everything boots back up I have to remount the USB hard drive in the drive-manager again.

for testing purposes, do a reboot and connect on command line afterwards. Now go inside your data directories /mnt/samba/backup as well as /mnt/samba/share and check if your data are visible.

If drives did not get mounted have a look to dmesg and journalctl for error messages. Information about the mount should be at the end of the list