# KVM: 32-bit or 64-bit?

## KayZee

I have KVM setup using  Gentoo as the host.  It is a x86_64 host.  Here is /proc/cpuinfo

```
processor   : 0

vendor_id   : AuthenticAMD

cpu family   : 16

model      : 6

model name   : AMD Athlon(tm) II Neo N36L Dual-Core Processor

stepping   : 3

cpu MHz      : 1297.543

cache size   : 1024 KB

physical id   : 0

siblings   : 2

core id      : 0

cpu cores   : 2

apicid      : 0

initial apicid   : 0

fpu      : yes

fpu_exception   : yes

cpuid level   : 5

wp      : yes

flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a 3dnowprefetch osvw ibs skinit wdt nodeid_msr npt lbrv svm_lock nrip_save

bogomips   : 2595.08

TLB size   : 1024 4K pages

clflush size   : 64

cache_alignment   : 64

address sizes   : 48 bits physical, 48 bits virtual

power management: ts ttp tm stc 100mhzsteps hwpstate

processor   : 1

vendor_id   : AuthenticAMD

cpu family   : 16

model      : 6

model name   : AMD Athlon(tm) II Neo N36L Dual-Core Processor

stepping   : 3

cpu MHz      : 1297.543

cache size   : 1024 KB

physical id   : 0

siblings   : 2

core id      : 1

cpu cores   : 2

apicid      : 1

initial apicid   : 1

fpu      : yes

fpu_exception   : yes

cpuid level   : 5

wp      : yes

flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a 3dnowprefetch osvw ibs skinit wdt nodeid_msr npt lbrv svm_lock nrip_save

bogomips   : 2595.80

TLB size   : 1024 4K pages

clflush size   : 64

cache_alignment   : 64

address sizes   : 48 bits physical, 48 bits virtual

power management: ts ttp tm stc 100mhzsteps hwpstate

```

The first guest VM is also Gentoo.  How can I tell if the vm environment is 32 or 64 bit?  /proc/cpuinfo in the vm shows this

```
rocessor   : 0

vendor_id   : AuthenticAMD

cpu family   : 6

model      : 2

model name   : QEMU Virtual CPU version 0.13.0

stepping   : 3

cpu MHz      : 1297.543

cache size   : 512 KB

fpu      : yes

fpu_exception   : yes

cpuid level   : 4

wp      : yes

flags      : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm up nopl pni cx16 popcnt hypervisor lahf_lm abm sse4a

bogomips   : 2595.08

TLB size   : 1024 4K pages

clflush size   : 64

cache_alignment   : 64

address sizes   : 40 bits physical, 48 bits virtual

power management:

```

When I try compiling the kernel I get this error

```
kernel/bounds.c:1 error: code model 'kernel' not supported in 32 bit mode

kernel/bounds.c:1 sorry, unimplemented:  64-bit mode not compiled in

make[1]: *** [kernel/bounds.s]  Error 1

make: *** [prepare0]  Error 2

```

----------

## NeddySeagoon

KayZee,

The KVM VM has a 64 bit CPS as evidenced by the lm flag (for Long Machine)

That does not stop you installing a 32 bit kernel in the VM.  However with a 32 bit kernel, you cannot perform a 64 bit install.

In the VM, do 

```
uname -a
```

Does the output containl i686 (32 bit)  or x86_64 (64 bit) ?

```
model name   : AMD Athlon(tm) II Neo N36L Dual-Core Processor

cpu MHz      : 1297.543 
```

That could be an HP Proliant Microserver. I have one of those that I'm using KVM and 64 bit VMs on.

----------

## KayZee

Yes, this is an HP Proliant Microserver.   Its a neat little server.  

In the VM

```
uname -a

Linux livecd 2.6.39-gentoo-r3 #1 SMP Thu Aug 4 13:48:43 UTC 2011 x86_64 QEMU Virtual CPU version 0.13.0 AuthenticAMD GNU/Linux
```

I note that I booted the vm with 

