0

I help out a company halfway across the country with maintaining their website and web server running on CentOS 7. The root partition keeps running out of disk space and crashing the server, so they say that they added another 300GB to it. I am having trouble identifying the new disk space, and adding it to the root partition.

Here is the fdisk -l output.

$ sudo fdisk -l

Disk /dev/sda: 322.1 GB, 322122547200 bytes, 629145600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x0007be79

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   266338303   132656128   8e  Linux LVM

Disk /dev/sdb: 136.4 GB, 136365211648 bytes, 266338304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/centos-swap: 4160 MB, 4160749568 bytes, 8126464 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/centos-home: 77.9 GB, 77921779712 bytes, 152190976 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

I'm confused here. /dev/sda has 322.1 GB, and the Disk label type is "dos". I'm assuming that this is the new disk.

However, there are sda1 and sda2 partitions on it. Is that the OS?

I need to add 300 GB to the /dev/mapper/centos-root partition. How do I do that?

I'm attaching the results of some other commands that may be helpful below.

$ sudo pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               126.51 GiB / not usable 3.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              32386
  Free PE               16
  Allocated PE          32370
  PV UUID               vFa16P-F0LF-hpTo-6xca-Wz83-wfoD-GbxNVp

$ sudo lvmdiskscan
  /dev/centos/root [      50.00 GiB] 
  /dev/sda1        [     500.00 MiB] 
  /dev/centos/swap [      <3.88 GiB] 
  /dev/sda2        [     126.51 GiB] LVM physical volume
  /dev/centos/home [      72.57 GiB] 
  /dev/sdb         [     127.00 GiB] 
  4 disks
  1 partition
  0 LVM physical volume whole disks
  1 LVM physical volume

$ sudo parted -l
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 322GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  525MB  524MB  primary  xfs          boot
 2      525MB   136GB  136GB  primary               lvm


Error: /dev/sdb: unrecognised disk label
Model: Msft Virtual Disk (scsi)                                           
Disk /dev/sdb: 136GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-home: 77.9GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system  Flags
 1      0.00B  77.9GB  77.9GB  xfs


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-swap: 4161MB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system     Flags
 1      0.00B  4161MB  4161MB  linux-swap(v1)


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-root: 53.7GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system  Flags
 1      0.00B  53.7GB  53.7GB  xfs
  • You could certainly expand sda2 to fill the rest of that virtual disk. – Michael Hampton Feb 27 '18 at 0:54
  • How would I do that? – scott80109 Feb 27 '18 at 0:56
  • Use fdisk to delete sda2 and recreate it with the same start sector, but the end at the end of the disk. – Michael Hampton Feb 27 '18 at 1:02
  • But what is on sda2? Would I lose data? – scott80109 Feb 27 '18 at 1:08
  • All the output you pasted says what's on sda2, and no. – Michael Hampton Feb 27 '18 at 1:20
1

I just found this excellent tutorial that solved all of my problems. I went through it twice. Once to format the unused /dev/sda space as an LVM partition and add it to the logical volume. And a second time to format the new /dev/sdb disk, and add it to the logical volume.

My centos-root disk space went from 54 GB to 376 GB!

https://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-expanding-the-virtual-machine-disk/

  • I've just seen your message. I'm glad to see that you have been solved problem. I followed this link and expand my Centos VM root partition about month ago too. I recommend to you repeat this steps on VM. As block devices for this experiments I recommend using loopback block devices. Create file over dd with corresponding size and mount it with 'losetup' (linux-utils package). Then your loopback block device will be visible as 'real' block device. – Yurij Goncharuk Feb 27 '18 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.