Enabling swap on LMDE (Solved)

Archived topics about LMDE 1 and LMDE 2
Locked
AlanWalker

Enabling swap on LMDE (Solved)

Post by AlanWalker »

When I installed LMDE I pre-partitioned my system's HD; this is how it looks.

When I installed LMDE I thought that Linux would recognize the swap partition, and use it; but now I see that that isn't so.

That fact leads me to ask 'How does one enable LMDE's use of a swap partition when that partition is alread defined?'

TIA
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
kyphi
Level 9
Level 9
Posts: 2735
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter Valley, Australia

Re: Enabling swap on LMDE

Post by kyphi »

When I installed LMDE I thought that Linux would recognize the swap partition, and use it; but now I see that that isn't so.
How so?
According to the image you posted the swap partition is recognised as shown in gparted.

You can also use

Code: Select all

inxi -plu
in a terminal to see your swap partition.
Linux Mint 21.3 Cinnamon
AlanWalker

Re: Enabling swap on LMDE

Post by AlanWalker »

kyphi wrote:
When I installed LMDE I thought that Linux would recognize the swap partition, and use it; but now I see that that isn't so.
How so?
According to the image you posted the swap partition is recognised as shown in gparted.

You can also use

Code: Select all

inxi -plu
in a terminal to see your swap partition.
To answer your question, I used gparted on a live CD. I formatted sda2 as swap when I did so; I now believe doing so unintentionally masks the situation.

Output of inxi -plu:

alan@lmde1 ~ $ inxi -plu
Partition: ID: / size: 58G used: 16G (28%) fs: ext3 dev: /dev/sda1
label: N/A uuid: cb82582b-c476-49f2-baa6-89b9b99e4894
ID: /home size: 168G used: 16G (10%) fs: ext3 dev: /dev/sda3

As it may help, this is how how my /etc/fstab looks.
Last edited by AlanWalker on Mon May 05, 2014 8:26 pm, edited 2 times in total.
User avatar
kyphi
Level 9
Level 9
Posts: 2735
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter Valley, Australia

Re: Enabling swap on LMDE

Post by kyphi »

I see what you mean. Using inxi -l this is what I have (our partitioning looks similar except for swap):

Partition: ID: / size: 12G used: 5.0G (45%) fs: ext4 dev: /dev/sda1 label: N/A
ID: /home size: 95G used: 37G (41%) fs: ext4 dev: /dev/sda3 label: N/A
ID: swap-1 size: 4.29GB used: 0.00GB (0%) fs: swap dev: /dev/sda2 label: N/A
Linux Mint 21.3 Cinnamon
User avatar
kyphi
Level 9
Level 9
Posts: 2735
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter Valley, Australia

Re: Enabling swap on LMDE

Post by kyphi »

This should have been sorted out during installation regardless of what you did with the live DVD.

http://www.cyberciti.biz/faq/linux-add- ... ile-howto/
Linux Mint 21.3 Cinnamon
AlanWalker

Re: Enabling swap on LMDE

Post by AlanWalker »

kyphi wrote:This should have been sorted out during installation regardless of what you did with the live DVD.

http://www.cyberciti.biz/faq/linux-add- ... ile-howto/
As it happens I had previously looked at the page you cite while
researching this problem. I moved on as the instructions were for
creating a swap file in "/". As you cited that page I decided to take
a closer look and try altering commands to work with a swapfile
on sda2.

Following on your cite (with alters to suit my system) I prepared
the following list of commands to setup my system to use swap:

1. dd if=/dev/zero of=/sda2/swapfile
2. mkswap /sda2/swapfile
3. chown root:root /sda2/swapfile
4. chmod 0600 /sda2/swapfile
5. swapon /sda2/swapfile

Command in Line 1. above is intended to create and zero out a file on
sda2 instead of "/".

Proceeding as per above, and as root, I entered the command:

"dd if=/dev/zero of=/sda2/swapfile"

The system responded with:

"dd: failed to open ‘/sda2/swapfile’: No such file or directory"

Is this because sda2 isn't mounted?
User avatar
martywd
Level 3
Level 3
Posts: 147
Joined: Sun May 08, 2011 10:35 am
Location: TX

Re: Enabling swap on LMDE

Post by martywd »

@AlanWalker

In a Terminal Window run this command:

Code: Select all

