A disk image is a computer file that encapsulates the full contents and organizational structure of a storage device. The concept has been extended to include any such file, regardless of whether it originates from an actual physical medium or is created virtually (Disk image - Wikipedia, 2026).
QEMU supports a wide range of disk image formats, including growable images (which expand as non‑empty sectors are written), as well as compressed and encrypted images (Disk Images — QEMU documentation, 2026).
In laboratory exercises, the qcow2 format will be used as QEMU’s second‑generation Copy On Write disk image type. A qcow2 image encapsulates the complete contents and structure of a virtual disk while supporting snapshots, compression, encryption, and growable size. Compared to the raw format, qcow2 offers greater flexibility and storage efficiency, whereas raw provides only maximum performance (2.4. Storage Formats for Virtual Disks | Technical Reference | Red Hat Virtualization | 4.3 | Red Hat Documentation, 2026). Two approaches exist for preparing an operating system on a qcow2 image: (a) manual installation on the newly created image, or (b) deployment of a pre‑built cloud image.
As the operating system, it is suggested to use Debian Linux, recommended for its stability, security and freedom, although another Linux distribution may also be chosen depending on preference.
cmd in the Start menu, right‑clicking to select Run as administrator, or alternatively navigating through Windows System → Command Prompt.mkdir C:\VMs, then switch into it using cd C:\VMs. You may choose any convenient location instead of C:\VMs. To move between drives, use the drive letter followed by a colon (e.g. D: to switch to drive D).qemu-img create -f qcow2 debian.qcow2 20G, where debian.qcow2 is the image file name and 20G sets the virtual disk size (Disk Images — QEMU documentation, 2026).debian-12.6.0-amd64-netinst.iso) into working folder such as C:\VMs.qemu-system-x86_64.exe -m 2G -smp 2 -boot order=dc -hda debian.qcow2 -cdrom debian-12.6.0-amd64-netinst.iso
Where:
-m 2G specifies 2GB of memory-smp 2 sets two CPU cores-boot order=dc means boot first from CD-ROM (d), then from hard disk (c)-hda debian.qcow2 defines the virtual hard disk in qcow2 format-cdrom debian-12.6.0-amd64-netinst.iso attaches the Debian installer ISO as a virtual CD-ROMMore details about these parameters can be found on the page Invocation — QEMU documentation.
Internet will be available in the guest system right away and no additional configuration is required (Network emulation — QEMU documentation, 2026).
Pressing Ctrl + Alt + G releases the grab.
qemu-system-x86_64.exe -m 2G -smp 2 -hda debian.qcow2
In case of problems with QEMU, use the help command: qemu-system-x86_64.exe --help
/storage/emulated/0/VMs (internal phone storage) or /storage/XXXX-XXXX/VMs (where XXXX-XXXX is the SD card identifier, e.g. /storage/1234-5678/) to store disk images and ISO files.debian-12.6.0-amd64-netinst.iso) and place it into working folder.debian‑13‑nocloud‑amd64.qcow2, and place it directly into the working directory (e.g. C:\VMs).
Verification can be performed by downloading the SHA512SUMS file in the same directory, running Get-FileHash debian-13-nocloud-amd64.qcow2 -Algorithm SHA512 in PowerShell on Windows, and comparing the output with the published checksum to confirm authenticity.
The nocloud image is chosen because it is self‑contained, does not rely on external cloud‑init metadata, and is therefore ideal for straightforward local QEMU deployment under Windows.
qemu-img resize debian-13-nocloud-amd64.qcow2 +20G, where +20G means adding 20 gigabyte to the current disk size (QEMU disk image utility — QEMU documentation, 2026).
After resizing the qcow2 image with qemu-img, extra steps are needed inside the VM. qemu-img only enlarges the virtual disk container. The partition table and filesystem inside the OS remain at their old size. Until the partition is expanded and the filesystem grown, the new space is invisible and cannot be used.
root at the login: prompt and pressing Enter, since no password is set. If a password is required, the characters entered will not be displayed. After a successful login, the system displays the root shell prompt root@localhost:~# █, indicating that you are now operating as the superuser. In the shell prompt, ~ marks the home directory, while # means root and $ means a regular user.lsblk to list all block devices and partitions, then compare the total disk size with the size of the root partition / to see how much space can potentially be added (lsblk(8) - Linux manual page, 2026).
root@localhost:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
fd0 2:0 1 4K 0 disk
sda 8:0 0 23G 0 disk
├─sda1 8:1 0 2.9G 0 part /
├─sda14 8:14 0 3M 0 part
└─sda15 8:15 0 124M 0 part /boot/efi
sr0 11:0 1 1024M 1 rom
On lsblk:SIZE for disk sda shows the total capacity (23G).SIZE for partition sda1 shows the current root / size (2.9G).lsblk table column, all other available fields can be listed with lsblk --list-columns or lsblk -H:
| Column | Meaning |
|---|---|
| NAME | Device or partition name (e.g., sda, sda1). |
| MAJ:MIN | Major and minor device numbers used by the kernel to identify the driver and specific device. Major device numbers map to drivers such as 1 for RAM disks (/dev/ram0), 3 for IDE (/dev/hda), 7 for loop devices (/dev/loop0), 8 for SCSI/SATA (/dev/sda), 9 for MD RAID (/dev/md0), 11 for CD‑ROM (/dev/sr0), 65–71 for additional SCSI disks (/dev/sdb, /dev/sdc), 128 for USB storage, and 179 for MMC/SD cards (/dev/mmcblk0). Minor numbers identify the specific device or partition handled by a driver, for example 8:0 is the whole disk /dev/sda, 8:1 is its first partition /dev/sda1, and 8:2 is the second partition /dev/sda2. |
| RM | Removable flag: 1 means removable (USB, SD card), 0 means fixed disk. |
| SIZE | Total size of the device or partition. |
| RO | Read‑only flag: 1 means the device is read‑only, 0 means writable. |
| TYPE | Type of entry: disk (whole device), part (partition), rom (optical media). |
| MOUNTPOINT | Directory where the partition is mounted (e.g., /, /home, /media/usb). |
apt update -y && apt upgrade -y to refresh the package lists and automatically upgrade all installed packages to their latest versions. The -y flag ensures the process runs non‑interactively, accepting all prompts (APT User's Guide, 2026).
apt install parted -y to manage disk partitions — it can display partition tables, create, resize, and delete partitions, and show filesystem information (parted(8) — Linux manual page, 2026).root@localhost:~# parted /dev/sda GNU Parted 3.6 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) █Launches interactive mode for disk
sda.
print at the parted prompt and pressing Enter to display the current partition table with sizes, types, and filesystem information.
(parted) print
Warning: Not all of the space available to /dev/sda appears to be used, you can
fix the GPT to use all of the space (an extra 41943040 blocks) or continue with
the current setting?
(Fix/Ignore?) █
This warning indicates that the GPT partition table on /dev/sda does not cover the full disk capacity — about 41,943,040 blocks remain unused — so type Fix and press Enter to update the GPT and make the entire space available for partitioning.
Fix/Ignore? Fix
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sda: 24.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
14 1049kB 4194kB 3146kB bios_grub
15 4194kB 134MB 130MB fat16 boot, esp
1 134MB 3220MB 3086MB ext4
(parted) █
resizepart 1 100% to extend it until the end of the disk (here 100% means all available space) and confirm the warning when prompted.
(parted) resizepart 1 100%
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?
Yes/No? Yes
(parted) █
print at the parted prompt and pressing Enter
(parted) print
Model: ATA QEMU HARDDISK (scsi)
Disk /dev/sda: 24.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
14 1049kB 4194kB 3146kB bios_grub
15 4194kB 134MB 130MB fat16 boot, esp
1 134MB 24.7GB 24.6GB ext4
(parted) █
The partition size has been increased.
quit and press Enter at the parted prompt to exit — no need to adjust fstab, since partition resizing does not change mount points.
resize2fs /dev/sda1
root@localhost:~# resize2fs /dev/sda1 resize2fs 1.47.2 (1-Jan-2025) Filesystem at /dev/sda1 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 3 The filesystem on /dev/sda1 is now 5996539 (4k) blocks long. root@localhost:~# █
lsblk to confirm the new capacity is recognized.
root@localhost:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS fd0 2:0 1 4K 0 disk sda 8:0 0 23G 0 disk ├─sda1 8:1 0 22.9G 0 part / ├─sda14 8:14 0 3M 0 part └─sda15 8:15 0 124M 0 part /boot/efi sr0 11:0 1 1024M 1 rom root@localhost:~# █
shutdown -h now