Let's talk about the time zone configuration. in the past, Debian had a great time zone configuration tool called tzconfig, which is no longer available. However, it is easy to configure the time zone, mainly in two files: etclocaltimeetctime.
Let's talk about the time zone configuration. in the past, Debian had a great time zone configuration tool called tzconfig, which is no longer available. However, it is easy to configure the time zone, mainly in two files:
/Etc/localtime
/Etc/timezone
The timezone file is a text file, which only needs to write a line of its own time zone. here we are Shanghai, Asia/Shanghai (who knows why it is not Beijing ?), The type of the localtime file is unclear, and some timezone data is written in it, which can be copied from the system's built-in time zone file at:/usr/share/zoneinfo
You can find the localtime copied from the Shanghai directory to the/etc directory. some people say that a connection is also acceptable, so that you do not have to worry about system data changes.
Set the time zone and determine the Linux time scheme. Linux supports UTC Time, Coordinated Universal Time, that is, the Time on the local meridian, and the GMT) the difference seems to be that it is averaged by multiple atomic clocks. In the/etc/default/rcS file, whether or not the system uses UTC is set, and UTC = yes is used.
The computer has its own time, that is, the hardware time, hard clock, that is, the time in the BIOS, and the shutdown will not be lost. This time will be read when the computer starts. If the time is set to UTC (GMT), that is, the time in London, it is required to set UTC = yes in the rcS file, and vice versa.
In short, there are two correct settings:
BIOS = local time, UTC = no
BIOS = UTC time, UTC = yes
Generally, the BIOS is set to the local time. This is because if a dual system is installed, Windows does not seem to understand utc, and the problem may occur. At this time, UTC = no.
If everything goes well, the time displayed after entering Linux should be correct. However, many machines, including this 640 m instance, are still incorrect. Instead, they ran eight hours ahead of the correct time. The problem lies in the hardware reading time in Linux.
The hwclock command is used to read the hardware in Linux:
Hwclock -- show: displays the hardware time.
Hwclock -- systohc: write system time to hardware
Hwclock -- hctosys: Write hardware Time to system time
When a problem occurs, hwclock commands cannot be run successfully. errors are often as follows:
Select () to/dev/rtc to wait for clock tick timed out
That is, it cannot read/dev/rtc, that is, the hardware time. This is because of the problem between the BIOS processing method of some machines and the rtc kernel module of Linux.
Linux has three other such modules, rtc/genrtc/rtc_dev, which seems to be a newer one, while debian usually uses the old rtc module; however, Dell, ibm, acer, and other vendors may all use new BIOS. such BIOS and rtc may not be used. If the above timeout problem occurs, there are two solutions:
1. add a parameter to hwclock, -- directisa, that is:
Hwclock -- directisa -- show
If the operation is successful, this method is feasible. Add this parameter as the default hwclock parameter. After debian 4.0, you can directly add a row in/etc/default/rcS:
HWCLOCKPARS = "-- directisa"
Before 4.0, you may only be able to add it in the hwclock startup script,/etc/init. d/hwclock. sh, replace "/sbin/hwclock" with "/sbin/hwclock -- directisa ". In the debian sid, the first line of this script is actually HWCLOCKPARS =. you can also add parameters like that of the rcS.
2. use other kernel rtc modules to test which module is easy to use:
- # Modprobe rtc
- # Hwclock -- show
- # Rmmod rtc
- # Modprobe genrtc
- # Hwclock -- show
- # Rmmod genrtc
- # Modprobe rtc_dev
- # Hwclock -- show
- # Rmmod rtc_dev
If the time out is not displayed, it is easy to use. then, you can stop the bad time in the blacklist, and add the useful one in the modules.
After using these two methods, hwclock should be able to work directly, that is, it can read the hardware time, and configure it with utc correctly. the restart time is correct.
In order to make the BIOS time more accurate, in addition to finding a precise time source, such as a CDMA mobile phone or GPS, you can use your fingers to accurately set the BIOS time, you can also use hwclock to write accurate time into the BIOS. the previous method can be careful with a few seconds of error, and the other method is less than 1 second.
Install the ntpdate package. it can read the correct time from the time server. the precision is still very high:
Aptitude install ntpdate
Ntpdate pool.ntp.org
At this time, the system time is already ntp time, which is quite accurate. write it into the hardware:
Hwclock -- systohc
In this way, the BIOS time will be very accurate, and no network will be available after the boot, so it will be accurate when ntpdate cannot be run.
The key points here are: bios Time, utc setting, rtc module, hwclock reading, and ntpdate pair.
In the old bug of Debian, we can see that because the system has multiple partitions, for example,/usr is divided separately, fsck will run on time, and thus cause problems that may take several hours, I don't know how to handle it.