Error when I purge snapd package in late-commands

Bug #1946609 reported by Francois Lafont
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
subiquity
New
Undecided
Unassigned

Bug Description

Hi,

I use this iso https://releases.ubuntu.com/20.04/ubuntu-20.04.3-live-server-amd64.iso (sha1 a6077cb573271ec3c85f9d8abb60c60471dcb73b) to make a full automatic install of Ubuntu Focal. In "late-commands", I want to purge snapd to have a minimal install. Here is my user-data file:

```yaml
#cloud-config
autoinstall:
  version: 1
  locale: en_US.UTF-8
  keyboard:
    layout: fr
    variant: ""
  proxy: http://aptproxy.virt.priv:3142
  apt:
    preserve_sources_list: false
    primary:
      - arches: [amd64]
        uri: "http://archive.ubuntu.com/ubuntu"
    geoip: false
  network:
    network:
      version: 2
      ethernets:
        enp0s3:
          dhcp4: true
  storage:
    layout:
      name: direct
  identity:
    hostname: focal-vbox
    realname: packer
    username: packer
    password: $6$e70e7d9a7b031659$ID9RRN/tqPeis32k3GEsXluR1FNIR5RuyhVdJfZXUZ/H2de6p3D4sIChX8YCdOOfRIpCVWkDQBadBNjr7Y3Yn1
  ssh:
    install-server: yes
  user-data:
    timezone: "Europe/Paris"
  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)
```

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.

Feel to handle this "bug" (is it really a bug?) as you want.

As an attachment, a .gz file with:
- the file /autoinstall.yml from the installer server.
- the output of `journalctl` from the installer server.
- the /var/log/ directory from the installer server (ignore the ssh errors, it's just paker which tries to ssh on the VM during the installation).

Regards.

Revision history for this message
Francois Lafont (francois-lafont) wrote :
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!

Revision history for this message
Francois Lafont (francois-lafont) wrote :

Hi,

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

Thx Michael, it works via "chroot /target apt-get -y -q purge snapd". I admit that I don't understand well why it works with chroot and not with curtin.

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

Good news. :)

I think we can consider that this bug is solved, no?

Thx.

Revision history for this message
Francois Lafont (francois-lafont) wrote :

Hi,

@mwhudson said:

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

@mwhudson, sorry for this message. I know this bug is closed and it's ok. But, now I would like to install Ubuntu 22.04 via Subiquity and the user-data file (ie a full automatic install). I have searched the way to make a minimal install but I have not found in documentation. Can you tell me which option I have to put the in user-data file to have a minimal install?

Thx.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.