SWAP PARTITION
SWAP PARTITION
A swap partition is a designated space on a computer's hard drive (or SSD) that is used by the
operating system as virtual memory. When the physical RAM (Random Access Memory) in a
computer is fully utilized, the operating system moves inactive or less frequently used data from
RAM to the swap partition. This frees up RAM for other tasks and prevents the system from
becoming sluggish or crashing due to lack of memory
swapon Command
Use the swapon command to activate a swap partition or to show the details about an
existing one. Follow the steps below:
Command:swapon –show
free Command
The free command provides information about memory usage in the system,
including virtual memory. Run the following command:
free -m
Steps:
1. Run the fdisk command for the disk you want to partition:
The output provides information about the available disk space for a new partition. If
the last partition ends before the last sector of the hard drive, there is enough space
to create a new partition. The output above shows the entire disk space is available
for creating a new partition.
3. Type n and press Enter to create a new partition. For partition type, enter p and
press Enter.
4. Set the partition number (or keep the default number 1) and press Enter to confirm.
. Enter the first available sector for the new partition and press Enter. You can also
keep the default one offered.
6. Set the last available sector for the partition. You can specify the partition size in
KiB, MiB, or GiB units. We will create a swap partition of 1GiB, so the command is:
+1G
8. By default, the partition type is 83, while 82 is a partition type identifier for swap
space.
Type t and press Enter to change the partition type. Change the value to 82 and
press Enter.
10. fdisk doesn't make any changes to the disk before confirmation. To proceed
with the changes, type w, and press Enter.
13. Use the mkswap command to format the partition for swap space. The command
writes a swap signature in the partition, leaving the rest unformatted. The
unformatted space stores the memory pages.
Use the following syntax to format the partition and create a swap space:
vim /etc/fstab
mount -a[permanent mounting applied]
dd->deleted
i->insert
esc=to come out
:wq!
step 1:- adding hard disk
step 2:- lsblk (check wether disk added or not)
step 3:- fdisk /dev/sda
n
1
default (press enter)
+3G
t (82)
w
step 4:- partprobe (to update partition table)
step 5:- lsblk
vim /etc/fstab
go to the last line and then press i to enter into insert mode