Linux File System

Earlier this year I purchased a production grade server (Dell r620 2@ 3.0Ghz Intel processors 10 cores each, 128GB or RAM, 8 @  SSD HDs with a 3.5T RAID 5) for my homelab. I hosted this blog site from home on a Raspberry Pi, so the last few days I have been transitioning my site to a VM on the server. I am running VMware vSphere 7.0 as my hypervisor software. So, I have been playing around with files systems, partitions, mount points and formatting. So let us dive in to creating a file system linux.

A filesystem controls how data is stored and retrieved and helps keeps the files organized on the storage media. Without a filesystem, information in storage would be one large block of data, and you couldn’t tell where one piece of information stopped and the next began. A filesystem helps manage all of this by providing names to files that store data and maintaining a table of files and directories—along with their start/end location, total size, etc.—on disks within the filesystem.

Drives are typically mounted in the /dev folder and will be called sda, the next disk would be sdb and so on. Partitions on each disk are then given a number. So, if we had three partitions on our sda disk then they would be labeled sda1, sda2, sda3. To identify partitions, you can use the command cat /proc/partitions this will show you all the current partitions.

Showing the current partitions

To identify the type of files systems we can add to our partitions we can use the command mkfs.<tab><tab> this will identify which files systems your distro is able to create. Most linux use the ext4 type of file system, windows systems like to use exFAT or FAT, Apple uses APFS (Apple file system).

Using context help to identify all files systems available

To create a ext4 file system on the sda1 partition we would use the command mkfs.ext4 /dev/sda1. The next step would be to mount the new file system, the main file system for the kernel will always get mounted at the root / but for a secondary system we typically would use the /mnt directory. We first need to create a directory to mount the disk to, so we would use the command mkdir /mnt/mount_point. So, to mount the newly created files system we use the command mount -t ext4 /dev/sd1 /mnt/mount_point/ the -t option tells the command what type of file system we are using. To see what files systems are mounted where we use the command df -h.

Result of the df command

In my example we see the main partition of /dev/sda2 mounted to / this is my main file system and where it is mounted. The draw back to the mount command is that the mounting of this disk will not persist when a reboot happens. We would need to manually mount the file system. In an upcoming post I will discuss modifying the fstab file to allow for persistent mounting when the system reboots.

References:

https://linux.die.net/man/8/mount

https://man7.org/linux/man-pages/man5/filesystems.5.html

https://linux.die.net/man/8/mkfs

https://linux.die.net/man/1/df

Leave a Reply

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