Wednesday, November 01, 2006

Debian HOW-TO : Writing to NTFS

Last revision : April 29th, 2007


On July 14th, Szakacsits Szabolcs, a developer for the Linux-NTFS project published a major update of the Linux NTFS driver. It is now possible to write to an NTFS partition in a safe manner.

I've tested it for months now and I have yet to report any issue. In fact, I have had more troubles with the old NTFS driver which allowed read-only operations on NTFS partitions. On February 21th, 2007, the first stable release of NTFS-3G was released as version 1.0.

So here we go...

  • Installation

On Debian Etch


First, download NTFS-3g. 2 packages are needed here: ntfs-3g and libntfs-3g. You can use wget to download them:

wget http://snapshot.debian.net/archive/2007/03/01/debian/pool/main/n/ntfs-3g/libntfs-3g0_0.0.0+20061031-6_i386.deb
wget http://snapshot.debian.net/archive/2007/03/01/debian/pool/main/n/ntfs-3g/ntfs-3g_0.0.0+20061031-6_i386.deb


Then install the dependencies:

sudo apt-get install fuse-utils libfuse2


Finally you can install ntfs-3g (using the 2 Debian packages you just downloaded):

sudo dpkg -i libntfs-3g0_0.0.0+20061031-6_i386.deb
sudo dpkg -i ntfs-3g_0.0.0+20061031-6_i386.deb




On Debian Sid, Ubuntu Edgy or Ubuntu Feisty


No need to download anything, nor to install any dependencies. Simply typing:

sudo apt-get install ntfs-3g


will do the trick.


  • Mounting partitions


Mounting partition is done quite simply. For example, this command (one line):

sudo mount -t ntfs-3g /dev/sda1 /mnt/windows -o umask=0,nls=utf8


will mount a partition (/dev/sda1 in that case, replace with your actual windows partition) on the /mnt/windows directory (which must exist and be empty), using the utf8 character set (for maximum compatibility with foreign languages) and giving read/write/execute permissions to everyone.

Once you have established that this command work fine on your system, you can add an entry for it in /etc/fstab:

/dev/sda1 /mnt/windows ntfs-3g umask=0,nls=utf8 0 0


If you wish, you can unmount that partition in the standard way:

sudo umount /dev/sda1


  • Tips


The output of

sudo fdisk -l | grep -i ntfs

will tell you the location of your windows partition.

28 comments:

Yeom Jaehyun said...

What an elegant work! Thank you so much.

Roman Lagunov said...

Thanks, Hugues.

Very useful HOWTO. All my music laying on NTFS partition, and I cannot edit tags of my mp3 file from inside linux.

From now, I think I will make this work without problem.

Anonymous said...

I'm glad you enjoy it.

Also, I'd like to remind you that you can use the NTFS-3g driver on any Linux distribution as well, even if there is no package avalaible.

Be sure to check the NTFS-3g wiki if that interest you.

Thanks for the feedback!

Anonymous said...

Hi, thanks a lot for you nice blog

I found your blog from KLDP.

Keep up the good work

cheers~~~

EmyrB said...

I too am trying to get write access to an NTFS partition where my music lies, but I dont get any joy with ntfs-3g.

I have downloaded it and I have tested it works by issuing the command ntfs-3g /dev/hda2 /media/hda2 and it works I can write to the partition with no problems. The problem comes with fstab. It doesn't mount the ntfs partition and the only way I can get to it is to either issue the ntfs-3g command or mount -a!

Any help would be really greatful.

Cheers

EmyrB

Hugues said...

I can help you with that no problem, emyrb. But perhaps here is not the best place, as we may have to exchange several "comments" till we find a solution. You can start a thread on www.linuxforums.org and I'll help you there. My username is "antidrugue" there.

Thanks.

Tony Narlock said...

Thank you for the great tutorial. It's nice to have safe NTFS write support now.

Everything in the tutorial worked fine.

Jacques said...

If someone knows how to make NTFS the default driver, especially when gnome/kde automounts external drives...

I tried to find some code parts to modify in /etc/udev or /lib/share/udev, unsuccesfully

I found some examples on how to do this on Ubuntu, but it can't apply to a regular Debian

(I'm running a Debian Etch with gnome).

If someone knows, thank you

Hugues said...

Hi Jacques,

There is a neat utility called NTFS-config which does exactly that (help you automount external NTFS drives as NTFS-3G partitions).

An alternate solution involving hacking the HAL scripts is explained here.

The main issue here is pmount (the automount process uses pmount) which doesn't support well NTFS-3G.

I haven't look too much into that though.

Google seems to be helpful in that matter, even if the results found are not consistent with one another.

Good luck,

Hugues

Anonymous said...

You guys are using Etch?

I'm geting failed dependencies all over my Etch install. :)

Hugues said...

Hi,

I am very sorry for that, I made a mistake and linked to the wrong packages.

It is corrected now.

Thank you for your comment,

Hugues

Anonymous said...

yes - very usefull.

codestar said...

I was looking for a way to make my NTFS hard disc writable. After two days of struggling with permissions in fstab and settings in Samba, I found this article. The instructions where very clear, and it works!

This article is awesome! Thanks.

Anonymous said...

just installed to debian etch. thanks much for the assistance. was basically a copy and paste routine except for the partition location (mine is /dev/hda1).

signed: debian in jamaica

gwaldo said...

Out-Freaking-Standing Tutorial

Much Thanks

#gWaldo

Anonymous said...

i have tried u're tutor but i cannot write ntfs..i don't know where is the problem..can you help me?

Moon Jaguar said...

I was having so muc trouble mounting windows and this works like a charm. Thanks!

I learned one thing though-- after doing a fresh Debian install that I have to boot into XP, let the Disk Check thing do its thing, let it reboot, then select XP from the boot list again, let that load, then boot into Debian and mount the partition to avoid getting that "boot into windows TWICE" error.

Έσάρ Σέβεντιουάν said...

Thank you for the great tutorial! Really good help :-)

Math. said...

Thanks you very much for this useful howto! :)

Math.

TheSionMan said...

Can anyone tell me how to achieve this on debian amd64 please?

Anonymous said...

Good work guys and gals, found this with new Etch installed. will test it hard and feed back results. very many thanks for your efforts.

Anonymous said...

TheSionMan: Use these debs instead:

http://snapshot.debian.net/archive/2007/03/01/debian/pool/main/n/ntfs-3g/libntfs-3g0_0.0.0+20061031-6_amd64.deb
http://snapshot.debian.net/archive/2007/03/01/debian/pool/main/n/ntfs-3g/ntfs-3g_0.0.0+20061031-6_amd64.deb

Anonymous said...

^ Sorry, the URLs got cut off. Just replace "i386" with "amd64" in the links to the deb packages.

Anonymous said...

To anyone coming to this thread: These packages are now included in upstream debian. It would be a bad idea to use these old packages linked here. Just do a "apt-get install ntfs-3g" and you'll be good to go.

Anonymous said...

its not showing up for amd64 debian4r3, and when borrowing another distro's sources.list it bitches about dependencies. (including libc) when trying to install it.

Anonymous said...

I love u ^^ really thanks!!!

chris said...

10x 4 the good job u did

regards

Barefoot Tyler said...

Hey. I am running Debian Lenny and had no problem using ntfs 3g from the default repositories. Great writeup!