Linux Mall - The Linux SuperStore!
Linux books, Linux CDs, Linux toys, you name it, they have it!

W W W . L I N U X D O T . O R G

Newbie's Linux Manual
Accessing Disks: The /etc/fstab File
by Laurence Hunter
[ Home ] [ Contents ] [ Download*] [ Previous ] [ Next ]
* In Linux enter: unzip nlm.zip
Anything You Can Do...

To the Linux newbie, a strange and unsettling feature exists...dozens of text files that need to be hand-edited to configure features you - for years - have taken for granted (in that other "OS") as "something the operating system takes care of". Fortunately Linux doesn't enjoy babysitting. Rather than the OS telling you what you can and can't do, Linux allows you to do anything. And when I say anything, I mean anything! Could this be why it's so popular?

Editing fstab: Pico & su

/etc/fstab is the file you use to set-up your drives for "mounting". The command I use to edit this file is:

pico -w /etc/fstab

Pico is a great little text editor. The -w option switches on word-wrapping, and /etc/fstab is the file I want opened for editing. The problem is, only root can save changes made to /etc/fstab. The solution is to temporarily become root for the duration of this one task. This is done but entering the following instead:

su -c 'pico -w /etc/fstab'

Looks pretty scary I know, but just think of it as:

su -c 'command here'

...and it'll soon sink in.

Note:

In Pico the Ctrl key is represented as a caret (^) to save space. Here's what the Pico "help bar" looks like:

^G Get Help ^O WriteOut ^R Read File ^Y Prev Pg ^K Cut Text  ^C Cur Pos
^X Exit     ^J Justify  ^W Where is  ^V Next Pg ^U Uncut Text^T To Spell

...indicating - for example - that Ctrl+O will "WriteOut" (save) the current text document.

A Word On "Mounting"

Whenever you insert a disk into a drive in Windows and double-click its icon, the disk is automatically mounted. Mount means, "make the disk part of the filesystem" to allow you to access it. Linux however, does not mount disks automatically (although you can if you want - with fixed disks, and to a certain extent with removable disks). The beauty of not having it happen automatically is that you get to specify the filesystem used by the disk and can therefore read and write to many different filesystems! (A feature sorely missing from Windows.)

Some Filesystems Linux Supports

As I've just said, Linux can deal with many filesystems. For most people though, two is all you'll ever need (with a third mentioned "just-in-case"):

ext2

The native Linux filesystem.

vfat

The Windows filesystem, allowing you to move files to and from Windows. This supports long filenames.

dos

Because of its hideous short filenames (8 character max + 3 character max file extension - referred to as "8:3"), it's beyond me why you would favour this over "vfat", unless of course you want to move files to and from the inept Windows 3.x.

How To Mount A Floppy Disk

There are two ways to mount a Linux-formatted (ext2) floppy disk:

  1. From the command line enter:
    mount /mnt/floppy
  2. Or from the User Mount Tool in X (System > Disk Management).
Problems:

* At the moment, only root can mount a floppy disk.
* Unless you use "mtools" (enter: info mtools) or enter:

mount -t vfat /dev/fd0 /mnt/floppy

