Saturday, January 27, 2007

Mounting external ntfs partitions using ntfs-3g

When you use removable media you probably want to mount it always to the same mount point regardless of its physical dev node location which can can change depending on the order you connect the devices or the slot you connect them to. This is where LABEL/UUID fstab options come in handy.

So, instead of a fstab entry like this:

/dev/sda5 /mnt/FOTO_BCKP ntfs defaults 0 0

you make an entry like this:

LABEL=FOTO_BCKP /mnt/FOTO_BCKP ntfs defaults 0 0


But if, instead of a default ntfs driver, you want to use a new ntfs-3g driver, there's a small problem: ntfs-3g, at the time of writing this, doesn't support LABEL or UUID options. A nice workaround, which I found here is to use /dev/disk/by-label/:

/dev/disk/by-label/FOTO_BCKP /mnt/FOTO_BCKP ntfs-3g defaults,user 0 0

To check labels or uuids, connect your media and simply list /dev/disk subdirectories:

ls -l /dev/disk/by-label/
ls -l /dev/disk/by-uuid/


To set the ntfs partition's label use `ntfslabel` from ntfsprogs package.

2 comments:

Anonymous said...

To make blog entry more complete, you could write, how to check and set uuid. And, there might be another approach to this problem - editing udev entreies. But this one seems to be simple and elegant.

banshee said...

Consider it done :-)