[英]Google Cloud How to reduce disk size?
I have an SDD disk of 200GB in Google Cloud, that I want to reduce to 50GB.我在 Google Cloud 中有一个 200GB 的 SDD 磁盘,我想将其减少到 50GB。 Google Cloud Console, and per documentation, only allows me to increase disk size.
Google Cloud Console 和每个文档只允许我增加磁盘大小。
What solutions do I have to decrease disk size?我必须使用哪些解决方案来减小磁盘大小?
Only increasing disk size is supported.仅支持增加磁盘大小。 Disks can be resized regardless of whether they are attached.
无论是否连接磁盘,都可以调整磁盘大小。
Read the following blog post for a solution to your problem.阅读以下博客文章以解决您的问题。 Google Compute Engine: Reducing the Size of a Persistent Disk
Google Compute Engine:减少永久性磁盘的大小
Updating the blog mentioned by @Thisara (as the options are outdated):更新@Thisara 提到的博客(因为选项已过时):
weresync
via a .deb package from the releases and install with egweresync
并安装,例如curl https://github.com/DonyorM/weresync/releases/download/v1.1.5/weresync_1.1.5-1_all.deb && apt install <PATH_TO_FILE>.deb
available at https://github.com/DonyorM/weresync/releases .可在https://github.com/DonyorM/weresync/releases 获得。 This can help where eg the pip installation fails
这可以帮助例如 pip 安装失败的地方
sudo weresync-daemon > /dev/null 2>&1 &
lsblk
one can see the partitions as below for this example from a Google Cloud VM instance:lsblk
后, lsblk
可以从 Google Cloud VM 实例中看到此示例的分区如下:sda 8:0 0 75G 0 disk
├─sda1 8:1 0 74.9G 0 part /
├─sda14 8:14 0 4M 0 part
└─sda15 8:15 0 106M 0 part /boot/efi
sdb
...
One might run:一个可能运行:
weresync -C --root-partition 1 --efi-partition 15 /dev/sda /dev/sdb
Or in shorthand:或者简写:
weresync -C -g 1 -E 15 /dev/sda /dev/sdb
You can't reduce the size of a persistent disk.您无法减小永久性磁盘的大小。 See google compute docs below.
请参阅下面的谷歌计算文档。
https://cloud.google.com/compute/docs/disks/working-with-persistent-disks?authuser=6#resize_pd https://cloud.google.com/compute/docs/disks/working-with-persistent-disks?authuser=6#resize_pd
Here is answer for anyone else that is trying to downsize the Boot Disk on a Google Cloud VM.这是其他任何试图缩小 Google Cloud VM 上启动磁盘大小的人的答案。 I tried many other solutions with no luck.
我尝试了许多其他解决方案,但都没有运气。
Create a disk from an image, in my case I used Ubuntu.从图像创建磁盘,在我的例子中我使用了 Ubuntu。 This partitions the disk and marks the disk as bootable.
这会对磁盘进行分区并将磁盘标记为可引导。
Add the disk to your VM with the Boot Disk you are wanting to resize.使用要调整大小的引导磁盘将磁盘添加到 VM。
Run lsblk to confirm the new disk location in my case it looked like:运行 lsblk 以确认我的新磁盘位置,它看起来像:
For me, sda was my primary Boot Disk (2.5T) and I wanted to shrink it to sdf (500G)对我来说,sda 是我的主要启动盘 (2.5T),我想将它缩小到 sdf (500G)
I installed 'weresync' with 'apt get' started the daemon, and ran:我用 'apt get' 安装了 'weresync' 启动了守护进程,然后运行:
sudo weresync -C -g 1 -E 1 -B 15 /dev/sda /dev/sdf sudo aresync -C -g 1 -E 1 -B 15 /dev/sda /dev/sdf
I still received several errors from weresync but continued.我仍然收到来自 wassync 的几个错误,但继续。
Remove the 500G drive from your VM and use the new Boot Disk with the exiting VM instance, or create a new instance.从您的 VM 中移除 500G 驱动器,并将新启动磁盘与现有 VM 实例一起使用,或者创建一个新实例。 This was the only way I was able to ssh into the new copied disk instance and boot successfully.
这是我能够通过 ssh 进入新复制的磁盘实例并成功启动的唯一方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.