Foreword

I have another article on setting up Proxmox and ZFS. Please see it for an introduction.

There is currently a bug (in my opinion) where Proxmox always installs GRUB on the MBR of the first active disk. In my case it was the SSD which I in turn, had made the l2ARC for my ZFS pool (which happened to destroy the boot loader).

Reinstall Grub

Boot into a Linux distribution that is 64 bit (We need the same architecture as Proxmox so we can chroot into it)

Proxmox sets up two Primary partitions, one primary partition with an ext filesystem for /boot and the other, an LVM primary partition on the install medium.

First We need to activate LVM and mount the the root partition that is inside the LVM container.

sudo vgscan
sudo vgchange -ay

Now create some mount points that are applicable for you (it could be off /mnt or /media in your distro or wherever you would like) and mount all file-systems (virtual too).

Note

The LVM device nodes will be located under /dev/pve.

Please check the location of the device you want to restore grub onto and mount /boot from. In my case it is /dev/sdc which is a spare USB flash disk. You can also reference it via /dev/disk/by-id or /dev/disk/by-uuid.

	sudo mkdir /media/USB
	sudo mount /dev/pve/root /media/USB/
	sudo mount /dev/sdc1 /media/USB/boot
	sudo mount -t proc proc /media/USB/proc
	sudo mount -t sysfs sys /media/USB/sys
	sudo mount -o bind /dev /media/USB/dev
	sudo mount -t devpts pts /media/USB/pts/

Now its time to chroot into the system

	chroot /media/USB

Finally, re-install Grub

/sbin/grub-setup /dev/sdc

You should receive no error messages. Now it’s time to reboot that flash disk and you are back in business 🙂

Re-install GRUB on Proxmox
  • Wilson Wong

    Great article – certainly helpful to me. But there are more puzzle pieces along my way.
    (chroot) # /usr/sbin/grub-setup /dev/sdX didn’t work
    instead I plucked from proxmox status screen
    (chroot) # /usr/sbin/grub-install –no-floppy ‘(hd0)’ worked with no error
    (chroot) # /usr/sbin/grub-setup also no error
    there might need another step of grub-update which I had not done yet, anyway, my proxmox usb drive failed to boot up completely. Instead it stopped at the grub command prompt

  • Wilson Wong

    I finally got it! Here are my steps:

    plug usb drive to ubuntu 64bit
    usb drive register on ubuntu as /dev/sdd

    $ sudo vgscan
    $ sudo vgchange -ay
    $ sudo mkdir /media/USB
    $ sudo mount /dev/pve/root /media/USB/
    $ sudo mount /dev/sdc1 /media/USB/boot
    $ sudo mount -t proc proc /media/USB/proc
    $ sudo mount -t sysfs sys /media/USB/sys
    $ sudo mount -o bind /dev /media/USB/dev
    $ sudo mount -t devpts pts /media/USB/pts/
    $ sudo chroot /media/USB
    (chroot) # /usr/sbin/grub-install –no-floppy ‘(hd0)’
    (chroot) # /usr/sgin/grub /dev/sdX
    (chroot) # /usr/sbin/grub-update no such command available
    (chroot) # exit
    $ sudo umount /media/USB/*
    $ sudo umount /media/USB
    $ sudo vgchange -an
    $

    in virtualbox
    (grub) > set root='(hd0,gpt2)’
    (grub) > linux /vmlinuz-2.6.32-29-pve root=/dev/mapper/pve-root ro
    (grub) > initrd /initrd.img-2.6.32-29-pve
    (grub) > boot

  • Brad McCormack

    Awesome WILSON WONG! I’m glad you figured it out. I’m happy I can be of assistance. Let me know if you need any help 🙂