lezzo.org/secretwiki/qemu-libvirt.html

129 lines
4.3 KiB
HTML
Raw Normal View History

2023-06-02 22:16:55 +01:00
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2023-06-02 Fri 23:16 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Lezzo secret wiki</title>
<meta name="author" content="bparodi" />
<meta name="generator" content="Org Mode" />
<link rel="stylesheet" type="text/css" href="./stylesheet.css"/>
</head>
<body>
<div id="content" class="content">
<h2>[ Lezzo secret wiki ]</a></h2>
<div id="outline-container-org0e43b68" class="outline-2">
<h2 id="org0e43b68"><b>~</b> QEMU e libvirt - comandi utili</h2>
<div class="outline-text-2" id="text-org0e43b68">
</div>
<div id="outline-container-org7608206" class="outline-3">
<h3 id="org7608206">Incrementa il disco virtuale della VM</h3>
<div class="outline-text-3" id="text-org7608206">
<p>
A macchina spenta, supponendo che l'immagine si chiami "macchina.qcow2":
</p>
<pre class="example">
root@hypervisor # qemu-img resize /var/lib/libvirt/images/macchina.qcow2 +10G
</pre>
<p>
Poi bisogna usare <code>resize2fs /dev/vda1</code>, probabilmente rifacendo anche la
partizione tramite fdisk. Un esempio:
</p>
<pre class="example">
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
</pre>
<p>
Nota come <code>Disk /dev/vda: 60 GiB</code> ma <code>/dev/vda2 ... 23.5G</code>.
</p>
<pre class="example">
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.
</pre>
<p>
Potrebbe anche presentarsi questo errore:
</p>
<pre class="example">
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.
</pre>
<p>
In tal caso semplicemente riscrivi la tavola premendo <code>w</code> e ricomincia la procedura.
</p>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: bparodi</p>
<p class="date">Created: 2023-06-02 Fri 23:16</p>
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>