Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to permanently change date on a xen VM running CentOS 5.5

I've set xen/independent_wallclock = 1 in /etc/sysctl.conf (and /proc/), but after reboot date is reset. I would like it to be preserved after reboot.

The intention is to test software behaviour on daylight saving time or year change. Sometimes a reboot is needed on such system and date reset would break the environment.

share|improve this question
    
1 means that virtual machine is using independent wallclock. Did you try to sync guest time with ntp? –  quanta Aug 9 '11 at 10:15
    
@quanta, I do not want to sync... I want to make the date out of sync (several days, months or even years) and preserved after reboot with none of the services inside VM aware of real date at any time. –  Paweł Nadolski Aug 9 '11 at 10:42

2 Answers 2

up vote 1 down vote accepted

Best solution I came up is to put in the /etc/inittab:

ci::sysinit:/bin/pushclock

Where pushclock is a shell script which will forward clock by specific time offset.

share|improve this answer

You can't; at boot, the initial time is taken from the host. All independent_wallclock does is allows the time of the running guest to be set differently to the host.

share|improve this answer
    
Changing independent_wallclock was needed to change date at all, but I need it to be preserved after reboot. I expected that once I change to different date on the VM the VM host will save it and restore it since it controls the "hardware clock" of the VM, but it seems not true. –  Paweł Nadolski Aug 9 '11 at 10:33
    
Where would the VM host keep it? And why? –  womble Aug 9 '11 at 10:41
    
it could store it in /etc/xen as an offset from VM server date. I would like to use it for testing environment which requires different date than current date. –  Paweł Nadolski Aug 9 '11 at 10:46
    
Put something in your init scripts that'll apply the required offset for a given VM. What you want to do is so utterly localised that the chances of it ever being implemented by anyone other than you are epsilon squared. –  womble Aug 10 '11 at 0:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.