guysoft / CustomPiOS

A Raspberry Pi and other ARM devices distribution builder
GNU General Public License v3.0
508 stars 146 forks source link

dangling files after build eat diskspace. #203

Closed umlaeute closed 1 year ago

umlaeute commented 1 year ago

i noticed that when running consecutive builds, my harddisk fills up.

i'm starting with 62GB of free space, and after the build there are only 49GB. This is not very exciting, as my workspace/ now contains a 14GB image file.

it's getting interesting, when rebuilding:

sudo rm -rf workspace
sudo ./build_dist

after a successful build, i now only have 36GB of free space. and so on. i'm doing this on a separate partition where nothing else (to my knowledge) could possibly be eating diskspace.

after a reboot, my diskspace is happily reclaimed and available again.

this strongly hints at some dangling image file, which - although deleted - still needs space allocated, e.g. because some process is still accessing it.

and indeed, after the build i see:

$ sudo losetup -l -a
NAME       SIZELIMIT    OFFSET AUTOCLEAR RO BACK-FILE                                                                                                  DIO LOG-SEC
/dev/loop0         0 272629760         0  0 /media/DATA/CustomPiOS/test/src/workspace/test.img   0     512

after running losetup -d /dev/loop0 the space is properly reclaimed.

so i conclude that the script does not properly detach all disk images

guysoft commented 1 year ago

Hey, It can happen, I am not sure of a way to fully fix it tightly. What I suggest is using the docker method, because after stopping+starting the container all volumes are detached, and the space will be claimed without a reboot.