In this tutorial, we’ll explain how to Mount Extra Disks On Google Cloud Engine (GCE) / (VM Instance). If you launch Engine/Instance in GCP (Google Cloud Platform) by default extra disk is attached but you cannot use it directly. You need to format the disk and create filesystem like if it is Linux then create an ext3/ext4/xfs filesystem and if it is windows then create the NTFS file system. In short, the filesystem needs to created by formatting the disk.
Steps to Mount Extra Disks On Google Cloud Engine
Let’s see the steps how to format and mount the extra disk on GCE
Steps to format and mount extra disk on Compute Engine/Instance
Step 1: Log in to the Compute Engine/Instance
Step 2: Check which all disk attached to Instance
$ sudo lsblk Or $sudo fdisk –l
In the below output you can see the extra disk will not have an entry under the mount point tab.
[sysadmin@dev ~]$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8: 10G disk └─sda1 8:1 10G part / sdb 8:16 20G disk
Step 3: Now create filesystem by formatting the extra disk with ext4
$sudo mkfs –t ext4 /dev/sdb
Step 4: Create a directory to mount this new extra-disk which we have formatted
$ sudo mkdir –p /oraprod
Step 5: Mount the disk to the directory “/oraprod”
$ sudo mount –t ext4 /dev/sdb /oraprod
Step 6: You can change the directory permission. Assume you want to provide write permission to all users on “/oraprod” then run below command.
$ sudo chmod a+w /oraprod
Step 7: Command to verify the disk mount
$ df –h
#Output
[sysadmin@dev]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 842M 842M % /dev
tmpfs 849M 849M % /dev/shm
/dev/sda1 10G 2.3G 7.8G 23% /
/dev/sdb 20G 45M 20G 1% /oraprod
[sysadmin@dev]$
Steps to automount disk whenever Linux reboot
You can automount disk on whenever you reboot your Linux machine. so for that, you need to add an entry in fstab
Step 1: Before adding/changing fstab file best practice is to take backup.
$ sudo cp /etc/fstab /etc/fstab-backup
Step 2: Edit fstab file “/etc/fstab” and add disk and mount point with filesystem as mention:
$ vi /etc/fstab /dev/sdb /oraprod /ext4 defaults 0 0
This is how to automount the extra disk on Linux, now on every reboot disk is automounted to the defined directory as mention in fstab file.
End of the tutorial, This is how to Mount Extra Disks On Google Cloud Engine.
Thanks for reading this article, you’ll also like to read below articles.