Welcome!

Linux Containers Authors: Elizabeth White, Zakia Bouachraoui, Liz McMillan, Yeshim Deniz, Pat Romanski

Related Topics: Linux Containers

Linux Containers: Article

Linux-Windows file access

How to access Windows files from Linux and vice-versa

(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:.

Listing the files on an ext2 partition

Mounting 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.

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.

Comments (7) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
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 .
plz sent solution to my problem.I have to do it
plz sent e-mail to me @ : [email protected]

Thanks
AMIT

Gopi.M 02/19/05 12:25:45 AM EST

sir,
i m working in HCL Infosystems Limited.my query is how to access the FAT and NTFS files from windows platform,what is the samba server & its use.please send me the answer as quick as possible.

Thanks,
GOPI.M

vijayakumar.c 01/25/05 01:57:50 AM EST

dear sir,
I am working in sona college of technology.we are
install linux os with win2000 and winxp with ntfs file system.Some student ask that we want access windows file from linux and how install software in linux then how remove
that installed software.Then few students forgot root passwd.how way go to root.Please sent solution to my problem.I neet ftp server install configuration,samba server
configuration,squid and also named service configuration.
Please sent e-mail to me.

Note: e-mail address: [email protected]

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.
What is the reason for poor access to NTFS from Linux? rw, of course.

IoT & Smart Cities Stories
DXWorldEXPO LLC announced today that Telecom Reseller has been named "Media Sponsor" of CloudEXPO | DXWorldEXPO 2018 New York, which will take place on November 11-13, 2018 in New York City, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities - ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups.
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, will provide an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life ...
Chris Matthieu is the President & CEO of Computes, inc. He brings 30 years of experience in development and launches of disruptive technologies to create new market opportunities as well as enhance enterprise product portfolios with emerging technologies. His most recent venture was Octoblu, a cross-protocol Internet of Things (IoT) mesh network platform, acquired by Citrix. Prior to co-founding Octoblu, Chris was founder of Nodester, an open-source Node.JS PaaS which was acquired by AppFog and ...
The Founder of NostaLab and a member of the Google Health Advisory Board, John is a unique combination of strategic thinker, marketer and entrepreneur. His career was built on the "science of advertising" combining strategy, creativity and marketing for industry-leading results. Combined with his ability to communicate complicated scientific concepts in a way that consumers and scientists alike can appreciate, John is a sought-after speaker for conferences on the forefront of healthcare science,...
"The Striim platform is a full end-to-end streaming integration and analytics platform that is middleware that covers a lot of different use cases," explained Steve Wilkes, Founder and CTO at Striim, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
The deluge of IoT sensor data collected from connected devices and the powerful AI required to make that data actionable are giving rise to a hybrid ecosystem in which cloud, on-prem and edge processes become interweaved. Attendees will learn how emerging composable infrastructure solutions deliver the adaptive architecture needed to manage this new data reality. Machine learning algorithms can better anticipate data storms and automate resources to support surges, including fully scalable GPU-c...
Predicting the future has never been more challenging - not because of the lack of data but because of the flood of ungoverned and risk laden information. Microsoft states that 2.5 exabytes of data are created every day. Expectations and reliance on data are being pushed to the limits, as demands around hybrid options continue to grow.
Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
The explosion of new web/cloud/IoT-based applications and the data they generate are transforming our world right before our eyes. In this rush to adopt these new technologies, organizations are often ignoring fundamental questions concerning who owns the data and failing to ask for permission to conduct invasive surveillance of their customers. Organizations that are not transparent about how their systems gather data telemetry without offering shared data ownership risk product rejection, regu...