3
votes

I am using Google Compute Engine for the first time and trying to attach additional disk to my instance. I am following instructions on this page with no luck.

Here is what I have done till now:

  1. Created a disk - 'test-disk' - of 10GB. I am using a small disk as of now since I am just trying things for the first time.

  2. Started an instance with this additional disk:

    $ ./bin/gcutil --service_version="v1" --project="my-project-id" ssh --zone="us-central1-a" "test-disk"

  3. Logged in to the instance via SSH and ran the safe_format_and_mount command.

    $ sudo mkdir /disk

    $ sudo /usr/share/google/safe_format_and_mount -m "mkfs.ext4 -F" test-disk /disk

At this point I keep getting this error:

safe_format_and_mount: Running: fsck.ext4 -a test-disk
safe_format_and_mount: fsck.ext4: No such file or directory while trying to open test-disk
safe_format_and_mount: test-disk: 
safe_format_and_mount: The superblock could not be read or does not describe a correct ext2
safe_format_and_mount: filesystem.  If the device is valid and it really contains an ext2
safe_format_and_mount: filesystem (and not swap or ufs or something else), then the superblock
safe_format_and_mount: is corrupt, and you might try running e2fsck with an alternate superblock:
safe_format_and_mount:     e2fsck -b 8193 <device>
safe_format_and_mount: 
safe_format_and_mount: Fsck could not correct errors on test-disk
safe_format_and_mount: Running: mount -o defaults test-disk /disk
safe_format_and_mount: mount: you must specify the filesystem type
safe_format_and_mount: Running: mkfs.ext4 -F test-disk
safe_format_and_mount: mke2fs 1.41.12 (17-May-2010)
safe_format_and_mount: mkfs.ext4: No such file or directory while trying to determine filesystem size
safe_format_and_mount: Format of test-disk failed.
safe_format_and_mount: Running: mount -o defaults test-disk /disk
safe_format_and_mount: mount: you must specify the filesystem type
safe_format_and_mount: Tried everything we could, but could not mount test-disk.

I am using CentOS 6.0, I have disabled the SELINUX. Apart from that I haven't made any change. any help is much appreciated.

Thanks.

2

2 Answers

13
votes

Here are a few of things to check:

First confirm that you created the additional disk with a "Source type" of "None (blank disk)" if you created it through the Google Developers Console. If you're creating the disk via gcutil then you should not specify a "source_image" when creating the disk in order to create a blank disk. You can confirm if a Persistent Disk is a blank disk by viewing the disk details in the Developers Console. If there's no "Source image" associated with the disk then it is a blank disk.

Once you've confirmed that you've got a blank disk, the next question is - do you see the name of the Disk when you ssh into the instance and run the following command?

$ls -l /dev/disk/by-id/*

If not then you need to attach the disk to the Instance in the Developers Console or using gcutil. Here's the gcutil command:

gcutil --project=<project-id> attachdisk --zone=<zone> --disk=<disk-name>,[deviceName=<alias-name>,mode=<mode>] <instance-name>

For an instance named "test-instance", the command to attach the disk should be:

gcutil --project="my-project-id" attachdisk --zone=us-central1-a --disk=test-disk test-instance

If your disk is listed when you run ls -l /dev/disk/by-id/* then you might just need to specify the complete path to the disk in your format_and_mount command. Given the values you mentioned in your question, the format_and_mount command should look something like this:

$sudo /usr/share/google/safe_format_and_mount -m "mkfs.ext4 -F" /dev/disk/by-id/scsi-0Google_PersistentDisk_test-disk /disk
1
votes

Sometimes disk mounting fails if you are trying to a mount a disk that was previously attached to a different instance and was not unmounted from that instance before detaching. See this google cloud doc

One way I found to resolve it was to recreate the disk.