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

2 Answers2

8

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.
SunnyDaze
  • 1,396
  • 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 02: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 02:31
  • ok, this works. Ended up physically going into the machine. – NinjaCowgirl Aug 17 '17 at 02:40
  • following this in 2023 with Ubuntu 23 the slider in step 7 is now labeled "User Session Defaults". I'd also add that once this is done, for the changes to take affect you should click the Stop icon to unmount (next to gear icon of step 5), then the Play icon to remount the drive. – yoduh May 30 '23 at 04:17
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
David Foerster
  • 36,264
  • 56
  • 94
  • 147