个人工具

UbuntuHelp:MountingWindowsPartitions

来自Ubuntu中文

Wikibot讨论 | 贡献2010年5月19日 (三) 23:27的版本

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航, 搜索


IconsPage?action=AttachFile&do=get&target=IconSambaShares.png Ubuntu is capable of reading and writing files stored on Windows formatted partitions. These partitions are normally formatted with NTFS, but are sometimes formatted with FAT32. You will also see FAT16 on other devices.

File System Differences

IconsPage?action=AttachFile&do=get&target=info.png For a more in depth analysis, see LinuxFilesystemsExplained, but here are some basics:

  • Windows Vista, XP, 2000, older NT systems, and Windows Server 2003 and 2008 are formatted with NTFS.
  • Older versions of Windows like Windows ME, 98, and 95 are formatted with FAT32.
  • Flash drives, like your USB thumb drive or your camera's flash card are typically formatted as FAT16.

In Windows, you can check what your partition is formatted as by right-clicking the partition in Windows Explorer and selecting Properties. In Ubuntu, run from terminal:

sudo fdisk -l

NTFS Partitions

The ntfs-3g driver is used in linux to read and write NTFS partitions. IconsPage?action=AttachFile&do=get&target=IconDisks.png NTFS (New Technology File System) is a file system developed by Microsoft and used by Windows computers (Windows 2000 and later). Until 2007, linux was not able to write to this type of filesystem, it could only read from it. The stable ntfs-3g driver now allows linux systems to read and write NTFS formatted partitions. The ntfs-3g packages comes pre-installed in currently supported versions of Ubuntu and most NTFS devices should work out of the box without further configuration.

Automatic Configuration

The ntfs-config application is a simple GUI configuration tool for those that find they need to enable/disable NTFS capabilities.

Installing ntfs-config

Click here to install the ntfs-config package (the Universe repository must be enabled). Alternatively, you can search for "ntfs-config" in Synaptic or install via terminal:

sudo apt-get install ntfs-config

Using ntfs-config

IconsPage?action=AttachFile&do=get&target=navigate.png Launch NTFS Configuration Tool from Applications->System Tools, or via the terminal:

gksudo ntfs-config

MountingWindowsPartitions?action=AttachFile&do=get&target=ntfs-config.png If you have at least one internal NTFS partition, it will allow you to check both boxes, otherwise you can only check the box for external devices. If your NTFS partition(s) are not yet configured, it will ask you to choose a name that will be used as the mount point (please no spaces). Then enable write support for internal and/or external devices.

Manual Configuration

IconsPage?action=AttachFile&do=get&target=IconGNOMETerminal.png First you need to find the device location of the NTFS partition(s) you want to mount. In terminal, run:

sudo fdisk -l | grep NTFS | awk '{print $1}'

The name of each partition should be something like /dev/hdxn or /dev/sdxn, where x is an alphabetical letter (ranges from a to z) and n is a number (e.g. /dev/hda1). If the drive is internal, you will now need to edit your file systems table configuration file, /etc/fstab. If the drive is an external USB or firewire drive, hal should automount it. Now, be sure to save a backup of fstab first, then open the file for editing:

sudo cp /etc/fstab /etc/fstab.orig
gksudo gedit /etc/fstab

After entering your password, find the line that matches the device location you just found and change it to the following. If there is no entry yet, add a new line like the following:

<your partition> /media/<mount point> ntfs-3g defaults,locale=en_US.utf8 0 0

NOTE: If it displays your NTFS partition with a UUID, you can check the relevant device location by running one of the following commands. It is OK (and even advisable) to keep the UUID setup if that is what already exists.

sudo blkid
ls -l /dev/disk/by-uuid/

Replace <your partition> with the name of the partition you identified earlier. Replace <mount point> with the location you would like the partition to be mounted at, so you have something like /media/windows or /media/documents for that column. Note: you can also change your locale option (ex: locale=fr_FR.utf8). Execute locale -a in a terminal to know which ones are supported on your system. Save and close the file. You will now need to create the mount point for each NTFS partition before you can actually mount them:

sudo mkdir -p /media/<mount point>

Now remount each partition with

sudo umount <your partition>
sudo mount -a

If you want to revert to your previous configuration, run:

sudo mv /etc/fstab.orig /etc/fstab
sudo umount /media/<mount point>

Known Issues

IconsPage?action=AttachFile&do=get&target=stop.png The present limitations of this driver are:

  • writing files encrypted or compressed at the filesystem level (does not include .zip, .gz, .rar files since they are compressed on the file, not the file system level)
  • changing NTFS file ownership and access rights

Custom Kernel

It is unknown if this issue still exists. Please remove this line if you can confirm that it does. If you compiled your own kernel, you probably will not have fuse installed. You can get the source with

sudo apt-get install fuse-source

and have a look at /usr/share/doc/fuse-source/README.Debian for instructions on how to compile it.

FAT32 and FAT16 Partitions

The vfat driver is used in linux to read and write FAT32 and FAT16 partitions. IconsPage?action=AttachFile&do=get&target=terminal.png To mount a FAT partition from terminal, first locate the device you want to mount using the fdisk command above, create the mount point, then use the mount command.

Generic Template

IconsPage?action=AttachFile&do=get&target=example.png Here is the format for mounting a FAT formatted device:

sudo mkdir <mount_point>
sudo mount -t vfat -o defaults,user,exec,uid=1000,gid=100,umask=000 <device> <mount_point>

Solid Example

IconsPage?action=AttachFile&do=get&target=IconExample48.png Let's say that using the fdisk command reveals that you want to mount /dev/sdb1 - run:

sudo mkdir /media/fat_partition
sudo mount -t vfat -o defaults,user,exec,uid=1000,gid=100,umask=000 /dev/sdb1 /media/fat_partition

Mounting at Boot

IconsPage?action=AttachFile&do=get&target=IconComputer.png To mount a partition automatically at boot time, you will need to add an entry to /etc/fstab - for more information on that, see Fstab. For an example of adding a FAT partition, see Section 2.1: "More Examples of Entries" on that page. The first example there uses the same options as above, and tends to work best for most users. That page has information on Editing fstab, so you just want to add a new line for your FAT partition if an entry does not already exist. Don't forget to mount all the entries in /etc/fstab after you edit the file, save and close it. This can be achieved simply by running:

sudo mount -a

Other Resources

IconsPage?action=AttachFile&do=get&target=IconBook-small.png