Red Hat Training

A Red Hat training course is available for Red Hat Gluster Storage

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.
  1. Using virt-manager, create a qcow2 image with two cores, 4 GB RAM, 20 GB virtio HDD, and a single NIC.
  2. 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.
  3. Reboot the instance and log in.
  4. Set a generic hostname.
    On Red Hat Enterprise Linux 7:
    # hostnamectl set-hostname localhost.localdomain
    On Red Hat Enterprise Linux 6:
    # vim /etc/sysconfig/network
  5. Confirm that DHCP is configured in /etc/sysconfig/network-scripts/ifcfg-eth0.
  6. 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
  7. 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
  8. Register the virtual machine.
    # subscription-manager register --auto-attach
    # subscription-manager repos --disable=*
  9. 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
  10. Update the system and install the Microsoft Azure Linux agent.
    # yum update –y
    # yum –y install WALinuxAgent
  11. 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
    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.
  12. 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.
    1. Add the following content to /etc/dracut.conf..
    2. Regenerate initramfs.
      # dracut -f -v
  13. Update the kernel boot settings.
    On Red Hat Enterprise Linux 7:
    1. Set the GRUB_CMDLINE_LINUX variable in /etc/default/grub.
      `` console=ttyS0 earlyprintk=ttyS0 rootdelay=300
    2. Refresh the grub2 configuration.
      # grub2-mkconfig -o /boot/grub2/grub.cfg
    3. Remove the rhqb, quiet, or crashkernel=auto parameters.
    On Red Hat Enterprise Linux 6:
    1. Update the kernel boot line in /boot/grub/menu.lst:
      console=ttyS0 earlyprintk=ttyS0 rootdelay=300 numa=off
    2. Remove the rhqb, quiet, or crashkernel=auto parameters.
  14. Enable the Windows Azure agent to start at boot.
    • On Red Hat Enterprise Linux 7:.
      # systemctl enable waagent
    • On Red Hat Enterprise Linux 6:.
      # chkconfig waagent on
  15. Unregister the virtual machine using Red Hat Subscription Manager.
    # subscription-manager unregister
  16. 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
  17. 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 qcow2 disk format.
    # virsh dumpxml image-name
    # qemu-img convert -f qcow2 -O vpc -o subformat=fixed -O vpc rhgs313.qcow2 rhgs313.vhd