Adding Local SSDs

Compute Engine offers always-encrypted local solid-state drive (SSD) block storage for virtual machine instances. Each local SSD is 375 GB in size, but you can attach up to eight local SSD devices for 3 TB of total local SSD storage space per instance . Optionally, you can format and mount multiple local SSD devices into a single logical volume.

Unlike persistent disks, local SSDs are physically attached to the server that hosts your virtual machine instance. This tight coupling offers superior performance, very high input/output operations per second (IOPS), and very low latency compared to persistent disks. See Persistent Disk and Local SSD Performance for details.

Local SSDs are suitable only for temporary storage such as caches, processing space, or low value data. If you store important data in a Local SSD device, you must also store that same data in a durable storage option.

You cannot stop and restart an instance that has a local SSD. If you do shut down an instance with a Local SSD through the guest operating system, you will not be able to restart the instance and the data on the Local SSD will be lost.

If Local SSDs do not meet your redundancy or flexibility requirements, you can use local SSDs in combination with other instance storage options.

Before you begin

Understanding Local SSD data persistence

Before you create an instance with a local SSD, you must understand what events preserve your Local SSD data and what events can cause your Local SSD data to be unrecoverable.

Data on Local SSDs persists only through the following events:

  • If you reboot the guest operating system.
  • If you configure your instance for live migration and the instance goes through a host maintenance event.
  • If the host system experiences a host error, Compute Engine attempts to preserve local SSD data, but it is only able to do so if the underlying drive recovers within 60 minutes.

Data on Local SSDs does not persist through the following events:

  • If you terminate your instance manually.
  • If you shut down the guest operating system and force the instance to stop.
  • If you configure the instance to be preemptible and the instance goes through the preemption process.
  • If you configure the instance to terminate on host maintenance events and the instance goes through a host maintenance event.
  • If the host system experiences a host error, and the underlying drive does not recover within 60 minutes, Compute Engine does not attempt to preserve the data on your Local SSD.
  • If you misconfigure the local SSD so that it becomes unreachable.

Create an instance with a local SSD

Because local SSDs are located on the physical machine where your virtual machine instance is running, they can be created only during the instance creation process. Local SSDs cannot be used as boot devices.

After creating a local SSD, you must format and mount the device before you can use it.

Selecting the NVMe or SCSI interfaces

Local SSDs can use either an NVMe or SCSI interface to communicate with the instance where it is attached. You can use either interface with any instance as long as the boot disk image has functional drivers, but the following public images include optimized drivers that work best with NVMe:

  • ubuntu-1404-trusty-v20170110 and newer or image family ubuntu-1404-lts
  • ubuntu-1604-xenial-v20170113 and newer or image family ubuntu-1604-lts
  • ubuntu-1610-yakkety-v20170103 and newer or image family ubuntu-1610

Other public images include NVMe drivers, but they do not perform as well as the images that include the optimized NVMe drivers.

Creating a local SSD

You can create an instance with a local SSD using the Google Cloud Platform Console, the gcloud tool, or the API.

Console


  1. In the Cloud Platform Console, go to the VM Instances page.

    Go to the VM Instances page

  2. Click the Create instance button.
  3. On the Create a new instance page, fill in the desired properties for your instance.
  4. Expand Management, disk, networking, SSH keys.
  5. Click Disks and under Additional disks, click Add item.
  6. In the Name field, select Create a new disk from the dropdown menu.
  7. In the popup screen, choose Local SSD under Disk Type.
  8. Click the Create button to create the instance.
  9. After creating a local SSD, you must format and mount the device before you can use it.

gcloud


To create a virtual machine instance with an attached local SSD, follow the instructions to create an instance, using the --local-ssd flag to create and attach local SSD devices. To create multiple local SSD devices, add additional --local-ssd flags. Optionally, you can also set values for the interface and the device name for each --local-ssd flag.

Similarly, you can create an instance with two local SSDs that each use a SCSI interface as follows:

gcloud compute instances create example-instance \
    --machine-type n1-standard-8 \
    --local-ssd interface=[INTERFACE_TYPE] \
    --local-ssd interface=[INTERFACE_TYPE] \
    --image-project [IMAGE_PROJECT] \
    --image-family [IMAGE_FAMILY]

