Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using LVM on Linux and resize swap partition
# RESCAN FOR NEWLY ADDED HDS
echo "- - -" > /sys/class/scsi_host/host#/scan
fdisk -l
# NEW LOGICAL VOLUME
sudo fdisk /dev/sdb
# then create a new partition of type 8e (Linux LVM)
# create a phisical volume
sudo pvcreate /dev/sdb1
# create new volume group
sudo vgcreate vgpool /dev/sdb1
# create logical volume
sudo lvcreate -L 3G -n lvstuff vgpool
# format new volume
sudo mkfs -t ext3 /dev/vgpool/lvstuff
# ENJOY
# RESIZE A SWAP PARTITION
# Create a physical volume on new disk
sudo pvcreate /dev/sdb
# Show volume groups
sudo vgdisplay
# Extend volume groups
sudo vgextend vg-name /dev/sdb
# Resize swap partition
sudo lvresize -L 2G /dev/mapper/xxxx-swap_1
# Turn off swap
sudo swapoff -a
# Re-make swap
sudo mkswap /dev/mapper/xxxx-swap_1
# Turn on swap again
sudo swapon -a
# BONUS
# re-size a non swap partition
sudo resize2fs /dev/mapper/xxx-noswap
https://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-expanding-the-virtual-machine-disk/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment