- a few remote debian 7 32bit servers
- only accessible via SSH
- more than half of the disks are empty
- 1 whole disk partition per server
- small maintenance window, cannot be down for long
- ext4 filesystems
- NOTE: I am developing my solution using a VirtualBox VM, but the servers are straight bare metal.
Goal: upgrade OS to debian 9+, in a non-destructive way, since ideally machine needs to stay up until the reboot into the new OS.
So, for each servers, I plan (other suggestions welcomed) to do the following:
- Shrink the current deb 7 rootfs with resize2fs to a bit less than 1/2 the partition size
- Shrink the partition to clear out 1/2 the disk
- Partition the newly freed space (/, /home, swap) and Install LVM2
(create VG,LV etc.) and Debian 9
My problem is that resize2fs can only shrink ext4 fs IF unmounted. So the idea is to use initrd image or initramfs to call resize2fs on the unmounted /dev/sda1 during the GRUB2 bootloading sequence.
I have built my own initrd image containing a static resize2fs binary and a shell script which calls it (and does other validations etc.), but I seem to have hit a snag trying to write the correct entry in the grub.cfg file to make it mount my initrd image and execute my resizing script on the unmounted /dev/sda1.
So my Question is:
What grub.cfg menuentry do I need to write in order to load my custom initrd image containing my /bin/resize.sh script and then execute it (the /bin/resize.sh)?