where:

  • [INTERFACE_TYPE] is the Local SSD interface that you wan to use for this device. Specify nvme if your boot disk image has optimized NVMe drivers, or scsi for other images.
  • [INSTANCE_NAME] is the name for the new instance.
  • [IMAGE_FAMILY] is one of the available image families.
  • [IMAGE_PROJECT] is the image project that the image family belongs to.

If necessary, you can attach local SSD devices a single instance using a combination of nvme and scsi for different devices. Performance for the nvme device depends on the boot disk image for your instance.

After creating a local SSD, you must format and mount the device before you can use it.

API


In the API, you can create a local SSD device when creating a virtual machine instance by using the initializeParams property. You must also provide the following properties:

  • diskType: Set to local SSD
  • autoDelete: Set to true
  • type: Set to SCRATCH

The following properties cannot be set for local SSD instances:

  • diskName
  • sourceImage property
  • diskSizeGb

Here is a sample request payload that creates an instance with a boot disk and a local SSD device:

{
   "machineType":"zones/us-central1-f/machineTypes/n1-standard-8",
   "name":"local-ssd-instance",
   "disks":[
      {
         "type":"PERSISTENT",
         "initializeParams":{
            "sourceImage":"projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts"
         },
         "boot":true
      },
      {
         "type":"SCRATCH",
         "initializeParams":{
            "diskType":"zones/us-central1-f/diskTypes/local-ssd"
         },
         "autoDelete":true,
         "interface": "NVME"
      }
   ],
   "networkInterfaces":[
      {
         "network":"global/networks/default"
      }
   ]
 }

After creating a local SSD, you must format and mount the device before you can use it.

For more information on creating an instance in the API, see the API reference.

Format and mount a local SSD device

Format and mount individual local SSD devices

The easiest way to connect local SSDs to your instance is to format and mount each device with a single partition. Alternatively, you can combine multiple devices into a single logical volume.

Linux instances


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 single ext4 partition.

  1. Go to the VM instances page.

    Go to the VM instances page

  2. Click the SSH button next to the instance that has the new attached local SSD. The browser opens a terminal connection to the instance.

  3. In the terminal, 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.

  4. In the terminal, use the ls command to identify the local SSD that you want to mount.

    $ ls /dev/disk/by-id/
    
    google-example-instance        scsi-0Google_EphemeralDisk_local-ssd-0
    google-example-instance-part1  scsi-0Google_PersistentDisk_example-instance
    google-local-ssd-0             scsi-0Google_PersistentDisk_example-instance-part1
    

    The disk ID usually includes the name of the local SSD with a google- prefix or a scsi-0Google_EphemeralDisk_ prefix. This example uses the google-local-ssd-0 ID.

  5. Format the local SSD with an ext4 file system. This command deletes all existing data from the local SSD.

    $ sudo mkfs.ext4 -F /dev/disk/by-id/google-local-ssd-0
    

  6. 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/disk/by-id/google-local-ssd-0 /mnt/disks/[MNT_DIR]
    

    where: [MNT_DIR] is the directory where you want to mount your local SSD.

  7. 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.

Optionally, you can add the local SSD to the /etc/fstab file so that the device automatically mounts again when the instance restarts. This entry does not preserve data on your local SSD if the instance stops or terminates. See Understanding Local SSD data persistence for complete details on Local SSD data persistence.

When you specify the entry /etc/fstab file, be sure to include the nofail option so that the instance can continue to boot even if the Local SSD is not present. For example, if you take a snapshot of the boot disk and create a new instance without any local SSDs attached, the instance can continue through the startup process and not pause indefinitely. For instances running Ubuntu 12.04 or Ubuntu 14.04, specify the nobootwait option instead of nofail.

  1. Create the /etc/fstab entry. Use the blkid command to find the UUID for the file system on the device and edit the /etc/fstab file to include that UUID with the mount options. You can complete this step with a single command. For example:

    $ echo UUID=`sudo blkid -s UUID -o value /dev/disk/by-id/google-local-ssd-0` /mnt/disks/[MNT_DIR] ext4 discard,defaults,[NOFAIL] 0 2 | sudo tee -a /etc/fstab
    

    where:

    • [MNT_DIR] is the directory where you mounted your local SSD.
    • [NOFAIL] is the option that specifies what the system should do if it is unable to mount this local SSD. For most distributions, specify nofail. For instances running Ubuntu 12.04 or Ubuntu 14.04, specify the nobootwait option.
  2. Use the cat command to verify that your /etc/fstab entries are correct:

    $ cat /etc/fstab
    

