# Day6 : Linux Filesystem

### What is Linux filesystem?

Filesystem defines how data is store in a disk.

### Why do we need Filesystem?

Lets say you have created a partition , but partition alone does not make a disk usable in the OS.

The disk and kernel is seen by the linux kernel as raw disk. So, to write to a disk or partition we must first create a filesystem.

After creating filesystem me must mount it to directory and thats when we can read or write data to it.

### 3 Commonly used Filesystem:

There are 3 commonly used filesystems : ext2, ext3 and etx4.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720517789389/87abf742-75ac-4bd4-979e-04b66bde8537.png align="center")

### Steps to Create and Mount a Filesystem on a Partitioned Disk

First lets create a partition of size 250M on disk /dev/xvdb of size 1GB by using gdisk command , please check the screenshot for the detailed steps:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720521485059/169d15ab-5c90-4c25-9a2f-6247a4e4b47d.png align="center")

Let's check if the partition of 250M is created on /dev/xvdb disk

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720521641084/ba4bf870-73d0-44be-b5e9-259ead8ad7f4.png align="center")

Now, that the partition is created next we have to create a filesystem to make this partition usable.

So to create a filesystem use mkfs command , here we are going to make use of ext4 filesystem.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720521904792/2ac85d7c-1d88-49c5-a03f-22de04f26a53.png align="center")

Lets check if the filesystem is created for partition /dev/xvdb1 for this use blkid command.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720522121609/4c4d4523-900a-4ba1-a804-f67f957b08c6.png align="center")

Next we have to create a directory on which the partition disk will be mounted. We will create /mnt/data directory using mkdir command

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720522382690/840fb7ab-08a4-4dd1-82cf-fa8e114f1bba.png align="center")

Once the directory is created , now the filesystem can be mounted on the system using mount command.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720522830286/dccb5302-8b56-43e8-b728-fb4221bb47e7.png align="center")

To check if the file system is mounted either use df command or mount command.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720523018020/db63edc4-2825-4962-92c2-37df6d829059.png align="center")

To make this mount to be available after system boot make entry to /etc/fstab file like this

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720523217682/5352ef8b-07e2-4a80-87c8-538a9641942d.png align="center")
