3.7. Appendix - Creating a Custom Disk Image from ISO
Instances within Microsoft Azure are created from disk images. Gluster Storage requires a custom image, rather than one of the default Microsoft Azure-supplied images. Building custom virtual machine images is typically done with Hyper-V, but custom images for Microsoft Azure can also be built using native Linux tools.
The overall process to configure a custom image takes about 30 minutes.
- Download the latest ISO for Gluster Storage from here: https://access.redhat.com/downloads/content/186/ver=3.1/rhel---7/3.1/x86_64/product-software
- Using
virt-manager, create a qcow2 image with two cores, 4 GB RAM, 20 GB virtio HDD, and a single NIC. - Boot the instance from the ISO image and complete the installation of Gluster Storage. Do not allocate swap space since the Windows Azure agent sets up an ephemeral disk at runtime for swap space.
- Reboot the instance and log in.
- Set a generic hostname.On Red Hat Enterprise Linux 7:
hostnamectl set-hostname localhost.localdomain
# hostnamectl set-hostname localhost.localdomainCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Red Hat Enterprise Linux 6:vim /etc/sysconfig/network NETWORKING=yes HOSTNAME=localhost.localdomain
# vim /etc/sysconfig/network NETWORKING=yes HOSTNAME=localhost.localdomainCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Confirm that DHCP is configured in
/etc/sysconfig/network-scripts/ifcfg-eth0.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Update the udev rules to avoid conflicts with Microsoft Azure and Hyper-V.
rm -f /etc/udev/rules.d/70-persistent-net.rules rm -f /lib/udev/rules.d/75-persistent-net-generator.rules
# rm -f /etc/udev/rules.d/70-persistent-net.rules # rm -f /lib/udev/rules.d/75-persistent-net-generator.rulesCopy to Clipboard Copied! Toggle word wrap Toggle overflow - On Red Hat Enterprise Linux 7, apply the default firewall rules for Gluster Storage. These rulesets are used for inter-node communication, the GlusterFS client, and NFS.
firewall-cmd --zone=public --add-service=glusterfs --permanent firewall-cmd --zone=public --add-service=nfs --add-service=rpc-bind --permanent
# firewall-cmd --zone=public --add-service=glusterfs --permanent # firewall-cmd --zone=public --add-service=nfs --add-service=rpc-bind --permanentCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Register the virtual machine.
subscription-manager register --auto-attach subscription-manager repos --disable=*
# subscription-manager register --auto-attach # subscription-manager repos --disable=*Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Enable the Extras and Gluster Storage repositories. This is either rhel-6- or rhel-7-.
subscription-manager repos --enable rhel-7-server-rpms --enable rhel-7-server-extras-rpms --enable rh-gluster-3-for-rhel-7-server-rpms
# subscription-manager repos --enable rhel-7-server-rpms --enable rhel-7-server-extras-rpms --enable rh-gluster-3-for-rhel-7-server-rpmsCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Update the system and install the Microsoft Azure Linux agent.
yum update –y yum –y install WALinuxAgent
# yum update –y # yum –y install WALinuxAgentCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Disable any swap space defined during the Gluster Storage installation. This is required on Red Hat Enterprise Linux 7. Microsoft Azure allocates ephemeral storage at runtime, which is used for swap, so swap space does not need to be explicitly defined.
swapoff -v /dev/rhgs/swap sed -i '/.* swap/d' /etc/fstab
# swapoff -v /dev/rhgs/swap # sed -i '/.* swap/d' /etc/fstabCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Red Hat Enterprise Linux 6, the installer enables disk configuration to be changed, so the swap is not defined. However, if a logical volume was created, then remove the configuration as on RHEL 7. - Red Hat Enterprise Linux 7 only. A Linux virtual machine running in Azure requires the hv_storvsc and hv_vmbus drivers within the initramfs image. The Red Hat Enterprise Linux 6 installer includes these drivers automatically, but under Red Hat Enterprise Linux 7, the installer only adds these drivers if Hyper-V devices are detected at installation time. When building a virtual machine image using virt-manager, add these Hyper-V drivers manually.
- Add the following content to
/etc/dracut.conf.. - Regenerate
initramfs.dracut -f -v
# dracut -f -vCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- Update the kernel boot settings.On Red Hat Enterprise Linux 7:
- Set the GRUB_CMDLINE_LINUX variable in /etc/default/grub.
``rd.lvm.lv=rhgs/root console=ttyS0 earlyprintk=ttyS0 rootdelay=300
``rd.lvm.lv=rhgs/root console=ttyS0 earlyprintk=ttyS0 rootdelay=300Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Refresh the grub2 configuration.
grub2-mkconfig -o /boot/grub2/grub.cfg
# grub2-mkconfig -o /boot/grub2/grub.cfgCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Remove the rhqb, quiet, or crashkernel=auto parameters.
On Red Hat Enterprise Linux 6:- Update the kernel boot line in /boot/grub/menu.lst:
console=ttyS0 earlyprintk=ttyS0 rootdelay=300 numa=off
console=ttyS0 earlyprintk=ttyS0 rootdelay=300 numa=offCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Remove the rhqb, quiet, or crashkernel=auto parameters.
- Enable the Windows Azure agent to start at boot.
- On Red Hat Enterprise Linux 7:.
systemctl enable waagent
# systemctl enable waagentCopy to Clipboard Copied! Toggle word wrap Toggle overflow - On Red Hat Enterprise Linux 6:.
chkconfig waagent on
# chkconfig waagent onCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- Unregister the virtual machine using Red Hat Subscription Manager.
subscription-manager unregister
# subscription-manager unregisterCopy to Clipboard Copied! Toggle word wrap Toggle overflow - De-provision the instance to remove the local settings; this allows the instance to be used as a disk image within Microsoft Azure.
yum clean all waagent -force -deprovision export HISTSIZE=0 poweroff
# yum clean all # waagent -force -deprovision # export HISTSIZE=0 # poweroffCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Dump the XML of the instance to find the filename of the virtual disk that was created, and convert it to a Microsoft Azure compatible VHD file. In this example, the instance was initially created using the
qcow2disk format.virsh dumpxml image-name qemu-img convert -f qcow2 -O vpc -o subformat=fixed -O vpc rhgs313.qcow2 rhgs313.vhd
# virsh dumpxml image-name # qemu-img convert -f qcow2 -O vpc -o subformat=fixed -O vpc rhgs313.qcow2 rhgs313.vhdCopy to Clipboard Copied! Toggle word wrap Toggle overflow