Traditional Storage Management in Linux
Sources:
- Logical Volume Manager (LVM) versus standard partitioning in Linux
Traditional storage management
I use the phrase traditional storage management to describe the process of partitioning, formatting, and mounting storage capacity from a basic hard disk drive. I contrast this standard partitioning with an alternative method called Logical Volume Manager, or LVM.
Storage space is typically managed based on the maximum capacity of individual hard disk drives. The result is that when a sysadmin thinks about storage, they do so based on each drive. For example, if a server has three hard disk drives of 1 TB each, the sysadmin considers the storage literally, I have three 1 TB drives to work with.
Let's very quickly review traditional storage management. Here is a sample scenario:
Install a new hard disk drive
Purchase a one terabyte (1 TB) hard disk drive, and then physically install it into the server.
Partition the drive
Use
fdisk
orgparted
to create one or more partitions. It's important to note that the partitions cannot consume more than the total 1 TB of disk capacity.Example
fdisk
command:1
fdisk /dev/sdb
I won't cover the syntax for
fdisk
in this article, but assume I created a single partition that consumes the entire 1 TB disk. The partition is/dev/sdb1
.Display the capacity by using the
/proc/partitions
andlsblk
content:1
2cat /proc/partitions
lsblkCreate a filesystem
Create a filesystem on the new partition by using the
mkfs
command. You could use ext4 or RHEL's default XFS filesystem.1
mkfs.ext4 /dev/sdb1
While XFS is Red Hat's default, it may not be as flexible when combined with LVM as ext4. XFS filesystems can easily be extended but not reduced. I'll expand on that idea further toward the end of the article.
Create a mount point
The rest of this process is relatively standard. First, create a directory to serve as a mount point. Next, manually mount the partition to the mount point.
1
2mkdir /newstorage
mount /dev/sdb1 /newstorageConfirm the storage capacity
1
df -h
Note: The
-h
option displays the output ofdf
in capacity terms that are easy for humans to understand, such as GB or TB.Configure the space to mount at boot
Edit the
/etc/fstab
file to mount the filesystem at boot. If you need a reminder on/etc/fstab
, check out Tyler Carrigan's article An introduction to the Linux /etc/fstab file here on Enable Sysadmin.
Commands
Disk usage and information
List block devices:
1
lsblk
-f
: List filesystem informations.
Check disk usage by filesystem:
1
df -h
Check disk usage of a directory:
1
sudo du -h --max-depth=1 /path/to/directory
Filesystem commands
Resize Filesystem (ext4):
1
sudo resize2fs /dev/<volume-group-name>/<logical-volume-name>
Resize Filesystem (XFS):
1
sudo xfs_growfs /mount-point
General management
- Check disk partitions:
1
sudo fdisk -l
- Display mounted filesystems:
1
mount
- Unmount a filesystem:
1
sudo umount /dev/<device>