Post

Adding filesystems to Red Hat

Adding filesystems to Red Hat

In today’s tutorial we are adding 1 new filesystem for a MariaDB database installation and we are doing it using fdisk.

fdisk - manipulate disk partition table

1
fdisk -l
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

First partition /dev/sdb

1
fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x8c0800e6.

Command (m for help): 

n add a new partition

1
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)

p primary

1
Command (m for help): p
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519): 

Created a new partition 1 of type 'Linux' and of size 10 GiB.

Command (m for help): 

w write table to disk and exit

1
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

XFS vs. Ext4 File Systems

When to Use XFS

Use XFS when you have applications that retrieve large files. High-traffic servers in the cloud might be best with the XFS file system for its parallel I/O. Critical servers that need fast response times with files or data queries could also benefit from using XFS.

When to Use Ext4

The ext4 file system offers better performance with smaller files and servers with limited CPU bandwidth. It can still be used with critical production servers, but it should not be the main server for high-volume servers transferring large files. Without disaster recovery tools, an ext4 server needs third-party tools to perform backups.

mkfs - build a Linux filesystem

mkfs is used to build a Linux filesystem on a device, usually a hard disk partition.

1
mkfs -t ext4 /dev/sdb
mke2fs 1.45.6 (20-Mar-2020)
Found a dos partition table in /dev/sdb
Proceed anyway? (y,N) y
Discarding device blocks: done                            
Creating filesystem with 2621440 4k blocks and 655360 inodes
Filesystem UUID: f70edf86-7b9c-4f35-a9a3-9da01c2e4ffc
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

Create a new directory and mount it.

1
2
mkdir /mariadb
mount -t ext4 /dev/sdb /mariadb

Linux /etc/fstab file

Is a configuration table designed to ease the burden of mounting and unmounting file systems to a machine.

1
vi /etc/fstab
/dev/sdb	/mariadb	ext4 defaults 2 1

Sources

Photo by Crissy Jarvis on Unsplash

XFS vs. Ext4: Which Linux File System Is Better? https://blog.purestorage.com/purely-educational/xfs-vs-ext4-which-linux-file-system-is-better/

An introduction to the Linux /etc/fstab file https://www.redhat.com/en/blog/etc-fstab

Want to thank me?

🤝 Buy me a coffee https://buymeacoffee.com/dbplatz

This post is licensed under CC BY 4.0 by the author.