If you create a snapshot from the boot disk of this instance and use it to create a separate instance that does not have local SSDs, edit the /etc/fstab file and remove the entry for this local SSD. Even with the nofail or nobootwait options in place, keep the /etc/fstab file in sync with the devices that are attached to your instance and remove these entries before you create your boot disk snapshot.

Windows instances


Use the Windows Disk Management tool to format and mount a local SSD on a Windows instance.

  1. Connect to the instance through RDP. For this example, go to the VM instances page and click the RDP button next the instance that has the local SSDs attached. After you enter your username and password, a window opens with the desktop interface for your server.

  2. Right click the Windows Start button and select Disk Management.

    Selecting the Windows Disk Manager tool from the right-click menu on the Windows Start button.

  3. If you have not initialized the local SSD before, the tool prompts you to select a partitioning scheme for the new devices. Select GPT and click OK.

    Selecting a partition scheme in the disk initialization window.

  4. After the local SSD initializes, right click on the unallocated disk space and select New Simple Volume.

    Creating a New Simple Volume from the attached disk.

  5. Follow the instructions in the New Simple Volume Wizard to configure the new volume. You can use any partition format that you like, but for this example select NTFS. Also, check Perform a quick format to speed up the formatting process.

    Selecting the partition format type in the New Simple Volume Wizard.

  6. After you complete the wizard and the volume finishes formatting, check the new local SSD to ensure it has a Healthy status.

    Viewing the list of disks that are recognized by Windows, verify that the local SSD has a Healthy status.

That's it! You can now write files to the local SSD.

Format and mount multiple local SSD devices into a single logical volume

Unlike persistent SSDs, local SSDs have a fixed 375 GB capacity for each device that you attach to the instance. If you want to combine multiple local SSD devices into a single logical volume, you must define volume management across these devices yourself.

Linux instances


You can use any partition format and volume management system that you like, but this example uses mdadm to create a RAID 0 array with a single ext4 partition.

  1. Go to the VM instances page.

    Go to the VM instances page

  2. Click the SSH button next to the instance that has the new attached local SSD. The browser opens a terminal connection to the instance.

  3. In the terminal, install the mdadm tool. The install process for mdadm includes a user prompt that will halt scripts, so run this process manually.

    Debian and Ubuntu:

    $ sudo apt-get update && sudo apt-get install mdadm --no-install-recommends
    

    CentOS and RHEL:

    $ sudo yum install mdadm -y
    

    SLES and openSUSE:

    $ sudo zypper install -y mdadm
    

  4. Use the ls command to identify all of the local SSDs that you want to mount together. For this example, the instance has four local SSD devices:

    $ ls /dev/disk/by-id/
    
    google-example-instance        scsi-0Google_EphemeralDisk_local-ssd-0
    google-example-instance-part1  scsi-0Google_EphemeralDisk_local-ssd-1
    google-local-ssd-0             scsi-0Google_EphemeralDisk_local-ssd-2
    google-local-ssd-1             scsi-0Google_EphemeralDisk_local-ssd-3
    google-local-ssd-2             scsi-0Google_PersistentDisk_example-instance
    google-local-ssd-3             scsi-0Google_PersistentDisk_example-instance-part1
    

    The disk ID usually includes the name of each local SSD with a google- prefix or a scsi-0Google_EphemeralDisk_ prefix. This example uses the IDs with the google- prefix.

  5. Use mdadm to combine multiple local SSD devices into a single array named /dev/md0. This example merges four raid devices:

    $ sudo mdadm --create /dev/md0 --level=0 --raid-devices=4 \
    /dev/disk/by-id/google-local-ssd-0 /dev/disk/by-id/google-local-ssd-1 \
    /dev/disk/by-id/google-local-ssd-2 /dev/disk/by-id/google-local-ssd-3

  6. Format the full /dev/md0 array with an ext4 file system. This command deletes all existing data from the local SSDs.

    $ sudo mkfs.ext4 -F /dev/md0
    

  7. Create a directory to where you can mount /dev/md0. For this example, create the /mnt/disks/ssd-array directory:

    $ sudo mkdir -p /mnt/disks/[MNT_DIR]
    

    where: [MNT_DIR] is the directory where you want to mount your local SSD array.

  8. Mount the /dev/md0 array to the /mnt/disks/ssd-array directory. 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/md0 /mnt/disks/[MNT_DIR]
    

    where: [MNT_DIR] is the directory where you want to mount your local SSD array.

  9. 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 array.