sudo blkid
Add the following line to your '/etc/fstab' file using the UUID obtained from the 'blkid' command for your 'swap' partition in place of my example (xxxxxxxxxyyyyyyyyyyyyyyyzzzzzzzzzzz):

Code: Select all

UUID=xxxxxxxxxyyyyyyyyyyyyyyyzzzzzzzzzzz	none	swap	sw	0	0
Save the '/etc/fstab' file.

Run the following command:

Code: Select all

sudo swapon -a
Or REBOOT.

To check status of your 'swap' partition, run this command:

Code: Select all

sudo swapon -s
.
User avatar
kyphi
Level 9
Level 9
Posts: 2735
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter Valley, Australia

Re: Enabling swap on LMDE

Post by kyphi »

Depending on how much RAM you have installed, the absence of a swap partition may not be all that important.

I understand that you used gparted from the live DVD but have you got it installed now? If so, in gparted click on the swap partition and then open Partition from the top menu. That should state that the swap partition is "Active" and also its UUID.
If necessary edit your /etc/fstab file with sudo and enter the UUID followed by "none swap sw 0 0" so that it looks similar to this:

# swap was on /dev/sda2 during installation
UUID=fec38302-1ex8-415c-af12-f63e9428b491 none swap sw 0 0

Save before exit. the "none" entry refers to the mount point (swap is not mounted).
Linux Mint 21.3 Cinnamon
AlanWalker

Re: Enabling swap on LMDE

Post by AlanWalker »

martywd wrote:@AlanWalker

In a Terminal Window run this command:

Code: Select all

sudo blkid
Add the following line to your '/etc/fstab' file using the UUID obtained from the 'blkid' command for your 'swap' partition in place of my example (xxxxxxxxxyyyyyyyyyyyyyyyzzzzzzzzzzz):

Code: Select all

UUID=xxxxxxxxxyyyyyyyyyyyyyyyzzzzzzzzzzz	none	swap	sw	0	0
Save the '/etc/fstab' file.

Run the following command:

Code: Select all

sudo swapon -a
Or REBOOT.

To check status of your 'swap' partition, run this command:

Code: Select all

sudo swapon -s
.
That did it! :D

Thanks.
AlanWalker

Re: Enabling swap on LMDE (Solved)

Post by AlanWalker »

kyphi wrote:Depending on how much RAM you have installed, the absence of a swap partition may not be all that important.

I understand that you used gparted from the live DVD but have you got it installed now? If so, in gparted click on the swap partition and then open Partition from the top menu. That should state that the swap partition is "Active" and also its UUID.
If necessary edit your /etc/fstab file with sudo and enter the UUID followed by "none swap sw 0 0" so that it looks similar to this:

# swap was on /dev/sda2 during installation
UUID=fec38302-1ex8-415c-af12-f63e9428b491 none swap sw 0 0

Save before exit. the "none" entry refers to the mount point (swap is not mounted).
I've 1.9gb of available ram on this system (Lenovo T500) and I've never seen more than 60% of it in use at the most demanding of times. I was interested in how to enable swap because I was irked that space had been made available but not usable.

So! I've learned several new things from you and martywd. Time to add them to my notes. :D

I'll be back (I have other questions).

Thanks!
User avatar
martywd
Level 3
Level 3
Posts: 147
Joined: Sun May 08, 2011 10:35 am
Location: TX

Re: Enabling swap on LMDE

Post by martywd »

AlanWalker wrote: That did it! :D

Thanks.
Glad it worked for ya.

One thing I should have added. If you haven't done so already, comment out with '#' at the beginning of that _old_ '/dev/sda2' line in your '/etc/fstab' file.

Code: Select all

/dev/sda2      Unknown      defaults     0     0
It might cause you headaches on boot up or reboots otherwise.

And. Edit the title of this post to add: [Solved] if you feel inclined?
.
AlanWalker

Re: Enabling swap on LMDE

Post by AlanWalker »

martywd wrote:
AlanWalker wrote: That did it! :D

Thanks.
Glad it worked for ya.

One thing I should have added. If you haven't done so already, comment out with '#' at the beginning of that _old_ '/dev/sda2' line in your '/etc/fstab' file.

Code: Select all

/dev/sda2      Unknown      defaults     0     0
It might cause you headaches on boot up or reboots otherwise.

And. Edit the title of this post to add: [Solved] if you feel inclined?
.
Done on both counts.

Thanks.
Locked

Return to “LMDE Archive”