| By Richard Sharpe | Article Rating: |
|
| January 23, 2001 12:00 AM EST | Reads: |
86,983 |
(LinuxWorld) -- Anyone who uses both Linux and Windows knows the problem. You need a couple of files that are on the Windows partition, but you forgot to copy them to a floppy or to the server before rebooting to Linux. Wouldn't it be great if you could just access those files from Linux, you think, as you prepare yourself for two more reboots.
As it turns out, there are a number of ways to solve that problem. You can mount your Windows partitions under Linux and you can access your ext2 filesystems under Windows. You can also access Linux (and Unix) servers from Windows via Samba and you can even mount Windows filesystems under Linux using smbmount. We will look at each of these methods below.
But there are more solutions on the horizon. The folks at Caldera have funded me to write a Samba client library. Please see the Resources section for more details. That library allows Linux and Unix systems to access Windows resources from within programs. Parts of the library already are available in the Samba CVS tree, and once the library becomes more generally used, programs like Midnight Commander and others should be able to browse the Windows systems on your network.
Accessing Windows files from Linux
There are plenty of Windows filesystems to worry about. There is the plain old DOS system with its 8,3 filenames. There is the long filename support introduced with Windows 95. There is the FAT32 file system introduced with the latter versions of Windows 95 and Windows 98 (known as VFAT filesystems). Finally, there is the NT filesystem, or NTFS.
Linux has been able to access MS-DOS and VFAT filesystems for quite some time. Read-only access to NTFS partitions has also been available for a while. In the past, you got NTFS support by downloading a driver that provided read-only access to NTFS partitions. Since Linux 2.2.x, however, read-only and read-write NTFS support has been a standard part of the kernel (albeit still considered experimental).
Unfortunately, that means it is not as easy to access Windows partitions under Linux as it is under Windows: You must first mount the partitions in order to access them. For example, if your hard disk is partitioned in the following way:
/dev/hda1 -- Windows 9x filesystem
/dev/hda2 -- Linux swap partition
/dev/hda3 -- Linux root filesystem
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.
Listing 1: 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.
Listing 2: listing files on a Win98 partition mounted as MS-DOS
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.
Listing 3: a modified fstab file
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. You can mount floppies in just the same way as you might a Windows partition on your hard disk:
mount -t vfat /dev/fd0 /mnt/floppy
Indeed, with modern Linux distributions, you can leave out the -t vfat and Linux will figure out the correct type. Another useful shortcut is to simply type mount /dev/fd0, because the Linux mount command can retrieve the rest of the information needed to mount the floppy from /etc/fstab. For more information about the mount and umount commands see man mount and man umount, respectively.
I don't know about you, but I get very tired of having to mount floppies just to access the files on them. You also have to remember to umount the floppy when you have finished using it and want to use another floppy.
Fortunately, the mtools package, which installs with many Linux distributions these days, contains a series of commands that eliminates all this mounting and umounting of floppies. It contains a series of commands for dealing with MS-DOS formatted floppies including mdir to list the files on a floppy, mcopy to copy files to or from floppies, mdel, and so forth. Those commands are the same as the MS-DOS commands to manipulate floppies with an "m" added to the front of each command. You may have to install the mtools package from your installation CD. Under Red Hat 7.0, the package to install is mtools-3.9.7-3.i386.rpm.
Listing 4 shows an example of using commands from the mtools package to list the contents of a floppy and copy files from the floppy to the user's current directory. For more information about the mtools package, try man mtools.
Listing 4: using mtools commands
If you have a mixed network of Windows and Linux systems, you may want to mount file systems from your Windows systems on your Linux machine. You can do that with the smbmount command, but since smbmount command is called from the mount command, it is just as easy to use mount.
Listing 5 shows an example of mounting the C drive from my Windows 95 system running under VMware as /mnt/win9x. For more information on smbmount, see man smbmount.
Listing 5: mounting C: from VMware
Accessing Linux files from Windows
I have no doubt that most of us need access to Windows filesystems from Linux, but many of us also need access to our Linux filesystems under Windows from time to time. There are a couple of ways to do that depending on your circumstances.
If you are on a network and want to access files on a Linux server from your Windows machine, Samba is the ideal solution. It looks very much like the Windows NT server and provides access to files on your Linux server from Windows systems. See Resources for more information on Samba.
You might also want to access a Linux ext2 partition on your machine from Windows if you have a dual-boot setup. Fear not, as there are also ways to do that. There are a number of approaches to access your ext2 filesystems from Windows. Those include LTools (for DOS and Windows 3.x, 9x, and NT), explore2fs (for Windows 95 and Windows NT), FSDext2 (for Windows 9x) and ext2fsnt (for NT). All of them are discussed in the Filesystems HOWTO (see Resources), which contains links to download each of the tools.
Each of those operates in different ways. For example, FSDext2 and ext2fsnt provide device drivers that access ext2 partitions on the Windows machine with standard Windows commands and tools. LTools and explore2fs provide commands that explore your ext2 partitions from Windows. Unfortunately, FSDext2 provides read-only access to your ext2 partitions, though the all the others provide read-write access.
FSDext2 is very easy to install under Windows 9x. Simply extract the files, run the install batch file, reboot (yes, Windows requires many reboots), and then mount your filesystem as a drive letter. Figure 1 shows an example of listing the files on an ext2 partition, while Figure 2 shows how to use the mount command to unmount and then mount an ext2 partition to drive L:.


