Sometimes an appliance has been created with a regular root partition and needs to be expanded. If it is full and needs to be expanded, it has to be moved to an LVM partition and the old partition can then be added.
Create a snapshot or backup before attempting this! |
Step-by-step guide
- Create a new LV
- create new partition on expanded drive (cfdisk /dev/sda)
- create new boot partition on expanded drive (100-200MB)
- create new LV
- pvcreate /dev/[newly created lv-partition]
- vgcreate volgroupname /dev/[lvpart1-x]
- lvcreate -l +100%FREE -n lvname volgroupname
- mkfs.ext4 /dev/mapper/volgroupname-lvname
- mkfs.ext4 /dev/[new boot partition]
- Mount new partitions
- mount /dev/mapper/volgroupname-lvname /mnt
- mkdir /mnt/boot
- mount /dev/[new boot partition] /mnt/boot
- Copy everything: rsync -axHAX --exclude '/mnt' / /mnt/
- Mount everyting
1. mount everything
|
2. chroot/mnt
3. update mtab (boot partition to correct location)
4. update /mnt/etc/fstab (change root partition, add boot partition)
|
5. Update Grub
- mv /mnt/boot/grub/grub.cfg /mnt/boot/grub/grub.old
- grub-mkconfig -o /boot/grub
- grub-install /dev/[main drive]
6. Check /boot/grub/grub.cfg
7. Check /etc/fstab
8. Check /etc/mtab
9. Reboot