15 C
Texas
Melhttp://www.osradar.com
Guru Unix /Linux and GNU supporter

How to Mount/Unmount a File System in Linux

–blocLinux is a really powerful system in case of the storage management. Because of all the systems, it has to go through, Linux ensures the top-notch security of all the OS in the world. If you connect a SATA/PATA or SCSI device, you can’t access it directly. You have to manually mount the filesystem to get access to it. Now, let’s take a look how to mount the filesystem.

Mounting a filesystem

At first, connect the device to your Linux system. We’ll be using “hwinfo” for this purpose. This tool is available in Ubuntu, Fedora, and OpenSUSE.

sudo apt install hwinfo

- Advertisement -

Identify the disk by running the following command:

hwinfo --block --short

Now, run this command to mount the file system:

sudo mount /dev/sdb

Generally, you don’t have to specify the file system type as Linux will automatically understand the file system type. In the case of above command, you can also specify the mount point for the drive. For example, running command will mount the “/dev/sdb” as “/data”.

sudo mount /dev/sdb /data

Before using other options, you need to understand the structure of “mount”.

mount [-t file_system_type] [-o mount_options] device mount_point_directory

There are several available options with “mount” command.

  • remount – Unmounts and mounts a file system. It’s really useful if you have made changes in the “/etc/fstab” file. Use this command to apply the changes.
  • exec, noexec – You can define whether any executable can be run from the file system or not.
  • ro, rw – You can make sure whether the file system will be read-only (ro) or writable (rw).

Unmounting the file system

After using the file system, it’s better to unmount it again if you’re not using. Use this command:

sudo umount /dev/sdb

You can also use the mount point for unmounting the file system.

sudo umount /data

If you get an error like the directory is being used by other apps, use this command to identify the processes that are accessing the file system at the time.

Force-unmounting the file system

In some scenario, the kernel sees the file system as “busy”, no matter whatever you do. In that case, forced unmounting is the only option. Use this command for force-unmount:

umount -f /dev/sdb

This should be used as a last resort and you’re sure of it.

List mounted file systems

If you’re interested in finding out all the available (mounted) file systems, run this command:

mount

Enjoy!

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article