How to mount a filesystem?

To mount a filesystem in Linux, you can use the mount command. Here’s a general syntax and example:

Syntax

sudo mount [options] <source> <mount_point>
  • sudo: Runs the command with superuser privileges.
  • mount: The command used to mount filesystems.
  • <source>: The device or filesystem you want to mount (e.g., a disk partition or network share).
  • <mount_point>: The directory where the filesystem will be mounted.

Example

If you want to mount a device (e.g., /dev/sdb1) to a mount point (e.g., ~/project/mount_point), you would do the following:

  1. Create the mount point (if it doesn't exist):

    mkdir -p ~/project/mount_point
  2. Mount the filesystem:

    sudo mount /dev/sdb1 ~/project/mount_point

Mounting an NFS Share Example

If you are mounting an NFS share, the command would look like this:

sudo mount -t nfs localhost:/srv/nfs/shared_data ~/project/nfs_mount

Note

  • Ensure that the source device or filesystem is available and that the mount point directory exists.
  • To unmount the filesystem later, use:
    sudo umount ~/project/mount_point

If you have any further questions or need more examples, feel free to ask!

0 Comments

no data
Be the first to share your comment!