<div dir="ltr"><div><div><br>On Wed, Aug 6, 2014 at 9:11 AM, sylecn <<a href="mailto:sylecn@gmail.com">sylecn@gmail.com</a>> wrote:<br>><br>><br>><br>><br>> On Wed, Aug 6, 2014 at 2:05 PM, Juerg Haefliger <<a href="mailto:juergh@gmail.com">juergh@gmail.com</a>> wrote:<br>
>><br>>> Hi,<br>>><br>>><br>>> On Wed, Aug 6, 2014 at 4:35 AM, sylecn <<a href="mailto:sylecn@gmail.com">sylecn@gmail.com</a>> wrote:<br>>> ><br>>> > Hi stackers,<br>>> ><br>
>> > I have come across this problem of growpart/resizefs not working with CentOS 6.5 Cloud image on first boot.<br>>><br>>> Which kernel version are you running in the guest?<br>>><br>>><br>
>><br>>> > Here is the relevant config in cloud.cfg<br>>> > ==============================<br>>> ><br>>> > growpart:<br>>> > mode: auto<br>>> > devices: ["/"]<br>
>> > resize_rootfs: True<br>>> > resize_rootfs_tmp: /dev<br>>> ><br>>> > cloud_init_modules:<br>>> > - bootcmd<br>>> > - write-files<br>>> > - growpart<br>
>> > - resizefs<br>>><br>>> Growpart called by cloud-init only works for kernels >3.8. Only newer kernels support changing the partition size of a mounted partition. When using an older kernel the resizing of the root partition happens in the initrd stage before the root partition is mounted and the subsequent cloud-init growpart run is a no-op.<br>
>><br>>><br>>> > Here is the relevant log on first boot:<br>>> > ============================<br>>> > [CLOUDINIT] helpers.py[DEBUG]: Running config-growpart using lock (<cloudinit.helpers.DummyLock object at 0x1ed06d0>)<br>
>> > [CLOUDINIT] util.py[DEBUG]: Running command ['growpart', '--help'] with allowed return codes [0] (shell=False, capture=True)<br>>> > [CLOUDINIT] util.py[DEBUG]: Reading from /proc/1108/mountinfo (quiet=False)<br>
>> > [CLOUDINIT] util.py[DEBUG]: Read 521 bytes from /proc/1108/mountinfo<br>>> > [CLOUDINIT] util.py[DEBUG]: Reading from /sys/class/block/vda1/partition (quiet=False)<br>>> > [CLOUDINIT] util.py[DEBUG]: Read 2 bytes from /sys/class/block/vda1/partition<br>
>> > [CLOUDINIT] util.py[DEBUG]: Reading from /sys/devices/pci0000:00/0000:00:05.0/virtio2/block/vda/dev (quiet=False)<br>>> > [CLOUDINIT] util.py[DEBUG]: Read 6 bytes from /sys/devices/pci0000:00/0000:00:05.0/virtio2/block/vda/dev<br>
>> > [CLOUDINIT] util.py[DEBUG]: Running command ['growpart', '--dry-run', '/dev/vda', '1'] with allowed return codes [0] (shell=False, capture=True)<br>>> > [CLOUDINIT] util.py[DEBUG]: Running command ['growpart', '/dev/vda', '1'] with allowed return codes [0] (shell=False, capture=True)<br>
>> > [CLOUDINIT] util.py[DEBUG]: resize_devices took 0.076 seconds<br>>> > [CLOUDINIT] cc_growpart.py[DEBUG]: '/' NOCHANGE: no change necessary (/dev/vda, 1)<br>>> > [CLOUDINIT] helpers.py[DEBUG]: Running config-resizefs using lock (<cloudinit.helpers.DummyLock object at 0x1ed08d0>)<br>
>> > [CLOUDINIT] util.py[DEBUG]: Reading from /proc/1108/mountinfo (quiet=False)<br>>> > [CLOUDINIT] util.py[DEBUG]: Read 521 bytes from /proc/1108/mountinfo<br>>> > [CLOUDINIT] cc_resizefs.py[DEBUG]: resize_info: dev=/dev/vda1 mnt_point=/ path=/<br>
>> > [CLOUDINIT] cc_resizefs.py[DEBUG]: Resizing / (ext4) using resize2fs /dev/vda1<br>>> > [CLOUDINIT] util.py[DEBUG]: Running command ('resize2fs', '/dev/vda1') with allowed return codes [0] (shell=False, capture=True)<br>
>> > [CLOUDINIT] util.py[DEBUG]: Resizing took 0.004 seconds<br>>> ><br>>> > In the base image, I have upgraded cloud-init to 0.7.4-1.el6, and installed cloud-utils, cloud-initramfs-tools. After the first *reboot*, growpart/resizefs does their job and the root file system is grown to disk size.<br>
>><br>>> There is no cloud-initramfs-tools package for CentOS. You need cloud-utils-growpart and dracut-modules-growroot from EPEL6 for the initrd based partition resizing.<br>>><br>>><br>>> > After a reboot, the relevant cloud-init logs:<br>
>> > ===================================<br>>> > cc_growpart.py[DEBUG]: '/' NOCHANGE: no change necessary (/dev/vda, 1)<br>>> > util.py[DEBUG]: Resizing took 13.776 seconds<br>>> > cc_resizefs.py[DEBUG]: Resized root filesystem (type=ext4, val=True)<br>
>><br>>> These are log messages from cloud-init's growpart run. Can you post the boot messages from initrd growpart?<br>>><br>>><br>>> ...Juerg<br>>><br>> Hi Juerg,<br>><br>> I didn't know about initrd based growpart. I see both cloud-utils-growpart and dracut-modules-growroot are installed in the base image (via yum info).<br>
> Do I need any config on kernel modules or build a special initrd to make growpart work on first boot?<br><br>The initrd needs to be rebuilt after installing the dracut-modules-growroot.<br><br><br>> I didn't see growpart message in dmesg and kernel syslog (/var/log/messages on the guest) in first boot and 2nd boot.<br>
> /var/log/boot.log also has no information on that. Where can I get the boot message from initrd growpart?<br><br></div>They should be in /var/log/boot.log. On CentOS 6.3:<br>[root@centos-6-3 ~]# cat /var/log/boot.log | grep grow<br>
growroot: CHANGED: partition=1 start=2048 old: size=4192256 end=4194304 new: size=20969408,end=20971456<br><br><br></div><div>Double-check that you have the growroot pieces in the initrd:<br>[root@centos-6-3 ~]# lsinitrd /boot/initramfs-2.6.32-279.19.1.el6.x86_64.img | grep grow<br>
-rwxr-xr-x 1 root root 7077 Jan 10 2013 usr/bin/growpart<br>-rwxr-xr-x 1 root root 3085 Jan 16 2013 pre-pivot/00growroot.sh<br><br><br></div><div>...Juerg<br><br></div><div><div><br>> guest kernel: 2.6.32-431.3.1.el6.x86_64<br>
><br>> package version:<br>> Installed Packages<br>> Name : cloud-utils-growpart<br>> Arch : x86_64<br>> Version : 0.27<br>> Release : 10.el6<br>> Size : 53 k<br>> Repo : installed<br>
> From repo : epel<br>> Summary : Script for growing a partition<br>> URL : <a href="https://launchpad.net/cloud-utils/trunk/0.27/+download/cloud-utils-0.27.tar.gz">https://launchpad.net/cloud-utils/trunk/0.27/+download/cloud-utils-0.27.tar.gz</a><br>
> License : GPLv3<br>> Description : This package provides the growpart script for growing a partition. It is<br>> : primarily used in cloud images in conjunction with the dracut-modules-growroot<br>
> : package to grow the root partition on first boot.<br>><br>> Name : dracut-modules-growroot<br>> Arch : noarch<br>> Version : 0.20<br>> Release : 2.el6<br>> Size : 43 k<br>
> Repo : installed<br>> From repo : epel<br>> Summary : Automatically resize the root partition on first boot<br>> URL : <a href="https://launchpad.net/ubuntu/saucy/+source/cloud-initramfs-tools/0.20ubuntu1/+files/cloud-initramfs-tools_0.20ubuntu1.tar.gz">https://launchpad.net/ubuntu/saucy/+source/cloud-initramfs-tools/0.20ubuntu1/+files/cloud-initramfs-tools_0.20ubuntu1.tar.gz</a><br>
> License : GPLv3<br>> Description : This dracut module will re-write the partition table of a disk so that the<br>> : root partition has as much space as possible, bumping it up to the edge of the<br>
> : disk, or the edge of the next partition.<br>><br>> growpart and resize still happens on 2nd boot, not first boot.<br>><br>> --<br>> YY Inc. is hiring openstack and python developers. Interested? Check <a href="http://soa.game.yy.com/jobs.html">http://soa.game.yy.com/jobs.html</a><br>
><br>> --<br>> Thanks,<br>> Yuanle<br><br></div></div></div>