Skip to content

Instantly share code, notes, and snippets.

@willjasen
Last active February 24, 2025 01:12
Show Gist options
  • Save willjasen/8577ae2201724513bcf79c0b3a484d78 to your computer and use it in GitHub Desktop.
Save willjasen/8577ae2201724513bcf79c0b3a484d78 to your computer and use it in GitHub Desktop.
# Variables
DISK=da0;
ROOT_PART_NUM=3;
SWAP_PART_NUM=4;
ROOT_FS=/dev/gpt/rootfs;
SWAP_FS=/dev/gpt/swapfs;
SWAP_PART="/dev/${DISK}p${SWAP_PART_NUM}"
# Show info
gpart show;
swapinfo;
# Turn off swap
swapoff -a;
# edit /etc/fstab so the swap partition doesn't mount
# $SWAP_PART none swap sw 0 0;
# Delete the swap partition
gpart delete -i $SWAP_PART_NUM $DISK;
# Extend the root partition
growfs -y $ROOT_FS;
# Resize the root partition to 32G
gpart resize -i $ROOT_PART_NUM -s 32G $DISK;
# Make a swap parition of 3500 Megabytes at the end of the disk
gpart add -t freebsd-swap -s 3500M $DISK;
# Turn on swap
swapon $SWAP_PART;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment