Format and Mount a Persistent Disk


In this tutorial, we are going to see, how to format the persistent disk and mount the disk volume to the existing VM instance in Compute Engine. Please follow the previous tutorial if you want to create a new persistent disk and attach the persistent disk to the running instance. If you want to have a look at the GCE storage concept, please visit this page

Once the new persistent disk is created and attached to the running instance, then it requires the below steps to format before it turns to access the filesystem. 

As per the GCE guideline, it is recommended to have a single partition for a persistent disk. However, we can also have multiple partitions in a single disk. In this tutorial, we will go ahead to create a single partition with ext4 filesystem. 

Login into the VM instance using the SSH method. 

datacloudies persistent disk

Switch to root user and list the attached disk in the instance.

lsblk

datacloudies persistent disk

Format the newly attached disk using the mkfs command. 

mkfs.ext4 -m 0 -F -E lazy_itable_init=0  /dev/sdb

datacloudies persistent disk

Formatting is complete. Now, mount the formatted disk to a directory. 

Create a directory,

mkdir /mnt/disk-1

Mount the disk,

mount -o  defaults /dev/sdb /mnt/disk-1

To make the RW permissions for users, change the permission as below,

chmod a+w /mnt/disk-1

Check the new filesystem using df -h command

datacloudies persistent disk

/mnt/disk-1 filesystem is created with a single partition on /dev/sdb device. Keep in mind that, when you create a new persistent disk, it should be in the same zone of the instance. 

Now the filesystem is ready to use for data storage. Please do visit the other tutorials for handling the VM customizations. Thank you

Recent Posts

  • Cloud SQL
    What is Cloud SQL  It is a fully managed relational database service for PostgreSQL and MySQL database in the GCP. MySQL instance can be...
    May 17 2020 | Read more
  • Deploy an application to Google Kubernetes Engine
    Welcome back, this is the continuation post of the previous article, where we have discussed the Kubernetes and its concepts in detail. In this...
    May 13 2020 | Read more
  • Google Kubernetes Engine
    What is GKE? GKE is a managed, production-ready environment for deploying containerized applications. It is like a managed cargo container in...
    May 13 2020 | Read more
  • Google App Engine – Flexible
    In the previous article, we have discussed what is google app engine and how to deploy the application in the Google app engine – Standard. In...
    May 10 2020 | Read more