The easiest way to connect local SSDs to your instance is to format and mount each device with a single partition.
Format and mount the new local SSD on your Linux instance. You can use any partition format and configuration that you need. For this example, create a single ext4 partition.
-
Go to the VM instances page.
-
Click the SSH button next to the instance that has the new attached local SSD. The browser opens a terminal connection to the instance.
-
In the terminal, use the lsblk command to identify the local SSD that you want to mount.
$ lsblk
Local SSDs in SCSI mode have standard names like sdb. Local SSDs in NVMe mode have names like nvme0n1, as shown in the NAME column of the following output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10G 0 disk
└─sda1 8:1 0 10G 0 part /
nvme0n1 259:0 0 375G 0 disk
-
Format the local SSD with an ext4 file system. This command deletes all existing data from the local SSD.
$ sudo mkfs.ext4 -F /dev/[SSD_NAME]
Replace [SSD_NAME] with the ID of the Local SSD that you want to format. For example, specify nvme0n1 to format the first NVMe Local SSD on the instance.
-
Use the mkdir command to create a directory where you can mount the device.
$ sudo mkdir -p /mnt/disks/[MNT_DIR]
where: [MNT_DIR] is the directory where you want to mount your local SSD.
-
Mount the local SSD to the instance. Optionally, you can disable write cache flushing to improve write performance while risking reduced durability for up to two seconds of cached data writes.
$ sudo mount /dev/[SSD_NAME] /mnt/disks/[MNT_DIR]
where:
-
Configure read and write access to the device. For this example, grant write access to the device for all users.
$ sudo chmod a+w /mnt/disks/[MNT_DIR]
where: [MNT_DIR] is the directory where you mounted your local SSD.
For more info refer to https://cloud.google.com/compute/docs/disks/local-ssd#formatandmount