To format an attached disk in Google Cloud Platform (GCP) using the command line, you can utilize the `gcloud` command. The `gcloud` command is a powerful tool that allows you to interact with various GCP services, including persistent disks. By using the appropriate `gcloud` command, you can format the attached disk to your desired file system.
Before formatting the disk, it is important to note that formatting a disk will erase all the existing data on it. Therefore, it is important to make sure you have backed up any important data before proceeding with the formatting process.
To format the attached disk, follow the steps outlined below:
Step 1: Open the Cloud Shell
– Open the GCP Console.
– Click on the Cloud Shell icon located at the top right corner of the console. This will open a new Cloud Shell session, which is a browser-based shell environment.
Step 2: Identify the disk
– Use the `lsblk` command to list the available disks and their mount points. This command provides information about the disks attached to your virtual machine instance.
– Identify the disk you want to format based on the disk size, mount point, or other relevant information.
Step 3: Unmount the disk
– If the disk is currently mounted, unmount it using the `umount` command followed by the mount point of the disk. For example, if the disk is mounted at `/mnt/mydisk`, use the following command: `sudo umount /mnt/mydisk`.
Step 4: Format the disk
– Use the `mkfs` command to format the disk with the desired file system. The specific command will depend on the file system you want to use.
– For example, to format the disk with the ext4 file system, you can use the following command: `sudo mkfs.ext4 [DISK_DEVICE]`, where `[DISK_DEVICE]` is the device name of the disk you want to format (e.g., `/dev/sdb`).
Step 5: Mount the disk
– After formatting the disk, you can mount it to a desired mount point using the `mount` command. For example, if you want to mount the disk at `/mnt/mydisk`, use the following command: `sudo mount [DISK_DEVICE] /mnt/mydisk`, where `[DISK_DEVICE]` is the device name of the formatted disk (e.g., `/dev/sdb`).
Once the disk is mounted, you can start using it to store data or configure it for your specific use case.
It is important to note that the exact commands and steps may vary depending on your specific environment and requirements. Therefore, it is recommended to refer to the official documentation or consult with a GCP expert for more detailed instructions tailored to your needs.
The `gcloud` command, along with the appropriate parameters, allows you to format an attached disk in GCP. By following the steps mentioned above, you can safely format the disk and prepare it for use.
Other recent questions and answers regarding Examination review:
- What command is used to mount the disk?
- What command is used to list the block devices in the SSH terminal?
- How do you confirm that a persistent disk has been created successfully?
- What are the steps to create and mount a persistent disk in Google Cloud Platform (GCP)?

