Table of Contents
- Introduction
- What is Storage Management?
- Core Storage Management Commands
- Real-World Scenario: Storage Management Commands
- Conclusion
- Let's Connect
Introduction
Welcome back to Day 26 of this practical Linux challenge!
In this post, we will cover Storage Management in RHEL 9, how to handle new storage devices, partition them, format, mount, and make them persistent.
If you are working with servers or cloud VMs, storage is something you will definitely encounter, whether it is adding more space or organizing existing disks.
What is Storage Management?
Store management comes handy whether you are:
- Adding an EBS volume on AWS,
- Attaching a new disk to a VM,
- Or just learning how Linux handles storage.
You will need to understand how to identify new disks, partition them, format, mount, and persist them in your system.
Core Storage Management Commands
More commonly used Core Storage Management Commands options are listed in the table below.
Storage Command | Use |
---|---|
lsblk |
Lists all block devices |
fdisk |
Create or manage partitions (for MBR disks) |
parted |
Create or manage partitions (especially GPT disks) |
mkfs.ext4 |
Format partition with ext4 filesystem |
mkfs.xfs |
Format partition with XFS filesystem |
mount |
Mount a file system |
umount |
Unmount a file system |
blkid |
Displays UUID and type of block devices |
df -h |
Show mounted disk usage in human-readable format |
vi /etc/fstab |
File to make mounts persistent |
Real-World Scenario: Storage Management Commands
You are a Junior Linux SysAdmin and your team adds a new virtual disk
/dev/sdb
to your RHEL 9 server. You have been asked to format and mount it to/mnt/backups
.
- Check Existing Disks
lsblk
Mine is already partitioned and mounted. but if yours isn't then follow these steps.
- Now, create a partition
fdisk /dev/sdb - # you can do this only using root, add sudo before the command if you are not
# type n to create a new partition, accept defaults and w to write changes
lsblk - # to see the new disk created
- Format the Partition
mkfs.ext4 /dev/sdb1 # depending on the file extension you want, you do .xfs as well
- You can go ahead and create the Mount Directory
mkdir /mnt/backups
- We go on to mount the partition we created earlier
mount /dev/sdb1 /mnt/backups
df -h - # to verify it mounted
- Let's make Mount persistent.
When you manually mount a disk using the mount command, it works only until the system reboots. After a restart, the OS forgets about your mount, and your disk won't be accessible from that mount point anymore.
So we say that the mount is temporary, not persistent.
To make sure your disk stays mounted even after a reboot, you need to tell Linux to mount it automatically every time the system starts.
That’s what we mean by making the mount persistent.
- We will first get the UUID of the partition.
blkid /dev/sdb1
- Open the fstab file in a text editor like vim
vim /etc/fstab
- Scroll down and add this line at the end of the file
UUID=abcd-1234 /mnt/data ext4 defaults 0 2
What they mean:
UUID=abcd-1234: uniquely identifies your disk (this won’t change across reboots)
/mnt/data: where you want the disk mounted
ext4: the file system type
defaults: standard mount options
0: skip dump (a legacy backup thing)
2: run fsck (filesystem check) after boot, after root file system
- Test it before rebooting
mount -a
If no errors, it is successful. After this, even if you restart your system, your disk will stay mounted at /mnt/data.
Before making any changes to /etc/fstab, always back it up. This simple step can save you from system boot issues due to a misconfiguration.
cp /etc/fstab /etc/fstab.bak - # to backup
cp /etc/fstab.bak /etc/fstab - # to restore if system breaks
mount -a # to remount
Conclusion
Understanding how Linux handles disks is essential whether you are working with physical servers or managing virtual machines in the cloud.
Feel free to try it out on your own server or VM.
See you in the next article!
If this is helpful to you, feel free to bookmark, comment, like and follow me for Day 27!
Let's Connect!
If you want to connect or share your journey, feel free to reach out on LinkedIn.
I am always happy to learn and build with others in the tech space.
#30DaysLinuxChallenge #Redhat#RHCSA #RHCE #CloudWhistler #Linux #Rhel #Ansible #Vim #CloudComputing #DevOps #LinuxAutomation #IaC #SysAdmin#CloudEngineer