Search

MachPanel Knowledgebase

GUIDE:SOP for preparation of Centos (Linux) & Ubuntu Sealed Images for Hyper-V

Mudesira Munir
Manuals and Guides

Summary

This article provides information about preparation of sealed images for Centos (Linux) and Ubuntu Virtual Machines.

Applies To

Applies to MachPanel v7.2.x and onward.

Important Note:

  • It is recommended to Create Virtual Machines for preparing sealed image based on Gen2 and in MachPanel also choose the option for Generation 2.
  • You may download Preconfigured Gen 2 sealed images to use with MachPanel for Centos7 and Ubuntu20 from links below:
  • Make sure when adding sealed image details to MachPanel for Ubuntu22, set correct "Default User" i.e. "machsol" (without quotes) if our preconfigured sealed image is used.

Pre-requisites
  • While installing CentOS, for Partitioning either choose Automatically Configure Partitioning OR if you choose I will configure partitioning set the Volume Group Name as centos.
  • Create a standard Centos & build
  • Configure the Network - nmtui
  • Install dos2unix - sudo yum install dos2unix
  • Change Permissions for rc.local file to run on bootup - chmod +x /etc/rc.d/rc.local
  • Remove all files from /etc/netplan/  folder (In case of Ubunto only)

Procedure for preparing Centos (Linux) Sealed Image for Gen 2 virtual Machines

  • Make rc.local file settings like below in your sealed image. (sudo nano /etc/rd.d/rc.local)

================================================================================

#!/bin/bash
touch /var/lock/subsys/local
sed -n 's/;#COMMAND//p' /root/Config.bat > /root/Config.bak && mv -f /root/Config.bak /root/Config.bat && chmod 777 /root/Config.bat && dos2unix /root/Config.bat
sh /root/Config.bat
rm -f /root/Config.bat
rm -f /root/Config.bak

================================================================================

Selinux Config: Selinux Config file should contain below settings. (root\etc\SELINUX\Config)

 ================================================================================

Procedure for preparing Centos (Linux) Sealed Image for Gen1 virtual Machines

Below are the settings which are required for preparing the Linux (Centos) Sealed image for Gen1.

  • Make sure your Centos flavor supports floppy
  • Create Floppy Folder under /media - mkdir /media/floppy
  • Make rc.local file settings like below in your sealed image. (sudo nano /etc/rc.local)

================================================================================

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do full Sys V style init stuff.

touch /var/lock/subsys/local
insmod /lib/modules/$(uname -r)/kernel/drivers/block/floppy.ko
mount /dev/fd0 /media/floppy && mount -o remount,rw /dev/fd0
wait
sed -n 's/;#COMMAND//p' /media/floppy/Config.bat > /media/floppy/Config.bak && mv -f /media/floppy/Config.bak /media/floppy/Config.bat && chmod 777 /media/floppy/Config.bat && dos2unix /media/floppy/Config.bat
sh /media/floppy/Config.bat
rm -f /media/floppy/Config.bat
rm -f /media/floppy/Config.bak
umount -l /dev/fd0

================================================================================

Selinux Config: Selinux Config file should contain below settings. (root\etc\SELINUX\Config)

Procedure for preparing Ubuntu Sealed Image
Important Note: While preparing sealed image below 2 commands need to run in Ubuntu terminal. Make sure internet is active before executing these commands:
  1. Sudo apt-get update
  2. Sudo apt-get install linux-azure

For Ubuntu Flavors / Versions with no rc.local file, following should be taken care during sealed image preparation.

  • Create rc.local file

=========================================================================

nano /etc/rc.local
Add following Content to rc.local file

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
touch /var/lock/subsys/local
#sed -n 's/;#COMMAND//p' /root/Config.bat > /root/Config.bak && mv -f /root/Config.bak /root/Config.bat && chmod 777 /root/Config.bat && dos2unix /root/Config.bat
sh /root/Config.bat
rm -f /root/Config.bat
#rm -f /root/Config.bak
exit 0
chmod +x /etc/rc.local

===============================================================================

  • Create rc-local.service Service

========================================================================


sudo nano /etc/systemd/system/rc-local.service
Then add the following content to it
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

sudo chmod +x /etc/rc.local
printf '%s\n' '#!/bin/bash' 'exit 0' | sudo tee -a /etc/rc.local

  • sudo chmod +x /etc/rc.local
  • sudo systemctl enable rc-local
  • sudo systemctl start rc-local.service
  • sudo systemctl status rc-local.service

===============================================================================

Details
Type: GUIDE
Access Type: Public
Last Modified: Last Year
Last Modified By: zohaib.shaikh
Rated 3 stars based on 10 votes.
Article has been viewed 7.8K times.
Options
Also In This Category
Tags