Have grub2 boot 32 and 64 bit Ubuntu
https://askubuntu.com/questions/97641/have-grub2-boot-32-and-64-bit-ubuntu
I just installed a system like this:
ubuntu@ubuntu:~$ ls -l /dev/disk/by-label/
total 0
lrwxrwxrwx 1 root root 10 2012-01-22 18:49 Boot -> ../../sda1
lrwxrwxrwx 1 root root 10 2012-01-22 18:49 ubuntu32 -> ../../sda2
lrwxrwxrwx 1 root root 10 2012-01-22 18:28 ubuntu64 -> ../../sda3
lrwxrwxrwx 1 root root 10 2012-01-22 18:49 Home -> ../../sda5
ubuntu@ubuntu:~$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 2012-01-22 20:55 3582d70f-f4a5-484c-b14c-45cd740346b9 -> ../../sda1
lrwxrwxrwx 1 root root 10 2012-01-22 20:55 741182a8-3f15-4dfd-994d-654c8a57a9e4 -> ../../sda2
lrwxrwxrwx 1 root root 10 2012-01-22 20:55 1c415472-a770-4d76-be9f-27b8c1408e2a -> ../../sda3
lrwxrwxrwx 1 root root 10 2012-01-22 20:55 3515d523-72a2-4e04-b7da-cb6a1fd572ef -> ../../sda5
lrwxrwxrwx 1 root root 10 2012-01-22 20:55 f1f1cd7e-30cb-44e7-9ef6-986a589e0045 -> ../../sda6
I need 32 and 64 bit separate so I can test driver performance on each, the Home directory is shared and each version of ubuntu is mounted as /ubuntuXX under the other version. /boot also points to /dev/sda1 on both.
When I run sudo update-grub from ubuntu32 it runs fine but I get an error booting ubuntu64. init fails and I'm assuming it is because of the wrong bit type. Shouldn't grub's OS probe be bit-aware? How can I get these two to boot properly.
I ran grub-customizer from a live disk, chose /dev/sda3 as root, selected all partitions in the second step, and then removed all entires except for OS-Prober and memtest. What resulted is the attached grub.cfg. It now lists /dev/sda2 as the only OS option. The grub.cfg has the root UUID set to /boot for every entry.
grub.cfg: http://pastebin.com/Dkdxian4
me@GAMMA:~$ cat /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/10_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function recordfail {
set recordfail=1
if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}
function load_video {
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
}
insmod part_msdos
insmod ext2
set root='(hd0,msdos3)'
search --no-floppy --fs-uuid --set=root 1c415472-a770-4d76-be9f-27b8c1408e2a
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=auto
load_video
insmod gfxterm
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root 3582d70f-f4a5-484c-b14c-45cd740346b9
set locale_dir=($root)/grub/locale
set lang=en_US
insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/10_header ###
### BEGIN /etc/grub.d/11_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 44,0,30; then
clear
fi
### END /etc/grub.d/11_debian_theme ###
### BEGIN /etc/grub.d/12_os-prober ###
menuentry "Ubuntu 11.10 (11.10) (on /dev/sda2)" --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root 3582d70f-f4a5-484c-b14c-45cd740346b9
linux /vmlinuz-3.0.0-12-generic root=/dev/sda2
initrd /initrd.img-3.0.0-12-generic
}
menuentry "Ubuntu 11.10 (11.10) (on /dev/sda2)" --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root 3582d70f-f4a5-484c-b14c-45cd740346b9
linux /vmlinuz-3.0.0-15-generic root=/dev/sda2
initrd /initrd.img-3.0.0-15-generic
}
### END /etc/grub.d/12_os-prober ###
### BEGIN /etc/grub.d/13_memtest86+ ###
menuentry "Memory test (memtest86+)" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root 3582d70f-f4a5-484c-b14c-45cd740346b9
linux16 /memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root 3582d70f-f4a5-484c-b14c-45cd740346b9
linux16 /memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/13_memtest86+ ###
fstab (both): http://pastebin.com/3sUabYRY
ubuntu@ubuntu:~$ cat /ubuntu32/etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda2 during installation
UUID=741182a8-3f15-4dfd-994d-654c8a57a9e4 / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=3582d70f-f4a5-484c-b14c-45cd740346b9 /boot ext2 defaults 0 2
# /home was on /dev/sda5 during installation
UUID=3515d523-72a2-4e04-b7da-cb6a1fd572ef /home ext4 defaults 0 2
# /ubuntu64 was on /dev/sda3 during installation
UUID=1c415472-a770-4d76-be9f-27b8c1408e2a /ubuntu64 ext4 defaults 0 2
# swap was on /dev/sda6 during installation
UUID=f1f1cd7e-30cb-44e7-9ef6-986a589e0045 none swap sw 0 0
ubuntu@ubuntu:~$ cat /ubuntu64/etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda3 during installation
UUID=1c415472-a770-4d76-be9f-27b8c1408e2a / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=3582d70f-f4a5-484c-b14c-45cd740346b9 /boot ext2 defaults 0 2
# /home was on /dev/sda5 during installation
UUID=3515d523-72a2-4e04-b7da-cb6a1fd572ef /home ext4 defaults 0 2
# /ubuntu32 was on /dev/sda2 during installation
UUID=741182a8-3f15-4dfd-994d-654c8a57a9e4 /ubuntu32 ext4 defaults 0 2
# swap was on /dev/sda6 during installation
UUID=f1f1cd7e-30cb-44e7-9ef6-986a589e0045 none swap sw 0 0``none
I know grub2 is all auto-generated and menus and jazz, but how do I just nuke all that and manually add entires (I'm not keeping this install long so there's no worry about kernel updates)
I took a shot at blindly replicating the /dev/sda2 entry but adjusting it for /dev/sda3 however it didn't go well. I did however, manage to get the same error as my first attempt (it's the line right before the kernel panic, run-init)
(null)
Begin: Running /scripts/local-bottom ... done.
done.
Begin: Running /scripts/init-bottom: ... done.
[ 3.402989] request_module: runaway loop modprobe binfmt-464c
run-init: /sbin/init: Exec format error
[ 3.406303] Kernel panic - not syncing: Attempted to kill init!
[ 3.406394] Pid: 1, comm: run-init Not tainted 3.0.0-15-generic #25-Ubuntu
[ 3.408290] [<c151a922>] ? printk+0x2d/0x2f
[ 3.408338] [<c151a800>] panic+0x5c/0x151
[ 3.408388] [<c104b564>] forget_original_parent+0x1e4/0x1f0
[ 3.408440] [<c10d3a48>] ? perf_cgroup_attach_task+0x20/0x20
[ 3.408489] [<c104b583>] exit_notify+0x13/0x140
[ 3.408536] [<c104bd8d>] do_exit+0x1ad/0x3a8
[ 3.408585] [<c1313850>] ? tty_write+0x228/0x228
[ 3.408632] [<c104c098>] sys_exit+0x18/0x28
[ 3.408680] [<c152e424>] syscall_call+0x7/0xb
I'm beginning to think it has to do with the kernel images that are in the /boot directory.
OK, now I'm certain that it is due to the fact that one partition is 32-bit and one is 64-bit.
updated part of grub.cfg: http://pastebin.com/DvfBhrBF
### BEGIN /etc/grub.d/12_os-prober ###
menuentry "Ubuntu 11.10 (11.10) (on /dev/sda2)" --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root 3582d70f-f4a5-484c-b14c-45cd740346b9
linux /vmlinuz-3.0.0-15-generic root=/dev/sda2
initrd /initrd.img-3.0.0-15-generic
}
menuentry "Ubuntu 11.10 (11.10) (on /dev/sda3)" --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root 3582d70f-f4a5-484c-b14c-45cd740346b9
linux /vmlinuz-3.0.0-15-generic root=/dev/sda3
initrd /initrd.img-3.0.0-15-generic
}
### END /etc/grub.d/12_os-prober ###
Figure 1: excerpt from /boot/grub/grub.cfg:
linux /vmlinuz-3.0.0-12-generic root=/dev/sda2
initrd /initrd.img-3.0.0-12-generic
Figure 2: Listings of /ubuntu64/vm* and /ubuntu32/vm*
me@GAMMA:~$ ls -l /vm*
lrwxrwxrwx 1 root root 29 2012-01-23 20:41 /vmlinuz -> boot/vmlinuz-3.0.0-15-generic
lrwxrwxrwx 1 root root 29 2012-01-22 13:05 /vmlinuz.old -> boot/vmlinuz-3.0.0-12-generic
me@GAMMA:~$ ls -l /ubuntu32/vm*
lrwxrwxrwx 1 root root 29 2012-01-22 12:41 /ubuntu32/vmlinuz -> boot/vmlinuz-3.0.0-15-generic
lrwxrwxrwx 1 root root 29 2012-01-22 12:22 /ubuntu32/vmlinuz.old -> boot/vmlinuz-3.0.0-12-generic
Figure 3: Magic File Type of /boot/vmlinuz-3.0.0-12-generic
/boot/vmlinuz-3.0.0-12-generic: Linux kernel x86 boot executable bzImage, version 3.0.0-12-generic (buildd@creste, RO-rootFS, root_dev 0x801, swap_dev 0x4, Normal VGA
/boot/vmlinuz-3.0.0-15-generic: Linux kernel x86 boot executable bzImage, version 3.0.0-15-generic (buildd@creste, RO-rootFS, root_dev 0x801, swap_dev 0x4, Normal VGA
Now here's the real kicker:
me@GAMMA:~$ sudo find / -name "vmlinuz*"
/boot/vmlinuz-3.0.0-12-generic
/boot/vmlinuz-3.0.0-15-generic
/vmlinuz.old
/vmlinuz
/ubuntu32/vmlinuz.old
/ubuntu32/vmlinuz
That's the only kernel on my system! How is that even possible? I'm running 64-bit right now (/dev/sda3 is / and uname reports 64-bit)!
I checked the package contents on packages.ubuntu.com and the am64 version of linux-image-3.0.0.15-generic lists /boot/vmlinuz-3.0.0-15-generic as a file, so I ran the following:
me@GAMMA:~$ sudo openssl dgst -md5 /boot/vmlinuz-3.0.0-15-generic > ~/3.0.0.15x86
me@GAMMA:~$ sudo apt-get install --reinstall linux-image-3.0.0-15-generic
(Output Omitted)
me@GAMMA:~$ sudo openssl dgst -md5 /boot/vmlinuz-3.0.0-15-generic
MD5(/boot/vmlinuz-3.0.0-15-generic)= f56839a4642eb97e06e5efb0bc74f4dc
me@GAMMA:~$ cat ~/3.0.0.15x86
MD5(/boot/vmlinuz-3.0.0-15-generic)= f56839a4642eb97e06e5efb0bc74f4dc
me@GAMMA:~$ sudo openssl dgst -md5 /boot/vmlinuz-3.0.0-15-generic > ~/3.0.0.15x86
So the Linux kernel acts very much like the Mach Kernel in OS X in that it is a 32-bit executable that switch to 64-bit mode when needed. The question then is why am I getting an error about "Exec format error"?
This Post however seems to indicate that the runaway loop modprobe from the Kernel Panic indicates that this is indeed a 32/64 bit issue. Grub must have some way of telling the kernel the bitlength, maybe it is in an associated file in /boot, looking into that tomorrow.
quick update:
The 32-bit and 64-bit kernels hash differently, but file reports them both to be x86.
< MD5(/boot/vmlinuz-3.0.0-15-generic)= f56839a4642eb97e06e5efb0bc74f4dc
---
> MD5(/boot/vmlinuz-3.0.0-15-generic)= cee6cd7db9016ee8531be92504ac802b
So I need to determine how to install the kernel to somewhere other than /boot so that the two kernels don't clobber each other...