We have a Centos server as a virtual machine where the / path is getting full. So we want to resize the partition from 50GB to 70GB.

I followed this guide https://www.thomas-krenn.com/de/wiki/LVM_vergr%C3%B6%C3%9Fern

So the first step was to increase the size in the VM preferences.

After this I used cfdisk to create a new parition.


sda1                        NC                          Primary                GPT                                                                      53687.10                *
                                                        Pri/Log                Free Space                                                               21474.84                *

AFTER Writing:

 sda1                        NC                          Primary                GPT                                                                      53687.10                *
 sda2                                                    Primary                Linux                                                                    21474.84                *

As the guide said I first didn't do a restart and used the command partprobe.

Error: The backup GPT table is not at the end of the disk, as it should be.
This might mean that another operating system believes the disk is smaller.   
Fix, by moving the backup to the end (and removing the old backup)?
Warning: Not all of the space available to /dev/sda appears to be used, you  
can fix the GPT to use all of the space (an extra 41943040 blocks) or  
continue with the current setting?
Warning: WARNING: the kernel failed to re-read the partition table on    
/dev/sda (Device or resource busy).  As a result, it may not reflect all of   
your changes until after reboot.

After this message I was not sure and did finally a restart.

Then I tried to initialize the new partition as PV

[root]# pvs
PV         VG            Fmt  Attr PSize  PFree
/dev/sda3  vg_atcrushftp lvm2 a--  49.31g 10.00g

and got this error message:

[root]# pvcreate /dev/sda2
Can't open /dev/sda2 exclusively.  Mounted filesystem?

Now I was not sure and did a df to look for it

[root]# df -h
Filesystem            Size  Used Avail Use% Mounted on
                   35G  8.4G   25G  26% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda2             477M  121M  331M  27% /boot
/dev/sda1             200M  260K  200M   1% /boot/efi

[root]# df -T
Filesystem           Type   1K-blocks       Used  Available Use% Mounted on
                 ext4    36380264    8720856   25804740  26% /
tmpfs                tmpfs    1962068          0    1962068   0% /dev/shm
/dev/sda2            ext4      487652     123566     338486  27% /boot
/dev/sda1            vfat      204580        260     204320   1% /boot/efi

A mount command shows this

[root]# mount
/dev/mapper/vg_atcrushftp-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda2 on /boot type ext4 (rw)
/dev/sda1 on /boot/efi type vfat (rw,umask=0077,shortname=winnt)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

It looks like I can't use the created partition because it is the /boot. Does this mean I destroyed the information on /boot? Before I started I created a snapshot. So I can recover the old state.

What should I do next? I want to resize the partition without losing data.

  • What's the output of lsblk? – csny Jun 9 '15 at 15:36
  • This command is very cool. Thanks for your help but I already solved the problem. I never deleted the old part and just resized it from the end blocks with gdisk. It seems that this was not the best way. After new partitioning with "parted" (without data loss) I changed the type to "LVM" and "pvresize" was now able to use it correct. – user3772108 Jun 10 '15 at 13:46

Resize an LVM partition on a GPT drive


pvs         Shows physical volume
lvs         Shows logical volume
vgs         Shows volume groups
vgdisplay   Shows volume groups including mount points
lsblk       Shows block hierarchy (plate, partition, LVM)

The basic flow of necessary steps is essentially:

  1. Resize LVM partition to use the new space.
  2. Resize the Physical Volume in the LVM partition to use the newly resized space.
  3. Resize the Logical Volume(s) inside the Volume Group to their new sizes.
  4. Resize the filesystems in each Logical Volume to match their sizes.


Reboot into Recovery Mode

or reboot into a Live CD/USB environment, as it is not possible to resize a partition while it is online.

(Since this is a GPT-partitioned disk, we have to use the Parted tool instead of FDisk.)

In your Recovery Mode or Live environment, open a terminal if you haven’t already got one and launch Parted to examine your array by typing in:

$ sudo parted /dev/sda

GNU Parted 2.3
Using /dev/sda Welcome to GNU Parted!
Type 'help' to view a list of commands.

Now we have a “(parted)” prompt. First up, we need to switch the units of measurement we’re using to sectors. Do that by issuing the following command:

(parted) u s

Now list the existing partitions using the “print” command. You will see something similar to the following:

(parted) print 
Disk /dev/sda: 19521474560s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
 1 2048s 1953791s 1951744s ext4 Boot boot
 2 (red)1953792s(/red) 19521474526s 19519520735s MYSERVER_HDD lvm

NOTE: You may be shown a warning message advising that the GPT table is not at the end of the disk, saying that the disk size is smaller than the system expects it to be (because you resized your array, remember?). It will ask you if you wish to fix this. Type in “F” and hit enter. You may then be warned that the kernel is not yet aware of changes being made. Respond to this with Ignore by typing in “I” and hit enter. You may be prompted with the latter message several times whilst using Parted. Respond “Ignore” to it each time. In this environment, the current kernel does not need to be aware of the changes because we’re going to reboot at the end of it anyway.

