Navigation Advertising

Next post Previous post

Post content

How to see Windows partitions from Linux

Linux

By default, Linux can only see his own partition(s).
But what if you need some data stored on a partition readable by Windows (wich uses an NTFS or FAT filesystem)?

Of course Linux allow you to read the content of both FAT and NTFS partitions, but you have to mount them: I’ll show you how.

A brief prologue is needed: mount a filesystem means that you virtually place the whole partition on a directory under the root directory /, and you specify what the system is allowed to do with it: you can mount a filesystem as read-only, or as writable.

The command is mount, and the syntax is the following:

mount -t filesystem_type device directory [options]

Let’s explain: this command mounts the filesystem found on device (which is formatted with filesystem_type) on directory (properly called mount point) with the specified [options].
Devices are usually listed under /dev; hard disk partitions are identified from the letters hd, followed by the disk order in letters (A for the first disc, B for the second, and so on) and then the number that identifies the number of the partition on the phisycal drive (1, 2, 3…).

Usually, the only options you will need to care about are -ro for read-only and -w for read-write.

Let’s make a practical example.
Say that you want to mount the partition in which is installed Windows XP, that is on /hda2 (then, /dev/hda2 under Linux) and you want to show its content, as read-only, in /mnt/windows. The command for that will be the following:

mount -t ntfs /dev/hda2 /mnt/windows -ro

Now, you can go to /mnt/windows, and you will see your so-called C: disc here. Quite simple, isn’t it?

So, now we know how to manually mount partitions.

How to mount partitions automatically at the system boot?

The key is on this file: /etc/fstab. This file contains informations about partitions and storage devices on your computer. During the boot, Linux reads its instructions and mount filesystems accordingly.
In this file, every row contains informations about a partition. The structure of a row is:

<device> <mount point> <type> <options> <dump> <check>

Let’s explain:
Device is your device (/dev/hda2 accordingly to the previous example), mount point is the directory where you will see your data, type is the filesystem (e.g. “ntfs” for windows), options have to be comma-separated (I will return on them in a moment), dump and check refers, respectively, to “do you want a backup of this” and “do you want the system to check this disc”. Both these values can be 0 or 1, respectively for True or False. If you’re mounting a Windows partition, leave 0 for both.
Options: they are almost the same allowed for mount command. When mounting a Windows unit, the only really useful options are: ro (or rw, respectively for Read-only and Read-write), and user (or nouser: default is nouser, and if you don’t change this to user, the system will not mount your device unless you are logged in as root).

Going on with the example, a row in /etc/fstab that will automatically mount the Windows XP partition found on /dev/hda2 in /mnt/windows as read-only, would look as the following:

/dev/hda2 /mnt/windows ntfs ro,user 0 0

Now, every time you boot, you will able to read contents from C: into /mnt/windows!

If you wish, you can read a more extensive documentation on fstab.

NOTE ON WRITING ON WINDOWS PARTITIONS: Linux support to write mode in NTFS partitions is experimental, and depending on the distribution in use. This means that write to NTFS from Linux could lead into unrecoverable errors. Use it at your own risk!

REMEMBER: default option in fstab (if you are going to use it instead of the suggested ro,user) mounts the filesystem with write privileges.

Bookmark:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • digg
  • del.icio.us
  • blogmarks
  • co.mments
  • NewsVine
  • Furl

Related articles

Other posts filed under Linux

Comments and trackbacks

Add your comment:

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>