How do I find out if I have a swap partition on my hard drive?
Solution 1
Easy, graphical way to check with Disk Utility
-
Open Disk Utility from the Dash:
-
In the left column, look for the words "Hard Disk", and click on that:
-
In the right column, see if you can find "Swap" as shown. If so, you have swap enabled; you can click on that portion to see details. It will look something like this:
Alternately, open a terminal with Ctrl+Alt+T
, and type swapon -s
; if you see a line like the below, with statistics, swap is enabled:
Solution 2
In terminal, type:
free -m
If you happen to have swap, you will see how much swap memory you have left.
Solution 3
Use
cat /proc/swaps
In addition to the size, it will tell the type of swap (partition/file).
It appears to give exactly the same output as swapon -s
(posted here, but apparently deprecated).
Or
cat /etc/fstab
which will not give you the correct info in the (unusual) case of a swap added manually, as per comment by Carlo Wood.
Solution 4
I'd use this method to verify presence of a swap partition
Open a terminal with CTRL + ALT + T and type
sudo blkid | grep swap
If you see an entry with TYPE="swap"
, be sure that, you have a swap partition.
My output is like below: You can see that /dev/sda7
is a swap partition.
/dev/sda7: UUID="4656a2a6-4de0-417b-9d08-c4a5b807f8dd" TYPE="swap"
The Installer should create a swap partition automatically. And also note that, You may never need a swap partition, unless you use "Hibernation" feature or use many more applications at a time. You can check these interesting question about swap size
I have 16GB RAM. Do I need 32GB swap?
what is SWAP and how large a swap partition should I create?
If it happens that, You did not create a swap partition, check this question for a help
Solution 5
Do lsblk
and check for SWAP near the end.
In simple terms, lsblk | grep SWAP
output:
├─sdb2 8:18 0 7.6G 0 part [SWAP]
If you're not familiar with lsblk
, lsblk
lists partitions , their mountpoint, their size etc.
Related videos on Youtube
dswhite85
Updated on September 18, 2022Comments
-
dswhite85 almost 2 years
I used the 12.04 live cd to install Ubuntu over my Windows 7 partition and deleted everything so I just have Ubuntu on my laptop. But since during the installer I chose the simple "erase entire disk" option, did the installer create a swap partition or is that something I should've done with the "something else" option? Btw I have 6GB of RAM
-
luv.preet almost 7 yearsrun
cat /proc/swaps
ORswapon -s
, It will list the swap partition and swap file which is being used. -
sancho.s ReinstateMonicaCellio over 4 years@luv.preet - This answer shows that.
-
-
thomasrutter almost 12 years
swapon -s
is the easiest way if you didn't set up the computer so you're not sure where the swap would be located (or if it uses a swap file instead of a swap partition, or swap on a different drive, swap in compressed RAM, etc). -
Takkat almost 12 yearsSee also: askubuntu.com/questions/33697/… and (for a swap file in case we can't partition) askubuntu.com/questions/126018/…
-
mightypile about 9 yearsAs Anwar Shah mentioned, this can show you whether you have a partition designated as swap, but this doesn't mean you're using it. Doing this to find swap partitions and verifying with idx's suggestion of 'swapon -s' that they match would be a great solution.
-
AnotherKiwiGuy over 7 yearsCan you explain this a little better? Not everyone is familiar with terminal commands. It might benefit others if you explain what this means. For example, what is
lsblk
, and what does it do? What does the output mean? Things like that :) -
dthor over 6 years
-
bbodenmiller over 6 years
free -mh
will make it human readable -
AjayKumarBasuthkar over 5 yearswith lubuntu 18.04.1,
sudo fdisk -l
did NOT show swap partition,swapon --show
works fine. -
sancho.s ReinstateMonicaCellio over 5 yearsIt appears that
cat /proc/swaps
is the perennial way of doing this, see answer below. -
Carlo Wood about 4 yearsThe info in /etc/fstab is neither a guarantee nor always available. That file is used to configure a swap during boot and/or running
swapon -a
, but if you added a swap manually then it won't necessarily be in/etc/fstab
. -
sancho.s ReinstateMonicaCellio about 4 years@CarloWood - Good to know. So you say
cat /proc/swaps
is reliable in those cases thatcat /etc/fstab
is not? -
Carlo Wood about 4 yearsYes - I had an empty
/etc/fstab
, but/proc/swaps
still showed me the swap that I just added manually. -
Alex Meiburg almost 3 yearsThis is incorrect, because
free -m
will only show the presence of swap at all; it won't show whether it's a swap file or swap partition. -
Timo almost 3 years
/proc/swaps
shows nothing,free -m
shows swap 0,df
shows nothing,'blkid` shows/dev/sda2
lsblk -o name,fstype,size
showsswap 5 G /dev/sda2
. So I haveswap
but a hidden one? When I dosystemctl hibernate
I getFailed to hibernate system via logind: Not enough swap space for hibernation
. What can I do?cat /proc/meminfo
shows 6 GB of RAM. Is 1 GB of swap space missing? -
Timo almost 3 yearsOn debian I had to
lsblk -o fstype, size
to showswap
. -
Timo almost 3 years@AnotherKiwiGuy,
man lsblk
will give you a starting kick in.