在移动磁盘并用符号链接替换原始磁盘时,我遇到了同样的问题。此后可以正常工作,但是使用'modifyhd'命令会遇到问题,因为在使用它时显然可以规范化vdi文件的路径。这看起来就像您要添加具有相同UUID但在不同路径上的新磁盘一样。
有两个问题:
磁盘必须从使用它的VM中删除,然后再从“ HDDS的VirtualBox列表”中删除。此问题已通过“ closemedium”命令修复,该命令会将其从该列表中删除。
要调整大小的磁盘是“固定磁盘”而不是“动态”磁盘,并且只能调整动态磁盘的大小。该问题已通过“克隆”命令(克隆为动态)修复,然后调整了生成的磁盘的大小。
这是我的操作日志。请注意,我在任何时候都没有以root身份运行,除非之后再调整分区和文件系统的大小。
将关联从VM删除到磁盘。
问题仍然存在:
virt_box@TestBox:~/VirtualBox VMs/TestInception 64 bit$ VBoxManage modifyhd TestInception\ 64\ bit.vdi --resize 8192
VBoxManage: error: Cannot register the hard disk '/datadisk/VirtualBox VMs/TestInception 64 bit/TestInception 64 bit.vdi' {6cd99209-e4db-4178-a6c2-53f9581b1fad} because a hard disk '/home/virt_box/VirtualBox VMs/TestInception 64 bit/TestInception 64 bit.vdi' with UUID {6cd99209-e4db-4178-a6c2-53f9581b1fad} already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBox, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 178 of file VBoxManageDisk.cpp
啊,磁盘仍然在“系统中”:
virt_box@TestBox:~/VirtualBox VMs/TestInception 64 bit$ VBoxManage list hdds
UUID: ba58276a-bbe1-4354-8ae5-246bdac390c8
Parent UUID: base
Format: VDI
Location: /home/virt_box/VirtualBox VMs/TestInception 32 bit/TestInception.vdi
State: locked write
Type: normal
Usage: TestInception 32 bit (UUID: a693ac62-7caa-4f11-9d00-51d3a149f5f7)
UUID: 6cd99209-e4db-4178-a6c2-53f9581b1fad
Parent UUID: base
Format: VDI
Location: /home/virt_box/VirtualBox VMs/TestInception 64 bit/TestInception 64 bit.vdi
State: created
Type: normal
从VirtualBox磁盘列表(“ closemedium”)中删除/删除磁盘:
virt_box@TestBox:~/VirtualBox VMs/TestInception 64 bit$ VBoxManage closemedium disk 6cd99209-e4db-4178-a6c2-53f9581b1fad
virt_box@TestBox:~/VirtualBox VMs/TestInception 64 bit$ VBoxManage list hdds
UUID: ba58276a-bbe1-4354-8ae5-246bdac390c8
Parent UUID: base
Format: VDI
Location: /home/virt_box/VirtualBox VMs/TestInception 32 bit/TestInception.vdi
State: locked write
Type: normal
Usage: TestInception 32 bit (UUID: a693ac62-7caa-4f11-9d00-51d3a149f5f7)
再次尝试调整大小:
virt_box@TestBox:~/VirtualBox VMs/TestInception 64 bit$ VBoxManage modifyhd TestInception\ 64\ bit.vdi --resize 8192
0%...
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!
该死的,“固定尺寸”不起作用!进行“ clonehd”解救,因为这留下了“动态分配”的克隆磁盘:
virt_box@TestBox:/datadisk/VirtualBox VMs/TestInception 64 bit$ VBoxManage clonehd TestInception\ 64\ bit.vdi TestInception\ 64\ bit-cloned.vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 8e237500-173b-401a-9e63-9e64da110da9
立即调整大小(即时):
virt_box@TestBox:/datadisk/VirtualBox VMs/TestInception 64 bit$ VBoxManage modifyhd --resize 8192 TestInception\ 64\ bit-cloned.vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
然后将其连接到某些VM,以进行大小调整。这是作为根完成的。假设您只有一个分区,并且可能会交换。
# fdisk /dev/sdb # <- The extra disk, just attached to be resized
// The procedure looks like this:
// m - print help
// p - print table
// d ... - delete partition (delete both if you have root and swap)
// n - new partition (create root/first partition starting on exact same sector as before, typically 2048, but ends on last, or last minus swap)
// ... n.. (.. then add the swap partition. Calculate how many sectors using original table)
// t - change type of partition (swap partition, if any, to 82 - not 83 which is "normal Linux").
// w - write partition table (write out, with the resized partition)
# e2fsck -f /dev/sdb1
e2fsck 1.42.5 (29-Jul-2012)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdb1: 99918/122160 files (0.3% non-contiguous), 471032/487936 blocks
# resize2fs /dev/sdb1
resize2fs 1.42.5 (29-Jul-2012)
Resizing the filesystem on /dev/sdb1 to 1965824 (4k) blocks.
The filesystem on /dev/sdb1 is now 1965824 blocks long.