Ext2tools—Reading Linux files from DOS
I don't know about you, but I will admit to using Windows on my PC along with Linux. It's just that some Windows applications are still better than those available for the X windows system. (No flames, please. I didn't mention any names!)
Unfortunately, using both Windows and Linux on the same machine means I sometimes have important files on the MS-DOS partition, which I need while using Linux. I can access files on the MS-DOS partition with Linux, but often the opposite is true—I need to access Linux files from DOS or Windows 95. This used to involve getting out of Windows, booting Linux, moving a file to the DOS partition, and then rebooting Windows. Not a particularly convenient method!
NB: Be sure to have Loadlin working or a working Linux boot disk before you try loading Windows 95 if you use LILO to start Linux, as the installation of Windows will overwrite the Master Boot Record.
But it isn't that complicated any more, thanks to ext2tools, a collection of DOS programs written by Claus Tondering (firstname.lastname@example.org ). ext2tools allows me to read Linux (ext2) files directly from DOS or Windows. Five of ext2tools' DOS programs mimic Unix commands, and a sixth is used for set-up. The programs are E2CAT, E2CD, E2CP, E2LS, E2PART and E2PWD.
Using these commands is straightforward. From DOS, or a DOS window, you get a listing of the files in your Linux root directory with the command e2ls. If you want a listing of another directory, just add the directory name.
To change to another Linux directory, say, home, you enter e2cd home. Another e2ls then lists the files in home. If you find the file you need in the home directory, say it is called stuff.ext, typing e2cp stuff.ext stuff.dos will copy the file into stuff.dos in your present DOS directory. To just look at the file instead, e2cat stuff.ext will list it on your DOS screen.
The other DOS programs included in ext2tools are E2PWD, which gives the Linux directory you are currently in, and E2PRT, which is used to determine the partitions on a hard disk, which is to be signified by the disk number discussed below.
The set-up of ext2tools is really simple. It just requires you to add one line to your DOS autoexec.bat file to define the environmental variable e2cwd. The value of this variable is set to a two (or three) part number. I use:
The 128 indicates the first hard disk (129 would be the second.). The 2 denotes the partition number of the ext2 file system on that disk. A third number, which I omit, is the inode number of the current working directory. Leaving it blank results in the default value of 2, which identifies the root directory. After re-running autoexec.bat in a DOS window, typing that command on the command line, or simply rebooting DOS/Windows, you should be ready to use the tool program.
Claus Tondering, the author of the program and a Unix programmer/electrical engineer at Olicom in Denmark, says there are two limitations of ext2tools that he knows of. If there are three or more partitions inside an extended partition table, the table is read incorrectly. Secondly, if you have more than two hard disks, there is no way to get to the third, due to limitations on the use of BIOS for disk information. He hopes that the next version should take care of both these problems and may even support wild cards, but no promises.
The access to the Linux file system by ext2tools is read-only. To write Linux files you must be in Linux. In fact, Tondering does not plan to add write capabilities to these DOS programs as he fears that it could be dangerous for a variety of reasons.
Finally, a big warning. ext2tools gives superuser status to the DOS user, as it does not respect the access permissions of the Linux file system. This was by design, since having DOS on a Linux system is an inherent security risk anyway. Be careful if you install it on a multi-user system.
See Getting ext2tools sidebar for more information.
Robert A. Dalrymple (email@example.com) works at the University of Delaware and tends two machines that are half-and- half (Win95/Linux). He thanks Claus Tondering for helpful comments.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Profiles and RC Files
- Astronomy for KDE
- Maru OS Brings Debian to Your Phone
- Understanding Ceph and Its Place in the Market
- Snappy Moves to New Platforms
- Git 2.9 Released
- What's Our Next Fight?
- OpenSwitch Finds a New Home
- The Giant Zero, Part 0.x
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide