[Openstack-operators] Problem creating resizable CentOS 6.5 image
Antonio Messina
antonio.s.messina at gmail.com
Fri Oct 3 12:50:44 UTC 2014
I use this snippet in my %post section. I don't find it particularly
elegant, but it works just fine:
# Set up to grow root in initramfs
cat << EOF > 05-grow-root.sh
#!/bin/sh
/bin/echo
/bin/echo Resizing root filesystem
/bin/echo "d
n
p
1
w
" | /sbin/fdisk -c -u /dev/vda
/sbin/e2fsck -f /dev/vda1
/sbin/resize2fs /dev/vda1
EOF
chmod +x 05-grow-root.sh
dracut --force --include 05-grow-root.sh /mount --install 'echo
fdisk e2fsck resize2fs' /boot/"initramfs-grow_root-$(ls /boot/|grep
initramfs|sed s/initramfs-//g)" $(ls /boot/|grep vmlinuz|sed
s/vmlinuz-//g)
rm -f 05-grow-root.sh
tail -4 /boot/grub/grub.conf | sed
s/initramfs/initramfs-grow_root/g| sed s/CentOS/ResizePartition/g |
sed s/crashkernel=auto/crashkernel=0 at 0/g >> /boot/grub/grub.conf
It only works if the root filesystem is `/dev/vd1` (which is a very
common setup anyway) but can be adapted.
I only tested it with CentOS 5 and 6. The full script is available at
https://github.com/gc3-uzh-ch/openstack-tools/
.a.
--
antonio.s.messina at gmail.com
antonio.messina at uzh.ch +41 (0)44 635 42 22
S3IT: Service and Support for Science IT http://www.s3it.uzh.ch/
University of Zurich
Winterthurerstrasse 190
CH-8057 Zurich Switzerland
More information about the OpenStack-operators
mailing list