managing swap
Create and manage swap spaces to supplement physical memory.
Task 1:
Make a swap partition having 100MB. Make automatically usable at system boot time.
Solution:
fdisk /dev/sdX
n
p
1
enter
+101M
t
82
w
mkswap /dev/sda1
swapon /dev/sda1
vim /etc/fstab
/dev/sda1 swap swap defaults 0 0
Task 2:
Add an additional swap partition of 656MiB to your system. The swap partition should be mount when your system boots. Do not remove or otherwise alter any existing swap partition on your system.
Solution:
fdisk /dev/sda
n
p
2
enter
+656M
t
82
w
mkswap /dev/sda2
swapon /dev/sda2
vim /etc/fstab
/dev/sda2 swap swap defaults 0 0
swapon -s
Task 3:
Create a 2G swap partition which take effect automatically at boot-start, and it should not affect the original swap partition.
Solution:
fdisk /dev/sda
n
p
1
enter
+2G
t
82
w
mkswap /dev/sda1
swapon /dev/sda2
swapon -s
vim /etc/fstab
/dev/sda1 swap swap defaults 0 0
swapon -s
Task 4:
Create a swap space, set the size is 600MB, and make it be mounted automatically after rebooting the system (permanent mount).
Solution:
fdisk /dev/sda
n
p
1
enter
+600M
t
82
w
partprobe
mkswap /dev/sda1
swapon /dev/sda1
vim /etc/fstab
/dev/sda1 swap swap defaults 0 0
mount -a
Last updated
Was this helpful?