Incus-growpart.service failed because of disk order

I run a standard debian VM and attached extra disks. The systemd service hardcodes /dev/sda

# /etc/systemd/system/incus-growpart.service
[Unit]
Description=Incus - grow root partition

[Service]
Type=oneshot
ExecStartPre=-/usr/bin/growpart /dev/sda 2
ExecStart=/sbin/resize2fs /dev/sda2

[Install]
WantedBy=default.target

but the root disk might not be sda. That boot it was sdb and the service failed. Is there any way to fix this or should I have just picked the cloud variants which don’t seem to have this issue from what I gathered?

It’s probably fixable, the question is whether it’s fixable in a very small and self-contained way that’s compatible with the basic incus-growpart.service definition.

We could use the by-id path for the root disk, but that will vary based on device name then.

Good idea. I added an override snippet and everything works again :slight_smile:

# /etc/systemd/system/incus-growpart.service
[Unit]
Description=Incus - grow root partition

[Service]
Type=oneshot
ExecStartPre=-/usr/bin/growpart /dev/sda 2
ExecStart=/sbin/resize2fs /dev/sda2

[Install]
WantedBy=default.target

# /etc/systemd/system/incus-growpart.service.d/override.conf
[Service]
ExecStartPre=-/usr/bin/growpart /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_incus_root 2
ExecStart=/sbin/resize2fs /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_incus_root-part2