May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Mounting Linux filesystems


Recommended Books

Recommended Links mount command Linux filesystems Loopback filesystem
Linux Swap filesystem Swap file Filesystem mount options /etc/fstab/  ext2 attributes Ext3 filesystem
udev Partition labels Managing Disks by UUID Loopback filesystem Linux Disk Partitioning Grub
The Linux Logical Volume Manager Linux Logical Volume Snapshots Linux SCSI subsystem Admin Horror Stories Linux Tips Humor

While the mount process actually mounts the filesystem on some device (or other resource), it is common to simply say that you "mount the device," which is understood to mean "mount the filesystem on the device."

Mounting and unmounting filesystems usually requires root authority. The basic form of the mount command takes two parameters: the device (or other resource) containing the filesystem to be mounted, and the mount point. For example, to mount  partition /dev/sda9 at the mount point /backup you can use the following command:

# mount /dev/sda9 /backup

The mount point must exist before you mount anything over it. If it does not, you will get an error and need to create the mount point or use a different mount point

When you mount a filesystem over an existing directory, the files on the filesystem you are mounting become the files and subdirectories of the mount point. If the mount point directory already contained files or subdirectories, they are not lost, but are no longer visible until the mounted filesystem is unmounted, at which point they become visible again. It is a good idea to avoid this problem by using only empty directories as mount points.

After mounting a filesystem, any files or directories created or copied to the mount point or any directory below it will be created on the mounted filesystem. So a file such as /dos/sampdir/file.txt will be created on the FAT32 filesystem that we mounted at /dos in our example.

Usually, the mount command will automatically detect the type of filesystem being mounted. Occasionally you may need to specify the filesystem type explicitly using the -t option as shown

# mount -t vfat /dev/sda9 /dos

To see what filesystems are mounted, use the mount command with no parameters. Listing 4 shows our example system. Note that you do not need root authority to simply list mounted filesystems.

$ mount
/dev/sda6 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)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda2 on /grubfile type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
gvfs-fuse-daemon on /home/ian/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=ian) on /mnt/dwcontent type nfs (rw,addr=
/dev/sdb9 on /mnt/sdb9 type ext3 (rw)
/dev/sda9 on /dos type vfat (rw)
/dev/sr0 on /media/KNOPPIX type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=1000,gid=1000

You can also view similar information by displaying /proc/mounts or /etc/mtab, both of which contain information about mounted filesystems.

Mount options

The mount command has several options that override the default behavior. For example, you can mount a filesystem read-only by specifying -o ro. If the filesystem is already mounted, add remount

# mount -o remount,ro /backup


Remount commands will not complete successfully if any process has open files or directories in the filesystem being remounted.

Labels, UUIDs, and links

In UNIX and early Linux systems, the /dev directory usually contained entries for all the devices that might ever be attached to a system. Any device that was used was always located in the same place in the /dev tree, so using names such as /dev/sda6 was natural. With the advent of hot-plugging of devices such as USB or Firewire (IEEE 1394) attached devices, a given device might appear in one USB port today, and that same device might be plugged into a different USB port tomorrow. In this environment, you might want to always mount your USB stick at /media/myusbstick, regardless of which USB port you plug it in to. In the article for topic 102, "Learn Linux, 101: Boot managers," you learned about using labels and UUIDs (Universally Unique IDs) instead of device names to identify partitions. If the filesystem on the partition supports either, you can use these with the mount command too. Use the blkid command to find out the UUID and label (if present) associated with a device. Listing 6 shows how to use blkid to find the label and UUID for our root partition and then how to create two additional mount points and mount the root partition at these two additional points. This example is for illustration. You would not normally do this in a production environment.

# blkid /dev/sda6
/dev/sda6: LABEL="Fedora-13-x86_64" UUID="082fb0d5-a5db-41d1-ae04-6e9af3ba15f7"
# mkdir /mnt/sda6label
# mkdir /mnt/sda6uuid
# mount LABEL="Fedora-13-x86_64" /mnt/sda6label
# mount UUID="082fb0d5-a5db-41d1-ae04-6e9af3ba15f7" /mnt/sda6uui

With the advent of udev, you will usually find additional symbolic links in the /dev directory for devices such as hard drives.

$ find /dev -lname "*sda6"

You can also use a symbolic link as another way of specifying the device name when mounting a device.

Boot time and fstab

Once /boot filesystem is mounted, the initialization process runs mount with the -a option to automatically mount a set of filesystems. The set is specified in the file /etc/fstab.

UUID=082fb0d5-a5db-41d1-ae04-6e9af3ba15f7 /                  ext4    defaults        1 1
UUID=488edd62-6614-4127-812d-cbf58eca85e9 /grubfile          ext3    defaults        1 2
UUID=2d4f10a6-be57-4e1d-92ef-424355bd4b39 swap               swap    defaults        0 0
UUID=ba38c08d-a9e7-46b2-8890-0acda004c510 swap               swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
# /etc/fstab: static file system information.
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
# / was on /dev/sda7 during installation
UUID=8954fa66-e11f-42dc-91f0-b4aa480fa103 /               ext3    errors=remount-ro 0  1
# /grubfile was on /dev/sda2 during installation
UUID=3a965842-b6dd-4d52-8830-2d0fdb4284a2 /grubfile       ext3    defaults        0  2
/dev/sda5       none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0

Lines starting with a # character are comments. Remaining lines contain six fields. Because the fields are positional, they must all be specified.

file system
This may be a device name such as /dev/sda1, or a label (LABEL=) or UUID (UUID=). For the root filesystem of our Fedora 13 example, it could be /dev/sda6, LABEL="Fedora-13-x86_64", or UUID="082fb0d5-a5db-41d1-ae04-6e9af3ba15f7". Using a label or UUID makes your system more robust when devices are added or removed.
mount point
This is the mount point we discussed in Mounting filesystems above. For swap space, this should be the value 'none' or 'swap'. On older systems you will usually find the value 'none'.
Specifies the type of filesystem. CD/DVD drives will often support either ISO9660 or UDF filesystems, so you may specify multiple possibilities in a comma-separated list as you see in Listing 9. If you want mount to automatically determine the type, specify auto as is done in the last line of Listing 9 for the floppy drive.
Specifies the mount options. Specify defaults if you want default mount options. Some options you will want to know about are:
Specifies whether the dump command should consider this ext2 or ext3 filesystem for backups. A value of 0 tells dump to ignore this filesystem.
Non-zero values of pass specify the order of checking filesystems at boot time, as discussed in our article "Learn Linux, 101: Maintain the integrity of filesystems."

When you mount a filesystems that is listed in /etc/fstab, you can give either the device name or the mount point when mounting the filesystem. You do not need to give both.

On some systems, for example SUSE 11.2, you may find that the fstab generated at install time uses symbolic links to the device. So, you may see /dev/disk/by-id/ata-WDC_WD1001FALS-00J7B1_WD-WMATV3772868-part6, rather than /dev/sda6 for the file system value.

Consult the man pages for fstab, mount, and udev for additional information, including options not covered here.

Unmounting filesystems

All mounted filesystems are usually unmounted automatically by the system when it is rebooted or shut down. When a filesystem is unmounted, any cached filesystem data in memory is flushed to the disk.

You may also unmount filesystems manually. Indeed, you should do this when removing writable media such as diskettes or USB drives or memory keys.

Use the umount command to unmount the filesystem, specifying either the device name or mount point as an argument. Listing 10 shows how to unmount /dos, then remount it and unmount again using the device name.

# umount /dos
# mount /dev/sda9 /dos
# umount /dev/sda9 

After a filesystem is unmounted, any files in the directory used for the mount point are visible again.

If you attempt to unmount a filesystem while a process has open files on that filesystem, you will see an error message. Before unmounting a filesystem, you should check that there are no processes running that have open files on the filesystem. Use the lsof or fuser command to determine what files are open or what process has open files. You may need the -w option on lsof to avoid warning messages related to the Gnome Virtual File system (gvfs). Check the man pages to learn about additional mount options and lsof. If you are checking a whole device, you can specify the device name or the mount point. You may also check whether an individual file is in use or not.

To illustrate these commands, I created a copy of /etc/fstab on /dos and a small script to read lines from stdin and print them to stdout with a 10 second pause between each line. Listing 11 shows the error message from umount when files are in use and the use of lsof and fuser to check for open files on /dos, or the underlying device /dev/sda9.

root@echidna ~]# umount /dos
umount: /dos: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
# lsof -w /dos
slowread. 2560  ian    0r   REG    8,9      899  123 /dos/fstab
sleep     2580  ian    0r   REG    8,9      899  123 /dos/fstab
# lsof -w /dev/sda9
slowread. 2560  ian    0r   REG    8,9      899  123 /dos/fstab
sleep     2580  ian    0r   REG    8,9      899  123 /dos/fstab
# fuser -m /dos
/dos:                 2560  2586
# fuser -m /dev/sda9
/dev/sda9:            2560  2588

