MandrakeUser.Org - Your Mandrake-Linux Knowledge Base!


 
 

* DocIndex - Administration

Mounting I

* Why Linux Handles Media Differently
* Default mount Setup In Mandrake Linux
* Mounting In Detail

Related Resources:

Filesystems HOWTO
man mount
man 8 umount
man fstab

Revision / Modified: Jan 08, 2001
Author: Tom Berger

 

* Why Linux Handles Media Differently

If you are coming from a non-Unix operating system like MS Windows 9.x or the 'classic' Mac OS, one of the main obstacles of getting to grips with Linux is its different handling of partitions, removable media and network shares (from now on referred to as 'media').

In those operating systems, partitions play a more or less prominent role in tasks related to files and directories. You have several 'drives' in Windows (e.g. A:, C:, D: etc) or 'Volumes' in Mac OS. Applications install to a folder of their own, dropping off one or more files in the 'system directories' of these operating systems. New partitions, external media or network shares appear as new 'drives' or 'volumes'.

In Unix, and thus in Linux, things are handled almost entirely differently. This is because in contrast to the later Mac OS and Windows operating systems, Unix systems have been developed as multi-user operating systems: usually there were one or more central servers accessed by users via their terminals. Often directories were distributed: the users' home directories were on machine A, the executables and libraries on machine B etc. Users were usually not allowed to install their own applications, they'd rather have asked the system administrator to install an application for them on the main server.
Something like the file systems on Mac OS and Windows with their rather arbitrary 'volume' and 'drive' naming, their separate application directories and their non-continuous directory structure would have been an administrative nightmare.

Linux has inherited the characteristics of the Unix file system:

  • All partitions, external media and network shares are regarded as internal part of the one system directory tree, starting at '/', the root directory.
  • There are no 'application folders'. Files are installed according to theirtype (e.g. executable, documentation etc), not according to the application they belong to.

* section index * top

* Default Mount Setup In Mandrake Linux

One of the very first ideas which started Mandrake Linux off from Red Hat was to make media easier to access for users. Back in the old days, you had to be 'root' to mount a medium and something as simple as installing an RPM from a CD was quite tedious: switch to 'root' account, insert CD, mount CD, install program, unmount CD, switch back to user account. Gets really old really fast.

Of course, this restriction makes perfectly sense in a multi-user environment with a system administrator where you don't want everyone to be able to muck around with the system but it is more or less ridiculous on single user machines.
Therefore are all removable media configured to be user (un)mountable in Mandrake Linux. With the introduction of 'supermount' in Mandrake Linux 7.2, to be discussed later, even mounting these media is done automatically (if you are using 8.1, read this hint on 'supermount'). Furthermore are all locally available Windows 9x partitions set up to be accessible (read-write) by users and are mounted automatically at boot time.

KDE and GNOME come with icons for removable drives. Mounting a medium via these icons is as simple as inserting the medium and clicking the icon. If you don't have 'supermount', you have to remember to unmount the medium via the right click content menu of the icon before removing it from the device.

Mandrake Linux also provides the DiskDrake tool which allows you to configure local and networked mounts as well as resize partitions. DiskDrake is available as a graphical module of the Mandrake Control Center (Hardware - Mount Points) but can also be run on the console.

If you want to know all the gory details, however, you're welcome to read on ;-).

* section index * top

* Mounting In Detail

The idea behind 'mount' is pretty simple: we use a command to tell the system which media it should integrate into the tree or which it should remove. This way the system will always know which media are accessible and which are not.

A simple

$ mount

