1

I have an external USB drive which is always plugged in. I have modified fstab and created a folder in media so that the drive is mounted at media/drive_name. However, is automount is enabled, every time I restart the system the drive get remounted in media/user_name/drive name. I would like to keep automount on for other devices, but for this specific one have my own mount point. Is there any way to do this?

16
  • Would you settle for running a script? Apr 21, 2015 at 0:16
  • What modifications did you make to fstab?
    – muru
    Apr 21, 2015 at 0:18
  • askubuntu.com/questions/214646/…. Read that. It might explain some stuff. Apr 21, 2015 at 0:24
  • I would settle for a script.
    – Steve Kiss
    Apr 21, 2015 at 0:40
  • I added the following to my fstab: /dev/sdb1 /media/drive_name defaults 0 2.. However, when I restart the system it will appear as /dev/sdc1 and be mounted as /media/user_name/drive_name. If I then unmount it, edit fstab to use sdc1, and remount it, on reboot it appears as sdb1 again.. I have to go through this process each time I reboot.
    – Steve Kiss
    Apr 21, 2015 at 0:43

1 Answer 1

2

Try this:

  1. Make your script: make a new text document and put this in:

    #!/bin/sh  
    mkdir -p /path/to/custom-mount  
    sudo umount /dev/sdaX ((This is the drive you want to mount in the custom location))  
    sudo mount -t filesystem-type -o rw /dev/sdaX /path/to/custom-mount  
    
  2. Put this script under /etc/init.d.

  3. Make it executable by running sudo chmod -x /etc/init.d/script-name.
  4. Run update-rc.d script-name defaults.

Hopefully, this will unmount your drive and then remount it under the folder you want.

4
  • @ThomasW. I think he already has that. Will it be removed upon reboot, when the drive gets unmounted? Apr 21, 2015 at 1:15
  • missed that. sorry. It should stay but it's still a good form to make a note that you should make sure the mount point exists yet. In fact if you change /bin/sh to /bin/bash we can add in some error check code but meh
    – Thomas Ward
    Apr 21, 2015 at 1:22
  • @ThomasW. I think it would be better to keep it simple. Apr 21, 2015 at 1:22
  • Yes, like - automatic. pmount takes care of this problem all by itself. askubuntu.com/questions/88523/…
    – SDsolar
    Aug 1, 2017 at 9:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .