LINUX CLASSES - DOS

How Do I Access DOS Partitions With Linux?

Accessing DOS Partitions with mount

Many people running Linux have a DOS partition on their hard drive. You can read, write, and manipulate your DOS files just as if they were native Linux files by mounting the DOS partition. When you mount the DOS partition, it becomes just another directory under the root of your Linux file system, and you can treat it like any other Linux directory. When you move a Linux file to the DOS partition (or vice versa), Linux figures out whether the file is plain text or binary data and performs any appropriate conversions behind the scenes. And it's pretty cool to use find, grep, and other Linux commands on your DOS files.

Before you perform the mount, you have to create a new directory in the root of your Linux file system. You can call this directory whatever you like, but I recommend /dos for simplicity. Create the directory with this command (you must be logged in as root):

$ mkdir /dos

Now we're ready to mount the DOS partition on top of the /dos directory. Here's the command to use:

$ mount -t msdos /dev/hda1 /dos



Translated into English, this tells Linux to mount the file system of type MSDOS (-t msdos) found on the first partition of the first hard drive (/dev/hda1) on top of the /dos directory. If your DOS partition uses the newer FAT32 filesystem, you may need to replace -t msdos with -t vfat in the mount command.

If you have a SCSI hard drive, you should use /dev/sda1 instead of /dev/hda1 in the preceding example. If you have a second hard drive on your system with a DOS partition, reference it as /dev/hdb1. (See Chapter 1, "Installing Linux on Your PC," for more information on hard drives, devices, and partitions.)

Okay, your DOS partition is mounted--now have a look around. If you issue the ls /dos command, you'll see the same list of files that would result from a dir C: command under DOS. You can use cd to see other directories under /dos and use any Linux command to slice and dice your DOS files.

It's great to have the ability to copy files back and forth between Linux and DOS, but you can also do some clever things if you think creatively. I find it particularly helpful to use the ln (link) command to share my Netscape bookmarks file between Linux and DOS, like this:

ln -s /dos/netscape/bookmark.htm $HOME/.netscape/bookmarks

By linking these files together, I need to manage just one bookmark file. Of course, this trick works only if both the DOS and Linux versions of a product use the same format for the files being shared.

If you want your DOS partition to mount each time you boot Linux, add the line shown here to the /etc/fstab file:

/dev/hda1 /dos msdos umask=022

When Linux boots up, it looks in the /etc/fstab file and mounts all the file systems specified there, so you won't have to issue the mount command manually to access your DOS partition. The line you just added to /etc/fstab has the same effect as the mount command shown earlier. The same caveat about FAT32 filesystems applies here, so you may need to replace msdos with vfat in the previous example.

Previous Lesson: Accesing DOS Files
Next Lesson: Running DOS Programs

[ RETURN TO INDEX ]


   

Comments - most recent first
(Please feel free to answer questions posted by others!)

pankaj     (29 Nov 2011, 01:49)
how i am chat with other person who login in other user in other machine .
please give the detail with example and also tell , if we using the virtual linux machine for setting the evvironment.

durgaprasad     (26 Oct 2011, 02:18)
how d i mount a NTFS windows partition in linux?
please help.........
sumeetkumar     (01 Feb 2010, 09:28)
author u r genius of making difficult things easy
rajeev     (23 Jan 2010, 20:08)
i had never thought that linux could be so interesting before visiting this site....

thnks Dr. bob for working hard to develop this site....

I welcome your comments. However... I am puzzled by many people who say "Please send me the Linux tutorial." This website *is* your Linux Tutorial! Read everything here, learn all you can, ask questions if you like. But don't ask me to send what you already have. :-)

NO SPAM! If you post garbage, it will be deleted, and you will be banned.
*Name:
Email:
Notify me about new comments on this page
Hide my email
*Text:
 
 


Ask Bob Rankin - Free Tech Support


Copyright by - Privacy Policy
All rights reserved - Redistribution is allowed only with permission.

Popular Pages