In Linux mounting of devices (external disks,usb,cd drive) 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.
Mount and change permissions on external drives
By default, it's only the user of the pen drive that has read and write permissions as shown below. The group and other users are restricted from having both read and write permissions as shown below. The pen drive, in this case, is labeled KIARIE found in /run/media/tarantula/ file path.
ls -l /run/media/tarantula
total 60 drwx------ 39 tarantula tarantula 61440 Jan 1 1970 KIARIE
This can also be seen in the file manager properties of the flash drive below
To grant other people access to the drive including all files and folders in the drive, run the following commands:
First, create a mount point in the /media/ directory. Let's call it /data
mkdir -p /media/data
fdisk -l to find out the partition information of the flash drive. If it's the only removable drive, you'll find that it's indicated as
/dev/sdb1 Implying that it's the first partition of the second hard drive with a filesystem of FAT32.
The second step is to mount it to /mnt/data with read and write options.
mount -t ext4 -o rw /dev/sdb1 /mnt/data
Change permissions recursively i.e
chmod + R a+rw /mnt/data
This procedure will only work for an external drive formatted in ext4 format. If you are using a drive in Vfat or FAT 32 filesystem, you'll need to convert it to ext4 using Gparted utility tool. Ensure to back up any data before conversion as this leads to formatting of the drive from one filesystem to another.
Another way you can mount and change permissions on external drives is by using pysdm package. However, this package has been obsoleted and is no longer in use for Ubuntu versions 12.10 and later.
When changing files permissions on the last step, you can also use the octal system i.e chmod +R 766 /mnt/data to give the group and other users Read and write permissions. Thank you.
Mounting 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.
Mounting a 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.
Mounting an 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.
Mounting 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.
How to Unmount 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.