RHCSA Series: Using ‘Parted’ and ‘SSM’ to Configure and Encrypt System Storage – Part 6

In this article we will discuss how to set up and configure local system storage in Red Hat Enterprise Linux 7 using classic tools and introducing the System Storage Manager (also known as SSM), which greatly simplifies this task.

Configure and Encrypt System Storage
RHCSA: Configure and Encrypt System Storage – Part 6

Please note that we will present this topic in this article but will continue its description and usage on the next one (Part 7) due to vastness of the subject.

Creating and Modifying Partitions in RHEL 7

In RHEL 7, parted is the default utility to work with partitions, and will allow you to:

  1. Display the current partition table
  2. Manipulate (increase or decrease the size of) existing partitions
  3. Create partitions using free space or additional physical storage devices

It is recommended that before attempting the creation of a new partition or the modification of an existing one, you should ensure that none of the partitions on the device are in use (umount /dev/partition), and if you’re using part of the device as swap you need to disable it (swapoff -v /dev/partition) during the process.

The easiest way to do this is to boot RHEL in rescue mode using an installation media such as a RHEL 7 installation DVD or USB (Troubleshooting Rescue a Red Hat Enterprise Linux system) and Select Skip when you’re prompted to choose an option to mount the existing Linux installation, and you will be presented with a command prompt where you can start typing the same commands as shown as follows during the creation of an ordinary partition in a physical device that is not being used.

RHEL 7 Rescue Mode
RHEL 7 Rescue Mode

To start parted, simply type.

# parted /dev/sdb

Where /dev/sdb is the device where you will create the new partition; next, type print to display the current drive’s partition table:

Creat New Partition
Creat New Partition

As you can see, in this example we are using a virtual drive of 5 GB. We will now proceed to create a 4 GB primary partition and then format it with the xfs filesystem, which is the default in RHEL 7.

You can choose from a variety of file systems. You will need to manually create the partition with mkpart and then format it with mkfs.fstype as usual because mkpart does not support many modern filesystems out-of-the-box.

In the following example we will set a label for the device and then create a primary partition (p) on /dev/sdb, which starts at the 0% percentage of the device and ends at 4000 MB (4 GB):

Set Partition Name in Linux
Label Partition Name

Next, we will format the partition as xfs and print the partition table again to verify that changes were applied:

# mkfs.xfs /dev/sdb1
# parted /dev/sdb print
Format Partition in Linux
Format Partition as XFS Filesystem

For older filesystems, you could use the resize command in parted to resize a partition. Unfortunately, this only applies to ext2, fat16, fat32, hfs, linux-swap, and reiserfs (if libreiserfs is installed).

Thus, the only way to resize a partition is by deleting it and creating it again (so make sure you have a good backup of your data!). No wonder the default partitioning scheme in RHEL 7 is based on LVM.

To remove a partition with parted:

# parted /dev/sdb print
# parted /dev/sdb rm 1
Remove Partition in Linux
Remove or Delete Partition

The Logical Volume Manager (LVM)

Once a disk has been partitioned, it can be difficult or risky to change the partition sizes. For that reason, if we plan on resizing the partitions on our system, we should consider the possibility of using LVM instead of the classic partitioning system, where several physical devices can form a volume group that will host a defined number of logical volumes, which can be expanded or reduced without any hassle.

In simple terms, you may find the following diagram useful to remember the basic architecture of LVM.

Basic Architecture of LVM
Basic Architecture of LVM

Creating Physical Volumes, Volume Group and Logical Volumes

Follow these steps in order to set up LVM using classic volume management tools. Since you can expand this topic reading the LVM series on this site, I will only outline the basic steps to set up LVM, and then compare them to implementing the same functionality with SSM.

Note: That we will use the whole disks /dev/sdb and /dev/sdc as PVs (Physical Volumes) but it’s entirely up to you if you want to do the same.

1. Create partitions /dev/sdb1 and /dev/sdc1 using 100% of the available disk space in /dev/sdb and /dev/sdc:

# parted /dev/sdb print
# parted /dev/sdc print
Create New Partitions
Create New Partitions

2. Create 2 physical volumes on top of /dev/sdb1 and /dev/sdc1, respectively.

# pvcreate /dev/sdb1
# pvcreate /dev/sdc1
Create Two Physical Volumes
Create Two Physical Volumes

Remember that you can use pvdisplay /dev/sd{b,c}1 to show information about the newly created PVs.

3. Create a VG on top of the PV that you created in the previous step:

# vgcreate tecmint_vg /dev/sd{b,c}1
Create Volume Group in Linux
Create Volume Group

Remember that you can use vgdisplay tecmint_vg to show information about the newly created VG.

4. Create three logical volumes on top of VG tecmint_vg, as follows:

# lvcreate -L 3G -n vol01_docs tecmint_vg		[vol01_docs → 3 GB]
# lvcreate -L 1G -n vol02_logs tecmint_vg		[vol02_logs → 1 GB]
# lvcreate -l 100%FREE -n vol03_homes tecmint_vg	[vol03_homes → 6 GB]	
Create Logical Volumes in LVM
Create Logical Volumes

Remember that you can use lvdisplay tecmint_vg to show information about the newly created LVs on top of VG tecmint_vg.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Gabriel Cánepa
Gabriel Cánepa is a GNU/Linux sysadmin and web developer from Villa Mercedes, San Luis, Argentina. He works for a worldwide leading consumer product company and takes great pleasure in using FOSS tools to increase productivity in all areas of his daily work.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

8 thoughts on “RHCSA Series: Using ‘Parted’ and ‘SSM’ to Configure and Encrypt System Storage – Part 6”

  1. I have created encrypted LVM using ssm

    ssm create -s 3G -n vol01_docs -p tecmint_vg –encrypt luks –fstype ext4 /mnt/docs /dev/sdb

    updated /etc/crypttab file with UUID and after that made entry in fstab. When i reboot its not booting up going to maintenance mode

    give root password for maintenance
    type Control-D to continue).
    fstab entry:
    /dev/mapper/vol01_docs /mnt/docs ext4 defaults 0 2

    Could you please let share you thoughts on the same issue. thanks in advance :)

    Reply
    • @suresh,
      Try using the UUID or device LABEL instead of the path to the logical volume. Do that in a regular mount command, and if it works change that in your /etc/fstab.

      Reply
      • @Gabriel Cánepa
        Thanks for your update, I used UUID and LABEL too but getting same problem ext4 file system is not found and went to maintenance mode..

        Reply
    • @Rizal,
      Feel free to use whatever tool you like :). I used parted because it seems to be the default tool suggested in the RHEL 7 documentation.

      Reply
  2. @Humayun,
    Thank you for your kind words about this series! I am the author, and apologize for the delay in publishing the next article. But it should be online in a day or two. Please stay tuned and make sure you subscribe to Tecmint and you’ll receive a notice each time a new guide is published :).

    Reply
  3. I am following your tutorial and it is very helpful. I can see only until part-6 and it was on 7th April. Am I missing something (some form of subscription) or the next parts are delayed?

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.