linux_wiki:add_new_partitions_and_logical_volumes_and_swap_to_a_system_non-destructively

This is an old revision of the document!


Add New Partitions And Logical Volumes And Swap To A System Non-destructively

General Information

About this page/how-to/script.


Logical Volume Method
Create new partition with the Logical Volume type

fdisk /dev/sdb
n
Partition type: primary
Partition number: 1
First sector: default
Last sector: +1G
t
Hex code: 8e
w

Setup LVM physical volume, volume group, logical volume

pvcreate /dev/sdb1
vgcreate vglocal /dev/sdb1
lvcreate -n lvswap -L 1G vglocal

Format logical volume with swap, enable, and add to fstab

mkswap /dev/mapper/vglocal-lvswap
swapon /dev/mapper/vglocal-lvswap
 
vim /etc/fstab
 
/dev/mapper/vglocal-lvswap  swap  swap  sw  0 0


Physical Partition Method
Create physical disk partition for swap

fdisk /dev/sdb
n
Partition type: primary
Partition number: 2
First sector: default
Last sector: +1G
t
Hex code: 82
w
  • Hex code 82 is Linux Swap

Create the swap filesystem

mkswap /dev/sdb2
swapon /dev/sdb2
  • edit /etc/fstab if you want persistent changes

View swap space

swapon -s

Activate all swap on /etc/fstab

swapon -a
  • Turn off swap with: swapoff /dev/<devname> or swapoff -a

  • linux_wiki/add_new_partitions_and_logical_volumes_and_swap_to_a_system_non-destructively.1456799583.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)