Expanding a disk using the parted utility in Linux

Parted is a free disk partition editor designed for creating and deleting partitions. The utility is useful for creating partitions for new operating systems, reorganizing the use of hard disk space, copying information between disks and creating disk images.

In one of the previous articles, a method was considered for expanding a disk using the utility growpart

But, when increasing the disk in Debian 8, I encountered the fact that growpart cannot expand the disk, an error appears:

FAILED: failed to resize
**** WARNING: Resize failed, attempting to revert ****
Re-reading the partition table ...
sfdisk: BLKRRPART: Device or resource busy
sfdisk: The command to re-read the partition table failed.
Run partprobe(8), kpartx(8) or reboot your system now,
before using mkfs
**** Appears to have gone OK ****

Installing the necessary software

$ sudo apt update
$ sudo apt -y install lvm2 parted xfsprogs

We expand the required disk in the hypervisor, reboot. Let’s start expanding the section

$ sudo parted /dev/sdb
(parted) print
Fix/Ignore? Fix
(parted) resizepart 1
End?  [4295MB]? 6392MB
(parted) print
(parted) quit

In this example, we expand the dyka / dev / sdb partition for the first time from 4 Gb to 6 Gb

Meaning 6392MB we get after executing the command print in line Disk / dev / sdb:

Well, then I expanded the physical volume, lvm-partition:

$ sudo pvresize /dev/sdb1
$ lsblk
$ df -hT | grep mapper
$ sudo lvextend -r -l +100%FREE /dev/mapper/storage--vg-vol_backups
$ sudo xfs_growfs /mnt/storage

Related Posts