On my Beaglebone Black I added a I2C real-time-clock to not being reliant on ntpd to maintain accurate timing. The outcome is that there are two special device files in /dev. These are /dev/rtc0 and /dev/rtc1 but there is also /dev/rtc which is a symlink to /dev/rtc0. /dev/rtc0 is the real-time-clock within the ARM SOC on the board, /dev/rtc1 is the I2C device. At the moment I'm using scripts that read and write the time manually to the I2C clock but I'd rather like the symlink /dev/rtc to point to /dev/rtc1. Hence the question, how can this be done? The Linux distro on my beaglebone black is Arch Linux which uses systemd for all the house keeping. When I delete the symlink and create a new one pointing to /dev/rtc1 not surprisingly it is reset after the next reboot and I didn't find any config files or systemd-units so far.Help is much appreciated.
How can the link target of /dev/rtc be changed?
arch linux;systemd
That udev rule hint pointed me in the right direction. After a quick review of writing udev rules I did the following.udevadm info -a -p /sys/class/rtc/rtc1The output (shortened) revealed some useful properties to define a udev rule.looking at device '/devices/platform/ocp/4802a000.i2c/i2c-1/1-0068/rtc/rtc1':KERNEL==rtc1SUBSYSTEM==rtcDRIVER==ATTR{date}==2015-12-04ATTR{hctosys}==0ATTR{max_user_freq}==64ATTR{name}==ds1307ATTR{since_epoch}==1449230817ATTR{time}==12:06:57...So the rules file needs to reside in /etc/udev/rules.d/ with a naming scheme like 99-rtc1.rules.The files content is KERNEL==rtc1, SUBSYSTEM==rtc, DRIVER==, ATTR{name}==ds1307, SYMLINK=rtc, MODE=0666To test the rule you can runudevadm test /sys/class/rtc/rtc1and the important lines in the output are...creating link '/dev/rtc' to '/dev/rtc1'atomically replace '/dev/rtc'...The result in /dev is the desired configuration.