0

I have an external HDD and when I plug it in, I'd like it that Ubuntu always mounted it to a particular mountpoint and with particular read/write permissions.

To be more precise, I have an external drive with a partition called "Backup" (/dev/sdb1) and I'd like it to me mounted to /media/Backup with read-only permissions. What's the easiest way to do that?

orion3
  • 405
  • 1
  • 5
  • 17
  • That is what the file `/etc/fstab` is for. Include a line with the unique disk ID, the mount point, and options like read-only permissions. At the time the drive is connected, the system will mount it as specified in `/etc/fstab`. – Jos Feb 11 '15 at 10:37
  • what type is the drive? – Jacob Vlijm Feb 13 '15 at 12:52
  • 1
    Possible duplicate of [Trouble automounting an SD card on Trusty](http://askubuntu.com/questions/679435/trouble-automounting-an-sd-card-on-trusty) – A.B. Oct 10 '15 at 17:47
  • Snitko, Did the below answer help? If yes, don't forget to click the grey **☑** at the left of this text, which means [Yes, this answer is valid](http://askubuntu.com/help/accepted-answer)! **;-)** – Fabby Nov 03 '15 at 10:21

1 Answers1

0

All of the parameters of the following how-to are explained in the official Ubuntu documentation for fstab

  1. Insert the USB drive
  2. Go to a terminal and type sudo blkid and you should receive the following output:

    /dev/sdb1: LABEL="BACKUP" UUID="mmmmmmmm-nnnn-oooo-pppp-qqqqqqqq" TYPE="szFileSystem"
    

If the label does not say "BACKUP", you made a mistake in assigning a name to your stick. Open gparted, unmount the volume and set the correct label.

  1. In the same terminal, type sudo md /media/BACKUP
  2. and: chmod -w /media/BACKUP
  3. and: sudo nano /etc/fstab/
  4. Download a nice square back-up icon and save it to /usr/share/pixmaps in png format.
  5. At the end of the file add:

    UUID=mmmmmmmm-nnnn-oooo-pppp-qqqqqqqq /media/BACKUP szFileSystem nosuid,nodev,noexec,users,nobootwait,nofail,ro,comment=x-gvfs-show,comment=x-gvfs-icon=NiceBackupIcon,comment=x-gvfs-name=BACKUP   0   2
    

where:

  • mmmmmmmm-nnnn-oooo-pppp-qqqqqqqq is the UUID from step 2
  • szFileSystem is the file system from step 2
  • NiceBackupIcon is the icon you downloaded in step 6 (note: no png file extension)
A.B.
  • 89,123
  • 21
  • 245
  • 323
Fabby
  • 34,341
  • 38
  • 97
  • 191
  • Don't thank me! ;-) Just click the little grey check-mark under the "0" now. If you do not like my answer, click on the little grey down-arrow below the 0, turning it into beautiful green and if you *really* like my answer, click on the little grey checkmark *and* the little up-arrow... If you have any further questions, go to http://askubuntu.com/questions/ask – Fabby Feb 13 '15 at 11:09
  • 1
    Not in a running system. ;) http://askubuntu.com/a/679669/367165 – A.B. Oct 10 '15 at 17:45