Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

How To Use NTFS Drives/Partitions Under Ubuntu Edgy Eft


Normally Linux systems can only read from Windows NTFS partitions, but not write to them which can be very annoying if you have to work with Linux and Windows systems. This is where ntfs-3g comes into play. ntfs-3g is an open source, freely available NTFS driver for Linux with read and write support. This tutorial shows how to install and use ntfs-3g on a Ubuntu Edgy Eft desktop to read from and write to Windows NTFS drives and partitions. It covers the usage of internal NTFS partitions (e.g. in a dual-boot environment) and of external USB NTFS drives.

I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

I have tested this on a Ubuntu Edgy Eft i386 system. If you are on an AMD64 system, have a look here: http://ubuntuforums.org/showthread.php?p=1647295#post1647295

 

2 External NTFS USB Hard Drive

In chapter two I describe how to use ntfs-3g with an external NTFS USB hard drive.

 

2.1 Current State

Before we install and use ntfs-3g, we should find out about the current state of our system. Plug in your external NTFS USB drive and switch it on. Your Ubuntu Edgy Eft desktop should auto-mount it, and you should see a new icon for the external drive on your desktop (my external HDD is called BACKUP):

1

In the file browser you should see the contents of the external HDD:

2

Now open a command line terminal and run

sudo mount

The output should look like this:

