Last active
March 20, 2020 00:10
-
-
Save mttjohnson/ac2c4c562fa1286affcca15867879d00 to your computer and use it in GitHub Desktop.
Resizing/Grow disk partitions on virtual machines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# resize the virtual attached disks | |
# List block storage devices | |
lsblk | |
# List file systems | |
df -Th | |
# List disk devices | |
fdisk -l | |
# List partitions | |
parted -l | |
parted /dev/nvme0n1 unit gb print all | |
parted /dev/sdb1 unit gb print all | |
# List open files | |
lsof | grep /var/www/html | |
lsof | grep /dev/sdb | |
# check nfs | |
systemctl status rpcbind | |
systemctl status nfs-lock | |
systemctl status nfs | |
# stop nfs | |
systemctl stop rpcbind | |
systemctl stop nfs-lock | |
systemctl stop nfs | |
# un-mount partition | |
umount /data | |
umount /var/www/html | |
# resize disk device (not partition) | |
parted /dev/nvme1n1 resizepart 1 100% # resize /dev/nvme1n1 | |
parted /dev/sdb resizepart 1 100% # resize /dev/sdb | |
# show any free space for the disk | |
parted /dev/nvme1n1 print free | |
parted /dev/sdb1 print free | |
# update partition table | |
partprobe /dev/nvme1n1 # re-read partition table | |
partprobe /dev/sdb # re-read partition table | |
# resize file system | |
resize2fs /dev/sdb1 # grow file system ext4 | |
xfs_growfs /dev/nvme1n1p1 # grow file system xfs | |
# start nfs | |
systemctl start rpcbind | |
systemctl start nfs-lock | |
systemctl start nfs | |
# Adjusted partition and formatted drive to use extended space | |
df -Th | |
lsblk | |
umount /data | |
parted -s /dev/nvme1n1 resizepart 1 100% | |
partx -u /dev/nvme1n1 | |
lsblk | |
mount -a | |
xfs_growfs /data | |
# Create a partition and format it for an unpartitioned block device | |
df -Th | |
lsblk | |
parted /dev/sdb mklabel gpt | |
parted -a opt /dev/sdb mkpart primary xfs 0% 100% | |
lsblk | |
mkfs.xfs -L data /dev/sdb1 | |
lsblk --fs | |
blkid -o list | |
mkdir /data | |
echo "/dev/sdb1 /data xfs defaults 0 0" >> /etc/fstab | |
mount -a | |
df -Th |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment