0

How to expand a volume given the following situation?

Looks like there is enough space on sda2 but I do not know how to make the volume centos-root use it.

#> parted /dev/sda print free
Disk /dev/sda: 537GB

Number  Start   End     Size    Type     File system  Flags
        32,3kB  1049kB  1016kB           Free Space
 1      1049kB  525MB   524MB   primary  xfs          boot
 2      525MB   537GB   536GB   primary               lvm
        537GB   537GB   16,9kB           Free Space


#> lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0   500G  0 disk 
├─sda1            8:1    0   500M  0 part /boot
└─sda2            8:2    0 499,5G  0 part 
  ├─centos-root 253:0    0   8,5G  0 lvm  /
  └─centos-swap 253:1    0     1G  0 lvm  [SWAP]

What I've tried so far:

  • resize2fs
  • lvextend

However I get the following errors:

#> resize2fs -P /dev/sda2
resize2fs: Device or resource busy while trying to open /dev/sda2
Couldn't find valid filesystem superblock.

#> lvextend -l 100%FREE /dev/mapper/centos-root 
New size given (10 extents) not larger than existing size (2168 extents)

Update

With further experimenting, I've found out that I've missed to run pvresize, then I could run also lvextend successfully:

#> pvresize /dev/sda2
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

#> lvextend -l 100%FREE /dev/mapper/centos-root
  Size of logical volume centos/root changed from <9,47 GiB (2424 extents) to <489,04 GiB (125194 extents).
  Logical volume centos/root successfully resized.

Now the output of lsblk looks much better:

#> lsblk 
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0   500G  0 disk 
├─sda1            8:1    0   500M  0 part /boot
└─sda2            8:2    0 499,5G  0 part 
  ├─centos-root 253:0    0   489G  0 lvm  /
  └─centos-swap 253:1    0     1G  0 lvm  [SWAP]

Still, df -h shows me the old size and the scsi rescan manual does not help, neither the official tool.

#> df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 7,8G     0  7,8G   0% /dev
tmpfs                    7,8G     0  7,8G   0% /dev/shm
tmpfs                    7,8G   17M  7,8G   1% /run
tmpfs                    7,8G     0  7,8G   0% /sys/fs/cgroup
/dev/mapper/centos-root  8,5G  2,5G  6,1G  30% /
/dev/sda1                497M  151M  347M  31% /boot
tmpfs                    1,6G     0  1,6G   0% /run/user/0
tmpfs                    1,6G     0  1,6G   0% /run/user/1013

What to do?

1 Answer 1

0

Finally, the missing step has been to apply lvresize:

 #> lvresize --extents +100%FREE --resizefs /dev/mapper/centos-root
      Size of logical volume centos/root changed from <489,04 GiB (125194 extents) to <498,51 GiB (127618 extents).
  Logical volume centos/root successfully resized.
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=555008 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=2220032, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

df -h confirms the desired result. Yeay! happy to see other answers if there have been a more straight-forward way perform this operation.

#> df -Ph /dev/mapper/centos-root 
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  499G  2,3G  497G   1% /

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.