0

For a project I'm doing with a Raspberry Pi Zero, I need to access raspi-config, compile some software, and do funky stuff with systemctl. With my other projects, I've always either SSHed into the Pi or just plugged in a keyboard and monitor. Unfortunately, I have neither a Micro HDMI adapter nor a Micro USB external keyboard (but do have Micro USB cables), so both of those paths seem out of the question.

The ways forward that seem like they might work would be to

  1. Chroot into the Zero, although doing this from my x86_64 machine looks to be asking for problems,
  2. Somehow SSH directly into the Zero over USB, or
  3. Boot into the Zero from my laptop, and have it drive my monitor and keyboard.

Would either of these options (or one not listed) let me access the command line, and if so, how would you go about accomplishing this?

3
  • 3
    A common approach is to use a serial link and log in that way. That does assume the serial login has not been disabled by raspi-config. – joan Oct 27 '20 at 11:29
  • If you configure the zero as an ethernet gadget you could do this via usb; it does not need an uplink to work. – goldilocks Oct 27 '20 at 15:06
  • @jj I put all that stuff into an answer and de-cluttered. – goldilocks Oct 27 '20 at 18:40
2

I use the serial debug console for a long time. You only need a really cheep USB to TTL serial adapter that you connect to pins 6, 8, 10 on the RasPi. I got some for about 3 € from china. Then you can use a serial terminal program to have the same text console (command line) than with ssh. For more details look at What is the correct way to connect serial console?.

0

Chroot into the Zero, although doing this from my x86_64 machine looks to be asking for problems,

If by "chroot in" you meant, put the card in your x86-64 machine and chroot into it there to run systemctl and raspi-config, that isn't "asking for problems" it simply will never work -- the system on the card is not compatible and cannot be run on an x86-64. You would need an emulator (QEMU being the one and only option I'm aware of there).

A bit more detail: Chroot (change root) is a command to switch the root filesystem inside a running OS. You can't do that with a Pi card on an x86-64 system because the software on the card was compiled for a different ISA. Just as software compiled for an x86-64 system cannot be run on a Pi.1

QEMU is a hardware emulator, more broadly a "virtual machine", if you've used a VM of any sort, same idea (but most VMs are not hardware emulators). So you are running a system inside a system, there is no chroot involved.

That said, I haven't used QEMU for this, and I think there's a restriction there whereby you can use it to develop, compile etc. software for the pi but you need to use a special OS image (ie., the card won't do). You'll need to investigate that part, there should be enough stuff here an online generally ("pi QEMU") -- but TBH that would be by far my last choice anyway, I suspect minimally this is an afternoon worth of fiddling the first time.

What I would recommend is considering whether everything you want to do really requires this (ie., is this an XY problem). Pretty much everything I can think of that raspi-config does (which surely isn't everything, but in general:) doesn't really require a running system. It is mostly about altering on-disk configuration in ways that are not hard to do manually, and, since it is just a few thousand lines of POSIX shell code, most of which is very simple, all you need to do is read it to find out what to do (and/or when in doubt, ask here about it since deciphering raspi-config is solidly on topic).

WRT systemd, if all you are talking about is adding and removing services, this just requires creating and deleting symlinks in a very, very straightforward way -- I presume that is by design, since what it means is you can do it without using systemctl, or the system running, or even a binary compatible system to do it on. This is something you can do quickly and easily by putting the card in an x86-64 box. The same applies to what I just said about raspi-config, because those configurations are mostly in text files. Text files don't have an ISA ;)

For the software you need to compile on the Pi, you could always do that and copy it out for installation to (another) card.

For what really does require a running system, you could just script it and have that run at first boot.


  1. Another issue with chroot is that not everything raspi-config does operates only on the root fs; much of it alters stuff on the boot partition, although that is not a hard problem to get around.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.