For more information on that subject, see the Filesystems HOWTO (see Resources for a link).
The future
Some people will always need to access filesystems from different operating systems, whether MS-DOS or VFAT from Linux, or ext2 from Windows. So the tools we discussed will prove useful to those people. However, more and more people live in a networked world where they have a mixture of Linux and Windows systems available, and they would like to browse resources on all systems in the network.
While smbclient from Samba can provide that ability, it is a command line-oriented tool, and many people would like a GUI tool for browsing the network and looking at files on Windows systems. The KDE package Konqueror can do that, but it is based on a C++ library for accessing Windows and Samba systems. The library is no longer supported, which makes it hard for non-C++ programs to access Windows systems.
However, as I mentioned above, Caldera has funded the development of a new Samba client library, to be written in C. Once that library is released in final form (some code has already been released), developers should find it much easier to integrate access to Windows systems into their applications. The library will include a GTK+ test program that could serve as a starting point for developers who want access to Windows systems.
Finally, while it promises to get easier and easier to access Windows systems from Linux, and you can already access Linux systems from Windows, there will always be a need, by some people, to use the tools mentioned in this article.
Published January 23, 2001 Reads 86,983
Copyright © 2001 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Richard Sharpe
Richard Sharpe, is an active open source software contributor to Ethereal and other projects, and a member of the Samba Team. He has used Linux since about 1993 and teaches a Linux systems administration course of his own creation around Australia.
![]() |
amit singh 02/28/05 11:45:55 PM EST | |||
dear sir, I m working in a leading IT company. my query is , how can we access the windows files from linux and vice-versa over LAN network . Thanks |
||||
![]() |
Gopi.M 02/19/05 12:25:45 AM EST | |||
sir, Thanks, |
||||
![]() |
vijayakumar.c 01/25/05 01:57:50 AM EST | |||
dear sir, Note: e-mail address: cvk_30@yahoo.co.in |
||||
![]() |
nithin 06/25/04 10:10:39 AM EDT | |||
plz mention how to mount a file from winxp to linux . |
||||
![]() |
s sarkar 04/15/04 10:10:44 AM EDT | |||
how to access windows files from Nautilius in linux? |
||||
![]() |
NZheretic 11/14/03 05:21:41 AM EST | |||
One solution for dual booters is to access Ext2 or Ext3 on Win98/ME/NT/2K/XP with Paragon's Ext2FS Anywhere. http://www.ext2fs-anywhere.com/ The full 2.5 version was free with the September 2003 issue of Australian Personal Computer (APC) magazine. |
||||
![]() |
Marek 11/14/03 04:15:12 AM EST | |||
My idea is to access Microsoft Office and/or OpenOffice.org files from both OS's. vfat seems to be OK, but it is necessary from Linix side use root access rights, so it is not user friendly. |
||||
- Ulitzer News: Search vs New Media
- Publishing Synergy: Blog, Twitter and Ulitzer
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- GovIT Expo Highlights Cloud Computing
- Confessions of a Ulitzer Addict
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- My Thoughts on Ulitzer
- Ubuntu-based Open Source Linux Mint Tests KDE Version
- Oracle-Sun: IBM Reportedly Behind Delay
- Ulitzer Aid Campaign for the Typhoon Ondoy Victims
- Cloud Computing Can Revitalize Your Career as Software Developer
- Virtualization Journal "Readers' Choice Awards" Voting Is Now Open
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Practical Approaches for Optimizing Website Performance
- 1st Annual GovIT Expo: Letter from the Technical Chair
- Ulitzer News: Search vs New Media
- Publishing Synergy: Blog, Twitter and Ulitzer
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- GovIT Expo Highlights Cloud Computing
- Confessions of a Ulitzer Addict
- Twitter, Linked In, Ning and Ulitzer: Easy Personal Branding Strategy
- The End of IT 1.0 As We Know It Has Begun
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- The i-Technology Right Stuff
- Linux.SYS-CON.com Exclusive: Linus Discloses *Real* Fathers of Linux
- After Ubuntu, Windows Looks Increasingly Bad, Increasingly Archaic, Increasingly Unfriendly
- Linus' Top Ten SCO Barbs
- A Closer Look at Damn Small Linux
- Netscape Co-Founder's 12 Reasons for Growth of Open Source
- Introducing "Cooperative Linux" - Linux for Windows, No Less
- *POINT - COUNTERPOINT SPECIAL* What's Wrong with the Open Source Community?
- Where Are RIA Technologies Headed in 2008?
- Linux.SYS-CON.com Exclusive: What Would UserLinux Look Like?
- i-Technology Viewpoint: The New Paradigm of IT Buying
- Is Linux Desktop-Ready Yet...or Not?
































