Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a system with an unrecoverable /usr partition. Terrified the drives are going bad, I've got it booted into a LiveCD environment, and I can't remember what the install architecture was, the most I have is it's CentOS 5.5.

Because of the Live environment, none of the standard methods work such as uname or checking /proc.

Here is the kernel that was used: vmlinuz-2.6.18-194.32.1.el5 Is there anything I can scan the file for to figure out if the architecture is 32 or 64 bit?

Or something else I can look at on the file system? Nothing in /usr will work because that partition is now dead.

share|improve this question
4  
Can you look at anything under /bin or /sbin and run file on one of those files? This will answer your question instantly. –  Renan Apr 29 '13 at 19:30
2  
This sounds like an XY problem. What do you plan to do once you know whether you were running a 32- or 64-bit system? –  depquid Apr 29 '13 at 19:44
add comment

7 Answers

file vmlinuz-2.6.18-194.32.1.el5 will tell you what architecture the kernel was compiled for. If there's a file /boot/config-2.6.18-194.32.1.el5, it will give more information about the kernel compilation options, including the processor architecture.

ls /lib* will tell you what architecture the userland supports. For example, if there's /lib/ld-linux.so.2 on an x86 system, then you have at least basic 32-bit support. If there's /lib/ld-linux-x86-64.so.2 or /lib64/ld-linux-x86-64.so.2 then you have at least basic 64-bit (amd64) support. file /bin/ls will tell you what architecture utilities are compiled from (usually, the whole OS userland is compiled for one architecture, perhaps with additional libraries for another ABI for custom applications).

The kernel and the userland aren't always the same architecture. Amd64 kernels can run 32-bit user programs (but not the converse). If you wanted to know whether you had a 32-bit or 64-bit edition of CentOS, check whether /bin/ls is a 32-bit or 64-bit program.

share|improve this answer
add comment

Just run file on the kernel image. It will show what architecture the binary was compiled as. file vmlinuz-2.6.18-194.32.1.el5.

EDIT: Running file on the OP's kernel doesn't return the exact architecture, so the answer is not valid. I'll try it on my kernels and see if I get more info.

share|improve this answer
    
At least on Debian it doesn't: file /boot/vmlinuz-3.8-trunk-amd64 gives /boot/vmlinuz-3.8-trunk-amd64: Linux kernel x86 boot executable bzImage, version 3.8-trunk-amd64 (debian-kernel@lists.debian.org) #1 SMP Debian , RO-rootFS, swap_dev 0x2, Normal VGA ... the only amd64 in there is from the kernel version string (which Debian puts in there). In fact, it says its x86, so you'd think 32-bit. –  derobert Apr 29 '13 at 21:09
2  
Now, if you do this on a random executable instead (say, /bin/bash) you get /bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x5bb332752cc304fa7fbb838bdf7d7766ffc7a8a1, stripped ... which does include the architecture. –  derobert Apr 29 '13 at 21:10
    
@derobert x86 doesn't imply 32-bit, the name covers both 32-bit and 64-bit variants of the architecture. amd64 implies 64-bit. –  Gilles Apr 29 '13 at 23:42
    
@Gilles Yes, AMD64 does, but that's part of the version (uname -r gives 3.8-trunk-amd64, and that's a Debian thing, not present on RHEL/CentOS/etc., AFAIK. Also you can have that version installed with 32-bit Debian as well.) And the 'x86 boot sector' is referring to the legacy BIOS boot sector (were you to copy the kernel to a floppy), which is definitely 32-bit code. But yeah, in general x86 sometimes includes both—but that doesn't help here. –  derobert Apr 30 '13 at 15:41
1  
@derobert The legacy BIOS boot code is 16-bit code, actually. Seeing “x86” here doesn't imply anything on the kernel being 32-bit or 64-bit. –  Gilles Apr 30 '13 at 16:41
show 5 more comments

Look for a /lib64 directory, if it's there and not empty you probably had a 64 bit install, if it's not then it was 32bit.

share|improve this answer
add comment

Run 'strings /boot/vmlinuz-$VERSION | grep x86-64'. If it returns something it's 64. If not, it's 32-bit.

share|improve this answer
add comment

Does rpm/yum still work? rpm -q kernel should tell, if it is x86_64 at the end, it is a 64 bit setup.

share|improve this answer
add comment

Look in /var/cache/yum. Your computer's architecture may be apparent in one of the directory names there.

share|improve this answer
add comment

The following StackOverflow question may help. You can extract the kernel's .config file and inspect it for the architecture selected: http://stackoverflow.com/questions/14958192/getting-config-from-linux-kernel-image

Since this is a CentOS kernel image, it probably has the IKCONFIG flag set. Most compiled kernels distributed have.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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