Что FS может восстанавливать неиспользуемые блоки к VirtualBox, когда используется динамически выделенное изображение?

Можно сделать так:

sed -n '/4$/p' file.txt

/4$/ соответствует 4 в конце строки, т.е. в конце последнего столбца.

0
14.10.2018, 17:18
1 ответ

Официальная документация:https://www.virtualbox.org/manual/ch08.html#vboxmanage-storageattach

VBoxManage storageattach <UUID> --nonrotational:

This switch allows to enable the non-rotational flag for virtual hard disks. Some guests (i.e. Windows 7+) treat such disks like SSDs and don't perform disk fragmentation on such media.

VBoxManage storageattach <UUID> --discard:

This switch enables the auto-discard feature for the virtual hard disks. This specifies that a VDI image will be shrunk in response to the trim command from the guest OS. The following requirements must be met:

The disk format must be VDI.

The size of the cleared area must be at least 1MB.

VirtualBox will only trim whole 1MB blocks. The VDIs themselves are organized into 1MB blocks, so this will only work if the space being TRIM-ed is at least a 1MB contiguous block at a 1MB boundary. On Windows, occasional defrag (with "defrag.exe /D"), or under Linux running "btrfs filesystem defrag" as a background cron job may be beneficial.

Notes: the Guest OS must be configured to issue trim command, and typically this means that the guest OS is made to 'see' the disk as an SSD. Ext4 supports -o discard mount flag; OSX probably requires additional settings. Windows ought to automatically detect and support SSDs - at least in versions 7, 8 and 10. Linux exFAT driver (courtesy of Samsung) supports the trim command.

It is unclear whether Microsoft's implementation of exFAT supports this feature, even though that file system was originally designed for flash.

Alternatively, there are ad hoc methods to issue trim, e.g. Linux fstrim command, part of util-linux package. Earlier solutions required a user to zero out unused areas, e.g. using zerofree, and explicitly compact the disk - only possible when the VM is offline.

Таким образом, хранилище определяется как:

<AttachedDevice discard="true" nonrotational="true" type="HardDisk">

с файловой системой типа Ext4 / Btrfs / JFS / XFS / F2FS / VFAT , смонтированной с помощью -o discard, должно работать...

ОБНОВЛЕНИЕ Поддержка TRIM в VirtualBox по-прежнему нестабильна:https://www.virtualbox.org/ticket/16795

См. такжеhttps://superuser.com/questions/646559/virtualbox-and-ssds-trim-command-support

1
28.01.2020, 04:12

Теги

Похожие вопросы