35

I have booted from a live USB ("Try Ubuntu"), that also has a persistent option set (I used LiLi to create one) to do some tests for this pcie hotplug issue I'm having.

I'm trying to test some boot paramaters (like in this question) by doing this

sudo nano /etc/default/grub
sudo update-grub

The problem is that that last command gives me this:

/usr/sbin/grub-probe: error: failed to get canonical path of /cow.

It looks like /cow is the file-system that is mounted on /, according to:

:~# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/cow             4056896 2840204   1007284  74% /
udev             1525912       4   1525908   1% /dev
tmpfs             613768     844    612924   1% /run
....

Is there a way for me to run update-grub?

Nanne
  • 8,625

2 Answers2

49

You'll need to do a bit of remounting and remapping.

After booting the liveCD, we'll mount the Ubuntu partition to /mnt with:

sudo mount /dev/sd*# /mnt

where /dev/sd*# is updated to your Ubuntu partition.

If you have a separate /boot partition, we'll need to mount it in /mnt/boot as well:

sudo mount /dev/sd*# /mnt/boot

where /dev/sd*# is updated to your /boot partition.

This should mount it with enough access to get the canonical path if needed, but we'll likely not need this.

To finish up, just update grub with the correct root and target:

sudo grub-install --root-directory=/mnt /dev/sdX

where /dev/sdX is the disk(not the partition) where we want GRUB.

nanofarad
  • 20,717
  • I'm not sure I follow you. What do you mean by "the Ubuntu partition" ? I'm not trying to change the boot parameters of the persistent USB drive, not of some other install? – Nanne Aug 15 '13 at 17:56
  • @Nanne The partition mounted at / of the installation in which you wish to configure GRUB. – nanofarad Aug 15 '13 at 17:57
  • I am booting from a usb-key. I want to reboot with that same key, but then with different parameters. There is only 1 installation, the one on the usb key. So the partition mounted at / of the installation I want to configure is 'currently' mounted at / – Nanne Aug 15 '13 at 17:59
  • Yes, as long as this is a full installation on said key. – nanofarad Aug 15 '13 at 18:01
  • hmm, sounds good, recursive mounting :) .. I'll give it a shot ;) – Nanne Aug 15 '13 at 18:03
  • 4
    Tried this, and got "Attempting to install GRUB to a partition disk or to a partition. This is a BAD idea. Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged.". Tried --force which made it install, but it destroyed grub and left the USB stick unbootable. That was with 14.04. Any other ideas? – DanielSmedegaardBuus Apr 30 '14 at 11:41
  • This doesn't seem to work if the sd*# is a software RAID array. – Cerin Apr 15 '15 at 01:55
  • 1
  • @zenith that's because your disk is partitioned using GPT. I don't have a system with it so I'm not particularly familiar with its operation and how a bootloader works on it. – nanofarad Aug 23 '15 at 22:01
  • You save my life man! where /dev/sdX is the disk(not the partition)!!! – WesternGun Sep 09 '16 at 06:55
0

For me, I just needed to install grub.

sudo apt-get update;
sudo apt-get install grub