[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Rdo-list] Automatic resizing of root partitions in RDO Icehouse



I'm sure someone could make this better, but this is what I've been using and it works well:

V/R,

Allan

1. Create disk image with QCOW2 format

qemu-img create -f qcow2 /tmp/centos-6.5-working.qcow2 10G

2. Install CentOS; Install onto a single ext4 partition mounted to “/” (no /boot, /swap, etc.) 

virt-install --virt-type {kvm or qemu} --name centos-6.5 --ram 1024 \
--cdrom=/tmp/CentOS-6.5-x86_64-minimal.iso \
--disk /tmp/centos-6.5-working.qcow2,format=qcow2 \
--network network=default \
--graphics vnc,listen=0.0.0.0 --noautoconsole \
--os-type=linux --os-variant=rhel6

3. Eject the disk and reboot the virtual machine

virsh attach-disk --type cdrom --mode readonly centos-6.5 "" hdc
virsh destroy centos-6.5
virsh start centos-6.5

4. After reboot, login into your new image and modify '/etc/sysconfig/network-scripts/ifcfg-eth0' to look like this
 
DEVICE="eth0" 
BOOTPROTO="dhcp" 
NM_CONTROLLED="no" 
ONBOOT="yes" 
TYPE="Ethernet" 

5. Add EPEL repository and update OS 

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm 
rpm -ivh https://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm

6. Update yum and install cloud-init

yum -y update 
yum install cloud-utils cloud-init parted git
cd /tmp
git clone https://github.com/flegmatik/linux-rootfs-resize.git (installed in place of cloud-initramfs-tools)
cd linux-rootfs-resize
./install

Edit /etc/cloud/cloud.cfg

Add the line:

user: ec2-user
	Under “cloud_init_modules”, add:
		- resolv-conf

7. Install and configure puppet

yum install puppet
edit /etc/hosts and add entry for foreman
edit /etc/puppet/puppet.conf and add the following lines:

	[main]
		pluginsync = true
	[agent]
		runinterval=1800
		server = {server.domain}
		chkconfig puppet on

8. Enable the instance to access the metadata service

echo "NOZEROCONF=yes" >> /etc/sysconfig/network

9. Configure /etc/ssh/sshd_config

	Uncomment the following lines:

		PermitRootLogin  yes
		PasswordAuthentication  yes

10. Power down your virtual Centos machine

11. Clean up the virtual machine of MAC address, etc.

virt-sysprep -d centos-6.5

12. Undefine the libvirt domain

virsh undefine centos-6.5

13. Compress QCOW2 image with 

qemu-img convert -c /tmp/centos-6.5-working.qcow2 -O qcow2 /tmp/centos.qcow2 


Image /tmp/centos-6.5.qcow2 is now ready for upload to Openstack


-----Original Message-----
From: Kashyap Chamarthy [mailto:kchamart redhat com] 
Sent: Wednesday, May 07, 2014 11:49 PM
To: St. George, Allan L.
Cc: rdo-list redhat com; Elías David
Subject: Re: [Rdo-list] Automatic resizing of root partitions in RDO Icehouse

On Wed, May 07, 2014 at 02:31:43PM +0000, St. George, Allan L. wrote:
> I haven’t had the time to work with Icehouse yet, but I have outlined 
> instruction that are used to create Havana CentOS images that resize 
> automatically upon spawning via linux-rootfs-resize.
> 
> If interested, I’ll forward it along.

That'd be useful. It'd be even better if you could make a quick RDO wiki page[1] that'll be indexed by the search engines.


[1] http://openstack.redhat.com/

PS: If you're a Markdown user, you can convert Markdown -> WikiMedia (RDO uses WikiMedia for wiki) trivially like this:

    $ pandoc -f markdown -t Mediawiki foo.md -o foo.wiki

