This document provides a clean and structured explanation of how loop devices behave across reboots, why storage pools become unavailable in the webUI, and how to make them available again.
Overview Loop devices are virtual block devices that allow files (e.g., disk images) to be mounted as if they were physical block devices. These devices are ephemeral by nature, meaning they do not persist across system reboots unless explicitly configured to do so.
/dev/loopX
) are removed and must be recreated manually or through automation after the reboot./dev/loop8
).To make the storage pool available after a reboot, follow these steps:
losetup
command to recreate the loop device association. For example:
sudo losetup /dev/loop8 /data/lxc/porter-in-demo1a-node01.img
sudo losetup /dev/loop9 /data3/lxc/pssb1avd003.img
losetup -a
/dev/loop8
or /dev/loop9
).To avoid manually recreating loop devices after every reboot, you can automate the process:
/etc/rc.local
Add the losetup
commands to /etc/rc.local
:
sudo nano /etc/rc.local
Add the following content:
#!/bin/bash
# Recreate loop devices for storage pools
# Detach existing loop devices if they are already in use
/usr/sbin/losetup -d /dev/loop8 2>/dev/null || true
/usr/sbin/losetup -d /dev/loop9 2>/dev/null || true
# Attach loop devices to their respective files
/usr/sbin/losetup /dev/loop8 /data/lxc/porter-in-demo1a-node01.img
/usr/sbin/losetup /dev/loop9 /data3/lxc/pssb1avd003.img
exit 0
Make /etc/rc.local
executable:
sudo chmod +x /etc/rc.local
Enable the rc-local
service:
sudo systemctl enable rc-local
sudo systemctl start rc-local
Reboot and verify:
sudo reboot
losetup -a
losetup
./etc/rc.local
or a custom script.By following these steps, you can ensure that your storage pools remain functional and accessible after every system reboot.