Make a note of the items that are highlighted in red above, namely the total sectors of the device (which represents the total size of your newly expanded array) and the start sector of the second partition. Please double-check your figures and make sure they are right. Any mistakes here can DESTROY YOUR DATA.

Now we’re going to resize the second partition to use all of the newly created space in the array. Unfortunately GPT has no ability to resize. Instead you must remove the partition and recreate it. Don’t worry, as scary as it sounds, this process will NOT change any of the data on the drive. It simply deletes the geometry data relating to the start and end of the partition on the drive only. Remove the second partition with the following command:

(parted) rm 2

Now let’s create a new partition to replace it. Type in the following:

(parted) mkpart

You will be asked for name for the partition. Give it the same name you had for it before, or specify a new name if you like:

Partition name?  []? MYSERVER_HDD

You will then be asked about the file system type. You can’t specify LVM here, so just hit enter to accept “ext2″ – we’ll change it later:

File system type?  [ext2]?

You will then be asked for the start sector. Specify the value of the start of the second partition that you recorded earlier (don’t write the letter “s” on the end):

Start? 1953792

You will then be asked for the end sector. Specify the value of the total size of the drive that you recorded earlier minus one. If you specify the actual value, you will get an error saying that the value is “outside of the device” which is why you specify a value just inside that limit.

End? 19521474559

You will then be told that the system cannot actually make a partition up to that location (because there’s another partition on the disk taking up space), so the system will offer the next closest value which will just happen to be the maximum space remaining on the array. Simply respond “Y” for Yes.

Warning: You requested a partition from 1953792s to 19521474559s.  The
closest location we can manage is 1953792s to 19521165533s. Is this
still acceptable to you? Yes/No?

Now we need to change the partition type to LVM as follows:

(parted) toggle
Partition number? 2
Flag to Invert? lvm

We’re now done with our partitioning so quit parted with the quit command:

(parted) quit

Reboot your server

and boot up as normal. If you check your drive using parted or fdisk, it should now show that the total partition size includes the newly added space in your array, but nothing is using it yet. Now it’s time to tell LVM to use the new space by resizing the Physical Volume with the following command:

$ sudo pvresize /dev/sda2
  1. Once completed, you can now check out the new free space (shown as free extents) in the LVM Physical Group by issuing the command:

    $ sudo pvdisplay

Now we can start allocating this newly acquired free space to our LVM Logical Volumes. First up, let’s get a list of all our defined Logical Volumes:

$ sudo lvdisplay

Note down the “LV Name” of each Logical Volume you wish to add space to.

Now let’s resize the Logical Volume. There are two ways you can do this. One method is to specify an absolute value that defines the new size of that Logical Volume, or specify a value that will add to the existing size of it. In this first example, I’m going to change the size of my Logical Volume called /dev/myserver/mylogicalvolume to be ab absolute size of 20 gigabytes:

$ sudo lvextend -L20G /dev/myserver/mylogicalvolume

…which will make the /dev/myserver/mylogicalvolume Logical Volume 20 gigabytes in size regardless of its previous size. It does NOT add to the existing size. Alternatively to add space to the existing size using the following command instead:

$ sudo lvextend -L+20G /dev/myserver/mylogicalvolume

(note the plus sign between the -L and the 20G) …which will add 20 gigabytes of space to the /dev/myserver/mylogicalvolume Logical Volume. If it was 10 gigabytes in size before, it will now be 30 gigabytes in size. Alternatively, if you wish to allocate all remaining free space to a Logical Volume, issue the following command:

$ sudo lvextend -l +100%FREE /dev/myserver/mylogicalvolume

(notice that the parameter is a lowercase L instead of a capital L) Repeat for all Logical Volumes you are extending. There are other ways to allocate space as well, but the above are the most common methods that would be used. See the man page of the lvextend command for more information.

You can confirm the new sizes for each Logical Volume by issuing the following command:

$ sudo lvdisplay

We’re nearly there! All that is left to do is now to resize the filesystems containing within our Logical Volumes to use the newly allocated space. Again, using the LV Names you recorded earlier, specify the following command for each Logical Volume you have modified:

$ sudo resize2fs /dev/myserver/mylogicalvolume

Once you have expanded the filesystems on all your Logical Volumes, you can check the free space on each of your filesystems by issuing the following command:

$ df -h

And that’s it! You have successfully expanded your LVM partition on your GPT-partitioned array! Pat yourself on the back. You are done.

Original post:

After long search this guide helped me out: http://www.serenux.com/2013/11/howto-resize-an-lvm-partition-on-a-gpt-drive-after-expanding-the-underlying-array/

(I tried my best to format it as nice as possible.)

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.