1

I've tried to shrink the root partition of a KVM guest. I managed to shrink it without data loss (as far as we consider only the data inside it, that is), but now the system does not boot anymore. It's a Debian system, root partition is /dev/mapper/vg0-root (LVM). If I boot SystemRescueCD I can mount it and I can access all the contents.

In order to shrink it, I did the following while booted in a live SystemRescueCD:

  1. e2fsck -f /dev/mapper/vg0-root
  2. resize2fs /dev/mapper/vg0-root 25G
  3. lvreduce -r --size 30G /dev/mapper/vg0-root
  4. pvresize --setphysicalvolumesize 30G /dev/vda1
  5. gdisk /dev/vda

Please note I'm writing those steps by memory, maybe that is not the exact syntax I used, but it gives a clue of what I've done.

In gdisk I wanted to shrink the partition, and I did so by removing the existing partition and creating a new one with same starting sector (2048), same type (8E00 Linux LVM), but smaller size (30G instead of 200G). gdisk was suggesting as starting sector 34 instead of 2048, but I didn't want to move the partition, so I entered 2048 manually.

Then I rebooted the system, but grub hung. Back in SystemRescueCD, I mounted the LVM root partition under /mnt/custom and tried to reinstall GRUB:

  1. mount /dev/mapper/vg0-root /mnt/custom
  2. cd /mnt/custom
  3. mount -o bind /dev dev
  4. mount -o bind /proc proc
  5. mount -o bind /sys sys
  6. chroot . /bin/bash
  7. grub-install /dev/vda

Here the result is:

Installing for i386-pc platform
 Warning: not using lvmetad with older version.
 Warning: not using lvmetad with older version.
 Warning: not using lvmetad with older version.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: error: embedding is not possible, but this is required for RAID and LVM install.

Now I suspect that using gdisk instead of fdisk above, it implicitly converted the partition table from MBR to GPT, I'm not sure but now I see a GPT partition table even with fdisk, so it's very likely IMHO.

Is there a way to make it MBR again? Or, is there tutorial to upgrade a Debian system from grub-pc to grub-efi manually, from a live CD system and a chroot?

0

1 Answer 1

0

Easier than I thought, here is the solution to convert GPT back to MBR.

In short, run gdisk /dev/vda, use r, then g. It worked.

1
  • However I'm courious to know if there is a way to ugrade to GPT using a live CD and a chroot environment, so if anyone wants to chime in with that kind of solution, I could accept that answer instead of mine, thanks Commented May 5, 2019 at 11:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .