1 Comment

Mounting a Windows NTFS Partition as a Regular User (Ubuntu)

To be able to mount a Windows NTFS partition in Linux as a regular user (e.g. mount /dev/sda1 /mnt/Windows), rebuilding the driver with internal FUSE (Filesystem in USErspace) support is required, and then setting correct permissions is needed.

Download and Compile

First setting a couple variables eases the process:

blddir=~/Downloads/build      # A good place to do compiling
pkgname=ntfs-3g               # The package/driver name

Here the package version variables defined to match the actual extracted package source namings (why 1: gets prepended and 2ubuntu3 gets appended I’m unsure of):

pkgname_ver=$(dpkg -l | grep ^[i,h]i | awk '{print $2"_"$3}' | grep $pkgname | sed 's/1://')
PKGNAME_VER=$(echo $pkgname_ver | sed 's/\(.*\)-.*/\1/')

Note: Theoretically this should not be needed if you use udisks2. Unfortunately it looks like no one has found out how to use udiskctl yet.

Install the compiling (building) programs and then packages need to build ntfs-3g:

sudo apt-get install build-essential fakeroot dpkg-dev lynx devscripts
sudo apt-get build-dep $pkgname

Create the building directories and change to it’s directory:

[ ! -d "$blddir" ] && mkdir -p "$blddir"
cd "$blddir"
[ ! -d "$pkgname" ] && mkdir "$pkgname"
cd "$pkgname"

Download the source code (which gets extracted after downloading):

apt-get source "$pkgname"

The source code is oddly owned by root, to make it editable change it’s permissions:

sudo chown -R username:username .

Entering the source code directory (required to build):

cd "$PKGNAME_VER"

Change the FUSE option to internal, comment the change, then compile:

sed -i 's/--with-fuse=external/--with-fuse=internal/g' debian/rules
dch -i "Changed fuse option to internal in configuration rules"
dpkg-buildpackage -rfakeroot -b

Replace the current NTFS-3G driver with the one just compiled with internal FUSE support:

sudo gdebi ntfs-3g_2011.4.12AR.4-2ubuntu3_i386.deb

And hold (freeze) the package so it doesn’t get updated with a new version on a system update:

echo ntfs-3g hold | sudo dpkg --set-selections

The driver will need to be set to setuid-root (there are risks doing this, read this for more information):

sudo chown root $(which ntfs-3g)
sudo chmod 4755 $(which ntfs-3g)

Finally, give the user the ability to be able to mount volumes:

sudo gpasswd -a username disk

Reboot to have the new driver loaded and the user to be put in the disk group.

Mounting

The fstab will need to have the right options to be able to mount as a regular user. In my next post, I’ll show what my fstab looks like.

Bug Fix

I had a problem with gcc-4.6_4.6.1 on my install. It would error out at the beginning of a compile. The workaround for me was to use an earlier version of GCC and then define it when compiling:

sudo apt-get install gcc-4.4
CC=gcc-4.4 dpkg-buildpackage -rfakeroot -b

Resources

About these ads

About Todd Partridge (Gently)

Good times, good people, good fun.

One comment on “Mounting a Windows NTFS Partition as a Regular User (Ubuntu)

  1. This is a great great, very informative. Thanks

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

Follow

Get every new post delivered to your Inbox.

Join 52 other followers

%d bloggers like this: