How can I determine the clock source that's used by an Amazon Elastic Compute Cloud (Amazon EC2) instance running Linux, and how can I change it?

By using an SSH client, you can find the current clock source, list the available clock sources, or change the clock source.

Note: Hardware Virtual Machine (HVM) instances use a variety of clock sources, such as Xen, Time Stamp Counter (TSC), High Precision Event Time (HPET), or Advanced Configuration and Power Interface Specification (ACPI). Xen is a clock source provided by the Xen virtualization system, and it's the recommended clock source for AWS offerings. Also note that EC2 instances such as C5 or M5 use the AWS Nitro Hypervisor, which uses different clock sources, and the Xen clock might not be available.

To find the clock source

Open an SSH client into your EC2 instance, and then run the following commands to find the current and available clock sources.

To find the current clock source, use the current_clocksource command to list the file content:

cat /sys/devices/system/clocksource/clocksource0/current_clocksource

To list the clock source, use the available_clocksource command:

cat /sys/devices/system/clocksource/clocksource0/available_clocksource
xen tsc hpet acpi_pm

To set the current clock source to a different value

1.    Run bash as a super user to override the current_clocksource:

sudo bash -c 'echo tsc > /sys/devices/system/clocksource/clocksource0/current_clocksource'

2.    Run the dmesg command to view the kernel messages:

dmesg | less

If the override was successful, this message appears:

clocksource: Switched to clocksource tsc

Note: The Linux kernel resets the clock source if the system is rebooted.

To set a clock source during the system boot loader

1.    Set clocksource in the kernel command-line parameter.

For example, if you use grub2 and you want to set the clock source to "tsc", edit the /etc/default/grub file and add clocksource=tsc tsc=reliable for the GRUB_CMDLINE_LINUX option:

GRUB_CMDLINE_LINUX="console=tty0 crashkernel=auto console=ttyS0,115200 clocksource=tsc tsc=reliable"

2.    Generate the grub.cfg file:

grub2-mkconfig -o /boot/grub2/grub.cfg

Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2018-07-18