- Host OS: Debian 8
- Guest OS: Debian 8
I configure my KVM system such that when the host OS shuts down or reboots, all the running guest OSes are suspended. And they are automatically resumed after the host OS boots up. (Here is the link which shows you how to do that. Read the section, "Automatic guest management on host shutdown/startup".)
Assuming the host OS and the guest OS are always accessible from the local network, I decide to use SSH and /etc/rc.local to automate the updating of system time of the guest OS after it is automatically resumed.
Here are the steps it takes to do it:
- Create a special unix user on the guest OS and, probably, name it, kvmupdatetimeman.
- Grant sudo permission to user kvmupdatetimeman by adding the line below in the vi editor which shows up when you issue the command `sudo VISUAL=vi visudo`:
- Assuming a unix user on the host OS you want to use for this purpose is debian, set up SSH public key authentication for user debian on the host OS so that it can SSH to the guest OS under user kvmupdatetimeman without having to enter a password. Make sure you SSH from the host OS to the guest OS at least once so that you already have accepted the SSH host key of the guest OS or else our automated script will have problem as we won't handle the accepting of the SSH host key from our script.
- On the host OS, add this line to the file /etc/rc.local which is executed every time after the machine boots up.
- Add the code below into the file updatesystimeinguest and don't forget to chmod +x it. Assuming the 2 IP addresses in the code are your guest OSes' IP addresses in your local network:
Related links
No comments:
Post a Comment