Differences
This shows you the differences between two versions of the page.
linux_wiki:os_install_vm_template [2016/09/28 22:05] billdozor [Add/Expand Storage] |
linux_wiki:os_install_vm_template [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== OS Install: VM Template ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | Creating a VM template " | ||
- | |||
- | **Checklist** | ||
- | * Distro(s): Enterprise Linux 6 or 7 | ||
- | * Other: VMware ESXi 5+ | ||
- | |||
- | ---- | ||
- | |||
- | ====== Create the Virtual Machine ====== | ||
- | |||
- | * Create a new virtual machine. | ||
- | * Virtual Hardware: | ||
- | * Enable CPU -> CPU Hot Plug -> check " | ||
- | * Enable Memory -> Memory Hot Plug -> check " | ||
- | * Install the EL OS. | ||
- | * If the screen resolution is too small | ||
- | * Press " | ||
- | * Add the following to the boot line, which will use a 1024x768 resolution< | ||
- | |||
- | ---- | ||
- | |||
- | ===== Partitioning ===== | ||
- | |||
- | Red Hat Recommendations | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | |||
- | LVM provides a very flexible partitioning layout. The goal is to create a small disk footprint and allow elastic growing for partitions depending upon the type of server being deployed. | ||
- | |||
- | * **Disk Total Size**: 20 GB | ||
- | * /boot = 512 MB | ||
- | * LVM = 19.5 GB | ||
- | * swap = 4 GB | ||
- | * / = 4 GB | ||
- | * /home = 2 GB | ||
- | * /tmp = 2 GB | ||
- | * /var = 4 GB | ||
- | * LVM Allocated: 16 GB | ||
- | * LVM Free: 3.5 GB (Available for minor partition expansion) | ||
- | |||
- | **NOTE:** Contrary to a lot of online documentation, | ||
- | |||
- | \\ | ||
- | After a CentOS 6.7 minimal install, the disk usage with that partitioning looks like this:\\ | ||
- | TODO - SCREENSHOT | ||
- | |||
- | After a CentOS 7.2 minimal install, the disk usage with that partitioning looks like this:\\ | ||
- | TODO - SCREENSHOT | ||
- | |||
- | ---- | ||
- | |||
- | ====== System Configuration ===== | ||
- | |||
- | Modify the OS with changes you want to be included on ALL systems. They should be server role generic. | ||
- | |||
- | ---- | ||
- | |||
- | ===== CentOS 6: Post Install/Pre Template Create ===== | ||
- | |||
- | The following are some useful post install configuration done to a CentOS 6 minimal install.\\ | ||
- | All of the following will be included in the VM template. Keep it server role generic. | ||
- | |||
- | <code bash> | ||
- | # System Update | ||
- | yum update | ||
- | |||
- | # Extra system packages | ||
- | yum -y install bash-completion bind-utils dmidecode iotop lsof mailx man mlocate nc nfs-utils openssh-clients rsync tcpdump vim-enhanced wget | ||
- | |||
- | # Install VMware Tools | ||
- | See: https:// | ||
- | |||
- | # Disable SELinux (/ | ||
- | sed -i " | ||
- | sed -i " | ||
- | |||
- | # Reboot for selinux to not interfere with the rest of the config changes | ||
- | shutdown -r now | ||
- | |||
- | # Remove Global Network Gateway | ||
- | sed -i "/ | ||
- | |||
- | # Grub Config => / | ||
- | timeout=3 | ||
- | removed ' | ||
- | removed 'rhgb quiet' from kernel boot lines | ||
- | |||
- | # Root's bashrc (/ | ||
- | PS1=' | ||
- | |||
- | #service shortcut | ||
- | alias sv=' | ||
- | |||
- | # Reboot and verify all changes persistent | ||
- | shutdown -r now | ||
- | |||
- | </ | ||
- | |||
- | **Proceed to " | ||
- | |||
- | ---- | ||
- | |||
- | ===== CentOS 6: VM Cleanup ===== | ||
- | |||
- | Perform any other customizations/ | ||
- | |||
- | <code bash> | ||
- | # Cleanup => Remove ssh host keys (so each deployed VM has a different fingerprint) | ||
- | rm -f / | ||
- | |||
- | # Cleanup => Remove persistent rules and network hw address - prevents eth0 from incrementing | ||
- | rm -f / | ||
- | sed -i "/ | ||
- | sed -i "/ | ||
- | |||
- | # Cleanup => Remove some of root's files | ||
- | rm -f / | ||
- | |||
- | # Cleanup => remove tmp files | ||
- | rm -rf /tmp/* | ||
- | |||
- | # Cleanup => stop auditd from logging, remove log files | ||
- | # Stop any other service that actively logs to sub directories of /var/log | ||
- | # Recommended to install sysstat (sar) during a post deployment phase. | ||
- | service auditd stop | ||
- | rm -rf /var/log/* | ||
- | mkdir / | ||
- | |||
- | # Update locate' | ||
- | updatedb | ||
- | |||
- | # Clear history and shutdown for template cloning | ||
- | history -c && history -w | ||
- | shutdown -P now | ||
- | </ | ||
- | |||
- | * Create a VM Template from the powered off system. | ||
- | |||
- | ---- | ||
- | |||
- | ===== CentOS 7: Post Install/Pre Template Create ===== | ||
- | |||
- | The following are some useful post install configuration done to a CentOS 7 minimal install.\\ | ||
- | All of the following will be included in the VM template. Keep it server role generic. | ||
- | |||
- | <code bash> | ||
- | # System Update | ||
- | yum update | ||
- | |||
- | # Extra system packages (dmidecode, | ||
- | yum -y install bash-completion bind-utils iotop lsof mailx mlocate nfs-utils open-vm-tools perl rsync tcpdump vim-enhanced wget | ||
- | |||
- | # Update man pages | ||
- | mandb | ||
- | |||
- | # Install VMware Tools (open-vm-tools included in CentOS 7 base repo) - Installed above | ||
- | |||
- | # Disable SELinux (/ | ||
- | sed -i " | ||
- | sed -i " | ||
- | |||
- | # Reboot for selinux to not interfere with the rest of the config changes | ||
- | shutdown -r now | ||
- | |||
- | # Grub Config => kernel options and change network interface names back to legacy | ||
- | vim / | ||
- | |||
- | timeout=3 | ||
- | #removed 'rhgb quiet' from kernel boot lines (" | ||
- | #append the ' | ||
- | GRUB_CMDLINE_LINUX=" | ||
- | |||
- | #generate new grub2 boot file | ||
- | grub2-mkconfig -o / | ||
- | |||
- | # Change network interface back to legacy scheme (continued) | ||
- | mv / | ||
- | |||
- | vim / | ||
- | |||
- | Name=" | ||
- | Device=" | ||
- | #removed UUID | ||
- | |||
- | systemctl restart NetworkManager | ||
- | |||
- | # Root's bashrc (/ | ||
- | |||
- | # systemctl shortcut | ||
- | alias sc=' | ||
- | |||
- | # Turn root's prompt red | ||
- | PS1=' | ||
- | |||
- | # Disable NetworkManager for old style network scripts | ||
- | vim / | ||
- | |||
- | NM_CONTROLLED=" | ||
- | PEERDNS=" | ||
- | IPV6_PEERDNS=" | ||
- | |||
- | systemctl stop NetworkManager | ||
- | systemctl disable NetworkManager | ||
- | systemctl mask NetworkManager | ||
- | systemctl start network | ||
- | systemctl enable network | ||
- | |||
- | # Reboot and verify all changes persistent | ||
- | shutdown -r now | ||
- | |||
- | </ | ||
- | |||
- | **Proceed to " | ||
- | |||
- | ---- | ||
- | |||
- | ===== CentOS 7: VM Cleanup ===== | ||
- | |||
- | Perform any other customizations/ | ||
- | |||
- | <code bash> | ||
- | # Cleanup => Remove ssh host keys (so each deployed VM has a different fingerprint) | ||
- | rm -f / | ||
- | |||
- | # Cleanup => Remove network hw address - prevents eth0 from incrementing | ||
- | sed -i "/ | ||
- | sed -i "/ | ||
- | |||
- | # Cleanup => Remove some of root's files | ||
- | rm -f / | ||
- | |||
- | # Cleanup => remove tmp files | ||
- | rm -rf /tmp/* | ||
- | |||
- | # Cleanup => stop auditd from logging, remove log files | ||
- | # Stop any other service that actively logs to sub directories of /var/log | ||
- | # Recommended to install sysstat (sar) during a post deployment phase. | ||
- | systemctl stop auditd | ||
- | rm -rf /var/log/* | ||
- | mkdir {/ | ||
- | touch / | ||
- | |||
- | # Update locate' | ||
- | updatedb | ||
- | |||
- | # Clear history and shutdown for template cloning | ||
- | history -c && history -w | ||
- | shutdown -P now | ||
- | </ | ||
- | |||
- | * Create a VM Template from the powered off system. | ||
- | |||
- | ---- | ||
- | |||
- | ====== Add/Expand Storage ====== | ||
- | |||
- | After deploying a VM from the template, you may need to expand storage on one of the partitions. | ||
- | |||
- | - Add an additional hard disk to the VM. (Either from initial deployment or hot add to the VM) | ||
- | - Verify disk device name to use:< | ||
- | - Create a new partition on the disk and format it as a ā8eā (Linux LVM) type | ||
- | - fdisk /dev/sdb | ||
- | - Command: n | ||
- | - Command action (primary partition): p | ||
- | - Partition number: 1 | ||
- | - First cylinder: enter for default of the first | ||
- | - Last cylinder: enter for default of the last | ||
- | - Command: t | ||
- | - Selected partition 1 (message displayed when only 1 partition exists) | ||
- | - Hex code: 8e (for LVM) | ||
- | - Command: w | ||
- | - Create a LVM physical disk from the partition< | ||
- | - Add the new physical disk to the existing volume group< | ||
- | - Extend the logical volume that needs the space (/home will be used in this example) | ||
- | - **Option 1 (Preferred)**: | ||
- | * This method is preferred because there is a performance hit when a partition spans VMDKs< | ||
- | lvextend --resizefs / | ||
- | - Option 2: Give the logical volume all of the space from the newly added physical volume< | ||
- | - Option 3: Give the logical volume a specific amount of additional free space from a specific physical volume< | ||
- | - Option 4: Give the logical volume all of the free space available to the volume group (potentially across multiple physical disks)< | ||
- | - Verify LVM Allocation | ||
- | - Logical Volume: <code bash> | ||
- | - Volume Group: <code bash> | ||
- | - Physical Volumes: <code bash> | ||
- | - Grow the file system (Not required if you used " | ||
- | - Ext2/ | ||
- | - XFS<code bash> | ||
- | - Verify filesystem space< | ||
- | |||
- | ---- | ||