Generic Linux

VM Hardware Settings

  • Anything with a Linux Kernel of v3.16 or lower, requires the Display to use Standard VGA.

  • Anything with a Linux Kernel of v3.16 or lower, may require to use the Default (LSI 53C895A) SCSI Controller type if it does not boot the disk using the recommended VirtIO SCSI single.


Install Guest-Agent

Install the qemu-guest-agent package.

Install the spice-vdagent package. This package is only required for GUI-based VMs.

Install the spice-webdavd package. This package is optional for folder sharing between the host and VM and future features.


Configure Network Interfaces

The drivers between VMware and Proxmox VE are different, thus the names of the interfaces will change, potentially causing issues with your lab content. The following instructions is for a Linux-based approach using udev.

Identify the attributes of the interface, specifically the MAC address.

Change eth0 based on your output.

sudo udevadm info --attribute-walk --path=/sys/class/net/eth0

Based on the output, create or edit a rule in /etc/udev/rules.d/70-persistent-net.rules.

sudo nano /etc/udev/rules.d/70-persistent-net.rules

Add the rule.

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:37:48:55", NAME="ens192"

This rule enforces ens192 to be persistent and is tied to the specified MAC address. Add additional rules for remaining NICs.

Reload the udev rules.

sudo udevadm control --reload-rules

Optimizing Disks

General Optimization

For general optimization, make sure clean the disk by running basic maintenance. For general maintenance, programs are available such as bleachbit, stacer (no longer maintained) etc.. You can also choose to do this manually by using commands in the CLI. Be sure to clean old cached packages and any old kernel packages. Also, clean out old journal logs.


Defragment the Disk

Launch the e4defrag utility to defrag the root partition.

If applicable, do this operation before zeroing out free disk space. The e4defrag utility is for ext4 filesystems. For xfs, xfs_fsr can be used instead. For zfs, defrag is not supported, but you may choose to conduct a zpool scrub.

sudo e4defrag /

Cleanup Slack Space

Usage 1: Create a file with all zero’s inside it

Be sure to shut down all services which writes to the target volume to avoid running out of space. If there are multiple partitions on a single virtual disk, same step needs to be performed on all partitions. Otherwise, the reclamation will be partial because not every data block will be zeroed. It is important to note that you have enough physical disk space on your datastore as zeroing a disk will expand the VM disk to fully use the allocated amount of disk space configured on that VM.

Create the file and zerofill the empty space.

sudo dd if=/dev/zero of=zerofill bs=1M

Once the file filled up all the free space, remove the file.

sudo rm -rf zerofill

Repeat this process if there are multiple partitions that need to be zero’d out.

Shutdown the VM and migrate the VM to a different datastore to compact the disks.


Usage 2: Use zerofree in single user mode

(Do note that zerofree is specifically designed for ext2, ext3, and ext4 filesystems only.)


If using zerofree on the root disk (mounted as /)

Check the root partition filesystem.

df -Th

Boot into single user mode.

sudo telinit 1

Stop the journaling service.

systemctl stop systemd-journald.socket

Turn off swap.

swapoff -a

Mount root / as read-only.

sudo mount -o remount,ro /
sudo mount -n -o remount,ro -t ext4 /dev/xxxx /

} Run zerofree against the root drive.

zerofree -v /dev/xxxx

Shutdown the VM migrate the VM to a different datastore to compact the disks.


If using zerofree on a drive other than the root disk

Start the machine in graphical mode (normal start).

Interrupt the GRUB menu by pressing the ESC key.

Press e to edit the GRUB line.

Scroll down to the one that says linux..., should be the next to last line.

Move to the end of the line and add break=init to the parameter list. Make sure to separate by using a space from the other parameters.

Press CTRL+X or F10 to boot.

Once the shell prompt appears, enter the following commands.

mount --bind /proc $rootmnt/proc
chroot $rootmnt /usr/sbin/zerofree -v /dev/sdxx

Shutdown the VM and migrate the VM to a different datastore to compact the disks.


Trim the Disk

Use fstrim to free unused blocks from SSD-backed storage.

Do this operation after zeroing out free disk space and migration.

sudo fstrim -av