3

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

9

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,416
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,890
  • 56
  • 97
  • 151
Ali Ghasempour
  • 449
  • 3
  • 7