This is part 6 of the RHCSA mini series, this one is a big topic…. storage.
You will learn about:
- creating volumes
- creating volume groups
- how to manipulate partitions
- how to manipulate file systems
LVM (Logical Volume Manager)
A Logical volume sits inside a Volume Group that can span multiple physical disks.
The LVM enables system administrators to create large file systems that can span any number of disks, taking advantage of hardware RAID configurations allows fail safe and rapid disk setups.
How to Create a Physical Volume
To create a physical volume follow these steps:
then list the attached disks on the server
use the physical volume create command a volume that spans the disks identified with the command above
pvcreate /dev/device /dev/device2 /dev/device3
next we need to create a volume group
How to create a volume Group
use the volume group create command
vgcreate myvg /dev/device /dev/device2 /dev/device3 (devices you want in vg)
You can use the pvdisplay and vgdisplay to view the volumes created
-to look at physical volumes
– to look at the volume groups
now you can create a logical volume
– to create a 100mb logical volume in a volume group
lvcreate -l 100m myvg -n weblv
now we can format the volume with any linux compatible file system. in this example I will use XFS
now we must create a mount point
mount /dev/myvg/weblv /mnt/web
The above command mounts the new filesystem in /mnt/web
– to display volume
– you can use blockid to list uuid numbers, this can later be added to /etc/fstab
there are several types of partitions that are compatible with red hat.
MBR (Master Boot Record)
not to be confused with MBR bootstrap code, MBR is also a partition table.
There are 3 types of MBR
Primary partitions can be bootable and are limited to four partitions per disk or RAID volume. If the MBR partition table requires more than four partitions, then one of the primary partitions needs to be replaced by an extended partition containing logical partitions within it.
– used to manage MBR
– list MBR
– to get MBR information about a specific device
p – print partition table
n – create new partition
Last Sector – use to set size, either max or +500m (or whatever)
t – change partition type
l – list HEX codes (82 is Linux Swap, 83 is Linux partition, 8e is Linux LVM partition)
d – to delete partition
w – write current changes to disk
partprobe – kernel looks at proc and pulls partition info live
For a detiled procedure check out this blog post
GUID Partition Table (GPT) is a partitioning scheme that is part of the Unified Extensible Firmware Interface specification; it uses globally unique identifiers (GUIDs), or UUIDs in the Linux world, to define partitions and partition types. It is designed to succeed the Master Boot Record partitioning scheme method
GPT is UEFI native, it will work on old bios, but added drivers are needed
The Maximum GPT partition is 16eXerbytes!
n – add new partition
t – type (commands are same as fdisk)
L – list types (8200 – linux swap. 8300 linux partition, 8e00 Linix LVM)
Use partprobe to scan for hardware changes. To mount the file system you need to create a mountpoint using
blkID is the UUID
It can be added to /etc/fstab
Managing Mounted Disks
XFS is a highly scalable, high-performance file system which was originally designed at Silicon Graphics, Inc. XFS is the default file system for Red Hat Enterprise Linux 7
– this formats the disk to xfs
To manage the mounted filesystem use
The following operators work with xfs-admin
L – is label the disk (max 12 characters)
xfs_admin -L “MyDISK” /dev/devicename
xfs_admin -l /dev/devicename
Use blkid to get the UUID
– to remove the UUID
xfs_admin -U nil /dev/devicename
– to restore the original UUID
xfs_admin -U restore /dev/devicename
– creates a new UUID (you can still restore to previous)
xfs_admin -U generate /dev/devicename
Use lazy counters -to disable or enable superblock access -which can speed up the file system
The ext4 file system is a scalable extension of the ext3 file system, which was the default file system of Red Hat Enterprise Linux 5. Ext4 is the default file system of Red Hat Enterprise Linux 6, and can support files and file systems up to 16 terabytes in size. It also supports an unlimited number of sub-directories (the ext3 file system only supports up to 32,000), though once the link count exceeds 65,000 it resets to 1 and is no longer increased.
– to create ext4 FS
tune2fs can manage ext2,3,4 file systems
– to label an EXT4 File system
tune2fs -L “DiskLABEL” /dev/devicename
– to list information about the disk EXT4 file system
tunes2fs -l /dev/devicename
– to generate UUID
tune2fs -U random /dev/devicename
The /etc/fstab file is a system configuration file that contains all available disks, disk partitions and their options. Each file system is described on a separate line. Each line contains six fields separated by one or more spaces or tabs. If you add a new hard disk or have to repartition the existing one, you’ll probably need to modify this file.
The /etc/fstab file is used by the mount command, which reads the file to determine which options should be used when mounting the specified device.
Each fstab entry consists of 6 columns
- Device Identifier (UUID)
- Mount Point
- Filesystem Type (xfs, ext4)
- Mount Options (defaults – rw,suid,dev,exec,auto,nouser,async).
- dump frequency
- filesystem check order
LABELS can be used in FSTAB as well.
mount -a mounts disks in /etc/fstab