Tuesday, September 16, 2008

Share Partitions Between Linux and Windows HOWTO

Disclaimer: This document is provided "as is" without warranty. Use at your own risk. In no event shall I be liable for any damage resulting from the use of this work.

So you have Linux and Windows installed on the same machine. What is the best way to access and transfer files between the OSs? That is, how do you make the same filesystems and files accessible when you are running either OS?

There are some considerations to note:

  • Linux supports Windows types of partitions (e.g. FAT, FAT32, etc), but
  • Windows does not recognize Linux types of partitions (e.g. ext2, ext3, etc)

A common solution is to mount the Windows partitions (e.g. C:) in Linux. However, this can be very dangerous. You could inadvertently damage critical system files for Windows while logged into Linux. If you mount the Windows partitions read-only, then access only works in one direction; you can see Windows partitions in Linux, but you have no way of transferring files from Linux to Windows.

In my opinion, sharing key partitions or filesystems is not a clean solution. The OSs should know as little as possible about each other. With the dual-boot setup I use, Windows only knows about Linux to the extent that I made a 1-line edit to C:\boot.ini and copied a 512-byte GRUB boot loader file to C:\. Other than that, Windows can't see any of the Linux partitions and Linux can't see the C: partition.

Recommended Solution

I recommend creating a separate partition that is accessible to both Windows and Linux. I'll refer to this as a "share" partition. It must be of type FAT32 (same as vfat) or FAT to be accessible and writable by both OSs (NTFS is not yet an option as Linux does not support writing to NTFS partitions). To make the share partition visible and writable by both OSs, do the following:

  1. Create a FAT32 partition that you want to be visible by both OSs. I don't explain how to do that here. I believe you can create the FAT32 partition in Windows using Start->Run->Administrative Tools->Computer Management->Disk Management. Many Linux installation programs (e.g. Red Hat) allow you to create FAT32 partitions during the installation process.
  2. For Windows, you don't have to do anything to make the FAT32 partition accessible. The OS will automatically detect it and assign it a drive letter (e.g. E:)
  3. For Linux, do the following steps to make the FAT32 partition accessible:
    1. Create the directory that serves as the mount point (e.g. mkdir /osshare). The mount point is the location in the filesystem where you want this FAT32 partition to appear.
    2. Put an entry in the /etc/fstab file for the share partition. Be very careful in editing this file, as it's used at system startup! For an example, check out the /osshare entry in my /etc/fstab file. The umask option determines the permissions for all filesystems on the partition.
    3. Upon your next reboot into Linux, the share partition should get mounted automatically. If you wish to mount the FAT32 partition immediately, use the mount command, e.g.: mount /osshare

Once you've set up your share partition, you can use it for transferring files between the OSs. For example, I found this invaluable for downloading RPMs while logged into Windows before I managed to get the Winmodem working for Linux.

Things to keep in mind for your share partition:

  • It's of type FAT32, so Linux functionality such as symbolic links won't work on it

hii welcome Everyone

I have created this blog in order to help everyone who are new to linux...

So Enjoy with Linux...

Happy Surfing
Regards
v2