At this point you can either wait until the filesystem is no longer busy, or you can do a lazy unmount, by specifying the -l option. A lazy unmount detaches the filesystem from the filesystem tree immediately, and cleans the references to the filesystem when it is no longer busy.

Removable filesystems

We mentioned some issues with removable devices such as USB or Firewire (IEEE 1394) attached devices. It is inconvenient to switch to root access every time you need to mount or unmount such a device. The same goes for CD, DVD, and floppy drives, where you need to unmount the device to change media. In the discussion of fstab above, we mentioned the user option, which allows ordinary users to mount and unmount devices. Listing 9 shows one way to code fstab entries for a floppy drive or for a CD or DVD drive.

Note that the filesystem types for the optical drive are specified as udf,iso9660, while the filesystem type for the floppy is specified as auto. For the optical drive, the mount process will check first for a udf filesystem (common on DVD) and then for an iso9660 filesystem (common on CD). For the floppy drive, the mount process will probe for a filesystem type. You can create or edit /etc/filesystems to change the order in which the filesystems will be probed.

Note: You should always unmount removable drives or media before disconnecting the drive or attempting to remove the media. Failure to do so may result in loss of data that has not yet been written to the device.

If you run a graphical desktop such as Nautilus, you will usually find options that allow removable devices and media to be automatically mounted. For example, if I insert a Knoppix DVD into the DVD drive of my system, I might see a mount entry such as shown in Listing 12. The presence of 'uid=1000' shows that the user with id 1000 can unmount this disc. The id command shows the uid for user ian is 1000, so ian can unmount this disc.

$ mount | grep sr0
/dev/sr0 on /media/KNOPPIX type iso9660 (ro,nosuid,nodev,uhelper=udisks,
$ id ian
uid=1000(ian) gid=1000(ian) groups=1000(ian)

You may also use the eject command to eject removable media when the drive supports the operation as most CD and DVD drives do. If you have not unmounted the device first, then eject will both unmount and eject the disc.

Swap space

You may have noticed in the discussion of fstab above that swap space does not have a mount point. The boot process usually enables swap space defined in /etc/fstab unless the noauto option is specified. To manually control swap space on a running system—for example, if you added a new swap partition—use the swapon and swapoff commands. See the man pages for details.

$ swapon -s
Filename				Type		Size	Used	Priority
/dev/sdb1                               partition	514044	0	-1
/dev/sdb5                               partition	4192928	0	-2
$ cat /proc/swaps
Filename				Type		Size	Used	Priority
/dev/sdb1                               partition	514044	0	-1
/dev/sdb5                               partition	4192928	0	-2

USB devices

fdisk -l is your friend

the device is visible in YAST/system/hardware

Some devices will be supported and some are not. You can check on to see if device supported.

First plug your usb card reader and to make sure your device was detected go to System Tools > Hardware Browser > enter root password and it will display your hardware information then go to > Hard Drives and it should be listed under /dev/sdc or other device name.
Open your favorite terminal....btw this works in gnome and kde.

$ cd /mnt/ <-as user cd yourself to the mnt folder and become root to create directory
$ su
# mkdir usbflash <- this created a directory in the mnt folder

# ls /mnt/ <-this command listed all my directories the mnt folder
cdrom cdrom1 floppy usbflash

# mount /dev/sda1 /mnt/usbflash <-this is the command to mount flash card reader

# ls usbflash <-this listed all the info in my usb flash card and this was the output:
bootex.log dns.bmp games and keys LinuxDocs01.21.04 pc's
dns2.bmp Documents LinuxDistributions_eBay my pics programs

then i just copied this to my home folder and i was done!

# umount /dev/sda1 /mnt/usbflash <-this unmounted my usb flash card
umount: /dev/sda1: not mounted
# exit
[imdeemvp@localhost mnt]$

THIS ALSO WORKED UNDER Mandrake 9.1, 9.2, and 10 official.

in terminal type as root: gedit /etc/fstab and NOW YOU CAN ADD THIS LINE TO FSTAB to auto mount it:

/dev/sda1 /mnt/usbflash vfat noauto,users,rw,umask=0 0 0

Adding "rw" allows to read and write in the usb flash drive. HAVE FUN!!
UPDATED 11.28.04
Please note that under FC3 it automounts in your desktop. It is plug and play.



Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy


War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes


Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law


Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D

Copyright © 1996-2021 by Softpanorama Society. was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site


The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: September 29, 2016