2

I have a drive on /dev/sda1 that's mounted to

/media/<username>/mydrive

Everytime I reboot my computer I have to execute the following two commands to change mount path:

sudo umount /media/<username>/mydrive
sudo mount /dev/sda1 /home/<username>/media/<username>/mydrive

How do I automate this? or change it so the default mount path can be:

/home/<username>/media/<username>/mydrive
5

You could edit the /etc/fstab file in a text editor like such as gedit or subl, or you could just do this:

  1. Make sure the Hard Drive is connected.
  2. Open Disks
  3. Click on the Hard Drive you want to modify.
  4. Click on the Partition you want to modify.
  5. Click on the gear icon
  6. Click on Edit Mount Options
  7. Move the Automatic Mount Options slider to Off
  8. Type in the path you want the Partition mounted too in the Mount Point text box.
  9. Click the OK button.
  10. Type in the super-user password. This will make the necessary changes to the /etc/fstab file for you.
| improve this answer | |
  • Thank you very much, forgot to mention i need shell commands since I can only connect via SSH. Any suggestions? – NinjaCowgirl Aug 17 '17 at 2:21
  • If you log in from a Linux machine with the -Y option, you should be able to just run the GUI application on your local machine. 1. Type ssh -Y user@remoteIPAddress 2. Type gnome-disks to open the GUI app on your local machine, well actually it opens on the remote machine, but sends the GUI info to your local machine. – SunnyDaze Aug 17 '17 at 2:31
  • ok, this works. Ended up physically going into the machine. – NinjaCowgirl Aug 17 '17 at 2:40
1

To mount automatically at boot time there is file /etc/fstab . In this file you specified which device should be mounted to mount point . As an example :

$ vim /etc/fstab
/dev/sda1 /home/USER-ID ext4 defaults 0 0

Replace USER-ID with your mount point and ext4 with your file system . For any information about more options in fstab see man fstab .

In systemD there is unit by the name of mount which supposed to be replaced with fstab . Try to mount with systemD may help :

cd /usr/lib/systemd/system
cp tmp.mount /etc/systemd/system
vim /etc/fstab

And take your added line out.

cd /etc/systemd/system
mv tmp.mount mydata.mount
vim mydata.mount

Edit these options:

  • What=/dev/sda1
  • Where=/home/USER-ID
  • type=ext4
  • options=defaults

umount old mounted partition.

systemctl deamon-reload
systemctl start mydata.mount
systemctl enable mydata.mount
| improve this answer | |
  • doesn't work... "root account locked" is the error message – NinjaCowgirl Aug 17 '17 at 2:29
  • Using sunnyDaze's method, it auto generated this line in fstab, looks like i need all these extra things to make it work: /dev/sda1 /home/<username>/media/<username>/mydrive auto nosuid,nodev,nofail,x-gvfs-show 0 0 – NinjaCowgirl Aug 17 '17 at 2:41
  • I edited answer with systemD unit. Try this . – Ali Ghasempour Aug 17 '17 at 2:44
  • @NinjaCowgirl that's looks fstab format . Hope it works . – Ali Ghasempour Aug 17 '17 at 2:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.