How To Mount Extra Disks on Google Cloud VM Instance

By default, the new disks attached during the instance creation cannot be used directly. You need to format and mount it to your instance to put that in use.

In this article, we will explain how to format and mount an extra disk to your google compute engine VM instance.

Note: We assume that you have created the VM instance with an extra disk attached to it.

Formatting and Mounting Extra Disk on VM Instance

1. Login to the instance and list the available extra disk using the following command.

An example output is shown below. All the extra disks will not have any entry under the MOUNTPOINT tab. Here, sdb is the extra disk that has to be formatted and mounted.

2. Next, we should format the disk to ext4 using the following command. In the below command we are mentioning /dev/sdb as that is the extra disk available.

3. Next, create a mount directory on the instance as shown below. You can replace the /demo-mount with a custom name and path you prefer.

4. Now, mount the disk to the directory we created using the following command.

5. If you want write permissions to this disk for all the users, you can execute the following command. Or, based on the privileges you need for the disk, you can apply the user permissions.

6. Check the mounted disk using the following command.

A sample output,

Automount Disk On Reboot

To automount the disk on system start or reboots, you need to add the mount entry to the fstab. Follow the steps given below for adding the mount to fstab.

1. First, back up the fstab file.

2. Execute the following command to make a fstab entry with the UUID of the disk.

2. Check the UUID of the extra disk

3. Open fstab file and check for the new entry for the UUID of the extra disk

Now, on every reboot, the disk will automatically mount to the defined folder based on the fstab entry.

Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.