Created
March 20, 2018 19:11
-
-
Save jeongho/a3f36444e2d68015a1ebd4faeb69dbc4 to your computer and use it in GitHub Desktop.
GCP Adding or Resizing Persistent Disks
This file contains 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
#https://cloud.google.com/compute/docs/disks/add-persistent-disk | |
#Formatting and mounting a persistent disk | |
sudo lsblk | |
sudo mkfs.ext4 -m 0 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/[DEVICE_ID] | |
sudo mkdir -p /mnt/disks/[MNT_DIR] | |
sudo mount -o discard,defaults /dev/[DEVICE_ID] /mnt/disks/[MNT_DIR] | |
sudo chmod a+w /mnt/disks/[MNT_DIR] | |
sudo cp /etc/fstab /etc/fstab.backup | |
sudo blkid /dev/[DEVICE_ID] | |
echo UUID=`sudo blkid -s UUID -o value /dev/sdb` /mnt/disks/disk-1 ext4 discard,defaults,nofail 0 2 | sudo tee -a /etc/fstab | |
cat /etc/fstab | |
#Resizing the file system and partitions on a persistent disk | |
df -h | |
sudo lsblk | |
#If the disk that you want to resize has a partition table, you must grow the partition before you resize the file system. Use growpart to resize your image partition. Not all images include growpart in their utilities, so you might need to install it. | |
sudo growpart /dev/[DISK_ID] [PARTITION_NUMBER] | |
#Extend the file system on the disk or the partition to use the added space. If you grew a partition on your disk, specify the partition. If your disk does not have a partition table, specify only the disk ID. | |
sudo resize2fs /dev/[DISK_ID][PARTITION_NUMBER] | |
#If you are using XFS, use the xfs_growfs command to extend the file system: | |
sudo xfs_growfs /dev/[DISK_ID][PARTITION_NUMBER] | |
df -h /dev/[DISK_ID] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment