drakkar-lig / debootstick

Generate a bootable live image from any Debian/Ubuntu filesystem tree.
62 stars 18 forks source link

Removal of /var/cache of chroot seems to cause ubiquity installer to fail #29

Closed kgilmer closed 4 years ago

kgilmer commented 4 years ago

I am building an Ubuntu based live installer environment using debootstick. I find that upon first boot of an image (via kvm) that the ubiquity installer fails with an error. I believe this error is due to the removal of /var/cache/debconf in create-image/common/finalize, as when I update this script to not delete that directory, ubiquity works as expected. The update is to remove var/cache/* from the following line in finalize:

    rm -rf proc/* sys/* dev/* tmp/* \
            $(find run -type f) var/cache/* var/lock

Steps to reproduce:

  1. create chroot with ubiquity installer
  2. make image with debootstick

expected result:

actual result:

eduble commented 4 years ago

Thank you for reporting and investigating the problem. As you might guess, clearing cache allows to build smaller images. Usually cache data is just a mean of speeding up things, so ideally it should not be a problem to remove it... Some distributions even mount this directory in RAM! So it would be better to narrow down the problem, and maybe improve the filter to keep precisely the files we need. Could you check if, in your case, there are other things in var/cache when this cleanup procedure is called? And are you sure the error message you get about missing locale is related to this problem? Thank you!

kgilmer commented 4 years ago

Could you check if, in your case, there are other things in var/cache when this cleanup procedure is called?

Yes, here is what I see in the chroot directory if I disable the deletion of /var/cache:

$ ls /tmp/chroot21/chroot/var/cache/
apparmor  cracklib  dictionaries-common  ldconfig  man         private
apt       debconf   fontconfig           lightdm   PackageKit

And are you sure the error message you get about missing locale is related to this problem?

I cannot prove a causal relationship. However the following findings lead me to believe this is the root cause to my issue:

  1. debconf stores it's files here
    
    $ cat /tmp/chroot21/chroot/etc/debconf.conf | grep -v ^#

Config: configdb Templates: templatedb

Name: config Driver: File Mode: 644 Reject-Type: password Filename: /var/cache/debconf/config.dat

Name: passwords Driver: File Mode: 600 Backup: false Required: false Accept-Type: password Filename: /var/cache/debconf/passwords.dat

Name: configdb Driver: Stack Stack: config, passwords

Name: templatedb Driver: File Mode: 644 Filename: /var/cache/debconf/templates.dat



2. When I first try to run Ubiqity and get the error, then run `dpkg-reconfigure ubiqutiy` I diff the file system and the only changes (outside of virtual filesystems like /proc and /sys) are the files in `/var/cache/debconf`.

3. The error given by debconf when ubiquty crashes reference strings that are contained in that cache file (`debian-installer/locale`)

4. I have tried many things in my chroot configuration script and none have them have any impact to the error, leading me to believe it's something that occurs after [my chroot script](https://github.com/regolith-linux/regolith-builder/blob/master/iso-build/init-chroot.sh) is complete.

5. By not deleting `/var/cache/debconf` the problem goes away.
kgilmer commented 4 years ago

I found this page regarding the policy of /var/cache and it seems that debconf should not be using this directory if it results in an application not being able to start. Hard to say if the fault is in Ubiquity, d-i, or debconf itself.

eduble commented 4 years ago

OK. Thanks for the investigation. Then I would suggest we specifically preserve /var/cache/debconf and remove all the rest in /var/cache. (Some files there can be quite big, such as the apt cache.) Something like this:

rm -rf proc/* sys/* dev/* tmp/* \
            $(find run -type f) $(ls -1d /var/cache/* | grep -v 'debconf$') var/lock