Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dealing with filesytems resizing
# 1 - Report file system disk space usage
# note: -h: human readable. print sizes in power of 1024.
$ df -h
# would print:
# Filesystem Size Used Avail Use% Mounted on
# udev 7.7G 0 7.7G 0% /dev
# tmpfs 1.6G 9.0M 1.6G 1% /run
# /dev/nvma1n1p1 59G 34G 25G 59% /
# tmpfs 7.7G 0 7.7G 0% /dev/shm
# tmpfs 5.0M 0 5.0M 0% /run/lock
# tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
# 2 - List block devices
$ lsblk
# NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
# nvma1n1 259:0 0 75G 0 disk
# └─nvma1n1p1 259:1 0 75G 0 part /
# 3 - List the filesystems type
$ df -Th
# Filesystem Type Size Used Avail Use% Mounted on
# udev devtmpfs 7.7G 0 7.7G 0% /dev
# tmpfs tmpfs 1.6G 9.0M 1.6G 1% /run
# /dev/nvma1n1p1 ext4 59G 34G 25G 59% /
# tmpfs tmpfs 7.7G 0 7.7G 0% /dev/shm
# tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
# tmpfs tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
# tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/1000
# 4 - Expand the partition size
$ sudo growpart /dev/nvma1n1 1
# 5 - Resizing ext4 filesystems
$ sudo resize2fs /dev/nvma1n1p1
# Filesystem at /dev/nvma1n1p1 is mounted on /; on-line resizing required
# old_desc_blocks = 4, new_desc_blocks = 5
# The filesystem on /dev/nvma1n1p1 is now 19660539 (4k) blocks long.
# 6 - Confirm the resizing
$ df -h
# Filesystem Size Used Avail Use% Mounted on
# udev 7.7G 0 7.7G 0% /dev
# tmpfs 1.6G 9.0M 1.6G 1% /run
# /dev/nvma1n1p1 73G 34G 39G 47% /
# tmpfs 7.7G 0 7.7G 0% /dev/shm
# tmpfs 5.0M 0 5.0M 0% /run/lock
# tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
# tmpfs 1.6G 0 1.6G 0% /run/user/1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment