Swap partition seems to have been deleted

Fedora 42

I booted my system yesterday from power off. Everything was working fine as far as I know when I powered it down (properly via “Application Launcher → Shut down” two days earlier.

Upon booting, one of my two external Western Digital drives was making all kinds of clicking noises as if the arm was being repositioned every 1/2 second, either from one end of its range to the other end, or being parked or something like that.

I unmounted, disconnected, and connected it to my laptop. I booted the laptop and no clicking noises. I could access all partitions on the drive and the files seemed intact.

I then shutdown my desktop, connected the drive, rebooted. I have not heard the clicking noises, and I can access all the data on the partitions.

But I noticed that the swap partition is no longer recognized. Below is some output I captured.


$ cat /proc/swaps
Filename                                Type            Size            Used            Priority
/dev/zram0                              partition       8388604         0               100
/dev/sda4\040(deleted)                  partition       134765564       908             200
$
$ swapon --show
NAME       TYPE        SIZE USED PRIO
/dev/zram0 partition     8G   0B  100
/dev/sda4  partition 128.5G 908K  200
$
$
$ cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Fri Nov 22 15:54:29 2024
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#

# fs_spec                                  fs_file      fs_vfstype  fs_mntops                    fs_freq  fs_passno

UUID=4a972d32-b4a0-418e-8f6d-f1aabcbe6b5f  /            btrfs       subvol=root,compress=zstd:1 0 0
UUID=0a70d693-9894-45d2-9668-122dffac9304  /boot        ext4        defaults                    1 2
UUID=EBC8-9DD9                             /boot/efi    vfat        umask=0077,shortname=winnt  0 2
UUID=4a972d32-b4a0-418e-8f6d-f1aabcbe6b5f  /home        btrfs       subvol=home,compress=zstd:1 0 0

LABEL=disk1s1        /mnt/disk1s1        ext4           auto,noexec,nosuid,nodev,nofail        0 0
LABEL=disk1s2        /mnt/disk1s2        ext4           defaults,nofail                        0 0
LABEL=disk1s3        /mnt/disk1s3        ext4           defaults,nofail                        0 0
LABEL=disk1s4        none                swap           defaults,nofail,pri=200                0 0

LABEL=disk2s1        /mnt/disk2s1        ext4           auto,noexec,nosuid,nodev,nofail        0 0
LABEL=disk2s2        /mnt/disk2s2        ext4           defaults,nofail                        0 0
LABEL=disk2s3        /mnt/disk2s3        ext4           defaults,nofail                        0 0
LABEL=disk2s4        none                swap           defaults,nofail,pri=200                0 0
$

It seems that there is an inconsistency between the output of “swapon” and the contents of /proc/swaps

I looked at the partitions using parted and it looks like the “swap” flag is properly set on the partition reserved for swap.
Any ideas are appreciated.

Fedora stopped using swap on disks a while ago.
Only old systems are likely to have a swap partition on disk.
Zram swap is now used that compresses pages in memory.

1 Like

The output of lsblk -f could also be useful.

This doesn’t look right

/dev/sda4\040(deleted)                  partition       134765564       908             200
1 Like

Right, agree with you @vekruse that line that you referenced doesn’t look right.

Here is the output of “lsblk -f”

$ lsblk -f
NAME        FSTYPE FSVER LABEL   UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sdb                                                                                  
├─sdb1      ext4   1.0   disk2s1 c4c592ac-e97a-42a3-8671-a6e8a54f27fc  615.6G    25% /mnt/disk2s1
├─sdb2      ext4   1.0   disk2s2 ddf57568-9704-4426-9a07-5c4c6d932946  376.6G     0% /mnt/disk2s2
├─sdb3      ext4   1.0   disk2s3 9db4ba26-573c-431e-af61-664330d4ed99  376.6G     0% /mnt/disk2s3
└─sdb4      swap   1     disk2s4 b2085844-7027-4225-a187-626b623e8037                
sdc                                                                                  
├─sdc1      ext4   1.0   disk1s1 4ab26b6b-1ca5-4768-8503-ea35a34fcdb7  615.9G    25% /mnt/disk1s1
├─sdc2      ext4   1.0   disk1s2 3307a999-d7b6-4560-8068-4b881da82ba7  376.2G     0% /mnt/disk1s2
├─sdc3      ext4   1.0   disk1s3 e2331797-3318-4548-88c9-940011a849c4  376.6G     0% /mnt/disk1s3
└─sdc4      swap   1     disk1s4 52e426bf-e5bf-4309-bdad-71290bacfdfe                
sr0                                                                                  
zram0       swap   1     zram0   6e9cb00d-b63e-434f-9db2-49472de17c22                [SWAP]
nvme0n1                                                                              
├─nvme0n1p1 vfat   FAT32         EBC8-9DD9                             579.5M     3% /boot/efi
├─nvme0n1p2 ext4   1.0           0a70d693-9894-45d2-9668-122dffac9304  475.6M    44% /boot
└─nvme0n1p3 btrfs        fedora  4a972d32-b4a0-418e-8f6d-f1aabcbe6b5f  638.4G    31% /home
                                                                                     /
$ 

You don’t have a sda anymore. The device names are not stable as they depend on the timing of when devices show up.

Best practice is mount by UUID.

You can refactor your /etc/fstab to replace the LABLE= with UUID= and it should then be reliable.

But before you reboot test your fstab by telling systemd to reload,

sudo systemctl daemon-reload

Then check for errors in the journal.

Well, I’m confused.

I understand what @barryascott said about the device names… the names such as /dev/sda, /dev/sdb, etc change with each boot (potentially) and the order in which the OS detects the devices affects the assignment of device name (sda, sdb, etc).

But I used disk labels to reference partitions. I don’t think I used device names anywhere. Did I miss something?

Also, my ‘df’ output shows no /dev/sda that I can see. Yet, ‘swapon --show’ shows a swap partition on /dev/sda4. This is the hard disk resident swap partition that I defined. And it seems to be recognized by the OS. It is the swap partition on the second hard disk (external disk) that seems to have ‘disappeared’ (not recognized by the OS).

So I believe that the swap partition that appears in the ‘swapon --show’ output was recognized by the LABEL i assigned.

I am probably missing something embarrassing, but I need to correlate /dev/sda4 (or just /dev/sda) with the partition entry from the ‘lsblk’ output to identify the problematic swap partition (the one that is not being recognized by the OS).

I will look at ‘parted’ to see if I can do this. Below is more ‘lsblk’ output.

$ lsblk -i -o name,fstype,label,uuid,partlabel,ptuuid
NAME        FSTYPE LABEL   UUID                                 PARTLABEL            PTUUID
sdb                                                                                  0cf24aeb-39e0-431d-b2dd-a71161dbecaa
|-sdb1      ext4   disk2s1 c4c592ac-e97a-42a3-8671-a6e8a54f27fc disk2s1              0cf24aeb-39e0-431d-b2dd-a71161dbecaa
|-sdb2      ext4   disk2s2 ddf57568-9704-4426-9a07-5c4c6d932946 disk2s2              0cf24aeb-39e0-431d-b2dd-a71161dbecaa
|-sdb3      ext4   disk2s3 9db4ba26-573c-431e-af61-664330d4ed99 disk2s3              0cf24aeb-39e0-431d-b2dd-a71161dbecaa
`-sdb4      swap   disk2s4 b2085844-7027-4225-a187-626b623e8037 disk2s4              0cf24aeb-39e0-431d-b2dd-a71161dbecaa
sdc                                                                                  d0de6796-7bcd-4aca-81f4-1b7f4376d256
|-sdc1      ext4   disk1s1 4ab26b6b-1ca5-4768-8503-ea35a34fcdb7 disk1s1              d0de6796-7bcd-4aca-81f4-1b7f4376d256
|-sdc2      ext4   disk1s2 3307a999-d7b6-4560-8068-4b881da82ba7 disk1s2              d0de6796-7bcd-4aca-81f4-1b7f4376d256
|-sdc3      ext4   disk1s3 e2331797-3318-4548-88c9-940011a849c4 disk1s3              d0de6796-7bcd-4aca-81f4-1b7f4376d256
`-sdc4      swap   disk1s4 52e426bf-e5bf-4309-bdad-71290bacfdfe disk1s4              d0de6796-7bcd-4aca-81f4-1b7f4376d256
sr0                                                                                  
zram0       swap   zram0   6e9cb00d-b63e-434f-9db2-49472de17c22                      
nvme0n1                                                                              7c28784d-bafd-44d6-bdf5-884cc65c35b3
|-nvme0n1p1 vfat           EBC8-9DD9                            EFI System Partition 7c28784d-bafd-44d6-bdf5-884cc65c35b3
|-nvme0n1p2 ext4           0a70d693-9894-45d2-9668-122dffac9304                      7c28784d-bafd-44d6-bdf5-884cc65c35b3
`-nvme0n1p3 btrfs  fedora  4a972d32-b4a0-418e-8f6d-f1aabcbe6b5f                      7c28784d-bafd-44d6-bdf5-884cc65c35b3
$ 

And here is ‘df’ output showing that there is no /dev/sda, which is perplexing to me as there is a swap partition /dev/sda4.

$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/nvme0n1p3 975097856 303950344 669409208  32% /
devtmpfs            4096         0      4096   0% /dev
tmpfs           14211644        16  14211628   1% /dev/shm
efivarfs             128        30        94  24% /sys/firmware/efi/efivars
tmpfs            5684660      2360   5682300   1% /run
tmpfs               1024         0      1024   0% /run/credentials/systemd-journald.service
/dev/nvme0n1p3 975097856 303950344 669409208  32% /home
/dev/nvme0n1p2    996780    440936    487032  48% /boot
/dev/nvme0n1p1    613184     19740    593444   4% /boot/efi
tmpfs           14211644       516  14211128   1% /tmp
tmpfs               1024         0      1024   0% /run/credentials/systemd-resolved.service
tmpfs            2842328      3824   2838504   1% /run/user/1000
/dev/sdc3      416053328      2076 394843444   1% /mnt/disk1s3
/dev/sdc1      927779112 234804316 645772544  27% /mnt/disk1s1
/dev/sdc2      415700072      2076 394508160   1% /mnt/disk1s2
/dev/sdb1      927423800 234761048 645478472  27% /mnt/disk2s1
/dev/sdb2      416053328      2076 394843444   1% /mnt/disk2s2
/dev/sdb3      416053328      2076 394843444   1% /mnt/disk2s3
$ 

How is is that ‘df’ mounted partitions on two external hard disk drives (/dev/sdb and /dev/sdc) but also mounted a swap partition on one of those drives using the name /dev/sda4 ?

I’m going to do a ‘sudo dnf update’ and reboot and look again.

After this post, I will look at ‘parted’ again. But when I did yesterday, the ‘boot’ flag was set on both of the swap partitions (one on each external hard disk drive). I’m wondering if some ‘glitch’ (for lack of better term) messed up something on the swap partition not recognized when I first heard that clicking noise while rebooting two days ago.

I can isolate which physical disk contains the ‘bad’ swap partition by disconnecting each of the two external drives one by one. But I don’t know how to fix it at this point. And I can’t explain the device name discrepancy described above.

Using the LABEL= in /etc/fstab is also fine as the LABEL just like UUID is defined in the file system and not in the device name.

Just a hunch. Check if you have any resume= entry in /proc/cmdline. This is probably not the case.

Or perhaps, did you reconnect the disk while running?

I also wonder if the problem persist after a reboot.

Or perhaps a .swap systemd unit file other than the generated ones. You can run systemctl list-units -t swap.

That is a classic indication of a failing drive. You should probably have a look at sudo smartctl -x /dev/sda and sudo smartctl -x /dev/sdb. It’s possible the swap partition isn’t showing simply because that part of your disk is corrupt.

Thanks, @vekruse … Here is the output:

$ cat systemctl_list_units 
  UNIT                                                                                                                                                        LOAD      ACTIVE SUB    DESCRIPTION
● dev-disk-by\x2ddiskseq-3\x2dpart4.swap                                                                                                                      not-found active active dev-disk-by\x2ddiskseq-3\x2dpart4.swap
● dev-disk-by\x2did-ata\x2dWDC_WD20JDRW\x2d11C7VS1_WD\x2dWX92A64AFZ7L\x2dpart4.swap                                                                           not-found active active dev-disk-by\x2did-ata\x2dWDC_WD20JDRW\x2d11C7VS1_WD\x2dWX92A64AFZ7L\x2dpart4.swap
● dev-disk-by\x2did-usb\x2dWD_Elements_2620_5758393241363441465A374C\x2d0:0\x2dpart4.swap                                                                     not-found active active dev-disk-by\x2did-usb\x2dWD_Elements_2620_5758393241363441465A374C\x2d0:0\x2dpart4.swap
● dev-disk-by\x2did-wwn\x2d0x50014ee26bbe4ec8\x2dpart4.swap                                                                                                   not-found active active dev-disk-by\x2did-wwn\x2d0x50014ee26bbe4ec8\x2dpart4.swap
  dev-disk-by\x2dlabel-disk2s4.swap                                                                                                                           loaded    active active /dev/disk/by-label/disk2s4
● dev-disk-by\x2dpartlabel-disk2s4.swap                                                                                                                       not-found active active dev-disk-by\x2dpartlabel-disk2s4.swap
● dev-disk-by\x2dpartuuid-b09cc65d\x2d8e56\x2d42ec\x2dbe32\x2db1f266a4bf27.swap                                                                               not-found active active dev-disk-by\x2dpartuuid-b09cc65d\x2d8e56\x2d42ec\x2dbe32\x2db1f266a4bf27.swap
● dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart-by\x2dlabel-disk2s4.swap                                             not-found active active dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart-by\x2dlabel-disk2s4.swap
● dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart-by\x2dpartlabel-disk2s4.swap                                         not-found active active dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart-by\x2dpartlabel-disk2s4.swap
● dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart-by\x2dpartnum-4.swap                                                 not-found active active dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart-by\x2dpartnum-4.swap
● dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart-by\x2dpartuuid-b09cc65d\x2d8e56\x2d42ec\x2dbe32\x2db1f266a4bf27.swap not-found active active dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart-by\x2dpartuuid-b09cc65d\x2d8e56\x2d42ec\x2dbe32\x2db1f266a4bf27.swap
● dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart-by\x2duuid-b2085844\x2d7027\x2d4225\x2da187\x2d626b623e8037.swap     not-found active active dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart-by\x2duuid-b2085844\x2d7027\x2d4225\x2da187\x2d626b623e8037.swap
● dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart4.swap                                                                not-found active active dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusb\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart4.swap
● dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusbv2\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart4.swap                                                              not-found active active dev-disk-by\x2dpath-pci\x2d0000:c5:00.3\x2dusbv2\x2d0:4.2:1.0\x2dscsi\x2d0:0:0:0\x2dpart4.swap
● dev-disk-by\x2duuid-b2085844\x2d7027\x2d4225\x2da187\x2d626b623e8037.swap                                                                                   not-found active active dev-disk-by\x2duuid-b2085844\x2d7027\x2d4225\x2da187\x2d626b623e8037.swap
● dev-sda4.swap                                                                                                                                               not-found active active dev-sda4.swap
  dev-sda4\x20\x28deleted\x29.swap                                                                                                                            loaded    active active /dev/sda4 (deleted)
  dev-zram0.swap                                                                                                                                              loaded    active active Compressed Swap on /dev/zram0

Legend: LOAD   → Reflects whether the unit definition was properly loaded.
        ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
        SUB    → The low-level unit activation state, values depend on unit type.

18 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
$ 
$  cat /proc/cmdline 
BOOT_IMAGE=(hd1,gpt2)/vmlinuz-6.14.8-300.fc42.x86_64 root=UUID=4a972d32-b4a0-418e-8f6d-f1aabcbe6b5f ro rootflags=subvol=root rhgb quiet
$ 

I do believe that I did disconnect at least one of the drives whil running, but only after I unmounted all the filesystems on it.

I have rebooted a couple times at least since first noticing the problem. But each time I shut down properly, and only after shutting down did I disconnect one drive or the other to try to figure out which physical drive I was looking at correlated to the device name (such as /dev/sda, /dev/sdb, /dev/sdc, etc)…

But did you also run sudo swapoff <device> to “unmount” the swap partition? Maybe that corrupted the partition and you just need to reformat it?

P.S. I like to use sudo eject <device> when I’m about to disconnect something on a running system. I think the eject command does slightly more than umount, but I’m not sure if it handles swap partitions.

And the next thing is

systemctl status 'dev-sda4\x20\x28deleted\x29.swap'

Don’t forget the quotes.

1 Like

Unmounting all the filesystems includes also running swapoff on any of the swap devices.

1 Like

Oh, no…!!! No, I did not run ‘sudo swapoff ’ …! Thanks, @glb for that catch…!
Sheesh…! My bad…!

I guess I should reformat the swap partition then. In fact, I’ll do both. The swap partition on the other drive that’s recognized might also have problems of corruption. It appears in ‘swapon --show’ but the USED value has not budged in 2 days… showing 908K. Normally, I run ‘swapon --show’ periodically to see how swap is working, and I normally see fluctuating values for USED.

1 Like

I will respond to all posts guys… thanks @steppybug and everyone else…

1 Like

@steppybug

$ cat /proc/swaps
Filename                                Type            Size            Used            Priority
/dev/zram0                              partition       8388604         0               100
/dev/sda4\040(deleted)                  partition       134765564       908             200
$ 
$ 
$ sudo dmesg | grep sda
[sudo] password for rhimbo: 
[   11.525576] sd 1:0:0:0: [sda] 3906963456 512-byte logical blocks: (2.00 TB/1.82 TiB)
[   11.526465] sd 1:0:0:0: [sda] Write Protect is off
[   11.526477] sd 1:0:0:0: [sda] Mode Sense: 47 00 10 08
[   11.527168] sd 1:0:0:0: [sda] No Caching mode page found
[   11.527179] sd 1:0:0:0: [sda] Assuming drive cache: write through
[   11.561877]  sda: sda1 sda2 sda3 sda4
[   11.562363] sd 1:0:0:0: [sda] Attached SCSI disk
[   12.396429] Adding 134765564k swap on /dev/sda4.  Priority:200 extents:1 across:134765564k 
[   13.863944] EXT4-fs (sda2): mounted filesystem ddf57568-9704-4426-9a07-5c4c6d932946 r/w with ordered data mode. Quota mode: none.
[   13.962205] EXT4-fs (sda1): mounted filesystem c4c592ac-e97a-42a3-8671-a6e8a54f27fc r/w with ordered data mode. Quota mode: none.
[   13.971231] EXT4-fs (sda3): mounted filesystem 9db4ba26-573c-431e-af61-664330d4ed99 r/w with ordered data mode. Quota mode: none.
[  826.619483] EXT4-fs (sda3): unmounting filesystem 9db4ba26-573c-431e-af61-664330d4ed99.
[  830.037675] EXT4-fs (sda1): unmounting filesystem c4c592ac-e97a-42a3-8671-a6e8a54f27fc.
[  832.150830] EXT4-fs (sda2): unmounting filesystem ddf57568-9704-4426-9a07-5c4c6d932946.
$ 

I am not doing any mirroring.

Yes, I have systemd-swap installed:

$ dnf list | grep systemd-swap
Updating and loading repositories:
Repositories loaded.
systemd-swap.noarch                                                                      3.3.0-17.fc42                                                                   fedora
$ 

I'm going to try to reformat the swap partition on each of the two drives....

And finally…

$ systemctl status 'dev-sda4\x20\x28deleted\x29.swap'
dev-sda4\x20\x28deleted\x29.swap - /dev/sda4 (deleted)
     Loaded: loaded
     Active: active
       What: /dev/sda4 (deleted)
$ 
$

Beware that when you have multiple swap partitions spread across different drives, Linux will effectively treat them as a RAID0 array – the block reads and writes will be striped across the drives. (I’m not sure that really matters, but I would reformat all the swap partitions just to be sure.)

OK, @glb thanks for that heads up.

I only have the two swap partitions, one on each of the two external drives. It will be easy to reformat them. I’m going to do that right now (after I run ‘swapoff’ on that second swap partition…! :rofl:)

1 Like

Question…

Sorry for the naive question, but just want to do a little risk management and avoid bolloxing up my system…

Should I use ‘mkswap’ to reformat the swap partitions? I think the man page is saying that I can specify the partition label on the command line for the partition to format?

$ mkswap -label disk2s4 

(one of swap partition labels).

Yes, mkswap would be the correct command, but you need to provide it the path to the device node (e.g. /dev/sdb4). Use lsblk first to be sure you are formatting the right partition!

The --label option (use two dashes when providing “long” option names) is to set the filesystem label at the same time (what you would reference with LABEL=... in /etc/fstab).

Also, just a minor point of clarification, partition labels and filesystem labels are not the same thing. You would use PARTLABEL=.... in /etc/fstab to reference a partition label. You can find your partition labels under /dev/disk/by-partlabel and you could set them with a partitioning tool such as sgdisk.

1 Like