1
votes

Am trying to view disk space on VM instance to which I have a attached Persistent Disk. From the Cloud console, the disk is shown as attached.

But Using the command: "df -h"; am not able to see the attached Persistent Disk. Strangely though, am able to cd to the mounted Persistent Disk.

Any ideas?

4

4 Answers

2
votes

After a new disk is attached to a running instance, the disk is not mounted automatically. You can find the disk under '/dev/disk/by-id'. Once the disk is attached, you can format and mount the disk using the following command:

sudo /usr/share/google/safe_format_and_mount -m "mkfs.ext4 -F" /dev/disk/by-id/<disk_name> <mount_point>

More information can be found here: Attaching a persistent disk to an instance

0
votes

Executed below commands and it worked :

sudo mkfs.ext4 -F /dev/disk/by-id/scsi-0Google_PersistentDisk_s4vm1-www.stutzen.co 

Above command will format the disk which success message in console. The Disk-ID will be different based on the name provided while creating disk. You can view all attached disk by executing below command

 cat /dev/disk/by-id/

Then execute below command to mount the disk in required location.

sudo mount -o discard,defaults /dev/disk/by-id/scsi-0Google_PersistentDisk_s4vm1-www.stutzen.co /mnt/d1/

Make sure "/mnt/d1/" directory is already created if not execute

sudo mkdir -p /mnt/d1

src: https://cloud.google.com/compute/docs/disks/persistent-disks#formatting

0
votes

I have added additional disk on a running instance, named as "apps".

Followed these steps to add disk:

  • sudo mkdir -p /apps
    List disk id by:
  • ls -l /dev/disk/by-id
    Found the disk id and used in the following commands.
  • sudo mkfs.ext4 -F /dev/disk/by-id/scsi-0Google_PersistentDisk_apps
  • sudo mount -o discard,defaults /dev/disk/by-id/scsi-0Google_PersistentDisk_apps /apps
  • df -h lists the volume.
0
votes

What shows you command:

sudo fdisk -l

maybe try df -ah