Google Cloud
How to Mount Extra Disks On Google Cloud Engine
In this tutorial, we 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.
Let’s see the steps how to format and mount the extra disk on GCE
Note: Assuming that you have already created engine/instance on GCP with the extra disk.
Steps to format and mount extra disk on Compute Engine/Instance
- Login to the Compute Engine/Instance
- Check which all disk attached to Instance
1 2 3 4 5 |
$ sudo lsblk Or $sudo fdisk –l |
1 2 3 4 5 |
[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 |
- Now create filesystem by formatting the extra disk with ext4
1 |
$sudo mkfs –t ext4 /dev/sdb |
- Create a directory to mount this new extra-disk which we have formatted
1 |
$ sudo mkdir –p /oraprod |
- Mount the disk to the directory “/oraprod”
1 |
$ sudo mount –t ext4 /dev/sdb /oraprod |
- You can change the directory permission. Assum you want to provide write permission to all user on “/oraprod” then run below command.
1 |
$ sudo chmod a+w /oraprod |
- Command to verify the disk mount
1 2 3 4 5 6 7 8 9 10 11 |
$ df –h <span style="color: #666699;">#Output</span> [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
Before adding/changing fstab file best practice is to take backup.
1 |
$ sudo cp /etc/fstab /etc/fstab-backup |
Edit fstab file “/etc/fstab” and add disk and mount point with filesystem as mention:
1 2 |
$ 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.
This is how to Mount Extra Disks On Google Cloud Engine.