VM Disk auf Host größer als überall angezeigt

BerndKleinert

Active Member
Feb 14, 2020
48
4
28
42
Hallo,

Proxmox 8.2.4 auf Debian 12, die Disk einer VM hat folgende Größe in Proxmox:

Code:
local:107/vm-107-disk-0.qcow2,format=qcow2,size=41G

Im Gast-Linux (auch Debian 12) hat sie 38G, das passt, kommt ja noch Swap und Boot dazu:


Code:
root@example:~$ df -h
Dateisystem                Größe Benutzt Verf. Verw% Eingehängt auf
udev                        1,9G       0  1,9G    0% /dev
tmpfs                       392M    1,3M  391M    1% /run
/dev/mapper/example--vg-root   38G    9,7G   27G   27% /
tmpfs                       2,0G       0  2,0G    0% /dev/shm
tmpfs                       5,0M       0  5,0M    0% /run/lock
/dev/sda1                   234M     91M  131M   42% /boot
tmpfs                       392M       0  392M    0% /run/user/1000
tmpfs                       392M       0  392M    0% /run/user/33
root@example:~$


root@example:~$ fdisk -l /dev/sda
Disk /dev/sda: 41 GiB, 44023414784 bytes, 85983232 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6fca5dd4


Device     Boot  Start      End  Sectors  Size Id Type
/dev/sda1  *      2048   499711   497664  243M 83 Linux
/dev/sda2       501758 85981183 85479426 40,8G  5 Extended
/dev/sda5       501760 85981183 85479424 40,8G 8e Linux LVM
root@example:~$


root@example:~$ cat /proc/partitions
major minor  #blocks  name


  11        0    1048575 sr0
   8        0   42991616 sda
   8        1     248832 sda1
   8        2          1 sda2
   8        5   42739712 sda5
 254        0   40640512 dm-0
 254        1    2097152 dm-1
root@example:~$ dmsetup info /dev/dm-0
Name:              example--vg-root
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        1
Event number:      0
Major, minor:      254, 0
Number of targets: 1
UUID: LVM-HCI0rbgquBDQAdydAIV9i8zAYOifnxqi02qJgoKai9Z0CrrUrbenPuFRryMjg27t


root@example:~$

Wenn ich aber unter dem Host schaue:

Code:
-rw-r--r-- 1 root root 107G 30. Jul 08:35 /var/lib/vz/images/107/vm-107-disk-0.qcow2

Ich verstehe es nicht ganz, nutzt hier LVM die Partition doppelt? Kommt das von LVM?

Hat jemand eine Idee bzw. einen Denkanstoß für mich?
 
Qcow2 kann Snapshots enthalten, vielleicht funktioniert auch fstrim nicht richtig,
check bitte mal mit:

qemu-img info /var/lib/vz/images/107/vm-107-disk-0.qcow2

dann (bei abgeschalteter VM)

qemu-img convert /var/lib/vz/images/107/vm-107-disk-0.qcow2 -O qcow2 /var/lib/vz/images/107/vm-107-disk-0.qcow2.shrunk
mv /var/lib/vz/images/107/vm-107-disk-0.qcow2.shrunk /var/lib/vz/images/107/vm-107-disk-0.qcow2

Siehe auch:
https://kofler.info/wie-ich-ein-qcow2-image-auf-ein-drittel-geschrumpft-habe
 
Last edited:
Vielen Dank, das erklärt einiges. Convert muss ich an einem anderen Tag testen (VM in Benutzung), aber qemu-info ist auch interessant:

Code:
root@host ~ # qemu-img info /var/lib/vz/images/107/vm-107-disk-0.qcow2
image: /var/lib/vz/images/107/vm-107-disk-0.qcow2
file format: qcow2
virtual size: 41 GiB (44023414784 bytes)
disk size: 37.9 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false
Child node '/file':
    filename: /var/lib/vz/images/107/vm-107-disk-0.qcow2
    protocol type: file
    file length: 106 GiB (114181079552 bytes)
    disk size: 37.9 GiB
root@host ~ #

NOchmal vielen Dank, damit bekomme ich vermutlich auch andere VM's deutlich kleiner.
 
Du kannst ja auch im laufenden Betrieb die Disk migrieren, z.B. gleich in RAW, außer du brauhst das qcow2 für irgendetwas unbedingt.
 
Ich würde nur ungern auf die Möglichkeit verzichten, Snapshots der VM's zu machen. Das würde, soweit ich das verstanden habe, mit RAW nicht mehr gehen. Ganz OT: mich würde interessieren ob Vmware und Konsorten da schon weiter sind oder ob es bereits Alternativen zum Qcow2-Format gibt die Snapshots können.

Edit: aber ich sehe gerade, alle Windows-VM's können sowieso keine Snapshots machen, obwohl sie in qcow2-Format installiert wurden.
 
Last edited:
Ich würde nur ungern auf die Möglichkeit verzichten, Snapshots der VM's zu machen. Das würde, soweit ich das verstanden habe, mit RAW nicht mehr gehen. Ganz OT: mich würde interessieren ob Vmware und Konsorten da schon weiter sind oder ob es bereits Alternativen zum Qcow2-Format gibt die Snapshots können.

Edit: aber ich sehe gerade, alle Windows-VM's können sowieso keine Snapshots machen, obwohl sie in qcow2-Format installiert wurden.
Für Snapshots brauchst du nicht zwingend qcow2.
Was für einen Storageunterbau hast du denn? Bei der Standardinstallation mit einem LVM-Thin Pool, legst du deine VM Disks als RAW in den Pool und kannst auch Snapshots machen.

P.S. Ich halte eh nicht viel davon, von VMs Snapshots zu machen. Wenn bei einem Update etwas Kaputt geht will man nicht immer alles Wegwerfen und von vorn beginnen, daher mache ich lieber ein Snapshot Backup vor einem Update und kann bei Bedarf auch einzelne Dateien aus dem Backup holen. Snapshot Backups gehen auch auf Storages wo sonst keine Snapshots der VMs möglich sind.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!