```
install-amd64-minimal-20110804.iso 
```

so its using x86_64 for installing.  

Yet my kernel compile fails with 

```
kernel/bounds.c:1 error: code model 'kernel' not supported in 32 bit mode

kernel/bounds.c:1 sorry, unimplemented:  64-bit mode not compiled in

make[1]: *** [kernel/bounds.s]  Error 1

make: *** [prepare0]  Error 2 
```

so something thinks it 32-bit.

----------

## KayZee

 *Quote:*   

> so something thinks it 32-bit.

 

Answering myself...I think I see my problem.

I booted the vm with an amd64 install iso.

```
install-amd64-minimal-20110804.iso 
```

But I download an i686 stage3.

```
stage3-i686-20110809.tar.bz2
```

So my /etc/make.conf contains march and CHOST that conflict with the boot environment.

```
# These settings were set by the catalyst build script that automatically

# built this stage.

# Please consult /usr/share/portage/config/make.conf.example for a more

# detailed example.

CFLAGS="-O2 -march=i686 -pipe"

CXXFLAGS="${CFLAGS}"

# WARNING: Changing your CHOST is not something that should be done lightly.

# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.

CHOST="i686-pc-linux-gnu"

MAKEOPTS="-j2"
```

I am going to trying starting over with an amd64 stage3.

----------

## NeddySeagoon

KayZee,

Start again with the amd64 stage3.

You can save a lot of compile time by starting out with the same install as on the bare metal in your first VM.

All you need to change is the VM kernel.  The bare hardware kernel may well boot but you should use the virtio block and net drivers for best performance, not the emulated hardware.

I keep a template VM, which I clone when I need another VM.  My VM filesystems are LVM slices too, so I can expand the filesystems if I need to.  This also avoids the filesystem in a file on a filesystem slowdown.

----------

## Gauss_Cleric

Hi KayZee, NeddySeagoon,

I was looking for someone with the Proliant microserver to ask for some help. Could one of you share a working .config for compiling the kernel? I've spent *days* already and I can't manage to make it boot from a usbkey. The whole root file system + boot + swap is in this key and the hard drives are only for data so I want it to boot from this key. I get the infamous "cannot mount root file system in /dev/sd?" kernel panic message. It shows only the partitions from the hard drives meaning that I am missing the drivers for the usbkey. The obvious choices (ohci, ehci, usb-storage) I have compiled in so I am clueless (could it be the usb power-saving feature?). If you can give me a working .config I can start comparing. Ah, of course, it would be preferable if you would also boot from the usb but just a working usb drive during boot would be enough I guess.

Many thanks,

GN

----------

## NeddySeagoon

Gauss_Cleric,

The easy way to get what you want is to put SystemRescueCD on a USB key.  Thats how I installed my server as it has five HDD drives, so no room for an optical drive.

I suspect your kernel is fine but you may be missing the kernel parameter rootdelay=7 in your grub.conf.

Normally, root is mounted before USB is started. Thats a bit of a showstopper for root on USB.  rootdelay=7 tells the kernel to wait 7 seconds before looking for root, which allows USB to get started.

For the microserver, you need SCSI disk, SCSI Generic, USB-Storage, EHCI_HCD all built into your kernel. My bare metal config you won't need the Virtualisation support.  Do check that the items I mentioned are built in.  I tend to make my kernels as modular as possible, without needing and initrd.  However, I have everything on LVM, except boot, so in this case I had to use an initrd.

I'm also using GPT disklables - be careful of the 2TiB limit to MSDOS disklabels.  The bare metal kernel only does enough to get the box up.  Its sole purpose is to support KVM, so its pretty minimalist.

----------

## Gauss_Cleric

The idea of rootdelay=7 worked like a charm. If only I would have thought that such a thing could happen :p.

Many thanks indeed!

Cheers,

GN

----------

## galandilias

Hi,

Guys can you re-post the kernel config for N36L? I am also interested in it but previous link has expired  :Sad: 

Regards,

Marcin

----------

