|
SYS-CON.TV Webcasts
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Top Links You Must Click On
Networks & connectivity Linux-Windows file access
How to access Windows files from Linux and vice-versa
By: Richard Sharpe
Jan. 23, 2001 12:00 AM
(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 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 LinuxThere 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:
and you want to mount the Windows partition under /mnt/windows, use the command Note that there is no need to specify a filesystem type (such as 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
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
Of course, manually entering those
Listing 3 shows an example of what your Listing 3: a modified 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:
Indeed, with modern Linux distributions, you can leave out the 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 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 Listing 5 shows an example of mounting the C drive from my Windows 95 system running under VMware as Listing 5: mounting C: from VMware
Accessing Linux files from WindowsI 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
For more information on that subject, see the Filesystems HOWTO (see Resources for a link).
The futureSome 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. Reader Feedback: Page 1 of 1
Your Feedback
Enterprise Open Source Magazine Latest Stories . . .
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||