Optionally, you can add the local SSD to the /etc/fstab file so that the device automatically mounts again when the instance restarts. This entry does not preserve data on your local SSD if the instance terminates. See Understanding Local SSD data persistence for complete details on local SSD data persistence.

When you specify the entry /etc/fstab file, be sure to include the nofail option so that the instance can continue to boot even if the Local SSD is not present. For example, if you take a snapshot of the boot disk and create a new instance without any local SSDs attached, the instance can continue through the startup process and not pause indefinitely. For instances running Ubuntu 12.04 or Ubuntu 14.04, specify the nobootwait option instead of nofail.

  1. Create the /etc/fstab entry. Use the blkid command to find the UUID for the file system on the device and edit the /etc/fstab file to include that UUID with the mount options. You can complete this step with a single command. For example:

    $ echo UUID=`sudo blkid -s UUID -o value /dev/md0` /mnt/disks/[MNT_DIR] ext4 discard,defaults,[NOFAIL] 0 2 | sudo tee -a /etc/fstab
    

    where:

    • [MNT_DIR] is the directory where you mounted your local SSD array.
    • [NOFAIL] is the option that specifies what the system should do if it is unable to mount this local SSD. For most distributions, specify nofail. For instances running Ubuntu 12.04 or Ubuntu 14.04, specify the nobootwait option.
  2. Use the cat command to verify that your /etc/fstab entries are correct:

    $ cat /etc/fstab
    

If you create a snapshot from the boot disk of this instance and use it to create a separate instance that does not have local SSDs, edit the /etc/fstab file and remove the entry for this local SSD array. Even with the nofail or nobootwait options in place, keep the /etc/fstab file in sync with the devices that are attached to your instance and remove these entries before you create your boot disk snapshot.

Windows instances


Use the Windows Disk Management tool to format and mount an array of local SSDs on a Windows instance.

  1. Connect to the instance through RDP. For this example, go to the VM instances page and click the RDP button next the instance that has the local SSDs attached. After you enter your username and password, a window opens with the desktop interface for your server.

  2. Right click the Windows Start button and select Disk Management.

    Selecting the Windows Disk Manager tool from the right-click menu on the Windows Start button.

  3. If you have not initialized the local SSDs before, the tool prompts you to select a partitioning scheme for the new devices. Select GPT and click OK.

    Selecting a partition scheme in the disk initialization window.

  4. After the local SSD initializes, right click on the unallocated disk space and select New Striped Volume.

    Creating a New Striped Volume from the attached disk.

  5. Select the local SSD devices that you want to include in the striped array. For this example, select all of the devices to combine them into a single local SSD device.

    Selecting the local SSD devices to include in the array.

  6. Follow the instructions in the New Striped Volume Wizard to configure the new volume. You can use any partition format that you like, but for this example select NTFS. Also, check Perform a quick format to speed up the formatting process.

    Selecting the partition format type in the New Striped Volume Wizard.

  7. After you complete the wizard and the volume finishes formatting, check the new local SSD to ensure it has a Healthy status.

    Viewing the list of disks that are recognized by Windows, verify that the local SSD has a Healthy status.

That's it! You can now write files to the local SSD.

Send feedback about...

Compute Engine Documentation