I'm preparing a Centos7.4 cloud image and I have install cloud-init cloud-utils and cloud-growpart.
When I import into Openstack as a qcow2 image it doesn't resize my root if I create an instance with a bigger disk than the orginal image. If I use normal disks with no LVM and a single partition it works .
For some reason it doesnt like a 2 partition set up where /boot is partition1 and / is partition 2. All the docs seems to say that cloud-utils-growpart will work with lvm and ext4 if the root partition is the last partition. Any ideas ?
fstab
# /etc/fstab
# Created by anaconda on Fri Jan 19 16:49:58 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
# /dev/mapper/centos-root / ext4 defaults 1 1 UUID=aa806546-2582-411d-9eba-7217376a8aa3 /boot ext3 defaults 1 2
and fdisk -l
[root@localhost ~]# fdisk -l
Disk /dev/vda: 9234 MB, 9234180096 bytes, 18035508 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 label type: dos Disk identifier: 0x000b5cce
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 616447 307200 83 Linux
/dev/vda2 616448 18034687 8709120 8e Linux LVM
Disk /dev/mapper/centos-root: 8917 MB, 8917090304 bytes, 17416192
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
I have the same problem - the reason is LVM. If you take a look at
/var/log/cloud-init.log
you will see entries like:So the answer is either to make your root partition a physical disk or to put in your own grow logic. I actually prefer to have my own logic as it makes expanding a root disk after the fact very easy without requiring an OpenStack resize (which requires rebuild of the VM). You simply attach a block volume, and then add the block volume to the LVM.
So here is my code (very similar code if you are adding a block volume and growing the LVM). Your code probably differs only in the name of the root volume group (
the_root_vgname
):