Linux – How to extend linux root partition size in CentOS 6.9 without LVM

centos6linuxpartition

I installed CentOS 6.9 instance with 50GB HDD in Openstack. It shows only 8GB for the root partition. But I need to allocate entire HDD size (50GB) for root.
fileSystem details

How can I fix this??

Best Answer

Are you using any LVM devices inside the 42 GB partition?

If not, you could proceed like this (as root):

  1. Back up your data
  2. Install parted (if not already installed): yum -y install parted
  3. Remove LVM partitions if present using lvremove
  4. List partitions: parted -l, you get an output like this

    Model: ATA something (scsi)
    Disk  /dev/vda:  50GB
    Sector size (logical/physical): 512B/512B
    Partition table: msdos
    Disk Flags: 
    Number  Start   End     Size    Type     File system     Flags
     1      1049kB  8GB      8GB    primary  ext4            
     2      8GB    50GB     42GB    primary                  lvm
    
  5. Remove the partition:

    $ parted
    (parted) rm 2
    

    Verify it's deleted:

    (parted) print
    Model: ATA something (scsi)
    Disk  /dev/vda:  50GB
    Sector size (logical/physical): 512B/512B
    Partition table: msdos
    Disk Flags: 
    Number  Start   End     Size    Type     File system     Flags
     1      1049kB  8GB      8GB    primary  ext4     
    
  6. resize the partition:

    (parted) resizepart 
    Partition number? 1
    End?  [8.0GB]? 50000
    
  7. Verify it worked:

    (parted) print
    Model: ATA something (scsi)
    Disk  /dev/vda:  50GB
    Sector size (logical/physical): 512B/512B
    Partition table: msdos
    Disk Flags: 
    Number  Start   End     Size    Type     File system     Flags
     1      1049kB  50GB    50GB    primary  ext4  
    
  8. Quit: (parted) quit and reboot and verify everything works.