will provide you with a list of media currently mounted. If you have any Windows 9x partitions on your system, these will usually be already mounted, too (directories '/mnt/win_drive).

In order to mount a medium ('to make it part of the local directory tree'), you have to be 'root' and you have to provide it with some facts about the medium you want to mount: what the medium is and via which directory of the directory you want to access it:

# mount device_name mount_point

To unmount, you use the 'umount' command:

# umount mount_point

An example: to mount an MS-Windows partition ('vfat') which resides on the first partition of the first IDE-disk to '/mnt/disk', you'll type (as root):

# mount /dev/hda1 /mnt/disk

To unmount:

# umount /mnt/disk

Easy, isn't it? ;-) Take this step by step.

Device Naming

In Unix and thus in Linux, everything is regarded as a file. All file and input/output operations are handled via files. Devices (hard disks, keyboards, graphic cards, printers etc) are also handled via files. These device files are located in the '/dev' directory. All read and/or write operations to and from devices go via these files. If you print a document, the data is simply sent to the device file of your printer in '/dev', if you save a file, that data is sent to the device file of the partition you save it to.

Device names follow strict conventions, which means that on all Linux systems each specific device has always the same device file.
The allowed device file names are listed in '/usr/src/linux/Documentation/devices.txt' (online copy).
Common device names are:

/dev/hda-h 1-63

These are devices connected via IDE (hard disks and their partitions, CD-R, internal ZIP etc). The letter describes the position of the device on the bus (a=master on first IDE channel, b=slave on first IDE channel, c=master on second channel etc.).
The number describes the position of the partition. If the medium does not feature partitions (CD-Rs or DVDs for example), it simply doesn't require that number. A CD drive which is master on the second IDE channel has just '/dev/hdc' for its device file (or '/dev/cdrom' which in turns links to '/dev/hdc').

Everything that has partitions has their device names subdivided in names according to the partitions available (device name + partition number). The master hard disk on the first IDE channel has the device file '/dev/hda'. The first partition on that disk has the device name '/dev/hda1', the second '/dev/hda2' etc.

Things are a bit different, however, when Windows is installed on the same disk. Windows 9x is based on MS-DOS and thus can't handle more than one of the four 'primary' partitions available. Therefore further partitions ('drives') in Windows are created as so-called 'extended partitions' in one of the four 'primary partitions'. In Linux, the first 'extended' partition isalways labeled as '5', even if one or more of the 'primary partitions' isn't used:

/dev/hda1 (...) b Win95 FAT32
/dev/hda2 (...) f Win95 Ext'd (LBA)
/dev/hda5 (...) b Win95 FAT32
/dev/hda6 (...) 83 Linux

As you can see, the first partition is used by Windows 9x, whichmust be installed on the first primary partition. The second provides the structure for the 'extended partitions' (it's of no use by itself). '/dev/hda5' is the second Windows partition ('D:'), and Linux lives on '/dev/hda6', despite the fact there are only three 'real' partitions on the disk.

Why it's done this way? Because this way there's no device name shift in case another primary partition gets created. This new partition would get the device name '/dev/hda3'.

As you can see, a maximum of 63 partitions per disk is allowed.

/dev/fd0-7

These are the floppy devices, with '0' being the first drive and '7' being the eight.

/dev/sda-p 0-15

SCSI disk devices. Numbering like IDE. Maximum of 15 partitions per disk. Notice that USB and IEEE1394 hard disks are also handled via these devices files.

/dev/sr0-15

SCSI CD-Rom devices, nowadays usually referred to as '/dev/scdx'. 0= first device, 1= second device etc. IDE CD-Roms are handled via '/dev/hd'. Notice that IDE CD burners as well as all USB and IEEE 1394 CD/DVD/CD-R are handled via these device files, too.

/dev/pda-d

Parallel port IDE devices. Partitions as with IDE. Maximum of 15 partitions.

/dev/pf0-3

Parallel port ATAPI disk devices.

To find out what partitions are available on a device, either use 'diskdrake' from the Mandrake Control Center (Hardware - Mount Points), or type

# cfdisk -P s /dev/device_name

as 'root'. E.g. to find out about the first IDE hard disk in a system, you'd type cfdisk -P s /dev/hda.

Notice that upon installation Mandrake Linux configures a few mnemonic links like '/dev/cdrom' which points to the 'real' CD-R device file. You can create such links, too. If you have a ZIP which mounts to '/dev/sda4', you can - as 'root' - create a link like this one:

# ln -s /dev/sda4 /dev/zip

Now you can use '/dev/zip' as an alternative device file name for that ZIP.

Optional: File System Type

Many explanations and tutorials on 'mount' mention the -ttype option to specify the file system on the medium. You will find that for mounting local file systems, providing this option isn't necessary. 'mount' supports auto-detection for most of the supported local file systems.

# mount /dev/hda1 -t vfat /mnt/disk

mounts the first partition on the first IDE hard disk to '/mnt/disk' and tells 'mount' which file system to expect ('vfat', the file system used by Windows 9x), instead of letting it figure it out on its own.

The -t option does have its use when mounting or unmounting multiple media at once:

# umount -a -t vfat

for example unmounts all media with a Windows FAT file system on them.

Mount Point

This is a directory a medium is mounted to. If the medium is mounted, its content is accessible via this directory like with any other directory. If the medium isn't mounted, this directory is just an ordinary empty directory. You can even copy files into this empty directory. These files however will disappear when a medium gets mounted to this directory and reappear when the medium gets unmounted. From this it should also be clear that one directory can only be host to one mounted medium at any given time, you can however mount a medium to a directory on a mounted medium.
Notice that the access permissions on these directories do not have any influence on the permissions of mounted media.

If you have a look at the 'diskdrake' module or the file '/etc/fstab', you notice that two types of mounts can be distinguished by their mount points: one type is mounted to directories across the system ('/', '/home', '/usr', '/dev' etc), while the other type has their mount directories in the '/mnt' directory. The first type is integral part of the system, whereas the second is regarded as temporary (e.g. removable media, Windows partitions, network shares).

The reason for this distinction is easy to conceive: this makes it much easier to exclude temporary media from backups or system maintenance jobs, like for example the update of the database for the 'locate' command.

Optional: Options

Usually you won't need the -o options argument for the mount command. The default options are sensible, and for everything beyond you'd use the '/etc/fstab' file (to be discussed later).

'mount' basically has two sets of options for every 'mount' command: a set of general options applicable to all file systems (like -o ro for mounting a medium read-only, and a set of file system specific options (like-o codepage=850 to enable a special character conversion on a mounted Windows partition). Options are separated by a comma, no spaces. Readman mount for a complete listing.

Like the -t option, -O (capital O) can be used to (un)mount multiple media at once:

# mount -a -O umask=0

for example mounts all media from '/etc/fstab' which have the 'umask=0' option in their entry. -t and -O can also be used together with -a:

# umount -a -t vfat -O ro

unmounts all media with the Windows FAT file system on them which are mounted read-only.

On the next page, we'll be cleaning up this mess with a nice configuration file and have a look at 'supermount'.

* section index * top

* Configuring mounts, supermount


 
Legal: All texts on this site are covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB (Tom Berger) and Mandrakesoft 1999-2002.