我是第一次使用 Google Compute Engine 并尝试将额外的磁盘连接到我的实例。我正在按照 this page 上的说明进行操作没有运气。
这是我到目前为止所做的:
创建了一个 10GB 的磁盘 - 'test-disk'。我现在使用的是小磁盘,因为我只是第一次尝试。
使用这个额外的磁盘启动了一个实例:
$ ./bin/gcutil --service_version="v1"--project="my-project-id"ssh --zone="us-central1-a""test-disk"
<通过 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/