Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Labs

Working with Disks on Google Compute Engine

In this hands-on lab, we will explore the variety of methods to create, modify, and attach disks in Compute Engine.

Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 1h 0m
Published
Clock icon Mar 14, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Create a Disk Using the Web Console

    1. Go toCompute Engine then select Disks.
    2. Click CREATE DISK.
    3. Name the disk disk-1
    4. Assign the disk to the us-east1 region, and zone us-east1-b.
    5. Change the Size (GB) to 100.
    6. Click on the command line button beneath the Create button.
    7. Save the gcloud command line for later reference.
    8. Close out of the gcloud reference, then click Create.
  2. Challenge

    Resize Disk Using the Web Console

    1. From the Disks screen, click on disk-1.
    2. Click the EDIT button.
    3. Change the size from 100 to 150.
    4. Click Save.
  3. Challenge

    Create Linux Instance and Attach the Disk

    1. Click VM instances in the left-hand menu.
    2. Click Create, and set the following values:
      • Name: linux-instance
      • Region: us-east1
      • Zone: us-east1-b
    3. Under the Firewall section, click to expand Management, security, disks, networking, sole tenancy.
    4. Click the Disks tab.
    5. Click Attach existing disk.
    6. In the Disk dropdown, choose disk-1.
    7. Click Done.
    8. Click Create.
  4. Challenge

    Format and Mount a Disk in the Linux Instance

    1. Click on SSH to log in to our linux-instance instance.
    2. Enter lsblk to view all disks.
    3. Format disk sdb:
    sudo mkfs.ext4 -m 0 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/sdb
    
    1. Create the disk mount directory:
    sudo mkdir -p /mnt/disks/disk2
    
    1. Mount the disk:
    sudo mount -o discard,defaults /dev/sdb /mnt/disks/disk2
    
    1. Set the read/write permissions:
    sudo chmod a+w /mnt/disks/
    
    1. Verify that the disk is mounted using either the lsblk or df -h commands.
  5. Challenge

    Create a Disk with `gcloud`

    1. Open the Cloud Shell
    2. Type the following command to create a disk named disk-2 in the zone us-east1-b, and set the size to ```
    gcloud compute disks create disk-2 --size=100GB --zone=us-east1-b
    
    If you wish, go back to the Disks menu in the web console to verify every step completes successfully.
    
  6. Challenge

    Resize Disk with `gcloud`

    1. Resize the disk-2 disk to 150GB. Confirm that you want to complete this when prompted:
    gcloud compute disks resize disk-2 --size=150 --zone=us-east1-b
    
    1. Next, enter the gcloud command to create a Windows instance named windows-instance in zone us-east1-b. We will not attach our disk-2 disk until after we create the instance:
    gcloud compute instances create windows-instance --zone=us-east1-b --image=windows-server-2019-dc-v20190225 --image-project=windows-cloud --boot-disk-size=50GB`
    
    1. Now that we have created our Windows instance let’s attach our disk-2 disk to the instance
    gcloud compute instances attach-disk windows-instance --disk=disk-2 --zone=us-east1-b
  7. Challenge

    Create Windows Instance with `gcloud`

    1. From the web console, go back to your VM Instances page.
    2. Under windows-instance, select the dropdown menu next to RDP, and select Set Windows password.
    3. Keep username as admin, and click SET.
    4. When it generates a password, copy and paste it into a text editor for reference, then click CLOSE.
  8. Challenge

    Attach Disk to Windows Instance with `gcloud`

    1. Connect to your Windows instance via RDP.
    2. For whichever RDP method you choose, once connected, enter the admin username and the generated password you created above to connect to the instance.
  9. Challenge

    Initialize Disk in Windows Instance

    1. Close out of the Server Manager - Dashboard screen

    2. Click the magnifying glass icon in the bottom left.

    3. Type "create and format hard disk partitions" and select the above match by the same name. You may automatically get a prompt to initialize our disk, if so you can ignore the below step:

    4. If you are not automatically prompted, from Disk Management, scroll down to Disk 1, which is listed as Not Initialized.

    5. Right-click on Disk 1 on the left side, and click on Initialize Disk.

    6. Make sure that Disk 1 is selected, and choose GPT (GUID Partition Table) for the partition style, then click OK.

      Note: There are compatibility reasons to choose MBR over GPT, but we are not concerned about those for this demo.

    7. Next, right-click on the disk bar next to Disk 1, and select New Simple Volume.

    8. Click Next through all prompts, accepting all defaults, to quickly format and allocate space.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans