Documente Academic
Documente Profesional
Documente Cultură
1. Mount a CD-ROM
The device file for CD would exist under /dev directory. For example, a CDROM device will be mounted as shown below.
In the above example, the option -o ro indicates that the cdrom should be
mounted with read-only access. Also, make sure that the destination
directory (in the above example, /mnt) exist before you execute the mount
command.
2. View All Mounts
After you execute mount a partition or filesystem, execute the mount
command without any arguments to view all the mounts.
In the example below, after mounting the USB drive on a system, the output
of mount looks like the below. As seen below, the USB device (i.e:/dev/sdb) is
# mount
/dev/sda5 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
/dev/sda6 on /mydata type ext2 (rw)
/dev/sda7 on /backup type vfat (rw)
You can also use df command to view all the mount points.
# df
Filesystem
1K-blocks
/dev/sda5
udev
2008336
tmpfs
806244
none
5120
none
2015604
4 2008332 1% /dev
928
0
805316 1% /run
5120 0% /run/lock
/dev/sda6
17729076
/dev/sda7
11707200
/dev/sdb
# cat /etc/fstab
#
proc
/proc
proc
nodev,noexec,nosuid 0
ext4
errors=remount-ro 0
ext2
defaults
vfat
defaults
Execute mount command with -a option to mount all the /etc/fstab entries.
# mount -a
# mount
The same -a option can be used with umount to unmount all the filesystems
mentioned in /etc/mtab
# umount -a
umount: /run/shm: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
umount: /run: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
umount: /dev: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
umount: /: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
Some filesystem are not unmounted as its busy or currently in use. Note that
the files /etc/mtab and /proc/mounts contents would be similar.
4. Mount only a specific filesystem from /etc/fstab
When you pass only the directory name to mount, it looks for mount point
entries, if not found, then search continuous for a device in /etc/fstab and
gets mounted.
ext2
defaults
# mount /mydata
If you execute the same again, you would get the error message as follows:
# mount /mydata
Here you may also pass the device name instead of directory name (to be
picked up from /etc/fstab file).
# mount /dev/sda6
Note that the files /etc/mtab and /proc/mounts contents would be similar.
5. View all mounted partitions of specific type
It is possible to list only the specific type of filesystem mounted using the
option -l with -t as shown below:
# mount -l -t ext2
/dev/sda6 on /mydata type ext2 (rw)
# mount -l -t ext4
/dev/sda5 on / type ext4 (rw,errors=remount-ro)
As seen above, /dev/sda6 is the only ext2 partition and /dev/sda5 is the only
ext4 partition accordingly.
6. Mount a Floppy Disk
The device file for floppy disk would exist under /dev directory. For example,
a floppy disk will be mounted as shown below.
After the successful mount, you would be able to access the contents of the
floppy disk. Once you are done with it, use umount before you physically
remove the floppy disk from the system.
# umount /mnt
# cd /mydata
# ls
test
# mkdir dir1
# mkdir dir2
# ls
test
dir1
dir2
# cd /mnt
# ls
test
dir1
dir2
Once its done, you cant use the old mount point as its moved to a new
mount point and this can be verified as shown below:
You cannot see any entry for this /mydata in mount command output and as
well from /etc/mtab file as follows:
# cd /mydata
# ls
dir1 dir2 test
ext3 and ext4 filesystem would still allow you to do write operation when the
filesystem is dirty. So, you may have to use ro,noload to prevent these kind
of write operation.
php/
mysql/
# umount /mydata -l
# umount -f /mnt
If this doesnt work for you, then you can go for lazy unmount.
Meanwhile, you can also have a look at ps command output that which
process is presently using the mountpoint as shown below:
# ps ajx | grep /mydata
0 0:00 cp -r
You can also execute fuser command to find out which process is holding the
directory for operations.
# fuser -cu /mydata
/mydata:
3087(root)
It gives you the process id with username (nothing but the owner of the
process). If you know what that process is, you may want to stop that
process and then try the umount again.