udev postinst fails because kvm group already exists and is not a system group

Bug #1791102 reported by Andreas Hasenack
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
New
Low
Unassigned

Bug Description

The udev postinst failed like this on an upgrade in cosmic from 237-3ubuntu10.3 to 239-7ubuntu7:
Setting up udev (239-7ubuntu7) ...
Installing new version of config file /etc/udev/udev.conf ...
The group `kvm' already exists and is not a system group. Exiting.
dpkg: error processing package udev (--configure):
 installed udev package post-installation script subprocess returned error exit status 1

The postinst script seemd to blindly add the kvm group. It is relying on the fact that the groups it's trying to add are already system groups, in which case addgroup --system doesn't fail
case "$1" in
    configure)
    # update/create hwdb before we (re)start udev
    update_hwdb

    # Add new system group used by udev rules
    addgroup --quiet --system input

    # Make /dev/kvm accessible to kvm group
    addgroup --quiet --system kvm

But on this machine "kvm" has a high gid, so it's not deemed to be a system group, in which case addgroup fails.

root@diamond:~# getent group input kvm
input:x:106:
kvm:x:1001:<big list of members sanitized>
root@diamond:~# addgroup --quiet --system input;echo $?
0
root@diamond:~# addgroup --quiet --system kvm;echo $?
The group `kvm' already exists and is not a system group. Exiting.
1

Someone, or some package, probably did an addgroup without --system some time ago. A quick grep in /var/lib/dpkg/info shows at least 3 packages trying to add a group called kvm:
root@diamond:~# grep -E "addgroup.*kvm" /var/lib/dpkg/info/*
/var/lib/dpkg/info/libvirt-daemon-system.postinst: addgroup --quiet --system kvm
/var/lib/dpkg/info/qemu-system-common.postinst: addgroup --quiet --system kvm || true
/var/lib/dpkg/info/qemu-system-common.preinst: addgroup --quiet --system kvm || true
/var/lib/dpkg/info/udev.postinst: addgroup --quiet --system kvm || /bin/true

Revision history for this message
Dan Streetman (ddstreet) wrote :

please reopen if this is still an issue

Changed in systemd (Ubuntu):
status: New → Invalid
Revision history for this message
Lars (l4rs) wrote :

We still have the same issue on Ubuntu 22.04 and udev version 249.11-0ubuntu3.11:

Setting up udev (249.11-0ubuntu3.11) ...
The group `kvm' already exists and is not a system group. Exiting.
dpkg: error processing package udev (--configure):
 installed udev package post-installation script subprocess returned error exit status 1

Changed in systemd (Ubuntu):
status: Invalid → New
Nick Rosbrook (enr0n)
Changed in systemd (Ubuntu):
importance: Undecided → Low
Revision history for this message
Frederik Heber (foo) wrote (last edit ):

I've also had the same issue after an update from ubuntu 20.04 to ubuntu 22.04 with udev (249.11-0ubuntu3.11).

Just as an additional note on how to mitigate if someone stumbles over this.

1. remove the group: sudo groupdel kvm
2. Then run upgrade again: sudo apt upgrade

On udev installation the group can then be successfully installed as a system group.

Please check beforehand whether any user was a member of that group "kvm" and re-add afterwards.

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.