Linux operating systems can mount different file systems in order to store data, files, and folders. Mount operation is attaching a specified disk or partition into the specified path of the Linux root file system. Linux and all its distributions provide the mount command in order to mounts file systems and umount in order to unmount the already mounted file system.
mount Command Syntax
The mount command or tool is installed by default. The mount command has the following syntax.
mount OPTION SOURCE DESTINATION
- OPTION is the mount options which can be used to specify file system type etc. This option is optional.
- SOURCE is the source partition or disk which will be mounted into the DESTINATION.
- DESTINATION is the local path where newly mounted partition or disk can be accessed.
List Mounted File Systems
The mount command can be used to list allready mounted filesystems. Linux is a file based operating system which provides a lot of mounts. But we need to list only /dev related mounts to list.
/dev/sda3 on / type ext4 (rw,relatime,errors=remount-ro) /dev/sda2 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
- “/dev/sda3” is the source partitions which is 4th partition of the sda drive.
- / is the destination mount point which is root.
- ext4 is the file system type.
- (rw,relatime,errors=remount-ro) is the mount options.
List Disks and Partitions
Before mounting file systems the existing disks and partitions can be listed with different commands. The lsblk is a modern Linux command which lists disks and partitions on the Linux system.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 51M 1 loop /snap/snap-store/518 loop1 7:1 0 217,9M 1 loop /snap/gnome-3-34-1804/60 loop2 7:2 0 55,4M 1 loop /snap/core18/1932 loop3 7:3 0 64,4M 1 loop /snap/gtk-common-themes/1513 loop4 7:4 0 64,8M 1 loop /snap/gtk-common-themes/1514 loop6 7:6 0 51M 1 loop /snap/snap-store/498 loop7 7:7 0 55,4M 1 loop /snap/core18/1944 loop8 7:8 0 31,1M 1 loop /snap/snapd/10238 loop9 7:9 0 31,1M 1 loop /snap/snapd/10492 sda 8:0 0 120G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 513M 0 part /boot/efi └─sda3 8:3 0 119,5G 0 part / sr0 11:0 1 1024M 0 rom
Mount Disk or Partition
The mount operation by default requires root privileges. We can provide the root privileges with the sudo command. The “/dev/sdb” is the disk we will mount into the “/mnt”.
sudo mount /dev/sdb /mnt