Mkqnximage - how to increase the disk size

Hi, I’m trying to create a QEMU QNX image, with around 500MB or more available in the data directory, or really anywhere else that can contain an app of a large size. What is the best way to create / attach / modify a disk of such size to a QNX image run with mkqnximage?

My current approach does not specify any size parameters, nor does the official documentation of mkqnximage mention anything about such option. The command to create the qnx image enviroment and to run the image are like below:

# create the image
mkqnximage --type=qemu --hostname=qnxmachine --arch='aarch64le'

# run the image
mkqnximage --run

That issues the following qemu command automatically:

qemu-system-aarch64 -machine virt-4.2 -cpu cortex-a57 -smp 2 -m 1G -drive file=output/disk-qemu.vmdk,if=none,id=drv0 -device virtio-blk-device,drive=drv0 -netdev bridge,br=br0,id=net0 -device virtio-net-device,netdev=net0,mac=52:54:00:b2:be:3c -pidfile output/qemu.pid -nographic -kernel output/ifs.bin -serial mon:stdio -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-device,rng=rng0 -nographic

which makes me think that modifying the size of output/disk-qemu.vmdk is the solution, but that only modifies the virtual volume size and not the real filesystem size. The SDP is QNX 8.0.0.

Thanks for all the help!

I have no idea because I’ve never used QEMU before.

But, when you run QNX in your virtual environment, what does the command ‘df’ return? That command will tell you how big QNX thinks its disk is.

Most VM software starts the virtual volume size small on the host machine and grows as needed. By that I mean if your virtual machine is meant to have a 500MB disk, the VM software won’t by default make the physical file 500MB because that would waste a lot of space on the host machines drive. Instead it just tells the guest O/S that it’s file system is 500 MB and then as the guest O/S uses disk space it will grow its VM file on the host machine as needed. So the VM file may appear ‘small’ when you look at it on the host machine drive but to the guest O/S it will appear to be the full 500 MB.

Tim

Hi Tim, thanks for your reply.

Below is the output of the df -h . command in the directories / and /data/home/root.

# cd /
# df -h .
ifs                         9.0M      9.0M         0     100%  /               
# cd data/home/root/
# df -h .
/dev/hd0t179                 61M       61M         0     100%  /data/          

I found this if you want to enlarge an existing one. But that may be complex to get QNX to see it

https://serverfault.com/questions/324281/how-do-you-increase-a-kvm-guests-disk-space

I also found this when creating the image. So maybe that initial line you just need to edit and add that parameter to the qemu-system-* line.


1. Creating a new disk:
.
When creating a new VM, you can use the --virtio0 option to specify the storage device and size. The syntax is STORAGE_ID:SIZE_IN_GiB. For example, --virtio0 local:8 creates an 8GB disk on the local storage.

This

Tim

The --virtio option is not recognized by mkqnximage or qemu-system-aarch64. I’ve discovered that the following steps do increase the virtual volume size, however the problem of increasing the size of the actual filesystem persists.

# Convert to raw format
qemu-img convert -O raw output/disk-qemu.vmdk output/disk.raw

# Resize the raw image
qemu-img resize output/disk.raw +512M

# (Optional) Convert back to VMDK, if needed
qemu-img convert -O vmdk output/disk.raw output/disk-resized.vmdk

The qnx system is not able to recognize that the virtual volume has changed its size.

This is a long shot but the docs for the command suggest that you might try doing ‘mkqnximage --run – build’ and hope the QNX rebuild recognizes the increased file system size. You’d only need to do this once obviously after that the --run would be all you need (if it works).

Running and stopping system images

Use --run to start the image in the current directory and --stop to stop it.

If you are using VMware Workstation Player, you cannot use mkqnximage to start and stop images. Instead, open the file local/vmware_files/vmware.vmx.

You can combine other options with --run. If the options are different than the ones you used to build the image, mkqnximage rebuilds the image before it runs it; otherwise, it just runs it. If needed, you can use --build to force a rebuild of the system image when you run it. For example, you can force a rebuild to pick up changed versions of files.

Tim

Thanks Tim,

I missed that part from the docs, this is crazy, but it did work!
After swapping the output/disk-qemu.vmdk for a larger copy, then running mkqnximage --run --build the free size output of the data/home/root reported by df -h . is 582M with only 4% occupied. This is exactly what I was looking for!

Full solution:

# create a qemu setup with mkqnximage
mkqnximage --type=qemu --hostname=qnxmachine --arch='aarch64le'

# convert output/disk-qemu.vmdk to raw format for the resizing operation
qemu-img convert -O raw output/disk-qemu.vmdk output/disk.raw

# Resize the raw image
qemu-img resize output/disk.raw +512M

# Convert back to vmdk in place of disk-qemu.vmdk
qemu-img convert -O vmdk output/disk.raw output/disk-qemu.vmdk

# Rebuild the QNX qemu instance
mkqnximage --run --build

Enjoy the larger image!

I think I’ve found an even better way. The disk size CAN actually be set during the creation of the qemu environment with an option --data-size=, the size is given in MB, so to create a machine with 2GB of data do:

mkqnximage --type=qemu --hostname=qnxmachine --arch='aarch64le' --data-size='2000'.

To learn more about the available options, list them with mkqnximage --options