I'm using busybox in a embedded system, and I would like to check its version. How do I check the busybox version from within busybox?
Busybox – How to Check Busybox Version
busybox
Related Solutions
The reason that switch_root
is not working on the command line is this code in busybox:
if (st.st_dev == rootdev || getpid() != 1) {
// Show usage, it says new root must be a mountpoint
// and we must be PID 1
bb_show_usage();
}
You are not PID 1, so you are falling through into this bb_show_usage
. The implication is that the switch_root
command in your initramfs init script should run switch_root
with exec
. i.e.
exec switch_root ...
The other issue with your "not found" errors is likely because the shared libraries needed by the executables are not found, because the initramfs root filesystem does not have them. If you can get switch_root
to work with exec
, then is likely the "not found" error will go away.
The options that the BusyBox
commands have depends a lot on the options that BusyBox
is compiled with. BusyBox
aims to be highly configurable so that very small cut down versions can be compiled for systems where resources are very limited. Larger, more full featured versions can be built where this isn't an issue.
In your case cpio
needs the -p
or --pass-through
(long form) option enabled. Normally cpio
behaves more like an archive utility like tar
, however it also has an extra function which allows it to copy files. To enable this in BusyBox
, it needs to be built with FEATURE_CPIO_P
defined (also LONG_OPTS
for long form options to be enabled for any program).
From your last question, I strongly recommend that you use rsync
for what you are doing. You are probably better off asking another question detailing exactly what you are doing with rsync
and why it doesn't do what you expect. rsync
is an extremely versatile tool and can no doubt be configured to do what you want.
That said, you could try the following with cpio
, this will create an archive and then extract it again (somewhat less efficient, but still the same result):
find . -mtime -2 | cpio -o | { cd /media/USB_FLASH_2 && cpio -imd; }
Unfortunately the -o
option can also be disabled in BusyBox
(FEATURE_CPIO_O
build option), so this may not work either.
Update
Based on this line of output, you need to add an extra option when creating an archive:
-o Create (requires -H newc)
This changes the command to:
find . -mtime -2 | cpio -oH newc | { cd /media/USB_FLASH_2 && cpio -imd; }
This time I have tested with the cpio
in the BusyBox
for my own system and it works for me, however in some cases the mtimes for directories won't be preserved. rsync
should be the best way to do this.
Best Answer
Invoke the busybox binary as
busybox
, and you get a line with the Busybox version, a few more lines of fluff, and the list of utilities included in the binary.Most utilities show a usage message if you call them with
--help
, with the version number in the first line.