Renaming the root volume group

Submitted by olaf on 2014-05-05
Last modified at 2014-05-17

A few days ago, I installed Ubuntu 14.04 on my laptop.

Usually, I use several partitions to separate /boot, /, /usr, /var, /tmp and /home. I do this with LVM2, so I can adjust the partition sizes later on, if necessary.

After the installation, I wanted to rename the volume group from the default ubuntu-vg to a plain vg0. Here is how I did this.

First, I booted into recovery mode and started a root shell. The root partition was mounted readonly. To modify anything, I had to remount it read-write

mount -o remount,rw /

Now, I can already rename the volume group with

vgrename ubuntu-vg vg0

With this rename alone, the system is unbootable, because Grub and the initial mount still search for the previous default name ubuntu-vg. To fix this, I needed to adjust the fstab entries

mv /etc/fstab /etc/fstab.orig
sed -e 's/ubuntu--vg/vg0/' /etc/fstab.orig >/etc/fstab

and the Grub config file

mount -o rw /boot
mv /boot/grub/grub.cfg /boot/grub/grub.cfg.orig
sed -e 's/ubuntu--vg/vg0/' /boot/grub/grub.cfg.orig >/boot/grub/grub.cfg

If you don’t have a separate /boot partition, you can omit the mount, of course.

This is all to rename the root volume group. I like to remount the partitions readonly first

mount -o remount,ro /boot
mount -o remount,ro /

Now you can reboot the system.

Post a comment

All comments are held for moderation; Markdown and basic HTML formatting accepted. If you want to stay anonymous, leave name, e-mail and website empty.