> 
> From: rdo-list-bounces redhat com [mailto:rdo-list-bounces redhat com]
> On Behalf Of Elías David Sent: Tuesday, May 06, 2014 12:57 PM To:
> Kashyap Chamarthy Cc: rdo-list redhat com Subject: Re: [Rdo-list] 
> Automatic resizing of root partitions in RDO Icehouse
> 
> 
> Hi thanks for the answers!
> 
> But how is the support right now in OpenStack with centos/fedora 
> images regarding the auto resizing during boot? does the disk size set 
> in the flavor is respected or not, or does it work only with fedora 
> and newer kernels than what CentOS uses...things like that is what I'm 
> looking for On May 6, 2014 4:09 AM, "Kashyap Chamarthy"
> <kchamart redhat com<mailto:kchamart redhat com>> wrote: On Mon, May 
> 05, 2014 at 10:22:26PM -0430, Elías David wrote:
> > Hello all,
> >
> > I would like to know what's the current state of auto resizing the 
> > root partition in current RDO Icehouse, more specifically, CentOS 
> > and Fedora images.
> >
> > I've read many versions of the story so I'm not really sure what 
> > works and what doesn't.
> >
> > For instance, I've read that currently, auto resizing of a CentOS
> > 6.5 image for would require the filesystem to be ext3 and I've also 
> > read that auto resizing currently works only with kernels >= 3.8, so 
> > what's really the deal with this currently?
> >
> > Also, it's as simple as having cloud-init, dracut-modules-growroot 
> > and cloud-initramfs-tools installed on the image or are there any 
> > other steps required for the auto resizing to work?
> 
> 
> I personally find[1] virt-resize (which works the same way on any
> images) very useful when I'd like to do resizing, as it works 
> consistent well.
> 
> I just tried on a Fedora 20 qcow2 cloud image with these below four 
> commands and their complete output.
> 
> 1. Examine the root filesystem size _inside_ the cloud image:
> 
>     $ virt-filesystems --long --all -h -a fedora-latest.x86_64.qcow2
> 
>     Name       Type        VFS   Label  MBR  Size  Parent /dev/sda1
>     filesystem  ext4  _/     -    1.9G  - /dev/sda1  partition   -
>     -      83   1.9G  /dev/sda /dev/sda   device      -     -      -
>     2.0G  -
> 
> 2. Create a new qcow2 disk of 10G:
> 
>     $ qemu-img create -f qcow2 -o preallocation=metadata \
>     newdisk.qcow2 10G
> 
> 3. Perform the resize operation:
> 
>     $ virt-resize --expand /dev/sda1 fedora-latest.x86_64.qcow2 \
>     newdisk.qcow2 Examining fedora-latest.x86_64.qcow2 ...  **********
> 
>     Summary of changes:
> 
>     /dev/sda1: This partition will be resized from 1.9G to 10.0G.  The
>     filesystem ext4 on /dev/sda1 will be expanded using the
>     'resize2fs' method.
> 
>     ********** Setting up initial partition table on newdisk.qcow2 ...
>     Copying /dev/sda1 ...  100%
>     ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧
>     00:00 Expanding /dev/sda1 using the 'resize2fs' method ...
> 
>     Resize operation completed with no errors.  Before deleting the
>     old disk, carefully check that the resized disk boots and works
>     correctly.
> 
> 4. Examine the root file system size in the new disk (should reflect
> correctly):
> 
>     $ virt-filesystems --long --all -h -a newdisk.qcow2 Name
>     Type        VFS   Label  MBR  Size  Parent /dev/sda1  filesystem
>     ext4  _/     -    10G   - /dev/sda1  partition   -     -      83
>     10G   /dev/sda /dev/sda   device      -     -      -    10G   -
> 
> 
> Hope that helps.
> 
> 
>   [1]
>   
> http://kashyapc.com/2013/04/13/resize-a-fedora-19-guest-with-libguestf
> s-tools/
> 
> 
> 
> -- /kashyap

> _______________________________________________
> Rdo-list mailing list
> Rdo-list redhat com
> https://www.redhat.com/mailman/listinfo/rdo-list


--
/kashyap


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]