Swap space: Difference between revisions
New page: Working with swap space: Creating swap space ---- In order to get a partition to be swapspace you have to fdisk it as swapspace (type 82), then make it into swap space using mkswap -L ... |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
Working with swap space: | Working with swap space: | ||
Creating swap space | =Creating swap space= | ||
In order to get a partition to be swapspace you have to fdisk it as swapspace (type 82), then make it into swap space using | In order to get a partition to be swapspace you have to fdisk it as swapspace (type 82), then make it into swap space using | ||
Line 21: | Line 20: | ||
Removing swapspace | =Removing swapspace= | ||
If it's on a logical volume, first | If it's on a logical volume, first | ||
Line 44: | Line 42: | ||
shows all the devices and if there are files open on it. | shows all the devices and if there are files open on it. | ||
dmsetup info -c | dmsetup info -c edgarghost-swap_1 | ||
shows the specific device (-c optional) | shows the specific device (-c optional) | ||
dmsetup remove --force | dmsetup remove --force edgarghost-swap_1 | ||
should reset the open file count to 0 (even if it gives a failure) then you can | should reset the open file count to 0 (even if it gives a failure) then you can | ||
dmsetup remove | dmsetup remove edgarghost-swap_1 | ||
again. | again. | ||
Line 65: | Line 63: | ||
and then reboot. | and then reboot. | ||
= testing swapspace by using it= | |||
vi memeater.c | |||
<pre> | |||
#include <unistd.h> | |||
#include <stdlib.h> | |||
#include <stdio.h> | |||
#include <string.h> | |||
int main(int argc, char** argv) { | |||
int max = -1; | |||
int mb = 0; | |||
char* buffer; | |||
if(argc > 1) | |||
max = atoi(argv[1]); | |||
while((buffer=malloc(1024*1024)) != NULL && mb != max) { | |||
memset(buffer, 0, 1024*1024); | |||
mb++; | |||
printf("Allocated %d MB\n", mb); | |||
sleep(1); | |||
} | |||
return 0; | |||
} | |||
</pre> | |||
gcc memeater.c -o memeater | |||
memeater |
Latest revision as of 08:54, 11 April 2018
Working with swap space:
Creating swap space
In order to get a partition to be swapspace you have to fdisk it as swapspace (type 82), then make it into swap space using
mkswap -L label /dev/sdc1
Once you have done this you enter it into /etc/fstab as
/dev/sdc1 none swap sw 0 0
and then activate it by
swapon -L label
or
swapon -a
Removing swapspace
If it's on a logical volume, first
swapoff -a
or swapoff -L label
then with
swapon -s
you can check which devices are being used for swap.
uncomment it from the /etc/fstab. Should lvm / LVM lvremove give you shit about it being busy you can try dmtools. Unmount the device first, check lsof and fuser as well.
dmsetup uses the /dev/mapper names, not /dev/pvname/lvname.
dmsetup info -c
shows all the devices and if there are files open on it.
dmsetup info -c edgarghost-swap_1
shows the specific device (-c optional)
dmsetup remove --force edgarghost-swap_1
should reset the open file count to 0 (even if it gives a failure) then you can
dmsetup remove edgarghost-swap_1
again.
If none of this works, you can see what's in
/etc/initramfs-tools/conf.d/resume
change the device and then do
update-initramfs -u
and then reboot.
testing swapspace by using it
vi memeater.c
#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> int main(int argc, char** argv) { int max = -1; int mb = 0; char* buffer; if(argc > 1) max = atoi(argv[1]); while((buffer=malloc(1024*1024)) != NULL && mb != max) { memset(buffer, 0, 1024*1024); mb++; printf("Allocated %d MB\n", mb); sleep(1); } return 0; }
gcc memeater.c -o memeater
memeater