1

I've inherited a server running Ubuntu 14.04.5 LTS that has a single 30 TB RAID partitioned into a very small boot partition and a big LVM partition containing everything else. Here's the current config:

# lsblk
NAME                     MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                        8:0    0    30T  0 disk 
├─sda1                     8:1    0   113M  0 part /boot
└─sda2                     8:2    0    30T  0 part 
  ├─vg01-root (dm-0)     252:0    0  55,9G  0 lvm  /
  ├─vg01-pooling (dm-1)  252:1    0   1,8T  0 lvm  /var/lib/bareos/pooling
  ├─vg01-postgres (dm-2) 252:2    0 465,7G  0 lvm  /postgres
  ├─vg01-swap (dm-3)     252:3    0   3,7G  0 lvm  [SWAP]
  └─vg01-storage (dm-4)  252:4    0  27,7T  0 lvm  /var/lib/bareos/storage

As you can see, the boot partition is really much too small. So I need to free up a comparably small amount of space at the beginning of sda2 in order to grow sda1. There are lots of well-written tutorials how to shrink an LVM Physical Volume on the 'net, but the freed space invariably shows up at the end of the PV.

Of course I can move the PV after shrinking it, but that would mean copying the entire 30 TB which would take ages, increasing the risk of something going wrong, and appears quite wasteful to me. Is there a better way? It doesn't matter which of the LVs the space is taken from, all of them have a Gig or two to spare.

Tilman
  • 3,599
  • 21
  • 27

1 Answers1

2

I don't know of a way to move the start of an LVM PV, but that doesn't mean it's not possible; my knowledge might simply be inadequate.

If you don't hear of a better solution, though, you might consider the following procedure:

  1. Shrink the physical volume from the end, leaving as much unpartitioned space at the end as is required for a new /boot partition. (There are various questions on this site about resizing an LVM PV, like this one and this one.)
  2. Create a new, larger, /boot partition after the now-shrunken LVM PV.
  3. Adjust your boot loader and /etc/fstab configurations to use the new /boot partition's location.
  4. Test that you can boot from the new partition. (You could delete one kernel on the old one, leaving at least one known-working kernel, and try booting from the kernel that matches the deleted one on the new partition to be sure you're booting from the new partition.)
  5. Wipe the old /boot partition clean.
  6. If necessary, adjust your boot loader configuration again to remove references to the now-wiped old /boot partition.
  7. If desired, add the old /boot partition to the volume group so that you can use its space. This might not be worthwhile for only 113MiB, but it is an option if you're desperate to keep that disk space.

As a variant, if you don't intend to add the old /boot partition to your VG, you could omit everything from step #5 onward. This will give you a backup location where you can store a couple of current kernels in case something bad happens to the new /boot partition.

Rod Smith
  • 44,284
  • 7
  • 63
  • 105
  • You can easily move beginning of LVM PV with GUI tools like KDE Partition Manager or GParted. Although if it contains root file system then live system is needed. – Andrius Štikonas Apr 12 '17 at 17:35