Auto mounting NTFS disks and making them accessible over a network


One of the tings which went wrong when I upgraded from Ubuntu 8.10 to 9.10 was that along the way my /etc/fstab file got changed and my NTFS data partition* no longer auto-mounted on login.

To make matters worse, manually mounting the drive was fine but none of my shares were accessible from other PCs on the network! I would just get the error in Nautilus “Unable to Mount Location – File doesn’t exist”, true but unhelpful!!

The following explains what I did to fix the automount NTFS issue in fstab and then goes on to explain how to fix the samba NTFS file sharing issue.

1. Find out what partitions are mounted and their UUID

From Terminal enter

sudo fdisk -l

you will get something like this:

Disk /dev/sda: 203.9 GB, 203928109056 bytes

255 heads, 63 sectors/track, 24792 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0xaad6c457

Device Boot Start End Blocks Id System

/dev/sda1 * 1 24792 199141708+ 7 HPFS/NTFS

Disk /dev/sdb: 18.4 GB, 18360785920 bytes

255 heads, 63 sectors/track, 2232 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x2627a149

Device Boot Start End Blocks Id System

/dev/sdb1 * 1 2231 17920476 7 HPFS/NTFS

Disk /dev/sdc: 72.8 GB, 72839168000 bytes

255 heads, 63 sectors/track, 8855 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0xd8e61fe6

Device Boot Start End Blocks Id System

/dev/sdc1 * 1 1020 8193118+ 7 HPFS/NTFS

/dev/sdc2 1021 8855 62934637+ 5 Extended

/dev/sdc5 1021 8530 60324043+ 83 Linux

/dev/sdc6 8531 8855 2610531 82 Linux swap / Solaris

Now enter

sudo blkid

to give you the UUID of the disks:

/dev/sda1: UUID=”129C05969C05760F” LABEL=”Data” TYPE=”ntfs”

/dev/sdb1: UUID=”FA04BF8104BF4005″ LABEL=”WINxpLIVE” TYPE=”ntfs”

/dev/sdc1: UUID=”00F06B7EF06B7934″ LABEL=”SWAP” TYPE=”ntfs”

/dev/sdc5: UUID=”c9f7c64f-97f1-4dae-b484-1b41edf6bd4b” TYPE=”ext3″

/dev/sdc6: UUID=”781f5133-c165-44bf-b3fd-7cf21dd561d3″ TYPE=”swap”

In the above example my NTFS drive is /dev/sda and the partition is /dev/sda1 which has the volume label of “Data” and a UUID of 129C05969C05760F. I’m now going to use these three bits of information to create a custom fstab entry for my NTFS partition.

2. Edit /etc/fstab

/etc/fstab is the File System Table and lists all available disk partitions, indicating how they should be initialised on system start-up.

To edit, go to Terminal and enter

sudo nano /etc/fstab

Note: I’ve used nano as my text editor but you could use vi, gedit, kate or any other text editor of your choice.

Because the NTFS Data partition was only being manually mounted, it will not appear in fstab. Based on the information obtained from section 1, enter the following lines before your CDROM drive entries and after you last hard disk entry as follows:

# NTFS ~ Use ntfs-3g for write access (rw)

# /dev/sdc1

UUID=129C05969C05760F /media/Data ntfs-3g auto,users,uid=1000,gid=100,dmask=000,fmask=111,utf8 0 0

The items in red are the resuts of the commands entered in section 1 and will need substituting with your own results.

Save the edited fstab file.

You can now either reboot, but as this is not Windows you can just reload your fstab file by entering the following to mount all devices listed:

mount -a

Your NTFS volume will now be auto mounted and you will no longer need to put in a password to access the volume.

3. Fixing Samba file sharing for NTFS partitions

Normally, you can change folder/ file permissions either by right clicking on the file/ folder and clicking properties and then selecting permissions or by using the chmod +o rwx command in terminal, at least if you are using ext2, 3 or 4 file systems which are native to Linux/ Unix. Unfortunately, neither method works for NTFS partitions and therefore they are not accessible over a network as a share!

However, if you are using ntfs-3g (which we are in the above example), all is not lost!

In the FSTAB community documentation (see Sources below) it says the following:

“ntfs/vfat = permissions are set at the time of mounting the partition with umask, dmask, and fmask and can not be changed with commands such as chown or chmod.

  • I advise dmask=027,fmask=137 (if you user umask=000 all your files will be executable). More permissive options would be dmask=000,fmask=111. “

So to enable more permissive access we need to change the dmask and fmask settings in fstab from the restrictive

dmask=027,fmask=137

to

dmask=000,fmask=111

Save the modified file and reboot.

Network users will now have access to shared ntfs files/ folders on that partition via your Linux PC.

Sources

I used the following sources to put together this article:

http://ubuntuguide.org/wiki/Ubuntu:Karmic#Mounting_NTFS_Partitions_.28with_read.2Fwrite_privileges.29

https://help.ubuntu.com/community/Fstab

*This is one of the few PCs I still have running Windows XP.

=-=-=-=-=
Powered by Bilbo Blogger

Advertisements

One thought on “Auto mounting NTFS disks and making them accessible over a network

  1. I added:

    # NTFS ~ Use ntfs-3g for write access (rw)

    # /dev/sdc1

    UUID=129C05969C05760F /media/Data ntfs-3g auto,users,uid=1000,gid=100,dmask=000,fmask=111,utf8 0 0

    to the /etc/fstab and saved (without quotes, and changing my information in red) but when I tried mount -a I get this:

    “mount: only root can do that”

    Please help!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s