centos - 无法在 GCE 实例上格式化和挂载磁盘

标签 centos google-cloud-storage mount google-compute-engine

我是第一次使用 Google Compute Engine 并尝试将额外的磁盘连接到我的实例。我正在按照 this page 上的说明进行操作没有运气。

这是我到目前为止所做的:

  1. 创建了一个 10GB 的磁盘 - 'test-disk'。我现在使用的是小磁盘,因为我只是第一次尝试。

  2. 使用这个额外的磁盘启动了一个实例:

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

    <
  3. 通过 SSH 登录实例并运行 safe_format_and_mount 命令。

    $ sudo mkdir/磁盘

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

此时我不断收到此错误:

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.

我使用的是 CentOS 6.0,我已经禁用了 SELINUX。除此之外,我没有做任何改变。任何帮助深表感谢。

谢谢。

最佳答案

以下是一些需要检查的事项:

如果您是通过 Google Developers Console 创建的,请首先确认您创建的附加磁盘的“源类型”为“无(空白磁盘)”。如果您通过 gcutil 创建磁盘,则在创建磁盘时不应指定“source_image”以创建空白磁盘。您可以通过在 Developers Console 中查看磁盘详细信息来确认 Persistent Disk 是否为空白磁盘。如果没有与磁盘关联的“源图像”,则它是一个空白磁盘。

一旦您确认您有一个空白磁盘,下一个问题是 - 当您通过 ssh 进入实例并运行以下命令时,您是否看到磁盘的名称?

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

如果没有,那么您需要在 Developers Console 中或使用 gcutil 将磁盘附加到实例。这是 gcutil 命令:

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

对于名为“test-instance”的实例,附加磁盘的命令应该是:

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

如果在运行 ls -l/dev/disk/by-id/* 时列出了您的磁盘 那么您可能只需要指定完整的路径磁盘在您的 format_and_mount 命令中。 鉴于您在问题中提到的值,format_and_mount 命令应如下所示:

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

关于centos - 无法在 GCE 实例上格式化和挂载磁盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23376755/

相关文章:

google-cloud-platform - 使用服务帐户进行 Google Cloud SQL 导入的权限

c - 关于 glib c setmntent 函数的查询

image - centos docker 镜像太大

linux - 将 ks.cfg 与 virt-install 一起使用?

google-cloud-storage - 如何通过bash检查谷歌云存储桶中是否存在任何给定的对象

linux - 挂载:您必须指定文件系统类型

java - 如何判断目录是否使用 Java 远程挂载

html - Apache 输出网页(布局)不正确

c++ - 找不到自定义编译 'CMake'

google-app-engine - 提供来自 Google Cloud Storage 的静态 SPA 和来自 Google App Engine 的 API