Sizing Non-LVM Root Partitions

Recently, I was faced with a busy production server with a space problem where the root partition was near capacity.

After some research, I determined that it was possible to add space to the RHEL root partition but felt that this would be risky as I did not have experience making this sort of change.

Fortunately, I was able to spin up a clone of this system in our QA Environment to test the procedure that I explain below.

Overview

  • Allocate Disk Space to Virtual Machine In VMWare vSphere
  • Backup Virtual Machine
  • Execute Steps Below
  • Test Services including Backup Process

Steps

  1. Login(ssh) to Server and Sudo to Root (su)
    ssh server-name
    sudo su

  2. List Disk Partitions
    fdisk -l

    Disk /dev/sda: 1319.4GB, 1319413952512 bytes
    255 heads, 63 sectors/track, 160509 cylinders

    Disk identifier: 0x00000000

    Device Boot Start End Blocks Id System
    /dev/sda1 1 8355 67108864 82 Linux swap / Solaris
    /dev/sda2 * 8355 133675 1006631936 83 Linux

  3. Determine unique device Identifiers
    blkid

    /dev/sda2: 970ab9b7-e71a-45da-907c-1b4005c1c8a9 /
    /dev/sda1: 43d83161-4d58-4cb5-8d39-4511f693cc87 swap

  4. Check mount list
    cat /etc/fstab

  5. Modify /dev/sda Disk using fdisk command
    fdisk /dev/sda

  6. In fdisk – List, delete, partition 2
    p d 2

  7. List, Add New Partition 2, Start 8355, End 160509, write partition table and quit
    p n p 2 8355 160509 W

  8. Modify /dev/sda Disk partition using fdisk command
    fdisk /dev/sda

    Check Partition ID and change Partition Type to 83 (Linux) If Incorrect.
  9. List, Set, Parition 2, Type 83 (Linux), List and Write Partition Table.
    p t 2 83 p w

  10. Use blkid command to check partition identifier is the same and move on to the next step or change identifier in /etc/fstab file to the new identifier value. *** Please Note *** Failure to change the value in the /etc/fstab file will most likely result in the system not booting.
    blkid

  11. Restart VM, Login, Check Disk Size, Update File System, Partitions, and Disk Size
    init 6
    ssh server-name
    sudo su
    df –h

    Filesystem Size Used Avail Use% Mounted on
    /dev/sda2 945G 756G 142G 85% /
    tmpfs 32G 0 32G 0% /dev/shm

    resize2fs /dev/sda2
    resize2fs 1.41.12 (17-May-2010)
    Filesystem at /dev/sda2 is mounted on /; online resizing required
    old desc_blocks = 60, new_desc_blocks = 73
    Performing an online resize of /dev/sda2 to 305343851 (4k) blocks.
    The filesystem on /dev/sda2 is now 305343851 blocks long.

    fdisk -l

    Disk /dev/sda: 1319.4 GB, 1319413952512 bytes
    255 heads, 63 sectors/track, 160409 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

    Device Boot Start End Blocks Id System
    /dev/sda1 1 8355 67108864 82 Linux swap / Solaris
    /dev/sda2 8355 160409 1221375404+ 83 Linux


    df –h

    Filesystem Size Used Avail Use% Mounted on
    /dev/sda2 1.2T 756G 334G 70% /
    tmpfs 32G 0 32G 0% /dev/shm

Outcomes

  1. Root Partition Disk Space Increased from 945G to 1.2T by resizing disk.
  2. Database Backups stopped failing
  3. Data migration continued successfully

Leave a Reply