[solved] swap partition in fstab not being mounted

Issues related to applications and software problems
Post Reply
LMHmedchem
Posts: 53
Joined: 2011/03/22 17:32:25
Location: Boston

[solved] swap partition in fstab not being mounted

Post by LMHmedchem » 2020/02/15 20:28:07

Hello,

When I installed CentOS, I set up and formatted an ~8GB swap partition. I have just recently noticed that the partition exists and is formatted as swap but is not mounted. The swapon -s command does not return any value.

The free command also does not list any available swap.

Code: Select all

[user_name@localhost ~]$ free -m
              total        used        free      shared  buff/cache   available
Mem:          15745        1147       13763         121         834       14202
Swap:             0           0           0
The partition is located at /dev/sda7 and is part of an extended partition. Looking at /etc/fstab,

Code: Select all

#
# /etc/fstab
# Created by anaconda on Mon Jan 20 11:41:51 2020
#
# 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
#
# centos root partition
UUID=59f2a07f-5863-4e45-9a18-1dd5f7a97463 /                       ext4    defaults        1 1
# centos home
UUID=43eae339-979e-4cbe-8c2a-21beb2365426 /home                   ext4    defaults        1 2
# centos swap
UUID=d960b749-64db-4a02-b225-1eb13f55463c swap                   swap    defaults        0 0
# shared linux data partition
UUID=a89334f7-59b7-4d04-b89b-a5a30c379644  /run/media/lmhall/linux_data  ext4  defaults  1 2
The partition is listed there by UUID. Checking the blkid output for sda7,

Code: Select all

[user_name@localhost ~]$ blkid /dev/sda7
/dev/sda7: UUID="d961b749-64db-4a02-b225-1eb13f55463c" TYPE="swap"
The UUID value in the fstab file is correct, so I don't understand why the partition isn't being mounted.

A check of the mount options using the Disks utility shows the same thing with the box checked for "mount at system startup" and "identify by" as,

Code: Select all

/dev/disk/by-uuid/d961b749-64db-4a02-b225-1eb13f55463c
As far as I can see, everything is correct here. Am I missing something? I did try changing the fstab entry from swap to /swap since it didn't look quite right but that doesn't fix the issue.

I have looked at these instructions,
https://www.digitalocean.com/community/ ... n-centos-7
but this is for creating a swap on /root.

LMHmedchem
Last edited by LMHmedchem on 2020/02/15 23:43:49, edited 1 time in total.

MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Re: swap partition in fstab not being mounted

Post by MartinR » 2020/02/15 20:59:23

Your fstab lists UUID=d960b749-64db-4a02-b225-1eb13f55463c whereas blobkid says UUID="d961b749-64db-4a02-b225-1eb13f55463c". Look closely at the fourth digit.

LMHmedchem
Posts: 53
Joined: 2011/03/22 17:32:25
Location: Boston

Re: swap partition in fstab not being mounted

Post by LMHmedchem » 2020/02/15 23:43:30

MartinR wrote:
2020/02/15 20:59:23
Your fstab lists UUID=d960b749-64db-4a02-b225-1eb13f55463c whereas blobkid says UUID="d961b749-64db-4a02-b225-1eb13f55463c". Look closely at the fourth digit.
I can't imagine how that happened. The fstab entries were created by CentOS on install. I added several other entries but didn't change anything that was already there.

Oddly, GParted still does not list that partition as having a mount point. The swapon -s command does now show the swap partition.

Code: Select all

[user_name@localhost ~]$ swapon -s
Filename				Type		Size	Used	Priority
/dev/sda7                              	partition	8127484	0	-2
The lsblk -f command also shows /dev/sda7 as swap but I have never seen the [SWAP] notation. I don't remember seeing it as anything other than /swap.

Code: Select all

[user_name@localhost ~]$ sudo lsblk -f
NAME   FSTYPE LABEL       UUID                                   MOUNTPOINT
sda                                                                   
├─sda6 ext4               59f2a07f-5863-4e45-9a18-1dd5f7a97463   /
├─sda7 swap               d961b749-64db-4a02-b225-1eb13f55463c   [SWAP]
└─sda8 ext4               43eae339-979e-4cbe-8c2a-21beb2365426   /home
I guess it is working now but I have no idea how it stopped working in the first place.

LMHmedchem

MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Re: [solved] swap partition in fstab not being mounted

Post by MartinR » 2020/02/16 12:31:42

Swap partitions are not mounted, they are used as raw storage by the kernel and there is no filesystem on them. Your swapon command is showing that the kernel is seeing 8 GiB of usable space. The [SWAP] notation reflects this, the partition is being used as swap but is not mounted.

Post Reply