Setting up a firstboot script after cloning a virtual machine
Linux - EnterpriseThis forum is for all items relating to using Linux in the Enterprise.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Setting up a firstboot script after cloning a virtual machine
I am looking for a script I can run that will handle setting up the hostname, IP address, network configs, install some 3rd party software and some other tasks. The script needs to be run on the first boot of a cloned virtual machine.
Either script examples or even just websites for reference would be helpful. I've never messed with firstboot so just looking for a starting point.
I'm not sure if a (firstboot) script is the way to go.
After cloning a VM the safest way to go is to start the clone in runlevel 1 right after the cloning is finished and change the network settings. If you don't udev will create a rule for a second network interface due to certain things not being unique, which would make things unclear and harder to trouble-shoot/fix.
If I assume you use a RedHat based distro you need to change /etc/sysconfig/network-scripts/ifcfg-ethX Don't forget to change the hardware address (HWADDR). Depending on how things are set up you might also need to change /etc/sysconfig/network.
After that reboot into your normal runlevel and add the 3rd party software (with or without the use of a script).
Thanks druuna. That is what we are currently doing. What I've been tasked with is to come up with a way that all that runlevel 1 stuff is done automagically. So the entire clone and boot process is hands off.
I'm not sure it is possible to automate it the way you want/need. The system you need to clone needs to be edited before you clone it (and be restored to the original settings afterwards). You need to change the default RL to 1, create and link a script in init.d that changes the appropriate settings when the clone boots. The clone process might be made hands-free this way, but you move the human actions to the original.
Wouldn't it be easier to use a kickstart file to create the copies? The %post section could possibly be used to install the 3rd party software.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.