Linux swap partition not mounted by systemd on boot after dist-upgrade

YuTendo asked:

Recently, I performed a dist-upgrade from Debian Wheezy to Jessie. The upgrade was performed without any error but after the upgrade the swap partition was no longer mounted/activated. The mentioned system is a KVM (qemu-kvm, centos7).

During the start up of the system, systemd tries to mount the swap partition but fails due to timeout with the message “Dependency failed for…”

What I tried so far:

  • performing “swapon /dev/sda2” manually works without any problem
  • recreated the swap partition with “mkswap /dev/sda2”
  • double check fstab entry and used UUID
  • removed the fstab entry so that systemd detects it automatically
  • different option parameter (fstab)
  • asked the german debian community -but no helpful response:
  • manually mounting with systemd (systemctl start dev-disk…) fails with the same error but after perfoming “swapon” and “swapoff” it works.

What I found so far:

Additional information:

journalctl -r | grep “dev-disk”

Mar 07 22:31:37 hostname systemd[1]: Dependency failed for /dev/disk/by-uuid/062c87ce-135e-45fc-b430-7336a9ab164a.
Mar 07 22:31:37 hostname systemd[1]: Timed out waiting for device dev-disk-by\x2duuid-062c87ce\x2d135e\x2d45fc\x2db430\x2d7336a9ab164a.device.
Mar 07 22:31:37 hostname systemd[1]: Job dev-disk-by\x2duuid-062c87ce\x2d135e\x2d45fc\x2db430\x2d7336a9ab164a.device/start timed out.

cat /etc/fstab

UUID=5443f0ed-f437-4804-8fa0-45a039413b9a               /       ext4            errors=remount-ro       0 1
UUID=062c87ce-135e-45fc-b430-7336a9ab164a               none    swap            sw                      0 0

uname -a

Linux hostname 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u4 (2016-02-29) x86_64 GNU/Linux


/dev/sda1: UUID="5443f0ed-f437-4804-8fa0-45a039413b9a" TYPE="ext4" PARTUUID="0006f6b9-01"
/dev/sda2: UUID="062c87ce-135e-45fc-b430-7336a9ab164a" TYPE="swap" PARTUUID="0006f6b9-02"

parted /dev/sda – print

(parted) print
Disk /dev/sda: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  10.2GB  10.2GB  primary  ext4            boot
 2      10.2GB  10.7GB  491MB   primary  linux-swap(v1)

dpkg -l systemd

ii  systemd                                               215-17+deb8u3                   amd64                           system and service manager

ls -l /dev/disk/by-uuid

lrwxrwxrwx 1 root root 10 Mar 24 23:01 062c87ce-135e-45fc-b430-7336a9ab164a -> ../../sda2
lrwxrwxrwx 1 root root 10 Mar 20 18:44 5443f0ed-f437-4804-8fa0-45a039413b9a -> ../../sda1

My answer:

The problem is in your /etc/fstab file:

UUID=062c87ce-135e-45fc-b430-7336a9ab164a               none    swap            sw                      0 0

This format refers to a block device by UUID, which is stored in the metadata of the swap space (or other filesystem). Because you recreated the swap space with mkswap, the UUID is no longer valid. More to the point, because upgrading Debian caused the swap to be recreated, the UUID is no longer valid.

You can resolve this in one of two ways:

  1. Update the UUID in /etc/fstab to the current UUID of the swap device. You can find this with the blkid command, i.e. blkid /dev/sda2
  2. Refer to the device by its /dev node rather than UUID, i.e. /dev/sda2. This is not recommended, as the device node may change if you add or remove storage devices.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.