3-4 Add New Partitions and Logical Volumes and Swap to a System Non-Destructively Flashcards
free -m
shows available physical memory and available swap memory
how is swap used
new processes start with physical memory
idle memory from older processes will be allocated over to swap
For swap generally good to use 2x to 2.5x of physical memory ex: 1GB physical so assign 2G or 2.5GB to swap
Best practice to assign swap size as
fdisk
option: n for setting up whole disk
enter for all defaults, will default set size to full disk
option: l (lowercase L) to see labels
option: t to give it label found from l option output list ex: 8e for linux lvm to make swap space
option: w to write changes to disk and exit
pvcreate /dev/xvda
pvdisplay
vgcreate newVolumeGroup1 /dev/xvda (to assign it to new volume group as its made)
vgdisplay
lvcreate -n newNamedLV_Swap (ex Swap) -L 2GB newVolumeGroup1
lvdisplay
How to make an LVM to use to make swap on
format it with swap signature with mkswap command
mkswap /dev/newVolumeGroup1/newNamedLV_Swap
mkswap returns with UUID, which can be used to mount it in fstab
swapon /dev/newVolumeGroup1/newNamedLV_Swap
free -m
swapon does not make it persistent swap storage, it needs to be added to /etc/fstab (similar to mount)
to take off swap mount
swapoff /dev/newVolumeGroup1/newNamedLV_Swap
free -m
How to format LVM (partioned, vg, and lv made. Label added 8e Linux LVM) into swap
Mount it as swap,
check swap space and physical memory
Swap in /etc/fstab
/dev/newVolumeGroup1/newNamedLV_Swap swap swap 0 0
Or
UUID=(UUID from mkswap command, and check blkid) swap swap 0 0
Set swap space mount as persistent
swapon -a
mount all swap entries in /etc/fstab file
fdisk to make mbr partition fdisk /dev/xvda option: n size +2G option: L to see labels, 82 for 'Linux swap / Solaris' option: t to label, put 82 option: w to save and exit
to put swap signature on it
mkswap /dev/xvda
returns with UUID to use in /etc/fstab for persistence
swapon /dev/xvda
free -m
How to make disk into swap space
swapoff -a
Unmounts all swap entries in /etc/fstab
swapon -s
Or
cat /proc/swaps
two ways to check which partitions and files are make up swap