DOWNLOAD THE IMAGE AND INSTALL IT
We used the one for 3.0.0, but you can use whatever you want from elastix web. Normally you will want to install it to a single ext3/ext4 partition so we can resize it when deploying to an instance.
Fundamental steps are:
- Select partition method. 1 partition ext4/ext3. No LVM. LVM is by default so you must override.
- Set root password: ‘elastix’
- Set mysql password. Something simple, leave blank. (Set it after).
FOLLOW CLOUD IMAGE CONVENTIONS
You should do all steps in this manual page from “Install the ACPI service”. For this to happen you must login in the machine with root:elastix user that we set on installation.
It’s very important that acpi is installed and also the cloud-init. The former will let your system be rebooted/shutdown by openstack, and the latter will allow the system to integrate into openstack by injecting ssh keys and metadata.
I also edited /etc/cloud/cloud.cfg to set gecos info of the default user to Elastix Cloud User. Just for info.
Another thing I like to do is to inform about what the user should do. I create a file with name /etc/motd.local
Please you must update the following settings: Set the root password or remove the ability to login. Currently 'elastix'. Set mysql root password. Currently blank. Set admin panel 'superadmin' pass.
And modify /usr/local/sbin/motd.sh:
Add this to the end.
cat /etc/motd.local echo ""
users: - default disable_root: 1 ssh_pwauth: 0 cc_ready_cmd: ['/bin/true'] locale_configfile: /etc/sysconfig/i18n mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2'] ssh_deletekeys: 0 ssh_genkeytypes: ~ ssh_svcname: sshd syslog_fix_perms: ~ cloud_init_modules: - bootcmd - resizefs - set_hostname - rsyslog - ssh cloud_config_modules: - mounts - ssh-import-id - locale - set-passwords - timezone - puppet - disable-ec2-metadata - runcmd cloud_final_modules: - rightscale_userdata - scripts-per-once - scripts-per-boot - scripts-per-instance - scripts-user - keys-to-console - phone-home - final-message system_info: default_user: name: centos lock_passwd: true gecos: Elastix Cloud User groups: [wheel, adm] sudo: ["ALL=(ALL) NOPASSWD:ALL"] shell: /bin/bash distro: rhel paths: cloud_dir: /var/lib/cloud templates_dir: /etc/cloud/templates ssh_svcname: sshd # vim:syntax=yaml
NOTE: I didn’t deleted the VM in case I have to do any updates.
MAKING THE IMAGE TO AUTORESIZE
We need it to autoresize the partition to fit the whole disk on the VM. So we need to install an additional tool:
# yum install cloud-utils-growpart
And execute following steps:
# Set up to grow root in initramfs cat << EOF > 05-grow-root.sh #!/bin/sh /bin/echo /bin/echo Resizing root filesystem growpart --fudge 20480 -v /dev/vda 1 e2fsck -f /dev/vda1 resize2fs /dev/vda1 EOF chmod +x 05-grow-root.sh dracut --force --include 05-grow-root.sh /mount --install 'echo awk grep fdisk sfdisk growpart partx e2fsck resize2fs' "$(ls /boot/initramfs-*)" $(ls /boot/|grep vmlinuz|sed s/vmlinuz-//g) rm -f 05-grow-root.sh
In my case I had to remove the udev rules that put the eth interface as the first one, because openstack adds a line to this file and since there’s one already I get first interface being eth1. So cloud-init is not initialized because all network stuff is configured as eth0. It means that you don’t have public key, nor network.
So remove all lines but two first from /etc/udev/rules.d/70-persistent-net.rules or just delete it.
Also you need to allow anyone in the group wheel to sudo.
This is done editing /etc/sudoers:
## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL
SHRINK THE IMAGE
I don’t want to have a 4GB image when it can be less than that. So I will resize.
Follow this tutorial for shrinking. I will try to resume steps:
# losetup /dev/loop0 /var/lib/libvirt/images/intermediate-pbx.img # partprobe /dev/loop0 # gparted /dev/loop0 ### And after a while # truncate --size=$[(4196352+1)*512] /var/lib/libvirt/images/intermediate-pbx.img
Once we done it. My image partition shrinked from 4GB to 1.8GB. This is a substancial gain.
After resizing I realized that grub failed to boot with “Geom error”. This means that grub still have the old information of the disk so it cannot find right places to make the system bootable.
The only way to fix it is to mounting the disk on the VM and boot from CD with rescue mode. You can enable rescue mode in the Elastix ISO by writing “linux rescue” on the grub prompt.
Once is booted you will have your system ready on /mnt/sysimage [check this]
# chroot /mnt/sysimage # source /etc/profile # grub-install /dev/vda
And you are set. The system is recovered.
I used horizon to do it but it should be easy to do from command line also. Don’t forget to set the following settings:
- Upload from file. The img file, we just created.
- Format: Raw
- Architecture: x86_64
- Minimal disk size: 2GB <- We need at least 1.8 GB.
It takes a little bit to upload because it’s almost 2GB.