OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Viewing A List Of Mounted File Systems

The mount command is used to mount file systems. Entering the command without ar- guments will display a list of the file systems currently mounted:



[me@linuxbox ~]$ mount

/dev/sda2 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/sda5 on /home type ext4 (rw)

/dev/sda1 on /boot type ext4 (rw)

[me@linuxbox ~]$ mount

/dev/sda2 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/sda5 on /home type ext4 (rw)

/dev/sda1 on /boot type ext4 (rw)


tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) fusectl on /sys/fs/fuse/connections type fusectl (rw)

/dev/sdd1 on /media/disk type vfat (rw,nosuid,nodev,noatime, uhelper=hal,uid=500,utf8,shortname=lower)

twin4:/musicbox on /misc/musicbox type nfs4 (rw,addr=192.168.1.4)

tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) fusectl on /sys/fs/fuse/connections type fusectl (rw)

/dev/sdd1 on /media/disk type vfat (rw,nosuid,nodev,noatime, uhelper=hal,uid=500,utf8,shortname=lower)

twin4:/musicbox on /misc/musicbox type nfs4 (rw,addr=192.168.1.4)


The format of the listing is: device on mount_point type file_system_type (options). For example, the first line shows that device /dev/sda2 is mounted as the root file system, is of type ext4, and is both readable and writable (the option “rw”). This listing also has two interesting entries at the bottom of the list. The next-to-last entry shows a 2 gigabyte SD memory card in a card reader mounted at /media/disk, and the last entry is a net- work drive mounted at /misc/musicbox.

For our first experiment, we will work with a CD-ROM. First, let's look at a system be- fore a CD-ROM is inserted:



[me@linuxbox ~]$ mount

/dev/mapper/VolGroup00-LogVol00 on / type ext4 (rw) proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/sda1 on /boot type ext4 (rw) tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

[me@linuxbox ~]$ mount

/dev/mapper/VolGroup00-LogVol00 on / type ext4 (rw) proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/sda1 on /boot type ext4 (rw) tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)


This listing is from a CentOS 5 system, which is using LVM (Logical Volume Manager) to create its root file system. Like many modern Linux distributions, this system will at- tempt to automatically mount the CD-ROM after insertion. After we insert the disc, we see the following:



[me@linuxbox ~]$ mount

/dev/mapper/VolGroup00-LogVol00 on / type ext4 (rw) proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/hda1 on /boot type ext4 (rw) tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

/dev/sdc on /media/live-1.0.10-8 type iso9660 (ro,noexec,nosuid,

[me@linuxbox ~]$ mount

/dev/mapper/VolGroup00-LogVol00 on / type ext4 (rw) proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/hda1 on /boot type ext4 (rw) tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

/dev/sdc on /media/live-1.0.10-8 type iso9660 (ro,noexec,nosuid,


nodev,uid=500)

nodev,uid=500)


After we insert the disc, we see the same listing as before with one additional entry. At the end of the listing we see that the CD-ROM (which is device /dev/sdc on this sys- tem) has been mounted on /media/live-1.0.10-8, and is type iso9660 (a CD- ROM). For purposes of our experiment, we're interested in the name of the device. When you conduct this experiment yourself, the device name will most likely be different.


image

Warning: In the examples that follow, it is vitally important that you pay close at- tention to the actual device names in use on your system and do not use the names used in this text!


Also note that audio CDs are not the same as CD-ROMs. Audio CDs do not contain file systems and thus cannot be mounted in the usual sense.


image

Now that we have the device name of the CD-ROM drive, let's unmount the disc and re- mount it at another location in the file system tree. To do this, we become the superuser (using the command appropriate for our system) and unmount the disc with the umount (notice the spelling) command:



[me@linuxbox ~]$ su -

Password:

[root@linuxbox ~]# umount /dev/sdc

[me@linuxbox ~]$ su -

Password:

[root@linuxbox ~]# umount /dev/sdc


The next step is to create a new mount point for the disk. A mount point is simply a direc- tory somewhere on the file system tree. Nothing special about it. It doesn't even have to be an empty directory, though if you mount a device on a non-empty directory, you will not be able to see the directory's previous contents until you unmount the device. For our purposes, we will create a new directory:



[root@linuxbox ~]# mkdir /mnt/cdrom

[root@linuxbox ~]# mkdir /mnt/cdrom


Finally, we mount the CD-ROM at the new mount point. The -t option is used to specify the file system type:



[root@linuxbox ~]# mount -t iso9660 /dev/sdc /mnt/cdrom

[root@linuxbox ~]# mount -t iso9660 /dev/sdc /mnt/cdrom


Afterward, we can examine the contents of the CD-ROM via the new mount point:



[root@linuxbox ~]# cd /mnt/cdrom

[root@linuxbox cdrom]# ls

[root@linuxbox ~]# cd /mnt/cdrom

[root@linuxbox cdrom]# ls


Notice what happens when we try to unmount the CD-ROM:



[root@linuxbox cdrom]# umount /dev/sdc

umount: /mnt/cdrom: device is busy

[root@linuxbox cdrom]# umount /dev/sdc

umount: /mnt/cdrom: device is busy


Why is this? The reason is that we cannot unmount a device if the device is being used by someone or some process. In this case, we changed our working directory to the mount point for the CD-ROM, which causes the device to be busy. We can easily remedy the is- sue by changing the working directory to something other than the mount point:



[root@linuxbox cdrom]# cd

[root@linuxbox ~]# umount /dev/hdc

[root@linuxbox cdrom]# cd

[root@linuxbox ~]# umount /dev/hdc


image

Now the device unmounts successfully.


Why Unmounting Is Important

If you look at the output of the free command, which displays statistics about memory usage, you will see a statistic called “buffers.” Computer systems are de- signed to go as fast as possible. One of the impediments to system speed is slow devices. Printers are a good example. Even the fastest printer is extremely slow by computer standards. A computer would be very slow indeed if it had to stop and wait for a printer to finish printing a page. In the early days of PCs (before multi-tasking), this was a real problem. If you were working on a spreadsheet or text document, the computer would stop and become unavailable every time you printed. The computer would send the data to the printer as fast as the printer could accept it, but it was very slow since printers don't print very fast. This prob- lem was solved by the advent of the printer buffer, a device containing some RAM memory that would sit between the computer and the printer. With the printer buffer in place, the computer would send the printer output to the buffer and it would quickly be stored in the fast RAM so the computer could go back to



image

work without waiting. Meanwhile, the printer buffer would slowly spool the data to the printer from the buffer's memory at the speed at which the printer could ac- cept it.

This idea of buffering is used extensively in computers to make them faster. Don't let the need to occasionally read or write data to or from slow devices impede the speed of the system. Operating systems store data that has been read from, and is to be written to storage devices in memory for as long as possible before actually having to interact with the slower device. On a Linux system for example, you will notice that the system seems to fill up memory the longer it is used. This does not mean Linux is “using“ all the memory, it means that Linux is taking advan- tage of all the available memory to do as much buffering as it can.

This buffering allows writing to storage devices to be done very quickly, because the writing to the physical device is being deferred to a future time. In the mean- time, the data destined for the device is piling up in memory. From time to time, the operating system will write this data to the physical device.

Unmounting a device entails writing all the remaining data to the device so that it can be safely removed. If the device is removed without unmounting it first, the possibility exists that not all the data destined for the device has been transferred. In some cases, this data may include vital directory updates, which will lead to file system corruption, one of the worst things that can happen on a computer.


Top OS Cloud Computing at OnWorks: