How to create a fixed size virtual disk with qemu-img?

7,949

The vmdk disk can be created with -o subformat=monolithicFlat option. A flat disk image fills unused space. Doc: qemu-img create options and vmdk format.

Share:
7,949
Satish
Author by

Satish

Updated on September 18, 2022

Comments

  • Satish
    Satish over 1 year

    What's the best way to create a fixed size disk with qemu-img ? I tried doing this., and it always seems to be creating a virtual /growing disk, doing a ls returns the actual small size of the vmdk.

    is there a way to create a "fixed size" disk?

    root@local:/tmp# qemu-img create -f vmdk test.vmdk 2G
    Formatting 'test.vmdk', fmt=vmdk size=2147483648 compat6=off zeroed_grain=off
    
    root@local:/tmp# qemu-img info test.vmdk
    image: test.vmdk
    file format: vmdk
    virtual size: 2.0G (2147483648 bytes)
    disk size: 12K
    
    root@local:/tmp# ls -lah test.vmdk
    -rw-r--r-- 1 root root 320K May 13 09:15 test.vmdk
    
    • some user
      some user over 2 years
      While the answer by user319088 checked out, I want to comment that if other user come here looking for way to create a fixed size, native .qcow2 image, I have not found a way. Even converting from flat vmdk does not work.