How to auto mount a flash drive with root and read/write/execute privileges

I have an issue with mounting my Flash drive on Ubuntu 10.04 with write privileges. It's currently partitioned as Fat32 with Label KINGSTON but when I insert it into the Laptop it reads it as usb0, read-only privileges.

What I've had to do so that it is writable is to unmount it using Disk Utility and mount it again, and then it picks it up as KINGSTON with root privileges.

What I want is to automatically mount the flash drive with root privileges without going to Disk Utility to set this. Any help would be appreciated.


Solution 1:

  1. Open the terminal using:

    Menu: Applications menu -> Accessories -> Terminal.

    Keyboard Shortcut: Ctrl + Alt + T

  2. And type the following:

    sudo fdisk -l
    

    The output should be similar to:

    karthick@Ubuntu-desktop:~$ sudo fdisk -l
    
    Disk /dev/sda: 160.0 GB, 160041885696 bytes
    255 heads, 63 sectors/track, 19457 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00af00af
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1        3188    25607578+   7  HPFS/NTFS
    /dev/sda2            3189        4462    10233405   83  Linux
    /dev/sda3            4463       19458   120449002+   f  W95 Ext'd (LBA)
    Partition 3 does not end on cylinder boundary.
    /dev/sda5            4463        9561    40957686    7  HPFS/NTFS
    /dev/sda6            9562       14660    40957686    7  HPFS/NTFS
    /dev/sda7           14661       19255    36905984   83  Linux
    /dev/sda8           19255       19458     1626112   82  Linux swap / Solaris
    
    Disk /dev/sdb: 4022 MB, 4022337024 bytes
    255 heads, 63 sectors/track, 489 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x000b5e92
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1         489     3927861    7  HPFS/NTFS
    

    My flash drive is located at /dev/sdb1 (yours may vary).

  3. Make the following ajustments:

    For NTFS file system:

    You should edit the fstab file. Type the following in terminal:

    sudo gedit /etc/fstab
    

    At the bottom of the fstab file paste the following:

    /dev/sdb1       /media/Datas ntfs-3g  defaults  0   0
    

    For FAT 16/32 file system run the following in terminal:

    sudo mount -t vfat /dev/sdb1 /media/Datas -o uid=1000,gid=100,utf8,dmask=027,fmask=137
    

Note: You should create the mount point, in terminal type the following:

sudo mkdir /media/Datas
sudo mount -a

Related Reading:

Mount/USB - Community Ubuntu Documentation

Fstab - Community Ubuntu Documentation

Solution 2:

This might sound like a bizarre answer, but I just ran into the same problem - it's worth a look.

Make sure you don't have the usbmount application installed - it seems to cause conflicts and mounts your USB drives to the "usb#" folders that you mentioned.

More information is available in the related Ubuntu forums post.