I run Ubuntu 14.04 and always update regularly (nearly every day). Today on July 8, the Ubuntu update behaved differently than usual. It said "Not all updates can be installed" and suggested a "Partial update". Never tried that, but I trust Ubuntu. One of the things I noticed on the update list was the bootloader GRUB, but hey, I trust Ubuntu.

After completion it asked me to restart and when I do this it boots directly into Windows. That is, GRUB is effectively uninstalled and I have no choice of whether I want to boot into Ubuntu now. I am not a shark in either Linux or Windows, but I feel quite the more handicapped in Windows 8 (it just came bundled).

Is Ubuntu still present on the laptop? If yes, how do I get back to it soonest possible? (I've got a presentation to give in the weekend and setting up a new system and fetching backup data is slow).

Failing to grub-install following answer of Christian Benke

I am now probing the system with a ubuntu usb stick.

ubuntu@ubuntu:~$ sudo parted -l
Model: ATA TOSHIBA THNSNJ25 (scsi)
Disk /dev/sda: 256GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system     Name                  Flags
 1      1049kB  1075MB  1074MB  ntfs            Basic data partition  hidden, diag
 2      1075MB  1180MB  105MB   fat32           Basic data partition  boot
 3      1180MB  1314MB  134MB   ntfs            Basic data partition  msftres
 4      1314MB  44.7GB  43.4GB  ntfs            Basic data partition  msftdata
 6      44.7GB  46.7GB  2000MB  linux-swap(v1)
 7      46.7GB  244GB   197GB   ext4
 5      244GB   256GB   12.1GB  ntfs            Basic data partition  hidden, diag

A quick "sudo mkdir /media/[mountpoint]" followed by "sudo mount /dev/sda[X] /media/[mountpoint]" allowed inspection of the partitions:

/dev/sda1  Windows boot files
/dev/sda2  EFI files
/dev/sda3  Empty
/dev/sda4  Windows system
/dev/sda5  Toshiba recovery
/dev/sda6  Ubuntu swap partition (not mountable)
/dev/sda7  Ubuntu system

Obviously, /dev/sda7 is what I want to continue with.

ubuntu@ubuntu:~$ sudo mkdir /media/oldroot
ubuntu@ubuntu:~$ sudo mount /dev/sda7 /media/oldroot
ubuntu@ubuntu:~$ sudo mount --bind /dev /media/oldroot/dev
ubuntu@ubuntu:~$ sudo mount --bind /proc /media/oldroot/proc
ubuntu@ubuntu:~$ sudo mount --bind /sys /media/oldroot/sys
ubuntu@ubuntu:~$ sudo chroot /media/oldroot /bin/sh 
# lsb_release -d
Description:    Ubuntu 14.04.2 LTS
# grub-install /dev/sda
Installing for x86_64-efi platform.
grub-install: error: cannot find EFI directory.
# exit

Clearly, grub-install did not find the EFI files at /dev/sda2, but mounting it beforehand at /media/oldroot/boot/efi seemed to work just fine:

ubuntu@ubuntu:~$ sudo mount /dev/sda2 /media/oldroot/boot/efi
ubuntu@ubuntu:~$ sudo chroot /media/oldroot /bin/sh 
# lsb_release -d
Description:    Ubuntu 14.04.2 LTS
# grub-install /dev/sda
Installing for x86_64-efi platform.
Installation finished. No error reported.
# update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.16.0-43-generic
Found initrd image: /boot/initrd.img-3.16.0-43-generic
Found linux image: /boot/vmlinuz-3.16.0-41-generic
Found initrd image: /boot/initrd.img-3.16.0-41-generic
Found linux image: /boot/vmlinuz-3.16.0-40-generic
Found initrd image: /boot/initrd.img-3.16.0-40-generic
Found linux image: /boot/vmlinuz-3.16.0-39-generic
Found initrd image: /boot/initrd.img-3.16.0-39-generic
Found linux image: /boot/vmlinuz-3.16.0-38-generic
Found initrd image: /boot/initrd.img-3.16.0-38-generic
Found linux image: /boot/vmlinuz-3.16.0-37-generic
Found initrd image: /boot/initrd.img-3.16.0-37-generic
Found linux image: /boot/vmlinuz-3.16.0-36-generic
Found initrd image: /boot/initrd.img-3.16.0-36-generic
Found linux image: /boot/vmlinuz-3.16.0-34-generic
Found initrd image: /boot/initrd.img-3.16.0-34-generic
Found linux image: /boot/vmlinuz-3.16.0-33-generic
Found initrd image: /boot/initrd.img-3.16.0-33-generic
Adding boot menu entry for EFI firmware configuration
# exit    

This did not solved the problem, however. Upon reboot, GRUB did not show up and it went directly into Windows again? Thank you so far, what seems to be the problem this time?

Failing to reinstall affected packages

As suggested, I look at the apt/history.log file to see what happened during the "partial update" which stopped GRUB from working. Unfortunately, it contains no entry for the update on July 8:

ubuntu@ubuntu:~$ cat /media/summer7/var/log/apt/history.log

Start-Date: 2015-07-03  09:32:40
Commandline: aptdaemon role='role-commit-packages' sender=':1.79'
Upgrade: lightdm:amd64 (1.10.5-0ubuntu1, 1.10.5-0ubuntu1.1), liblightdm-gobject-1-0:amd64 (1.10.5-0ubuntu1, 1.10.5-0ubuntu1.1)
End-Date: 2015-07-03  09:32:42

Start-Date: 2015-07-05  20:02:01
Commandline: aptdaemon role='role-commit-packages' sender=':1.85'
Upgrade: libxcomp3:amd64 (,, nxproxy:amd64 (,, irqbalance:amd64 (1.0.6-2ubuntu0.14.04.1, 1.0.6-2ubuntu0.14.04.2)
End-Date: 2015-07-05  20:02:04

Start-Date: 2015-07-07  20:00:24
Commandline: aptdaemon role='role-commit-packages' sender=':1.81'
Install: linux-image-3.16.0-43-generic:amd64 (3.16.0-43.58~14.04.1), linux-headers-3.16.0-43:amd64 (3.16.0-43.58~14.04.1), linux-headers-3.16.0-43-generic:amd64 (3.16.0-43.58~14.04.1), linux-image-extra-3.16.0-43-generic:amd64 (3.16.0-43.58~14.04.1), linux-signed-image-3.16.0-43-generic:amd64 (3.16.0-43.58~14.04.1)
Upgrade: linux-signed-image-generic-lts-utopic:amd64 (,, libfontembed1:amd64 (1.0.52-0ubuntu1.4, 1.0.52-0ubuntu1.5), linux-image-generic-lts-utopic:amd64 (,, cups-browsed:amd64 (1.0.52-0ubuntu1.4, 1.0.52-0ubuntu1.5), linux-signed-generic-lts-utopic:amd64 (,, cups-filters-core-drivers:amd64 (1.0.52-0ubuntu1.4, 1.0.52-0ubuntu1.5), cups-filters:amd64 (1.0.52-0ubuntu1.4, 1.0.52-0ubuntu1.5), libgtksourceview2.0-0:amd64 (2.10.5-1ubuntu2, 2.10.5-1ubuntu2.14.04.1), linux-generic-lts-utopic:amd64 (,, linux-libc-dev:amd64 (3.13.0-55.94, 3.13.0-57.95), libgtksourceview2.0-common:amd64 (2.10.5-1ubuntu2, 2.10.5-1ubuntu2.14.04.1), linux-headers-generic-lts-utopic:amd64 (,, libcupsfilters1:amd64 (1.0.52-0ubuntu1.4, 1.0.52-0ubuntu1.5)
End-Date: 2015-07-07  20:01:11

In fact, it seems a bit small in length doesn't it? Also, the last entry was 2 hours into the future compared to when the file was touched last:

ubuntu@ubuntu:~$ ls -l /media/summer7/var/log/apt/history.log
-rw-r--r-- 1 root root 1925 Jul  7 18:01 /media/summer7/var/log/apt/history.log

So maybe we are looking at a file corruption here? Oh well, I tried an apt-get update and it did not work:

ubuntu@ubuntu:~$ sudo mount --bind /dev /media/oldroot/dev
ubuntu@ubuntu:~$ sudo mount --bind /proc /media/oldroot/proc
ubuntu@ubuntu:~$ sudo mount --bind /sys /media/oldroot/sys
ubuntu@ubuntu:~$ sudo chroot /media/oldroot apt-get update

Everything failed to fetch with "could not resolve" error, much like this question. The following fails

ubuntu@ubuntu:~$ sudo chroot /media/oldroot ping dk.archive.ubuntu.com
ping: unknown host dk.archive.ubuntu.com

and the /media/oldroot/etc/resolv.conf file is completely empty. Is this a bad sign?

  • "but I cannot mount sda1" - You forget to tell it the destination of the mount, try: "sudo mount /dev/sda1 /media/<mountpoint>" – Christian Benke Jul 8 '15 at 8:28
  • Thank you, with a 'sudo mkdir /media/<mountpoint>' before, the mount command now works. I will try to look into the other partitions. – user2646234 Jul 8 '15 at 8:36
  • Try to mount the EFI-partition in /media/oldroot/boot/efi, similar to here: askubuntu.com/questions/53578/… – Christian Benke Jul 8 '15 at 9:09
  • Can you check /var/log/apt/history.log to see what grub-package exactly has been uninstalled/broken and see if you can install the deb-packages manually from packages.ubuntu.com/trusty? – Christian Benke Jul 8 '15 at 9:48

I had this same problem happen to me on the same day that you did. I was working on some things, ubuntu suggested a partial update, I complied, and then spent most of yesterday trying to reinstall grub (to no avail).

My install was a dual boot with windows 8.1, so aside from the windows partitions I had three linux partitions: one for the system ("/"), one for home ("/home") and one for swap. I was unable to reinstall grub using boot-repair, so I booted using an ubuntu thumb-drive, and launched the installer.

When it asked me what I wanted to do, I selected something else. I then set my original system directory "/" as the root partition and told the installer to format it, I set swap as swap, and my home directory as "/home", but I told the installer to not format the home directory.

I also told the installer to install the bootloader on the disk (/dev/sda in my case) not a partition. The install completed, on reboot grub appeared and I was able to reboot into ubuntu and windows 8.1.

My home directory was completely intact, my desktop background and .bashrc loaded automatically, and once I started reinstalling programs I was automatically logged back into teamviewer, chrome, etc.

If you have separate /home and system partitions, this may be the best fix. No data loss, and the reinstall doesn't take too long.

  • I did not have a separate /home partition, unfortunately, and the installer on my ubuntu-usb did not offer the option to keep data (cdn5.howtogeek.com/wp-content/uploads/2014/09/…) even though it did recognize "Ubuntu 14.04 LTS with windows boot loader" as currently installed. So I wiped it all and have spent all day installing and setting up applications and fetching online backup. Thanks for your answer. – user2646234 Jul 9 '15 at 17:05
  • Sorry there wasn't a good solution on this one. It was a very odd bug. I think it may have been caused (in my case) because my computer wanted to do a restart to install updates, but before it did I attempted to install some proprietary nvidia drivers. Making a big system change like that when it already needed a reboot may have killed it. – Gregory Butron Aug 4 '15 at 0:43

You can use a small bootable live-system like Grml and the command chroot to get back into your old system to fix the broken bootloader.

After you have booted from the live-cd, you want to get access to the filesystem of your installed Linux-system. So first thing you do is to mount the root-partition of the installed Linux (As root-user in your live-cd-environment):

# mkdir /media/oldroot
# mount /dev/sda1 /media/oldroot

If you are not sure which one your Linux-partition is, mount all of the available partitions and check which one is your root-partition.

The next step to get a functional chroot-environment is to mount the pseudo-filesystems (/dev, /proc, /sys) from your live-cd-environment inside of the root-partition we just mounted:

# mount --bind /dev /media/oldroot/dev
# mount --bind /proc /media/oldroot/proc
# mount --bind /sys /media/oldroot/sys

Now our system is ready to be chrooted, which means you "replace" the environment of your live-cd by the installed system (We also tell it to use /bin/sh as the command-prompt in the installed environment:

# chroot /media/oldroot /bin/sh

Verify you are in your old installed Linux:

# lsb_release -d
Description:    Ubuntu 14.04.2 LTS

From the chroot try to run

# grub-install /dev/sda

to reinstall the grub-bootloader in the Master boot record of your harddisk.

If grub2 really has been uninstalled and grub-install does not exist, you can reinstall it by copying the grub2-package to an usb-stick:

Download the deb-file from http://packages.ubuntu.com/trusty/grub2 and copy it to an usb-stick. Mount the usb-stick inside of your chroot (Use Alt-F2 to get a second tty on the live-cd environment to mount the USB-stick, switch back to the chroot-environment with Alt-F1 afterwards):

-- Press <Alt-F2> to get to the second tty of the live-cd-env
# mkdir /media/oldroot/media/<yourusername>/usb_stick
# mount /dev/sdb1 /media/oldroot/media/<youruser>/usb_stick

-- Press <Alt-F1> to get back to the first tty to our chroot
# cd /media/<yourusername>/usb_stick
# ls
dpkg -i grub2_2.02~beta2-9_amd64.de
# dpkg -i grub2_2.02~beta2-9_amd64.deb

After that, continue with grub-install.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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