[ Lezzo secret wiki ]
+~ QEMU e libvirt - comandi utili
+Incrementa il disco virtuale della VM
++A macchina spenta, supponendo che l'immagine si chiami "macchina.qcow2": +
++root@hypervisor # qemu-img resize /var/lib/libvirt/images/macchina.qcow2 +10G ++
+Poi bisogna usare resize2fs /dev/vda1, probabilmente rifacendo anche la
+partizione tramite fdisk. Un esempio:
+
+root@orazio ~# fdisk /dev/vda -l +Disk /dev/vda: 60 GiB, 64424509440 bytes, 125829120 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 +Disklabel type: gpt +Disk identifier: 8E12E056-0076-4C2C-AC88-51E48D3D105E + +Device Start End Sectors Size Type +/dev/vda1 2048 1050623 1048576 512M BIOS boot +/dev/vda2 1050624 50331614 49280991 23.5G Linux filesystem ++
+Nota come Disk /dev/vda: 60 GiB ma /dev/vda2 ... 23.5G.
+
+root@orazio ~# fdisk /dev/vda
+
+Welcome to fdisk (util-linux 2.38.1).
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+This disk is currently in use - repartitioning is probably a bad idea.
+It's recommended to umount all file systems, and swapoff all swap
+partitions on this disk.
+
+
+Command (m for help): d
+Partition number (1,2, default 2): 2
+
+Partition 2 has been deleted.
+
+Command (m for help): p
+Disk /dev/vda: 60 GiB, 64424509440 bytes, 125829120 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
+Disklabel type: gpt
+Disk identifier: 8E12E056-0076-4C2C-AC88-51E48D3D105E
+
+Device Start End Sectors Size Type
+/dev/vda1 2048 1050623 1048576 512M BIOS boot
+
+Command (m for help): n
+Partition number (2-128, default 2):
+First sector (1050624-125829086, default 1050624):
+Last sector, +/-sectors or +/-size{K,M,G,T,P} (1050624-125829086, default 125827071):
+
+Created a new partition 2 of type 'Linux filesystem' and of size 59.5 GiB.
+Partition #2 contains a ext4 signature.
+
+Do you want to remove the signature? [Y]es/[N]o: n
+
+Command (m for help): w
+
+The partition table has been altered.
+Syncing disks.
+
+root@orazio ~# resize2fs /dev/vda2
+resize2fs 1.47.0 (5-Feb-2023)
+Filesystem at /dev/vda2 is mounted on /; on-line resizing required
+old_desc_blocks = 3, new_desc_blocks = 8
+The filesystem on /dev/vda2 is now 15597056 (4k) blocks long.
+
++Potrebbe anche presentarsi questo errore: +
++root@orazio ~ # fdisk /dev/vda + +Welcome to fdisk (util-linux 2.38.1). +Changes will remain in memory only, until you decide to write them. +Be careful before using the write command. + +GPT PMBR size mismatch (50331647 != 125829119) will be corrected by write. +The backup GPT table is not on the end of the device. This problem will be corrected by write. +This disk is currently in use - repartitioning is probably a bad idea. +It's recommended to umount all file systems, and swapoff all swap +partitions on this disk. ++
+In tal caso semplicemente riscrivi la tavola premendo w e ricomincia la procedura.
+