/dev/hda1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.17-10-generic/volatile type tmpfs (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sda1 on /media/BACKUP type ntfs (rw,nosuid,nodev,uid=1000,gid=1000,umask=077,iocharset=utf8)

In the last line you see your USB drive, it is of type ntfs and has been mounted to /media/BACKUP. If you try to write to the USB HDD, you should get an error message saying that the drive is read-only.

Now unmount the drive by right-clicking on its desktop icon and choosing Eject from the menu that comes up. After the desktop icon has disappeared, you can switch off the USB HDD. It is important that you choose Eject before switching off/disconnecting the USB HDD because otherwise Ubuntu will copmplain that it cannot mount the drive the next time you plug it in because it was not cleanly unmounted before. Close all applications that are currently accessing the drive (like the file browser) before choosing Eject because otherwise Eject will fail.

2.2 Modify /etc/apt/sources.list

The ntfs-3g packages that we need to install are in an external Ubuntu repository (http://flomertens.keo.in/ubuntu/) therefore we must add deb http://flomertens.keo.in/ubuntu/ edgy main main-all to /etc/apt/sources.list:

sudo vi /etc/apt/sources.list

[...]
deb http://flomertens.keo.in/ubuntu/ edgy main main-all
[...]

Afterwards we update our packages database:

sudo apt-get update

 

2.3 Update pmount

The tool that auto-mounts our USB HDD when we plug it in is called pmount. It uses the normal Linux ntfs driver to mount an NTFS drive, but we want it to use the ntfs-3g driver instead. Therefore we update pmount by installing the pmount package from the repository we’ve just added to /etc/apt/sources.list:

sudo apt-get install pmount

If you see this, please answer with y:

Reading package lists… Done
Building dependency tree
Reading state information… Done
Suggested packages:
cryptsetup
The following packages will be upgraded:
pmount
1 upgraded, 0 newly installed, 0 to remove and 84 not upgraded.
Need to get 74.0kB of archives.
After unpacking 20.5kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
pmount
Install these packages without verification [y/N]?
<– y

2.4 Install ntfs-3g

Next we install ntfs-3g:

sudo apt-get install ntfs-3g

If you see this, please answer with y:

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
fuse-utils libfuse2 libntfs-3g0
The following NEW packages will be installed:
fuse-utils libfuse2 libntfs-3g0 ntfs-3g
0 upgraded, 4 newly installed, 0 to remove and 82 not upgraded.
Need to get 226kB of archives.
After unpacking 659kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
WARNING: The following packages cannot be authenticated!
libntfs-3g0 ntfs-3g
Install these packages without verification [y/N]?
<– y

That’s it already.

 

2.5 Plug In The External NTFS USB Hard Disk

Now we plug in and switch on our external USB HDD again. After a few seconds its icon should appear again on the desktop:

1

In the terminal window, type

sudo mount

to see what our external HDD looks like now:

/dev/hda1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.17-10-generic/volatile type tmpfs (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sda1 on /media/BACKUP type fuse (rw,nosuid,nodev,noatime,allow_other)

As you see, it’s not of type ntfs anymore, but of type fuse which means it has been mounted with ntfs-3g.

Again, you should see the contents of the drive in the file browser which means we are still able to read from the drive:

2

Now let’s check if we can write to it. Open a text editor (e.g. gedit) and write some text:

3

Then save it to your external NTFS USB drive:

4

If all goes as expected, you should see your new file now on your NTFS drive:

5

Again, please don’t forget to right-click the drive icon on the desktop and choose Eject when you want to unmount the drive! Do not disconnect the drive before you have done so! Close all applications that are currently accessing the drive (like the file browser and the text editor) before choosing Eject because otherwise Eject will fail.

 

2.6 Auto-mount Failed…

If auto-mount failed in chapter 2.5 and no drive icon appeared on your desktop, you can try to mount your external drive manually with this command:

sudo pmount-hal /dev/sda1

Please replace /dev/sda1 with your external hard drive. You can find out about it by running

sudo fdisk -l | grep NTFS

The output should look like this:

/dev/sda1               1       48641   390708801    7  HPFS/NTFS

3 Internal NTFS Partition

Chapter three is about using ntfs-3g with an internal NTFS drive (e.g. if you are in a dual-boot environment and want to mount your Windows partition under Linux).

 

3.1 Modify /etc/apt/sources.list

The ntfs-3g packages that we need to install are in an external Ubuntu repository (http://flomertens.keo.in/ubuntu/) therefore we must add deb http://flomertens.keo.in/ubuntu/ edgy main main-all to /etc/apt/sources.list:

sudo vi /etc/apt/sources.list

[...]
deb http://flomertens.keo.in/ubuntu/ edgy main main-all
[...]

Afterwards we update our packages database:

sudo apt-get update

 

3.2 Install ntfs-3g

Next we install ntfs-3g:

sudo apt-get install ntfs-3g

If you see this, please answer with y:

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
fuse-utils libfuse2 libntfs-3g0
The following NEW packages will be installed:
fuse-utils libfuse2 libntfs-3g0 ntfs-3g
0 upgraded, 4 newly installed, 0 to remove and 82 not upgraded.
Need to get 226kB of archives.
After unpacking 659kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
WARNING: The following packages cannot be authenticated!
libntfs-3g0 ntfs-3g
Install these packages without verification [y/N]?
<– y

 

3.3 Find Out About Your NTFS Partition

Next we must find out how our NTFS partition is named. Therefore we run

sudo fdisk -l | grep NTFS

The output should look like this:

/dev/sda1               1       48641   390708801    7  HPFS/NTFS

So our NTFS partition is /dev/sda1 in this example.

 

3.4. Mount The NTFS Partition

Now we can use ntfs-3g to mount our NTFS partition. In this example I want to mount it in the directory /mnt/windows, so we must make sure it exists:

sudo mkdir /mnt/windows

Next we mount our NTFS partition:

sudo ntfs-3g /dev/sda1 /mnt/windows

(Of course this works only if /dev/sda1 hasn’t been mounted before.)

Now open a file browser on your desktop and see if you can access your NTFS drive and save files to it.

 

3.5 Mount The NTFS Partition At Boot Time

Of course we don’t want to mount our NTFS partition manually all the time, but rather have it mounted automatically when the system boots up. To do this, make a backup of /etc/fstab:

sudo cp -pf /etc/fstab /etc/fstab_orig

and then open /etc/fstab:

sudo vi /etc/fstab

and check if there is already an entry for the NTFS partition. If so, modify it, otherwise add a new line like this one:

[...]
/dev/sda1     /mnt/windows     ntfs-3g     defaults,locale=en_US.utf8   0    0
[...]

If you want to use another locale than en_US.utf8, replace it with your preferred locale. You can get a list of all available locales on your system by running

sudo locale -a

The output should be similar to this:

C
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZW.utf8
POSIX

After you have modified /etc/fstab, reboot your system:

sudo shutdown -r now

After the reboot, your NTFS partition should have automatically been mounted to /mnt/windows.

 

  • NTFS-3G: http://www.ntfs-3g.org
  • NTFS-3G on Ubuntu: http://www.ubuntuforums.org/showthread.php?t=217009
  • NTFS-3G on Ubuntu Edgy Eft AMD64: http://ubuntuforums.org/showthread.php?p=1647295#post1647295
  • Ubuntu: http://www.ubuntu.com

Comments

comments