磁盘已满,我无法SSH到实例

时间:2015-10-14 13:27:01

标签: google-compute-engine

尝试SSH进入我的实例时出错。它告诉我检查控制台串行输出。根据我的理解,它说我的磁盘没有更多的空间。我该怎么办?我需要SSH来清除空间但不能SSH,因为没有空间!

这就是我所看到的:

Starting OpenBSD Secure Shell server: sshdopen: No space left on device
Oct 14 13:18:13 instance-1 sshd[2771]: Server listening on 0.0.0.0 port 22.
[?25l[?1c7[1GOct 14 13:18:13 instance-1 sshd[2771]: Server listening on :: port 22.
[[32m ok [39;49m8[?25h[?0c.
udhcpd: Disabled. Edit /etc/default/udhcpd to enable it.
mktemp: failed to create file via template `/tmp/tmp.XXXXXXXXXX': No space left on device
mktemp: failed to create file via template `/tmp/tmp.XXXXXXXXXX': No space left on device
mktemp: failed to create file via template `/tmp/tmp.XXXXXXXXXX': No space left on device
mktemp: failed to create file via template `/tmp/tmp.XXXXXXXXXX': No space left on device
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  2384  100  2384    0     0  1126k      0 --:--:-- --:--:-- --:--:-- 2328k
Oct 14 13:18:13 instance-1 google: {"attributes":{"sshKeys":"ishener:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAFbCZDZDvuIxUbH5AHYeUU/WUWaOBYI1S7Yl9k3oVFwrenn6XsMdDHKiSH2VtpenQ7mHu3YcLDFe0pO1AwJjnSO39JR/3tTVLeVbuHDTEhOhDHt0NE84S1rqHX6r591IDwLhoGnFdNibGs0Sc0uyR/kRxl5hjAWdskOm4wzald+uRctBd+hbdBmt6az7iF2UzHEV362LxUtIzaYWoo1hnhld07+eimi6t+bUHsgqDkVGaEUUDaRFWTaNlFI9UW/AMYOcu9C24molfpPKwe2R5C5HLI+8nNI7qvoGtrUZww7K5bxNQPe+bMvVitArjYItYNDU6OXvQVA/u6gnqnbt1MM= google-ssh {\"userName\":\"ishener@gmail.com\",\"expireOn\":\"2015-10-14T13:13:05+0000\"}\nishener:ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCKT2j4VbRM6DXSjLb5UlOdzfaB4K2TvZHWGV3JD7T++EbWX87JLOKg6AdbDPWTlgKRan02TIT/Xshy28r7fCCc= google-ssh {\"userName\":\"ishener@gmail.com\",\"expireOn\":\"2015-10-14T13:12:58+0000\"}\nrsa-key-20150806:ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAxtMUn200CaOuRa8bHFuqrjDiyUDrLECUf9V/ZpxT24lrqEbS1bDT7oWQwcuxQZEcrTnfeCEDeIwQpbNoOGp8NufrZUUG8jpVnVQqCHQZ3T+0Gs6et6JYxldhb0xT3KJVwQM+qnZOfwsk7co/+XOhE63u62NvUlqpGDQQUvuFY1wV3B7Rfjhg2JYEHCMswLRnSfnvyxp6+uQJ
Oct 14 13:18:13 instance-1 google: 4THd/FlcGQJyJHUvpVQAqBIii8yc59+Rb32Xlyii6YU4+G60dfP6ON1iX2qkxJT5/mIkPfd3yPizbGsYhJbaqNQHPUE9hdqTlfk3gyA8S6SySNwViQtUqOH+sbo+suiJHHwr67V/qw== rsa-key-20150806\n"},"cpuPlatform":"Intel Ivy Bridge","description":"","disks":[{"deviceName":"instance-1","index":0,"mode":"READ_WRITE","type":"PERSISTENT"}],"hostname":"instance-1.c.united-wavelet-102819.internal","id":1871676137734806120,"image":"","machineType":"projects/273410245967/machineTypes/g1-small","maintenanceEvent":"NONE","networkInterfaces":[{"accessConfigs":[{"externalIp":"104.197.52.39","type":"ONE_TO_ONE_NAT"}],"forwardedIps":[],"ip":"10.240.238.207","network":"projects/273410245967/networks/default"}],"scheduling":{"automaticRestart":"TRUE","onHostMaintenance":"MIGRATE"},"serviceAccounts":{"273410245967-compute@developer.gserviceaccount.com":{"aliases":["default"],"email":"273410245967-compute@developer.gserviceaccount.com","scopes":["https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write"]},"default":{"al
Oct 14 13:18:13 instance-1 google: iases":["default"],"email":"273410245967-compute@developer.gserviceaccount.com","scopes":["https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write"]}},"tags":["http-server","https-server"],"virtualClock":{"driftToken":"12943060760861539723"},"zone":"projects/273410245967/zones/us-central1-f"}
Oct 14 13:18:13 instance-1 google: No startup script found in metadata.
[....] startpar: service(s) returned failure: tomcat7 ...[?25l[?1c7[1G[[31mFAIL[39;49m8[?25h[?0c [31mfailed![39;49m
Oct 14 13:18:40 instance-1 accounts-from-metadata: WARNING Could not update /home/rsa-key-20150806/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:18:40 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:18:40 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener_zaph/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:18:45 instance-1 sshd[2884]: Connection closed by 173.194.92.49 [preauth]
Oct 14 13:18:46 instance-1 sshd[2886]: Connection closed by 173.194.92.49 [preauth]
Oct 14 13:18:47 instance-1 accounts-from-metadata: WARNING Could not update /home/rsa-key-20150806/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:18:47 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:18:47 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener_zaph/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:18:49 instance-1 sshd[2903]: Connection closed by 173.194.92.52 [preauth]
Oct 14 13:18:51 instance-1 sshd[2905]: Connection closed by 173.194.92.52 [preauth]
Oct 14 13:18:55 instance-1 sshd[2907]: Connection closed by 173.194.92.52 [preauth]
Oct 14 13:19:02 instance-1 sshd[2909]: Connection closed by 173.194.92.48 [preauth]
Oct 14 13:19:17 instance-1 sshd[2912]: Connection closed by 173.194.92.48 [preauth]
Oct 14 13:19:58 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener_zaph/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:19:58 instance-1 accounts-from-metadata: WARNING Could not update /home/rsa-key-20150806/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:19:58 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:20:01 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener_zaph/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:20:01 instance-1 accounts-from-metadata: WARNING Could not update /home/rsa-key-20150806/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:20:01 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:20:02 instance-1 sshd[2929]: Connection closed by 173.194.92.51 [preauth]
Oct 14 13:20:03 instance-1 sshd[2946]: Connection closed by 173.194.92.50 [preauth]
Oct 14 13:20:06 instance-1 sshd[2948]: Connection closed by 173.194.92.49 [preauth]
Oct 14 13:20:09 instance-1 sshd[2950]: Connection closed by 173.194.92.51 [preauth]
Oct 14 13:20:13 instance-1 sshd[2952]: Connection closed by 173.194.92.50 [preauth]
Oct 14 13:20:25 instance-1 sshd[2955]: Connection closed by 173.194.92.49 [preauth]
Oct 14 13:20:36 instance-1 sshd[2957]: Connection closed by 173.194.92.52 [preauth]
Oct 14 13:20:55 instance-1 sshd[2959]: Connection closed by 173.194.92.52 [preauth]
Oct 14 13:21:01 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener_zaph/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:21:01 instance-1 accounts-from-metadata: WARNING Could not update /home/rsa-key-20150806/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:21:01 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:21:34 instance-1 sshd[2977]: Connection closed by 173.194.92.51 [preauth]
Oct 14 13:23:01 instance-1 accounts-from-metadata: WARNING Could not update /home/rsa-key-20150806/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:23:01 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener_zaph/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']
Oct 14 13:23:01 instance-1 accounts-from-metadata: WARNING Could not update /home/ishener/.ssh/authorized_keys due to [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']

2 个答案:

答案 0 :(得分:17)

您有不同的选项来解决此问题:

  1. Check if your operating system supports automatic resizing:如果是这样,使用云控制台可以编辑VM的根磁盘并增加其大小。重新启动实例后,虚拟机实例可以自动调整分区大小以识别其他空间。

  2. 使用Interactive Serial Console feature登录您的虚拟机并清理您的虚拟机磁盘或将其复制到另一个存储空间(如果您以后需要它们)。

  3. 如果您知道要删除的数据,可以配置startup script删除文件并重新启动VM以运行脚本(例如rm / tmp /*)。

  4. 您可以分离永久磁盘并将此磁盘作为附加磁盘附加到另一台计算机。在临时计算机上,您可以挂载它并清理数据或将它们复制到另一个存储,如果以后需要它们。最后使用相同的引导磁盘重新创建原始实例。您可以按照此video中描述的相同步骤将磁盘添加到另一个Linux VM,但添加现有的启动盘而不是创建新磁盘。

  5. Check if your operating system supports automatic resizing:如果是,则创建永久磁盘的快照,从快照创建一个更大的新永久磁盘。最后使用这个更大的启动盘重新创建原始实例。

答案 1 :(得分:3)

对于遇到此问题的其他人!

我必须处理的最简单的解决方案(从完全无法访问centos 7实例上的ssh 10 GB引导SSD到20 GB引导SSD)

使用云控制台:

  1. 创建启动磁盘快照:https://console.cloud.google.com/compute/snapshots
  2. 从刚刚创建的快照中创建新的启动磁盘,但将新磁盘的大小设置为20 GB(或您可能需要的大小):https://console.cloud.google.com/compute/disks
  3. 下一步停止实例:https://console.cloud.google.com/compute/instances
  4. 一旦停止编辑实例,然后单击启动磁盘右侧的“ X”,“ ADD”按钮将变为可用,单击该按钮并选择新创建的启动磁盘并保存-这将分离出您已超载的磁盘无法访问并以新大小将具有完整分区的新创建的启动磁盘附加到磁盘上,而无需将10 gb分区扩展到20,因为它是自动魔术的

此接缝可解决与没有剩余空间的启动盘相关的多个问题。

如果您像我一样看到ssh登录通知,说您应该切换到oslogin,因为它无法通过Web ssh连接,然后对其进行正确设置只是为了找出“即使您可以通过ssh访问实例,也是如此受限,因为它无法将用户添加到sudo组策略中,并且无法创建主目录-因此,尝试执行任何操作(包括扩展引导盘)时都会遇到错误,但我也曾尝试过这样做(但没有权限进入为了删除文件以允许连接而没有错误以扩展启动驱动器或通过yum添加必要的工具,我需要使用主目录。这肯定也可以解决所有问题。

一旦“如果您的预算有限”,我建议您删除快照和旧的引导磁盘,该磁盘不再与任何东西相连。

支持链接: 如何创建快照:https://cloud.google.com/compute/docs/disks/create-snapshots#creating_snapshots

如何从快照创建启动永久磁盘:https://cloud.google.com/compute/docs/disks/create-root-persistent-disks#applying_snapshots

如何更新实例的启动盘:https://cloud.google.com/compute/docs/disks/detach-reattach-boot-disk#updating_a_boot_disk_for_an_instance