I have a machine that used to dual-boot Ubuntu (16.04 currently) and Windows 7, with Ubuntu's GRUB as boot loader.
Now I just added Arch Linux as third OS, following the official installation instructions. I did not install GRUB from Arch because I wanted to use the one controlled by Ubuntu. The instructions contained a command mkinitcpio -p linux
that probably generated some boot files which I ran as described.
Now when I try to boot Ubuntu from GRUB through its default entry, I get this unpleasant error (sorry for the screen photo):
As the output of uname -a
shows, it's trying to boot the Arch kernel, but /dev/sda6
is the Ubuntu root partition.
I have to navigate to Advanced options for Ubuntu
and select one of the Ubuntu, with Linux 4.4.0-*
entries to be able to load Ubuntu, I couldn't find an entry that would correctly load Arch though.
Running sudo update-grub
from Ubuntu ("update-grub
is a stub for running grub-mkconfig -o /boot/grub/grub.cfg
to generate a grub2 config file.") does not change anything. The grub-customizer
tool was also useless in fixing this so far.
What causes this confusion of GRUB and how do I fix it so that each Linux version boots with the correct kernel and from the correct partition?
It looks like I stupidly installed Arch with Ubuntu's /boot mounted, so it probably placed its boot files in there.
I'm fine with erasing all the Arch related stuff to get Ubuntu's boot loader straight again and do a clean install of Arch later.
Updates (thanks to @terdon for his support in the Ask Ubuntu chat):
Here is my /boot/grub/grub.cfg
.
All Linux entries seem to point at my /dev/sda6 partition, which is Ubuntu's root:
$ grep ' linux /' /boot/grub/grub.cfg
linux /vmlinuz-linux root=UUID=eee18451-b607-4875-8a88-c9cb6c6544c8 ro
linux /vmlinuz-linux root=UUID=eee18451-b607-4875-8a88-c9cb6c6544c8 ro
linux /vmlinuz-linux root=UUID=eee18451-b607-4875-8a88-c9cb6c6544c8 ro
linux /vmlinuz-linux root=UUID=eee18451-b607-4875-8a88-c9cb6c6544c8 ro init=/sbin/upstart
linux /vmlinuz-linux root=UUID=eee18451-b607-4875-8a88-c9cb6c6544c8 ro recovery nomodeset
linux /vmlinuz-4.4.0-21-generic root=UUID=eee18451-b607-4875-8a88-c9cb6c6544c8 ro
linux /vmlinuz-4.4.0-21-generic root=UUID=eee18451-b607-4875-8a88-c9cb6c6544c8 ro init=/sbin/upstart
linux /vmlinuz-4.4.0-21-generic root=UUID=eee18451-b607-4875-8a88-c9cb6c6544c8 ro recovery nomodeset
linux /vmlinuz-4.2.0-35-generic root=UUID=eee18451-b607-4875-8a88-c9cb6c6544c8 ro
linux /vmlinuz-4.2.0-35-generic root=UUID=eee18451-b607-4875-8a88-c9cb6c6544c8 ro init=/sbin/upstart
linux /vmlinuz-4.2.0-35-generic root=UUID=eee18451-b607-4875-8a88-c9cb6c6544c8 ro recovery nomodeset
I tried to update GRUB config from Ubuntu:
$ sudo grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
dpkg: warning: version 'linux' has bad syntax: version number does not start with a digit
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found linux image: /boot/vmlinuz-4.4.0-21-generic
Found initrd image: /boot/initrd.img-4.4.0-21-generic
Found linux image: /boot/vmlinuz-4.2.0-35-generic
Found initrd image: /boot/initrd.img-4.2.0-35-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
Found Arch on /dev/sda8
done
I tried to reinstall GRUB to the MBR from Ubuntu:
$ sudo grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
$ sudo grub-install --recheck /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
Those are the installed Ubuntu kernel packages by the way, I did try to dpkg-reconfigure
all of them, but without any effect on the issue:
$ dpkg -l linux-image* | grep ^ii
ii linux-image-4.2.0-35-generic 4.2.0-35.40 amd64 Linux kernel image for version 4.2.0 on 64 bit x86 SMP
ii linux-image-4.4.0-21-generic 4.4.0-21.37 amd64 Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii linux-image-extra-4.2.0-35-generic 4.2.0-35.40 amd64 Linux kernel extra modules for version 4.2.0 on 64 bit x86 SMP
ii linux-image-extra-4.4.0-21-generic 4.4.0-21.37 amd64 Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
I also tried to regenerate the Ubuntu initramfs:
$ sudo update-initramfs -u -k all
update-initramfs: Generating /boot/initrd.img-4.4.0-21-generic
update-initramfs: Generating /boot/initrd.img-4.2.0-35-generic
My partition layout:
Checked from the Ubuntu system. The labels should explain themselves.
$ lsblk -f /dev/sda
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 ntfs win7-boot 90DCF3A5DCF3842E /win/boot
├─sda2 ntfs windows7 482C7A572C7A3FCC /win/c
├─sda3 ext4 grub-boot 6dbb8633-dadd-4b5e-8d85-b0895fde9dfb /boot
├─sda5 ext4 images 81dc42c4-a161-4ccd-b704-6e5c09298943 /images
├─sda6 ext4 ubuntu-1604 eee18451-b607-4875-8a88-c9cb6c6544c8 /
├─sda7 ext4 ubuntu-home 485b3ef1-7216-4053-b25c-f656d529e8e6 /home
├─sda8 ext4 arch-root 8d281a0c-969c-44cf-ba6a-1d3c7b4be7ec
├─sda9 ext4 arch-home 32522902-a53d-44c8-90f2-6bbf14c40f1f
└─sda10 swap linux-swap 8b05bd9b-bc42-46f6-8c18-50711a3c48b9 [SWAP]
My GRUB menu structure:
My /boot
directory:
$ ls -la /boot
total 118480
drwxr-xr-x 4 root root 4096 Apr 24 20:50 .
drwxr-xr-x 28 root root 4096 Apr 24 19:44 ..
-rw-r--r-- 1 root root 1313029 Mär 16 01:45 abi-4.2.0-35-generic
-rw-r--r-- 1 root root 1239577 Apr 19 00:21 abi-4.4.0-21-generic
-rw-r--r-- 1 root root 184888 Mär 16 01:45 config-4.2.0-35-generic
-rw-r--r-- 1 root root 189412 Apr 19 00:21 config-4.4.0-21-generic
drwxr-xr-x 6 root root 4096 Apr 26 19:58 grub
-rw-r--r-- 1 root root 18598360 Apr 24 20:59 initramfs-linux-fallback.img
-rw-r--r-- 1 root root 3516429 Apr 24 20:59 initramfs-linux.img
-rw-r--r-- 1 root root 33642388 Apr 24 18:31 initrd.img-4.2.0-35-generic
-rw-r--r-- 1 root root 36143341 Apr 24 19:51 initrd.img-4.4.0-21-generic
drwx------ 2 root root 16384 Okt 28 17:43 lost+found
-rw-r--r-- 1 root root 182704 Jan 28 13:44 memtest86+.bin
-rw-r--r-- 1 root root 184380 Jan 28 13:44 memtest86+.elf
-rw-r--r-- 1 root root 184840 Jan 28 13:44 memtest86+_multiboot.bin
-rw------- 1 root root 3745312 Mär 16 01:45 System.map-4.2.0-35-generic
-rw------- 1 root root 3853719 Apr 19 00:21 System.map-4.4.0-21-generic
-rw------- 1 root root 6829104 Mär 16 01:45 vmlinuz-4.2.0-35-generic
-rw------- 1 root root 7013968 Apr 19 00:21 vmlinuz-4.4.0-21-generic
-rw-r--r-- 1 root root 4435552 Apr 14 19:20 vmlinuz-linux
The 4.4.0 and 4.2.0 kernels should be Ubuntu, Arch should have a 4.5.0 kernel. But how do I find out which file without kernel version in its name belongs to what?
My Ubuntu root directory (directories excluded):
$ ls -la / | grep ^[^d]
total 124
lrwxrwxrwx 1 root root 32 Apr 24 19:44 initrd.img -> boot/initrd.img-4.4.0-21-generic
lrwxrwxrwx 1 root root 32 Apr 5 17:45 initrd.img.old -> boot/initrd.img-4.2.0-35-generic
lrwxrwxrwx 1 root root 29 Apr 24 19:44 vmlinuz -> boot/vmlinuz-4.4.0-21-generic
lrwxrwxrwx 1 root root 29 Apr 5 17:45 vmlinuz.old -> boot/vmlinuz-4.2.0-35-generic
My Arch root directory does not contain any files or links.
os-prober
. then run thesesudo mkinitcpio -p linux
thensudo grub-mkconfig -o /boot/grub/grub.cfg
lastlysudo grub-install /dev/sda
Root device mounted successfully, but /sbin/init does not exists
. Did you investigate this? Isinit
really missing? If so, you should definitely install it, if instead it is present, any idea why it cannot be found?