Linux-Windows file access

By Richard Sharpe, LinuxWorld.com |  Networking, Linux




and you want to mount the Windows partition under /mnt/windows, use the command mount /dev/hda1 /mnt/windows.


Note that there is no need to specify a filesystem type (such as mount -t vfat /dev/hda1 /mnt/windows) because the mount command tries to mount the filesystem as VFAT before it tries MS-DOS.


After executing the above command, you can explore your Windows partition using any Linux command you want. You can read or write files on your Windows partition, and you can edit them using editors like vi and Emacs. Listing 1 shows an example of listing the files on your Windows partition.


However, if you get a detailed listing on your Windows partition, you may notice that the files in the partition have some interesting properties. For one thing, the user and group of the person who mounted the filesystem owns all of them. That person may be root. That happens because Windows 9x has no concept of user and group owners of files.


Linux can mount both MS-DOS and VFAT filesystems. When you issue the mount command, simply use msdos rather than vfat:


mount -t msdos /dev/hda1 /mnt/win98


That will mount the partition, but you will see only MS-DOS-style filenames. Listing 2 shows an example of listing files on a Windows 98 partition after it has been mounted as an MS-DOS filesystem.


You can mount an NTFS partition in a similar fashion. Assuming that your NTFS partition is located on /dev/hda1, simply enter the following command:


mount -t ntfs /dev/hda1 /mnt/win98


Of course, manually entering those mount commands can get a bit tiresome if you swap between Windows and Linux frequently, so you might like to add an entry in the file /etc/fstab to automate the process. Simply add a line like the following to /etc/fstab to automatically mount your Windows 9x partition at boot time:


/dev/hda1 /mnt/windows vfat defaults 00


Listing 3 shows an example of what your fstab file might look like with this new entry added.


You also might want to access VFAT devices to use floppies. Floppies are quite convenient for moving files between systems, and they are almost always in DOS format, rather than say, ext2 format.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Spotlight on ...
Online Training

    Upgrade your skills and earn higher pay

    Readers to share their best tips for maximizing training dollars and getting the most out self-directed learning. Here’s what they said.

     

    Learn more

NetworkingWhite Papers & Webcasts

See more White Papers | Webcasts

Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Ask a Question
randomness