Inconsistent results for checking whether the OS is 32 or 64 bit

Jul 17, 2024 Last reply: 1 year ago 10 Replies

-=> Adam Funk wrote to All <=-

AF> I have a Pi 4 B that I use headlessly over SSH. I can't remember AF> whether I installed the 32-bit or 64-bit OS on it, but different AF> commands found on the web give different results.

AF> $ uname -m AF> aarch64

AF> $ getconf LONG_BIT AF> 32

AF> $ dpkg --print-architecture AF> armhf

AF> Which one is right?

On my Pi4B, which I know has a 64-bit OS installed, I get:

$ uname -m aarch64

$ getconf LONG_BIT

64

dpkg --print-architecture arm64

So.... I'd say you have a 32-bit OS installed.

The "uname -m" reports on the device HARDWARE, not software/kernel, so your results make sense.

... So easy, a child could do it. Child sold separately. === MultiMail/Linux v0.52

Hi



I have a Pi 4 B that I use headlessly over SSH. I can't remember whether I installed the 32-bit or 64-bit OS on it, but different commands found on the web give different results.



$ uname -m aarch64



$ getconf LONG_BIT



32

$ dpkg --print-architecture armhf



Which one is right?



Thanks


That sounds like a 32 bit OS on 64 bit hardware. Not sure if uname -m is the kernel or the hardware, but perhaps you're running a 32 bit userland on a 64 bit kernel?

Seems that Pi OS switched to a 64 bit kernel on the Pi4 in March 2023:

formatting link
It looks like 'getconf' returns glibc parameters, which would be 32 bit on a

32 bit userland.

Theo

Try looking at a representable executable, e.g. /bin/bash:

file /bin/bash

On my (admittedly AMD64) machine, I get

/bin/bash: ELF 64-bit LSB pie executable, ...

but that initial part should not be architecture-specific.

Hello Adam!

17 Jul 24 15:03, you wrote to all:

AF> $ uname -m AF> aarch64

This shows your kernel is 64-bit

AF> $ getconf LONG_BIT AF> 32

This indicates that the user applications are compiled for a 32-bit architecture.

AF> $ dpkg --print-architecture AF> armhf

This shows the distribution you have installed is for the 32-bit ARM architecture

AF> Which one is right?

The mix you have is because Raspbian (Raspberry Pi OS) can be installed with a

64-bit kernel while using 32-bit user space applications. It is a common configuration to maximize compatibility while allowing the benefits of a 64-bit kernel.

If you want to run a fully 64-bit system on your RPi 4B, I'm afraid you got to reinstall.

Otherwise it's not a problem at all to run a 32-bit user space on a 64-bit kernel. But be aware that some packages or apps may have copatibility issues.

Christian LPIC-1/LPIC-2/LPIC-3 Security certified

I ran that configuration on my Pi 4B's for years.

You can just install a fresh 64 bit Bookworm and set it all up again from scratch. But if you have a lot of customisation of your existing system it is fairly straightforward to move to from 32 bit Buster to 64 bit Buster. You can then upgrade from Buster to Bookworm if desired.

  1. Fully upgrade your existing 32 bit system
  2. Make a list of all installed 32 bit packages
  3. Install the 64 bit image of the same OS release on a new card (or another partition on a SSD, which is easier)
  4. Fully update the new 64 bit system
  5. Make a list of the installed 64 bit packages
  6. Install any packages you had installed on the 32 bit system that aren't on the 64 bit one (if available)
  7. Copy over your /home and /root folder from the 32 bit system
  8. Copy over your /etc folder from the 32 bit system
  9. Reboot

Step 8 is the bit which could give problems, but I didn't encounter any by following the above as the package versions are identical which generally means the configuration files are compatible.

Steps 7 & 8 ensure the machine key and all ssh keys are preserved, so the machine will slot back to your network with trusted relationships maintained.

---druck

OK, that makes sense because I also get

$ file /lib/systemd/systemd /lib/systemd/systemd: ELF 32-bit LSB pie executable, ARM, [ETC.]

I'm starting to wonder if I just moved the SD card and external USB drive from a 2 to a 4B when I got the 4B and kept upgrading. Would that explain this situation?

Oh, I'm not surprised by that. It will be a bit of a nuisance because the SD card is only used for /boot --- everything else is on the external drive.

That does seem to be the case.

"After updating 32 bit Raspi OS Pi 4 is on 64bit kernel" --- yes, that would explain it. Thanks!

It looks like it was changed in an update. I think the Pi maintains multiple kernels in /boot, so it's possible the same SD card will boot with a 64-bit kernel on a Pi4 and 32-bit kernel on a Pi2 (especially the v1.0 Pi2 with a Cortex A7 which doesn't support 64 bit).

So it may not be that moving the card has affected it, just that the single '32 bit' Pi OS boots a different kernel depending on which hardware you put the card into.

(this has caused some troubles for build systems which use uname -m to work out whether to build 32 or 64: it returns 64, but the right answer is 32. The same would happen with a 32 bit chroot on a 64 bit x86)

Theo

Right.

Well, if I had done a fresh install on a 4B, I would have picked the

64-bit option, so the 32-bit userland is a vestige of that.

Ouch. Fortunately I haven't run into that.

Yes there are multiple kernels, and on suitable machines you can change from 32 to a 64 bit kernel by putting this in line /boot/config.txt

arm_64bit=1

---druck

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required