creating CentOS based VM Template

Mainly you will need to create Centos VM manually and then do the following steps to the template before converting it to Template

  1. create new CentOS vm and while installing it make sure you do the following steps(actually default centos install will be having those 2 properties)
    • make the boot partition is separate from other partitions (you can choose any file system for it)
    • remaining partitions should be lvm based storage be on lvm based storage
          so that after you are done installing the following when you do lvdisplay
      lvdisplay
        --- Logical volume ---
        LV Path                /dev/VolGroup/lv_root
        LV Name                lv_root
        VG Name                VolGroup
        LV UUID                aaVIJ1-EmVY-vjCG-Y6bH-1FaC-nUYk-IPrF6V
        LV Write Access        read/write
        LV Creation host, time localhost.localdomain, 2014-05-13 22:28:44 -0400
        LV Status              available
        # open                 1
        LV Size                6.71 GiB
        Current LE             1718
        Segments               1
        Allocation             inherit
        Read ahead sectors     auto
        - currently set to     256
        Block device           253:0
         
        --- Logical volume ---
        LV Path                /dev/VolGroup/lv_swap
        LV Name                lv_swap
        VG Name                VolGroup
        LV UUID                rAQkcv-dqye-gFPb-9QCx-bJFP-fGez-kOwJSH
        LV Write Access        read/write
        LV Creation host, time localhost.localdomain, 2014-05-13 22:28:48 -0400
        LV Status              available
        # open                 1
        LV Size                816.00 MiB
        Current LE             204
        Segments               1
        Allocation             inherit
        Read ahead sectors     auto
        - currently set to     256
        Block device           253:1

      and df output is

      df -h
      Filesystem                    Size  Used Avail Use% Mounted on
      /dev/mapper/VolGroup-lv_root  6.7G  732M  5.6G  12% /
      tmpfs                         497M     0  497M   0% /dev/shm
      /dev/xvda1                    485M   33M  427M   8% /boot
      
      

      Note: the sizes are not important

  • now we need to make scripts run automatically on system startup ,

get the script file: xenicastart.sh from your xenica package (or you can get it from here) , and put inside /etc/ so that you will have the file locations as follows

/etc/xenicastart.sh
  1. assign the executable mode to the file by the command
    chmod +x /etc/xenicastart.sh
  2. To make the script run at the start of the VM:
  3. Open the file /etc/rc.local in edit mode
  4. put the line
    source /etc/xenicastart.sh

    inside /etc/rc.local

  5. run this script as /etc/rc.local on the command line to make sure it executes our script
  6. make sure xentools installed
  7. install in the vm parted package
    yum install parted
  8. convert to template
  • create_centos_template.txt
  • Last modified: 2018/07/03 22:54
  • by giannis