You are not logged in.
Pages: 1
Hi,
In my custom initramfs I need to set system time according to some calculation to be different from the hardware RTC time.
(I need it for a very particular usage scenario, not everyday usage - so *this* is the problem I'm trying to solve, and I'm not trying to solve some other problem with it
)
In the default initramfs there is no `date` utility.
So my question is: do I have to include the `date` binary with a build hook, or is there some other way to set the system time, with more basic utilities: through sysfs, or something?
The time which I'm trying to set is in a "seconds since epoch" format, so just a single string/integer.
Last edited by blochl (2020-04-08 15:46:29)
Offline
The "busybox" binary is (probably?) in your initramfs, and it contains a 'date' command. You can run "busybox --help" to check things out, there might be some other commands you'd like to have and busybox contains a lot of stuff.
You can get to that 'date' that's inside busybox by running "busybox date ...". Check out "busybox date --help" to see what that special 'date' can do.
If you want an actual 'date' command inside your initramfs, instead of adding the date binary, you can also try to find out how to create a link inside /usr/bin named 'date' that points to the busybox binary.
Last edited by Ropid (2020-04-08 14:52:27)
Offline
mkinitcpio-busybox is not currently built with date support https://bugs.archlinux.org/task/62163.
Offline
Further, busybox's date does not allow you to set time with a seconds-since-epoch input. And unless I'm missing something, neither does gnu-coreutil's date. You can get the current time as seconds since epoch, but not set it.
EDIT: oops, I was missing something, the seconds string needs to be prefaced by an '@' symbol. And this works with my version of busybox's date as well. But that's still not included in mkinitcpio's busybox.
Last edited by Trilby (2020-04-08 15:00:13)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks for your replies. Eventually I just included `date`, and it works fine.
Offline
Pages: 1