How to mount the file system in linux | Ubuntu Server

How to mount the drive in the ubuntu. So in order to mount any drive in Linux we need to follow the 4 steps and will see in this article those 5 steps in detailed.

1. We need to identify the drive in system for that you need to run the command lsblk and you need to understand that command in the detailed. so there you will find few things like SbX(this is the drive) and you need to check the mount point.

So from the Sbx you will find the drive and from the mountpoint you will find the path from where you can access that drive.








2. Now you need to create the mount point. mountpoint is nothing but the point from where we can access that point. its more like a dir in linux. so we need to create a new dir using which we can access that drive

sudo mkdir data






3. Now we need to create a filesystem(file system or filesystem is a method and data structure that the operating system uses to control how data is stored and retrieved) and you can create using the below command.

sudo mkfs.ext4 /dev/sdb1










4. Now we have everything needed now we need to mount the drive to the mountpoint so that we can access that drive from the below command.

sudo mount /dev/sdb1 /media









5. If you do till here your FS is mounted but its not a permanent mount, its a temporary mount if you restart your machine it will again unmount. In order to make it permanent you need do some confirm changes and for that you need to run the below commands

sudo nano /etc/fstab

it will open the fstab file and there you need to add the below line but we need to understand the below line:

/dev/sdb1 /media ext4 defaults 1 2

so here you can see we have 6 component and will discuss these components in detail:

/dev/sdb1 -> This is the partition that you want to mount

/media -> This is the mount point

ext4 -> This is the filesystem type

defaults -> lists any active mount options. If using multiple options they must be separated by commas.

1 ->  This is known as backup option,  (the first digit) this is a binary system where 1 = dump utility backup of a partition. 0 = no backup. This is an outdated backup method and should NOT be used.

2-> This is File System Check Order, (second digit) Here we can see three possible outcomes.  0 means that fsck will not check the filesystem. Numbers higher than this represent the check order. The root filesystem should be set to 1 and other partitions set to 2.

Leave a Reply

Your email address will not be published. Required fields are marked *