As we all know that we can store our data in different kind of storage mediums like Hard Disks, Floppy Drives, and CD-ROMs. Even we also know that we can split our Hard Disk in different partitions having multiple file-systems. When you are using Windows based machines, you would be using all the file systems easily. You just start your computer and then go to My Computer and you will find all the partitions there. You can easily access them to store the data. Same concept also applies to Floppy, CD-ROMs and other storage devices. You just plug the storage device and access them immediately. But, if you are using Linux then this is not the case.
Here, you will be little bit confused. First you put the floppy or CD in the drive and start looking at it that why you are not having access of it. The reason behind this is because your CD, Hard Disk and Floppies as well as other storage devices should get attached to some directory of the system so that you can access them easily. This process of attaching is known as mounting in Linux and the place or directory where you attach them are known as mount point. Once they are mounted, you can easily access the files and directories available in that device. Once you are done with your task and you want to remove that storage device from the system, you should detach them and it is known as unmount.
Basic Syntax of Mount Command
Generally, mounting of device is done with a command known as mount. While mounting any device you should pass the argument to the command that what is the name of the partition and where do you want to mount the same. The mount point should be any directory present on your system.
[[email protected] Desktop]# mount <device to mount> <place where to mount>
For Instance, if you want to mount a Floppy drive then,
[[email protected] Desktop]# mount /dev/fd0 /mnt/floppy
So, here the /dev/fd0 is the alias for floppy drive in Linux system and /mnt/floppy is the mount point. It is the folder where we are mounting the floppy drive. So, if you want to view the files under floppy disk then you should directly access /mnt/floppy folder.
Note: In some Linux distribution, alias for the floppy drive may be different so, you should check the same before executing the command.
Syntax of Mounting the CD Drive
[[email protected] Desktop]# mount /dev/cdrom /mnt/CD
Here, the alias for the CD ROM is /dev/cdrom and the mount point is /mnt/CD.
Syntax of Mounting the USB Device
Once we plug the USB device in the port, Linux will detect it as a new device and create its alias in /dev directory. To check that alias you can execute the following command.
[[email protected] Desktop]# fdisk –l
Disk /dev/sdb: 60.0 GB, 60060155904 bytes
255 heads, 63 sectors/track, 7301 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000b2b03
Device Boot Start End Blocks Id System
/dev/sdb1 1 7301 58645251 b W95 FAT32
Once you identify your USB device from the above output then you can mount the same with the following command:
[[email protected] Desktop]# mount /dev/sdb1 /mnt/test
Here, the mount point that should be creating in the system is /mnt/test.
Syntax of Mounting the ISO Image
ISO Image is actually an image of any optical disk having extension .iso.
[[email protected] Desktop]# mount –o loop disk1.iso /mnt/disk
Here, -o loop option is used to support a file system that is in ISO format. It helps us to access such file system.
Syntax of Mounting the Hard Disk partitions
Once you have created a partition of your Hard Disk in Linux box then you should also mount those partitions to access them. Here, you can use the same command to find out the total partitions of the hard disk.
[[email protected] Desktop]# fdisk –l
… [Output Truncated]
Once you identify the partition which you want to mount then use the following command to mount the same.
[[email protected] Desktop]# mount /dev/sda1 /mnt/part1
Here, the mount point that should be created in the system is /mnt/part1.
Un-mounting the Devices in Linux
Un-mount means detaching any device from the Linux system and it is generally done with umount command. So, while un-mounting any device you should tell Linux what device to un-mount. For example,
To un-mount a floppy drive
[[email protected] Desktop]# umount /dev/fd0
[[email protected] Desktop]# umount /mnt/floppy
To un-mount a CD ROM drive
[[email protected] Desktop]# umount /dev/cdrom
To un-mount a USB drive
Assuming /dev/sda1 is the usb mount partition
[[email protected] Desktop]# umount /dev/sda1
This will detach the device from your Linux box. You can then remove that device from the system.