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