Senin, September 29, 2014

How to NTFS Partition Accessible by All Users on Raspbmc

After installing Raspbmc on my Raspberry Pi, I just found out that whenever I plug any USB disk (USB flash disk or external hard disk) with NTFS partition, all files and directories within this partition only accessible by root user. Partition with ext format such as ext3 and ext4 can be mounted normally without any file permissions issue.
Here are sample of my root directory content from my NTFS partition:
-rw------- 1 pi   pi   4.0K Dec 12  2012 ._.TemporaryItems
drwx------ 1 pi   pi      0 Aug 29 21:42 .Trashes
drwx------ 1 pi   pi   8.0K Sep 18 20:48 .
drwx------ 1 pi   pi      0 Sep 18 20:48 .AppleDouble
drwx------ 1 pi   pi    44K Sep 27 05:11 Movies

It’s not funny whenever I want to access my files, I should switch to root at first. So, after some searching on internet, I found several useful articles which can help me solve this issue.

Raspbmc uses udisks-glue daemon to perform auto mount partition whenever you plug any USB disk. Your USB disk partition will be automatically mounted at /media directory. So, if you have an external hard disk with two partitions, one have label: Movies and another one: Music, these partition will be auto mounted and accessible on /media/Movies/ and /media/Music/ when you plug it.

What I learn from several articles I found on internet is, this udisk-glue daemon is not run as root at start up. Second, user’s permission on NTFS partition is different from ext partition. Since Unix or Raspbmc uses ext partition format, when you plug USB disk with ext3 or ext4 partition, you will be able to read or write to any files or directory within the partition as long as you have the permission (for example you can read and write to any file which belong to you or any file which r and w permission). However this mechanism will not apply to NTFS partition which is not supported natively by Unix. So whenever you plug NTFS partition, Raspbmc will mount the partition using default permission: read and write permission to the owner (for this case the owner is pi user). Other user will not be able to read or write any files within this partition.

So, how to make NTFS partition accessible to other users? First, you need to change default setting on udisk-glue configuration, which can be found on: /etc/udisk-glue.conf. Change dmask and fmask value to “0000” to set all files and directories permission to read, write, and execute which apply to owner, group, and other user. The /etc/udisk-glue.conf should be looked like following:

filter disks {
    optical = false
    partition_table = false
    usage = filesystem

match disks {
    automount = true
    automount_options = { sync, noatime, "dmask=0000", "fmask=0000” }

Second, udisk-glue daemon must be run as root user. To do this, modify /etc/init/udisk-glue.conf. Replace exec su - pi -c “udisks-glue” to exec udisks-glue. So the content of /etc/init/udisk-glue.conf should be looked like following:

# udisks-glue

description "udisks-glue for udisks"

start on started dbus

stop on (runlevel [06] or stopped dbus)

expect fork

exec udisks-glue

You need to be root to modify /etc/udisks-glue.conf and /etc/init/udisks/glue.conf.

After modifying the files, restart your Raspberry Pi to take the effect. Now, whenever you plug any NTFS partition, it will be accessible by other users.


2 komentar:

  1. Thanks! I also want to make sure my NTFS drives are mounted to a relative path instead of using the drive label. I would expect /media/usb0 for the first drive or partition, /media/usb1 for the second etc. Do you have any idea how to do this?

    Also, to get the best speed with NTFS drives on Linux, I always learned to use these options:

    How to do this with udisk-glue?? I have no idea where these options are defined (I am used to fstab).

  2. Hi, can u help me please, how i can use ntfs-3g mount options, 4 ex: "big_writes", when i include it at automount_options section udisks-glue not mount any storage, i used like with/out "", but it not works