Lesson 4.6: Add new partitions and logical volumes, and swap to a system non-destructively


Format the newly created disk partition with SWAP filesystem

[root@server dev]# mkswap /dev/nvme0n2p3
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=8d24af54-42be-455c-ab9f-c7fa9e85b9ff
 
[root@server dev]# free -h 
               total        used        free      shared  buff/cache   available
Mem:           3.5Gi       1.0Gi       1.9Gi        25Mi       808Mi       2.5Gi
Swap:          2.0Gi          0B       2.0Gi
[root@server dev]# 

Activate the newly created SWAP Partition

Temporary Activation

[root@server dev]# swapon /dev/nvme0n2p3 
[root@server dev]# free -h 
               total        used        free      shared  buff/cache   available
Mem:           3.5Gi       1.0Gi       1.9Gi        25Mi       808Mi       2.5Gi
Swap:          3.0Gi          0B       3.0Gi

Deactivation

[root@server dev]# swapoff /dev/nvme0n2p3 
[root@server dev]# free -h 
               total        used        free      shared  buff/cache   available
Mem:           3.5Gi       1.0Gi       1.9Gi        25Mi       808Mi       2.5Gi
Swap:          2.0Gi          0B       2.0Gi

Permanent Activation

[root@server dev]# vim /etc/fstab 
/dev/nvme0n2p3                                  none    swap    defaults        0       0
 
[root@server dev]# free -h 
               total        used        free      shared  buff/cache   available
Mem:           3.5Gi       1.0Gi       1.9Gi        25Mi       812Mi       2.5Gi
Swap:          2.0Gi          0B       2.0Gi
 
# Updating the SWAP
[root@server dev]# swapon -a 
 
# Viewing the SWAP 
[root@server dev]# free -h 
               total        used        free      shared  buff/cache   available
Mem:           3.5Gi       1.0Gi       1.9Gi        25Mi       812Mi       2.5Gi
Swap:          3.0Gi          0B       3.0Gi
 
[root@server dev]# lsblk 
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sr0          11:0    1 1024M  0 rom  
nvme0n1     259:0    0   20G  0 disk 
├─nvme0n1p1 259:1    0  600M  0 part /boot/efi
├─nvme0n1p2 259:2    0    1G  0 part /boot
└─nvme0n1p3 259:3    0 18.4G  0 part 
  ├─cs-root 253:0    0 16.4G  0 lvm  /
  └─cs-swap 253:1    0    2G  0 lvm  [SWAP]
nvme0n2     259:4    0    5G  0 disk 
├─nvme0n2p1 259:5    0   50M  0 part /data1
├─nvme0n2p2 259:6    0  100M  0 part /data2
└─nvme0n2p3 259:8    0    1G  0 part [SWAP]
nvme0n3     259:7    0    6G  0 disk 
All systems normal

© 2025 2023 Sanjeeb KC. All rights reserved.