Resizing a LibreELEC image

I'm using LibreELEC (and therefore Kodi) on a small RaspberryPi 3 as a media center since quite some years.

This small installation also holds a PiHole instance in a docker container.

But of cause, over the years, more containers and services followed and the original 16GB card was getting too small.

So I bought a new one, made a copy from the old and restored it onto the new one.

And then the trouble with resizing the image began...

LibreELEC is not a full-fledged Linux distro, but really just enough to run Kodi.

To cut a long story short, I found a way to resize the image:

1. Trigger Resizing

The resizing trigger only works on a "fresh" installation. Instead of really doing a fresh install and restore, it's possible to just rename some directories and pretend to be a fresh install.

Connect to the installation via ssh and run this commands:

# stop the running kodi instance
systemctl stop kodi

# shutdown all docker containers
docker stop $(docker container ls -q)

# rename old stuff
mv /storage/.kodi /storage/.kodi_old
mv /storage/.config /storage/.config_old
mv /storage/.cache /storage/.cache_old

# trigger resizing on next boot
touch /storage/.please_resize_me

# reboot
sync
reboot

After reboot, the "fresh installation wizard" appears. You need to configure Wifi (luckily I use ethernet) and turn ssh access back on.

2. Restore the old setup

Connect once again via ssh and run this commands:

# stop the running kodi instance
systemctl stop kodi

# remove the "fresh" setup
rm -rf /storage/.kodi
rm -rf /storage/.config
rm -rf /storage/.cache

# rename old stuff back
mv /storage/.kodi_old /storage/.kodi
mv /storage/.config_old /storage/.config
mv /storage/.cache_old /storage/.cache

# reboot
sync
reboot

Fingers crossed that it works. The docker containers probably won't start automatically since they were stopped manually - so you have to restart them manually again.