...(that's fd-zero by the way), mount /mnt/floppy will only mount Linux-formatted (ext2) floppy disks.

Solutions:

If you require mount /mnt/floppy to mount Windows-formatted (vfat) disks instead, change the /etc/fstab line:

/dev/fd0   /mnt/floppy   ext2   noauto   0 0

...to read:

/dev/fd0   /mnt/floppy   vfat   noauto   0 0

...and then add ,user so that users other than root can also issue the mount /mnt/floppy command, like so:

/dev/fd0   /mnt/floppy   vfat   noauto,user   0 0
Tip:

If you need to alternate between mounting a Linux-formatted (ext2) floppy disk and a Windows-formatted (vfat) floppy disk, simply create a directory e.g. mkdir /mnt/winfloppy and have the following lines in the /etc/fstab file:

/dev/fd0   /mnt/floppy      ext2   noauto,user   0 0
/dev/fd0   /mnt/winfloppy   vfat   noauto,user   0 0
Note:

Until you unmount the floppy disk, /mnt/floppy is for all purposes "just another directory", containing the files and subdirectories contained on the disk.

How To Unmount A Disk

Just as disks need to be mounted, disks also need to be unmounted before you can mount another disk in the same drive.

To unmount a disk, either select the appropriate unmount button from the User Mount Tool in X (System > Disk Management), or at the command line, enter umount pathname e.g.:

umount /mnt/floppy
Note:

You can't unmount a disk at the command line if your in /mnt or any of its subdirectories.

How To Mount A CD
There are two ways to mount a CD:
  1. From the command line enter:
  2. mount /mnt/cdrom
  3. Or from the User Mount Tool in X (System > Disk Management).
Problem:
* At the moment, only root can mount a CD.
Solution:

To allow any user to mount a CD, go into /etc/fstab and change the line:

/dev/cdrom   /mnt/cdrom   iso9660 noauto,ro     0 0

...to read:

/dev/cdrom   /mnt/cdrom   iso9660 noauto,user   0 0
How To Mount A Zip Disk

The following guide is for internal Zip drives. If you have an external Zip drive (you did select Yes - during the installation of Linux - when it asked if you had any SCSI devices didn't you?), replace all instances of h with s, e.g. hdc4 becomes sdc4. As far as I know, a Jaz drive is mounted in exactly the same way as an external Zip drive.

Ok, down to business. First create a directory to mount Zip disks to. To do this, enter:

mkdir /mnt/zip
Next Find Out How Your Zip Drive Is Setup

To mount a Zip disk you'll first need to find out which IDE controller your Zip disk is using. To find out this, enter:

dmesg | less

...and scroll down the list using the down cursor key, until you find something similar to the following:

hda: IBM-DCAA-33610, 3445MB w/96kB Cache, CHS=875/128/63
hdb: HITACHI GD-2000, ATAPI CDROM drive
hdc: IOMEGA ZIP 100 ATAPI, ATAPI FLOPPY drive

The following table will explain what the above hda, hdb and hdc mean:

hdaPrimary Master (Usually the hard drive.)
hdbPrimary Slave (Usually the CD-ROM drive.)
hdcSecondary Master
hddSecondary Slave
Mounting

To mount a Windows-formatted (vfat) Zip disk, you could enter:

mount -t vfat /dev/hdc4 /mnt/zip

By the way, that 4 tagged onto hdc is because Windows/DOS-formatted Zip disks use partition 4. (Macs must use partition 4, so having Windows PCs also use partition 4 prevents compatibility problems.)

Or if you need to mount a Linux-formatted (ext2) Zip disk, you could enter:

mount -t ext2 /dev/hdc1 /mnt/zip
Note:

A Linux-formatted (ext2) Zip disk uses partition 1 instead of 4 because to format it as an ext2 disk you first need to "fdisk" it to remove the vfat filesystem. In Fdisk you'll assign it the first partition, not the fourth. Details of how to format floppy disks and Zip disks in Linux feature in a later chapter.

Problem:
* At the moment, only root can mount a Zip disk.
Solution:

To allow any user to mount a Windows-formatted (vfat) Zip disk, add the following line to /etc/fstab:

/dev/hdc4   /mnt/zip   vfat   noauto,user   0 0

...so that now any user can mount a Zip disk using easier to remember:

mount /mnt/zip

As an added bonus you can now mount a Zip disk from the User Mount Tool in X (System > Disk Management).

Tip:

If you need to alternate between mounting a Linux-formatted (ext2) Zip disk and a Windows-formatted (vfat) Zip disk, simply create a directory e.g. mkdir /mnt/winzip (excuse the pun) and have the following lines in the /etc/fstab file:

/dev/hdc1   /mnt/zip      ext2   noauto,user   0 0
/dev/hdc4   /mnt/winzip   vfat   noauto,user   0 0
How To Mount Your Windows Partition
- 1 -

First create a directory (I think c is an appropriate name) to mount your Windows partition to. To do this, enter:

mkdir /mnt/c

- 2 -

Now enter:

su -c "pico -w /etc/fstab"

...to open the /etc/fstab file in Pico with root privileges, so that you are permitted to save changes.

- 3 -

Add the following line:

/dev/hda1   /mnt/c   vfat   noauto,user   0 0

...then press Ctrl+O to save the file and Ctrl+X to exit Pico.

Tip:

If you'd like your Windows partition to automatically mount each time you boot Linux, simply change noauto to auto.

Troubleshooting

It's likely that hda1 is your Windows partition (or sda1 if it's a SCSI hard drive). If this fails to work though, check the section above on "How To Mount A Zip Disk" for help.

- 4 -

Now any user can mount the Windows partition by entering:

mount /mnt/c

...or in X, using the User Mount Tool (System > Disk Management).

Note:

Until you unmount the partition, /mnt/c is for all purposes "just another directory" with its respective subdirectories, e.g. issuing the command line ls /mnt/c/windows/desktop will display the contents of your Windows desktop.

[ Home ] [ Contents ] [ Download*] [ Previous ] [ Next ]
* In Linux enter: unzip nlm.zip
Homepage | The Last 5 Days | The Daily Linux News | The Linux Bits | Newbie's Linux Manual
The Best Linux Sites | Linux Book Reviews | A Windows Vendetta?
Diary of a Linux Newbie | Diary of an Open Source Newbie
The Linux Forum | Just For Fun
Amazon - The World's Biggest Bookstore!
4.7 million books, CDs, videos, and DVDs available to buy!
© MM Linuxdot.org | Webmaster | Manual's Copyright Terms