Comment 2 for bug 1946609

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote : Re: [Bug 1946609] [NEW] Error when I purge snapd package in late-commands

> - curtin in-target --target=/target -- sh -c 'printf "root:root\n" |
> chpasswd'
> - sed -i -r 's/^#?PermitRootLogin .*$/PermitRootLogin yes/'
> /target/etc/ssh/sshd_config
> - curtin in-target --target=/target -- apt-get -y -q purge snapd
> - sleep 10000 # Just to have time to ssh on the installer and retrieve
> all logs.
> ```
>
> In the installer, I can see this error (via journalctl):
>
> ```
> Oct 10 23:36:30 ubuntu-server subiquity_log.2004[36987]: Removing snap
> snapd and revision 12704
> Oct 10 23:36:30 ubuntu-server subiquity_log.2004[36987]: Removing
> snap-snapd-12704.mount
> Oct 10 23:36:30 ubuntu-server subiquity_log.2004[36987]: Discarding
> preserved snap namespaces
> Oct 10 23:36:30 ubuntu-server subiquity_log.2004[37372]: umount:
> /run/snapd/ns/lxd.mnt: not mounted.
> Oct 10 23:36:30 ubuntu-server subiquity_log.2004[37373]: rm: cannot remove
> '/run/snapd/ns/lxd.mnt': Device or resource busy
> Oct 10 23:36:30 ubuntu-server subiquity_log.2004[36986]: dpkg: error
> processing package snapd (--purge):
> Oct 10 23:36:30 ubuntu-server subiquity_log.2004[36986]: installed snapd
> package post-removal script subprocess returned error exit status 1
> Oct 10 23:36:30 ubuntu-server subiquity_log.2004[36986]: Errors were
> encountered while processing:
> Oct 10 23:36:30 ubuntu-server subiquity_log.2004[36986]: snapd
> Oct 10 23:36:32 ubuntu-server subiquity_log.2004[36772]: E: Sub-process
> /usr/bin/dpkg returned an error code (1)
> ```
>

Hmmm. You might have better luck with chroot /target apt-get purge snapd.
Or at least it would be worth a try :)

> Maybe there is a way to avoid this error when snapd is purged but, to be
> honest, I would much prefer an option in the `user-data` file to have a
> **minimal** install, so without snapd installed, something with just
> `apt-get` basically.
>

Well, luckily for you this feature has been implemented in the soon to be
released Ubuntu 21.10!