Online resizing of lvm partition for libvirtd guests

This use case just reappeared the third time and I had to lookup the commands again. So I am documenting them here, to easier find them the next time.

Assume the follwoing:

  • we have a guest VM running in libvirtd called guest01
  • besides its root device it has a data partition backed in an LVM
  • the volume group is called vg01 and the logical volume data01
  • we want to grow the data partition to 100G
  • the resizing should be done online, so without a downtime of the VM

First we need to resize the logical volume:

lvresize -L 100G /dev/vg01/data01

Next we need to find out the path name of this device in the libvirt VM. The list of all devices can be printed with:

virsh domblklist guest01

Take the path value and use it in the next command (I will use vdX here). The blockresize command will inform libvirtd about the new size of the LVM volume.

virsh blockrezise guest01 --path vdX --size 100

Now the logical volume is bigger and libvirtd propagated the change into the VM. So you can see the new partition size inside the VM. But the file system was not changed yet.

The last step, resizing the file system, has to be done inside the VM:

resize2fs /dev/vdX   # for ext[2,3,4]
xfs_growfs /dev/vdX  # for xfs

openSUSE 12.2 with GRUB2 with entire root partition in LVM

It took me a long evening to figure it out how to do it, but it is possible to install an openSUSE 12.2 with GRUB2 on a disk with GTP partition table and have the entire root partition within LVM (and in my case even have the LVM in a MD RAID). The current openSUSE installer (partitioning and bootloader) does not fully support this use case, but they will however install it correctly even though the warning messages shown might be misleading.

These are my partitions (adapt them to your use case):

  • sda (GPT partition table: gpt_sync_mbr)
    1. 7.84 MB primary, flags: bios_grub (do not format or mount)
    2. 8 GB primary, flags: raid (raid1, md0), swap
    3. ? GB primary, flags: raid (raid1, md1), LVM
  • sdb (same as sda)
    • Note: the first partition of both disks is not part of any raid. The sda1 partition has to be synced manually once after installation to its pendant on sdb.

The first partition has to be unformatted and unmounted and have the flag bios_grub set. This can be done with parted by running (for both disks):

(parted) toggle 1 bios_grub on
(parted) select /dev/sdb
(parted) toggle 1 bios_grub on

This will allow GRUB2 to find space to install its core.img to.

There is more than one way to do this kind of installation. But with YaST you can not (yet) create set the bios_grub flag during installation. Here are two ways which should work pretty nicely (I took the latter):

  1. Prepare the partition setup before booting the installation media. Make sure to have all partitions setup correctly (including the flags you need). There is no need to create the RAID and LVM beforehand – of course you could, but this is something where YaST has a pretty nice and intuitive graphical UI for. During the installation also make sure that YaST uses the existing partition setup. The default is to propose an own partition setup.
  2. Start the installation with the plain and empty disks. Do the partitioning via YaST (make sure to use a GTP partition table; see the export button within the YaST partitioner). Let the system do the installation and ignore the warnings that are shown. While the installation process is installing the packages do this:
    1. Press Ctrl+Alt+Shift+X to open an xterm
    2. In the xterm run parted and set the flags for the first partitions of each disk
    3. If you finish this before YaST installs the bootloader everything work smoothly
      If you do not manage to do this before the YaST installs the bootloader it will popup an error message with warnings that your setup is totally unsupported and will not be able to boot. Just ignore the warning, but to not yet press the OK button. Continue to toggle the flags in the xterm and close parted. When done, press the OK button of the warning message and YaST will try again to install the bootloader and now will succeed without any error message.

The bootloader will only be installed on /dev/sda by default. So after the first boot sync the content of the first partition of sda to the first one on sdb (e.g. using dd).

openSUSE 11.2

openSUSE 11.2 is now available

OpenSUSE_11.2_468x60Are you new to linux and want to learn about it or have never used it before? Then now its your turn to download openSUSE 11.2 and give it a try. Besides the installation DVD images you can also download LiveCD images to run linux on your computer without installation – the harddisk will not be touched. Find more information in the openSUSE wiki about whats new in this release.

/dev/fd0

I still don’t believe what I did last night :)

On Friday I’m going to upgrade a friend’s computer and install two new hard disks. In order to save some time I wanted to preinstall the operating system (the one of my companies’ cooperation partner). Up to then it was a good idea. But then I connected one new disk to my computer and booted the XP Home installation CD. No hard disks installed was the short message after the installer probed the system. I realized that this CD must be so old that it had no SATA drivers – or at least not for my mainboard.

I searched for the driver CD of my mainboard and – thinking like a developer who wants to be nice to the users – booted again, pressed F6 when prompted to include 3rd party drivers, inserted the driver CD and found that the only way to hand new drivers to an XP installation was via floppy.

But I have no floppy drive in this machine. Nor has my PC in the living room, nor has my Laptop. A month ago I cleaned up my cellar and got rid of my last PC with a floppy drive – a Pentium 133 machine that I got in 2001, when it already was used (Siemens wanted to get rid of it back then). Well … no way to solve that, it seemed. I didn’t want to give up that easy and crawled though my board with PC components and really found a lonely floppy drive. But then I recalled that I also disposed my collection of SCSI and floppy cables – nobody uses floppies any more and everything is SATA nowadays, I kept some IDE cables as my file server still has an IDE drive.

So the next objective was: get a floppy cable. When I almost gave up on this I had a look in an old ASUS mainboard box where I keep some manuals in – and amazingly there was a brand new floppy cable still in its original package. Ok, great, now I could connect the floppy drive with my mainboard … but stop, it needs a small power plug – but there was none. As my power supply has cable management there must be some power cords left in its packaging … so again, searching for a cable – but that one was easier to find.

But what is a floppy drive without a floppy. Those I disposed about 5 years ago after I created a last backup of thier content on my file server. So now it became quite hard. I even had to search in those tow boxes with unused stuff that I left untouched for three years now since I moved into my current apartment. And astonishingly there were about 10 floppies left.

Then the amazing thing happened. After over 5 years it was the first time I logged into my own workstation with a floppy drive connected. Ok, the workstations changed in the meantime from a custom built one to a MacMini and now I’ve got a custom built one again (does not look as nice as Apple products but its a lot cheaper and much more flexible).

Well, the rest of the story is short: formatting the floppy with KDE was easy, installing wine to extract the SATA drivers on the CD from the self extrating *.exe archives went smoothly as well, and so did the installation of XP in the end. It just was so curious to use a technology again after such a long time (5 years can seem long). Maybe I now start to understand what it feels like for the computer poineers to touch a Zuse or to power on a DEC PDP-7.