13

Hi I am new to Ubuntu and recently installed 14.04 LTS. I am having issues with mounting external hard drives for all users at start up. For example, after start up if I login as a user A, only user A can access the external media, and others can't access these external media. Could someone please help me fix this issue.

Outputs to following commands

sudo blkid

/dev/sda1: UUID="98715d8d-bf13-48f5-882e-36270c539c94" TYPE="ext4" 
/dev/sda2: UUID="qOUDEc-qHDq-y9NL-OWCF-fO04-vnPI-8UNrtV" TYPE="LVM2_member" 
/dev/sdb1: UUID="6ulNAl-1Hky-orpE-ntL2-Brgu-Qen1-BYqCIh" TYPE="LVM2_member" 
/dev/mapper/VolGroup-lv_root: UUID="a7e84558-d5d3-43f3-8788-a483dde96fd8" TYPE="ext4" 
/dev/mapper/VolGroup-lv_home: UUID="fb65cc75-ab1a-44a4-8f98-b1767d03f15a" TYPE="ext4" 
/dev/mapper/VolGroup-lv_swap: UUID="69e3381b-a2b5-4866-81b6-bd368c9157d5" TYPE="swap" 
/dev/sdc1: LABEL="ExtHDD04" UUID="0DFFA1CB15212E12" TYPE="ntfs" 
/dev/sdd1: LABEL="ExtHDD03" UUID="485AA7713243CEFB" TYPE="ntfs" 
/dev/sde1: UUID="485ef4bd-0093-42c5-a3e5-0090e68e93c1" TYPE="ext4" 
/dev/sr1: LABEL="WD SmartWare" TYPE="udf" 
/dev/sdg1: LABEL="ExtHDD01" UUID="00148BDE148BD4D6" TYPE="ntfs" 

sudo fdisk -l

Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders, total 488281250 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc648a420

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   488280063   243627008   8e  Linux LVM

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000617c8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048  3907028991  1953513472   8e  Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_root doesn't contain a valid partition table

Disk /dev/mapper/VolGroup-lv_home: 2168.7 GB, 2168656494592 bytes
255 heads, 63 sectors/track, 263657 cylinders, total 4235657216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_home doesn't contain a valid partition table

Disk /dev/mapper/VolGroup-lv_swap: 27.5 GB, 27481079808 bytes
255 heads, 63 sectors/track, 3341 cylinders, total 53673984 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_swap doesn't contain a valid partition table

WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sdc: 3000.6 GB, 3000558944256 bytes
255 heads, 63 sectors/track, 364797 cylinders, total 5860466688 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1  4294967295  2147483647+  ee  GPT
Partition 1 does not start on physical sector boundary.

WARNING: GPT (GUID Partition Table) detected on '/dev/sdd'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sdd: 3000.6 GB, 3000558944256 bytes
255 heads, 63 sectors/track, 364797 cylinders, total 5860466688 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1  4294967295  2147483647+  ee  GPT
Partition 1 does not start on physical sector boundary.

WARNING: GPT (GUID Partition Table) detected on '/dev/sde'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sde: 3000.6 GB, 3000558944256 bytes
255 heads, 63 sectors/track, 364797 cylinders, total 5860466688 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1  4294967295  2147483647+  ee  GPT
Partition 1 does not start on physical sector boundary.

Disk /dev/sdg: 1999.7 GB, 1999696297984 bytes
228 heads, 56 sectors/track, 305894 cylinders, total 3905656832 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe534f55f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048  3905656831  1952827392    7  HPFS/NTFS/exFAT

cat /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/VolGroup-lv_root /               ext4    errors=remount-ro 0       1
/dev/mapper/VolGroup-lv_home /home           ext4    defaults        0       2
/dev/mapper/VolGroup-lv_swap none            swap    sw              0       0
6
  • i am not clear with the question. Do you want to restrict access to User A and disallow access to other users or do you want to enable access for other users?
    – astrob0t
    Nov 10, 2014 at 16:39
  • Hi astrobot, I have different user accounts setup on the machine and users need access to the external media to read/write data remotely. Now in my case when I restart the machine and select a particular user, only that user can access the external media and the rest can't and this is undesired. If you happen to have a solution to this, please let me know. Nov 11, 2014 at 19:13
  • are you manually mounting the external hdd after logging in?
    – astrob0t
    Nov 11, 2014 at 19:17
  • No, I am not. External drives are automounted for the first user that logs in after reboot Nov 11, 2014 at 19:37
  • ok. Please log in into your system and edit your question by posting the outputs of the following commands sudo blkid , sudo fdisk -l , cat /etc/fstab
    – astrob0t
    Nov 11, 2014 at 19:44

3 Answers 3

15

To mount a partition at startup for all users, we need an entry in the fstab file. What is happening presently is, the HDD is getting mounted for the user who logs in which gives access permissions to only that user. By adding an entry in the fstab, the partition will be mounted by root with access to all users. this r/w access can be controlled later on.

sudo blkid lists down all partitions available on your system. Note down the UUID of the NTFS partition that you want to mount at boot. In your case, it seems 00148BDE148BD4D6

now create a folder, for example sudo mkdir /media/ExtHDD01. This is the folder where your external HDD partition will be mounted at. This folder will be owned by root. To give other users permission to r/w into this folder we need to give the proper permissions. so chmod -R 777 /media/ExtHDD01 would be good enough. Now you need to edit your fstab file. to do so, type the following command.

sudo nano /etc/fstab

go to the bottom of the file and add the following line there.

UUID=00148BDE148BD4D6 /media/ExtHDD01/    ntfs-3g        auto,user,rw 0 0

Reboot system and you should be good to go. You can follow the same procedure for any number of HDDs.

4
  • Hi astrob0t, thanks it helped. But why is this new /media/<username> thing in latest release of ubuntu? Does if confer any advantages? Nov 11, 2014 at 21:07
  • That's not username. That can be any random folder. Generally when you manually Mount a device, it gets mounted at /media/<UUID> this uuid is a typically long string. So to keep everything consistent, i gave an example to Mount it at /media/<some_random_folder_name>. You can create any folder, anywhere.
    – astrob0t
    Nov 11, 2014 at 21:14
  • I am sorry, I may not be clear earlier. In the latest release of ubunutu the media is being mounted in a different folder for each user. For example /media/bhaskar/ExtHDD01 instead of /media/ExtHDD01 (where ExtHDD01 is the external harddrive). Hope I could explain clearly this time. Nov 11, 2014 at 21:29
  • the command that worked for me in ubuntu 20 is as follow /dev/disk/by-uuid/5fe8185a-af16-436d-8085-4f9865cdbd0c /mnt/data auto nosuid,nodev,nofail,x-gvfs-show 0 0 May 17, 2021 at 9:32
14

GUI method

  1. plug in the drive.

  2. Go to Disks in the desktop finder (or sudo gnome-disks on a terminal)

  3. Select the correct disk in the left column.

  4. Click the gear icon enter image description here

  5. Select edit mount options

  6. Turn off

  7. Check both mount at startup and show user interface

Thats it!

3
  • This would be an answer for desktop users, however this is likely not applicable for server users.
    – Laice
    Nov 1, 2016 at 23:47
  • 1
    Ok, find the correct information to update the fstab file manually. Good day. Dec 4, 2016 at 3:07
  • The original post says nothing about servers. This was perfect for me. Thanks.
    – matty
    Oct 3, 2021 at 23:34
2

I recently was in the same situation and I figured out a solution.

I have 2 users, ADMIN and DESKTOP USER for which I wanted to mount same drive labeled STORAGE upon their respective logins, so:

In the file /etc/fstab I had to add following entry:

LABEL=STORAGE /media/$USER/STORAGE auto nosuid,nodev,nofail,x-gvfs-show 0 0

The notable thing is the use of the environment variable $USER.

This is for Ubuntu 16.04 where new drive is mounted under /media/<username>/<drive-label>

You may also use UUID instead of <drive-label>.

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