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?
Asked
Active
Viewed 2,320 times
1 Answers
2
Try this:
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
Put this script under
/etc/init.d
.- Make it executable by running
sudo chmod -x /etc/init.d/script-name
. - Run
update-rc.d script-name defaults
.
Hopefully, this will unmount your drive and then remount it under the folder you want.

muru
- 197,895
- 55
- 485
- 740

TheWanderer
- 19,395
- 12
- 50
- 65
-
@ThomasW. I think he already has that. Will it be removed upon reboot, when the drive gets unmounted? – TheWanderer Apr 21 '15 at 01: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 '15 at 01:22 -
-
Yes, like - automatic. pmount takes care of this problem all by itself. https://askubuntu.com/questions/88523/creating-a-mount-point-if-it-does-not-exist/941726#941726 – SDsolar Aug 01 '17 at 09:56
fstab
? – muru Apr 21 '15 at 00:18sh
file to the startup directory, which I will search for and include in the answer I will write if this is what you want. – TheWanderer Apr 21 '15 at 00:52/dev/sdXY
. See http://askubuntu.com/questions/17381/unity-doesnt-load-no-launcher-no-dash-appears – muru Apr 21 '15 at 01:21