Systemd how delete .device unit

Today I had the brilliant idea of deleting the swap partition to switch to using swapfile.

I’m using the btrfs filesystem encrypted with luks so I created a subvolume, created the swapfile, updated fstab, /etc/default/grub and dracut configs.

Everything works as it should except that on startup I have this message

Evidently there is a systemd unit related to the old swap partition but I can’t delete it.

Some advice ??

Thank you!

systemctl status dev-disk-by\\x2duuid-b7e0858a\\x2d5114\\x2d45d2\\x2da976\\x2d7af690655243.device
○ dev-disk-by\x2duuid-b7e0858a\x2d5114\x2d45d2\x2da976\x2d7af690655243.device - /dev/disk/by-uuid/b7e0858a-5114-45d2-a976-7af690655243
     Loaded: loaded
     Active: inactive (dead)

set 03 17:33:49 macbookpro systemd[1]: dev-disk-by\x2duuid-b7e0858a\x2d5114\x2d45d2\x2da976\x2d7af690655243.device: Job dev-disk-by\x2duuid->
set 03 17:33:49 macbookpro systemd[1]: Timed out waiting for device /dev/disk/by-uuid/b7e0858a-5114-45d2-a976-7af690655243.
set 03 17:33:49 macbookpro systemd[1]: dev-disk-by\x2duuid-b7e0858a\x2d5114\x2d45d2\x2da976\x2d7af690655243.device: Job dev-disk-by\x2duuid->
lines 1-7/7 (END)

That is probably being created dynamically.

Can you describe what changes you made and what commands you ran exactly?

sudo blkid
/dev/mapper/luks-fd085464-4840-43bd-a55b-e1713c6c5a4f: LABEL="EndeavourOS" UUID="24be0b8b-ae79-4258-b1b6-fe4a44d47bc0" UUID_SUB="73ad4ded-e350-4be8-83ca-da26429611aa" BLOCK_SIZE="4096" TYPE="btrfs"
/dev/sda2: UUID="fd085464-4840-43bd-a55b-e1713c6c5a4f" TYPE="crypto_LUKS" PARTLABEL="EndeavourOS" PARTUUID="4fded22e-ed9f-44f7-ba56-1a61e8ab9f62"
/dev/sda1: UUID="BC78-4354" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="f0cfffc4-e95d-4d5d-a2e4-ceb45d9520a2"
/dev/zram0: LABEL="zram0" UUID="e56cb9e9-4874-466e-8008-e953d3804f5a" TYPE="swap"
`lsblk -f
NAME                                          FSTYPE      FSVER LABEL       UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda
├─sda1                                        vfat        FAT32             BC78-4354                             997,3M     0% /boot/efi
└─sda2                                        crypto_LUKS 1                 fd085464-4840-43bd-a55b-e1713c6c5a4f
  └─luks-fd085464-4840-43bd-a55b-e1713c6c5a4f btrfs             EndeavourOS 24be0b8b-ae79-4258-b1b6-fe4a44d47bc0  324,3G    25% /var/log
                                                                                                                                /var/cache
                                                                                                                                /swap
                                                                                                                                /home
                                                                                                                                /
sr0
zram0                                                                                                                           [SWAP]`

fstab : I deleted the old swap partition entry and inserted the lines for the swapfile

cat /etc/fstab

UUID=BC78-4354                            /boot/efi      vfat    defaults,noatime 0 2
/dev/mapper/luks-fd085464-4840-43bd-a55b-e1713c6c5a4f /              btrfs   subvol=/@,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-fd085464-4840-43bd-a55b-e1713c6c5a4f /home          btrfs   subvol=/@home,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-fd085464-4840-43bd-a55b-e1713c6c5a4f /var/cache     btrfs   subvol=/@cache,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-fd085464-4840-43bd-a55b-e1713c6c5a4f /var/log       btrfs   subvol=/@log,defaults,noatime,compress=zstd 0 0

# swapfile
/dev/mapper/luks-fd085464-4840-43bd-a55b-e1713c6c5a4f /swap          btrfs   noatime,subvol=@swap
/swap/swapfile none swap defaults 0 0

tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0

I commented out the line about the swap partition in dracut

cat /etc/dracut.conf.d/calamares-luks.conf
File: /etc/dracut.conf.d/calamares-luks.conf
# Configuration file automatically written by the Calamares system installer
# (This file is written once at install time and should be safe to edit.)
# Enables support for LUKS full disk encryption with single sign on from GRUB.

# force installing /etc/crypttab even if hostonly="no", install the keyfile
install_items+=" /etc/crypttab /crypto_keyfile.bin "
# enable automatic resume from swap
#add_device+=" /dev/disk/by-uuid/b7e0858a-5114-45d2-a976-7af690655243 "

Finally in /etc/default/grub I removed the references to the UUID of the swap partition (in line GRUB_CMDLINE_LINUX_DEFAULT)

cat /etc/default/grub
# GRUB boot loader configuration

GRUB_DEFAULT='0'
GRUB_TIMEOUT='5'
GRUB_DISTRIBUTOR='EndeavourOS'
GRUB_CMDLINE_LINUX_DEFAULT='nowatchdog nvme_load=YES rd.luks.uuid=fd085464-4840-43bd-a55b-e1713c6c5a4f loglevel=3'
GRUB_CMDLINE_LINUX=""

# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

# Uncomment to enable booting from LUKS encrypted devices
GRUB_ENABLE_CRYPTODISK=y

# Set to 'countdown' or 'hidden' to change timeout behavior,
# press ESC key to display menu.
GRUB_TIMEOUT_STYLE=menu

# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console

# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `videoinfo'
GRUB_GFXMODE=auto

# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY='true'

# Uncomment and set to the desired menu colors.  Used by normal and wallpaper
# modes only.  Entries specified as foreground/background.
#GRUB_COLOR_NORMAL="light-blue/black"
#GRUB_COLOR_HIGHLIGHT="light-cyan/blue"

# Uncomment one of them for the gfx desired, a image background or a gfxtheme
GRUB_BACKGROUND='/usr/share/endeavouros/splash.png'
#GRUB_THEME="/path/to/gfxtheme"

# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"

# Uncomment to make GRUB remember the last selection. This requires
# setting 'GRUB_DEFAULT=saved' above.
#GRUB_SAVEDEFAULT=true

# Uncomment to disable submenus in boot menu
GRUB_DISABLE_SUBMENU='false'

# Probing for other operating systems is disabled for security reasons. Read
# documentation on GRUB_DISABLE_OS_PROBER, if still want to enable this
# functionality install os-prober and uncomment to detect and include other
# operating systems.
#GRUB_DISABLE_OS_PROBER=false

As a last thing I updated with the commands

sudo dracut --regenerate-all -f && sudo update-grub

Use sudo dracut-rebuild instead. I suspect this is your issue.

Unless you added an update-grub script, you need sudo grub-mkconfig -o /boot/grub/grub.cfg

I tried with your advice, unfortunately nothing to do!

For update-grub you’re right, I have an alias.

I also tried with sudo systemctl reset-failed but always without success.

Edit.

I don’t know if it’s the most elegant solution but I was able to fix it with

systemctl mask 'dev-disk-by\x2duuid-b7e0858a\x2d5114\x2d45d2\x2da976\x2d7af690655243.device'

Thank you @dalto for the help!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.