通常我使用 growpart 来增加 aws 上的根分区的大小,这样我就不必重新启动
由于某种原因,在我的一个实例中,它不再起作用:
# df -h
Filesystem Size Used Avail Use% Mounted on
udev 993M 4.0K 993M 1% /dev
tmpfs 201M 668K 200M 1% /run
/dev/xvda1 129G 55G 67G 46% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 1002M 0 1002M 0% /run/shm
none 100M 0 100M 0% /run/user
# fdisk -l
Disk /dev/xvda: 161.1 GB, 161061273600 bytes
63 heads, 31 sectors/track, 161071 cylinders, total 314572800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x8d503283
Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 272629034 136313493+ 83 Linux
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 150G 0 disk
└─xvda1 202:1 0 130G 0 part /
# growpart /dev/xvda 1
attempt to resize /dev/xvda failed. sfdisk output below:
|
| Disk /dev/xvda: 161071 cylinders, 63 heads, 31 sectors/track
| Old situation:
| Units = cylinders of 999936 bytes, blocks of 1024 bytes, counting from 0
|
| Device Boot Start End #cyls #blocks Id System
| /dev/xvda1 * 1+ 139594 139594- 136313493+ 83 Linux
| /dev/xvda2 0 - 0 0 0 Empty
| /dev/xvda3 0 - 0 0 0 Empty
| /dev/xvda4 0 - 0 0 0 Empty
| New situation:
| Units = sectors of 512 bytes, counting from 0
|
| Device Boot Start End #sectors Id System
| /dev/xvda1 * 2048 314571662 314569615 83 Linux
| /dev/xvda2 0 - 0 0 Empty
| /dev/xvda3 0 - 0 0 Empty
| /dev/xvda4 0 - 0 0 Empty
| Warning: partition 1 does not start at a cylinder boundary
| Successfully wrote the new partition table
|
| Re-reading the partition table ...
| BLKRRPART: Device or resource busy
| The command to re-read the partition table failed.
| Run partprobe(8), kpartx(8) or reboot your system now,
| before using mkfs
| If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
| to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
| (See fdisk(8).)
FAILED: failed to resize
***** WARNING: Resize failed, attempting to revert ******
Re-reading the partition table ...
BLKRRPART: Device or resource busy
The command to re-read the partition table failed.
Run partprobe(8), kpartx(8) or reboot your system now,
before using mkfs
***** Appears to have gone OK ****
CLoud-Utils 的版本0.27-0ubuntu9.2
,相同版本和更新版本可以在其他服务器上正常工作!
我尝试了 partx:
# partx --update 1 /dev/xvda
partx: /dev/xvda: error updating partition 1
答案1
我刚刚遇到了同样的问题。
由于有较新版本的 growpart 可用,我刚刚升级了该软件包(在 Debian 8 上,从 backports 存储库将版本从“0.26-2”升级到“0.29-1”)并且能够在之后立即调整我的分区大小。
答案2
parted -s -a opt /dev/sda "resizepart 3 100%"
对我有用。