How to: Create LXC container on Proxmox VE (PVE)

1 Login to Proxmox VE terminal via web gui or SSH or from the host directly

2 Use following command to update templates

pveam update

3 When we see the returned message “update successful” from last command, open the Proxmox web gui

4 Navigate to one of the storage which we want to use to store templates

5 Click on “Templates” button

6 Select the lxc container template we want to download and click on “Download” button to download it (e.g. TurnKey WordPress)

7 Once the download is finished, we click on “Create CT” button from Proxmox VE web gui

8 The rest will be very similar with creating the virtual machine, assign disk space, CPU, RAM etc.


How to: Fix Windows Terminal Server, User being put to temporary profile

We can try following fix, but not guaranteed to work.

1 Launch registry editor

2 Navigate to “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList”, there will be a list of folders which start with “S-1-5-21……” each of them corresponds to a user profile

3 At the right hand side, look at “ProfileImagePath” which will have their user login name/ID, find the user’s name who is having issue, delete the folder which holds that user’s profile

4 Try to logon again


Sandbox software – Sandboxie is now completely free (and open source)!

What is Sandbox? How It Works?

Sandboxie runs your programs in an isolated space which prevents them from making permanent changes to other programs and data in your computer.

Sandboxie
Sandboxie

The red arrows indicate changes flowing from a running program into your computer. The box labeled Hard disk (no sandbox) shows changes by a program running normally. The box labeled Hard disk (with sandbox) shows changes by a program running under Sandboxie. The animation illustrates that Sandboxie is able to intercept the changes and isolate them within a sandbox, depicted as a yellow rectangle. It also illustrates that grouping the changes together makes it easy to delete all of them at once.

Why do I want to use it?

  • Testing random software/program
  • Installing some unknown software/program
  • Don’t want to have any trash/rubbish left by the software/program
  • Want to keep operating system clean
  • Isolating the software from the host operating system

Download

Github Page


How to: Backup and Restore Proxmox VE host

Warning: This guide is to backup Proxmox VE host, not virtual machines, Proxmox VE has built-in VM backup mechanism which can be configured easily via its web gui.

There are many ways to backup Proxmox VE host, e.g. using xfsdump, using different kinds of third party backup programs like rsync etc.

For this guide we will be using UrBackup

Pre-requirements

  • A working Proxmox VE host
  • A spare server for running as UrBackup server with big enough storage
  • The Proxmox VE host and the UrBackup Server is connected and in the same LAN

1 Install UrBackup Server

The server can be Windows or Linux (Debian/Ubuntu etc.)

1.1 For Windows Server

1.1.1 Download the exe or msi file from here: UrBackup Windows Server [1]

1.1.2 Execute the downloaded binary file, install the UrBackup server

1.1.3 Open any browser from the server, navigate to “localhst:55414” or “127.0.0.1:55414”

Note 1: The web interface is available at port 55414. To restrict the access you have to create an admin account in Settings->Users. Without this account everyone can access all backups using the web interface.

Note 2: This web interface is accessible from other device within the same LAN

1.2 For Linux (Ubuntu) Server

1.2.1 We can simply use following commands to install it

sudo add-apt-repository ppa:uroni/urbackup
sudo apt update
sudo apt install urbackup-server

or

wget https://hndl.urbackup.org/Server/2.4.12/urbackup-server_2.4.12_amd64.deb
sudo dpkg -i urbackup-server_2.4.12_amd64.deb
sudo apt install -f

Note 1: It has some dependencies which you can automatically resolve by running apt-get -f install. If it does not work you probably chose the wrong packet from stable/testing/unstable. [2]

Note 2: The web interface is available at port 55414. To restrict the access you have to create an admin account in Settings->Users. Without this account everyone can access all backups using the web interface. [2]

Note 3: This web interface is accessible from other device within the same LAN

2 Install UrBackup Client on Proxmox VE host

2.1 Login to Proxmox VE terminal directly or via SSH or via web gui -> Shell

2.2 Execute following command to install UrBackup client

TF=$(mktemp) && wget "https://hndl.urbackup.org/Client/2.4.10/UrBackup%20Client%20Linux%202.4.10.sh" -O $TF && sh $TF; rm -f $TF

Note: Unless you are sure you want to use snapshot, dattobd require manual installation, LVM requires free space that equals to the size we are backing up. Choose not to use snapshot here if you are not sure even it says you can use dattobd and LVM.

3 Configure the UrBackup Server (and Proxmox host)

3.1 Before we start to configure UrBackup server, we need to make sure Proxmox VE host’s firewall is disabled, or we will have to open ports for UrBackup server, where are listed in following tables

The Server binds to following default ports:

PortUsageIncoming/OutgoingProtocol
55413FastCGI for web interfaceIncomingTCP
55414HTTP web interfaceIncomingTCP
55415Internet clientsIncomingTCP
35623UDP broadcasts for discoveryOutgoingUDP
[3]

The Client binds to following default ports (all incoming):

PortUsageProtocol
35621Sending files during file backups (file server)TCP
35622UDP broadcasts for discoveryUDP
35623Commands and image backupsTCP
[3]

3.2 Login to UrBackup web interface

3.3 Check if the Proxmox VE host appear under “Status” tab, if not, wait 30 – 60 minutes, if we can see the Proxmox VE is displayed under status tab, proceed to next step

3.4 Click on “Settings”

3.5 Click on “Clients”, then click on the name of Proxmox VE host

3.6 Check “Separate settings for this client”, make necessary changes for “File Backups”, no need to worry about “Image Backups” since it is not supported on Linux. (Do not forget to click on “Save” button)

Important: Make sure for File Backups, we exclude zfs pool if we are backing up the root “/”

e.g. Backing up the root file system “/”

Excluded files (with wildcards): /rpool/*;/mnt/proxmox-hostname/*;/tmp/*
Default directories to backup: /

Note: You probably want to exclude “/mnt/data/*” as well.

If we are not doing any modification to system files, we can just backup following folder

/etc

What’s inside

# Note: replace <proxmox-hostname> with your node name
 
# Virtual machine .conf, LXC .conf, SSL certificates, storage related configuration, system settings etc.
/etc/pve/nodes/<proxmox-hostname>/
  
# Virtual machine .conf files
/etc/pve/nodes/<proxmox-host-name>/qemu-server/
 
# LXC .conf files
/etc/pve/nodes/<proxmox-hostname>/lxc/
 
# Mounting information
/etc/fstab
 
/root
 
/usr/local
 
/var

3.7 Click on “Client”, configure a value for “Soft client quota” if you have very limited storage, probably should modify “File Backup” frequency and other numbers too if storage is very limited.

3.8 If everything is set, we can now start to backup.

(Note: We can use “urbackupclientctl stauts” command from Proxmox VE host to check UrBackup status)

4 Restore

To restore the Proxmox VE host, we just simply perform following steps

4.1 Install the same Proxmox VE version on the new hard drive

4.2 Install UrBackup client again on Proxmox VE host (Make sure the hostname is the same), and the client connectes to the server

Note: If we are restoring to a different hardware, we need to make sure that the hostname is the same and we need the tokens in “/usr/local/var/urbackup/tokens” [4], or we can use “Download client for Linux” button from UrBackup web gui, then the token will be included

4.3 There are two ways to restore file and folders, one is through server web gui, another is via client command with “urbackupclientctl ….”

  • If we are using the client command on client, use “urbackupclientctl –help” to check available options, “urbackupclientctl browse” to browse backups and “urbackupclientctl restore-start” to restore

References

[1] “UrBackup – Download UrBackup for Windows, GNU/Linux or FreeBSD”, Urbackup.org, 2020. [Online]. Available: https://www.urbackup.org/download.html

[2] “UrBackup – Install UrBackup on Debian/Ubuntu”, Urbackup.org, 2020. [Online]. Available: https://www.urbackup.org/debianserverinstall.html

[3] “UrBackup – Server administration manual”, Urbackup.org, 2020. [Online]. Available: https://www.urbackup.org/administration_manual.html#x1-9000010.3

[4] “Restoring files to a different VM / PC”, UrBackup – Discourse, 2016. [Online]. Available: https://forums.urbackup.org/t/restoring-files-to-a-different-vm-pc/2221


How to: Fix UrBackup no “Restore” button from web gui from server

The Issue

There is no “Restore” button besides files from “Backup” tab in web gui

The Fix

To have the “Restore” button on the web gui, which allows us to restore directly from server web gui.

1 For Linux

1.1 Edit following file [1]

/etc/default/urbackupclient

1.2 Find following lines

# Valid settings:
#
# "client-confirms": If you have the GUI component the currently active user
#                    will need to confirm restores from the web interface.
#                    If you have no GUI component this will cause restores
#                    from the server web interface to not work
# "server-confirms": The server will ask the user starting the restore on 
#                    the web interface for confirmation
# "disabled":        Restores via web interface are disabled.
#                    Restores via urbackupclientctl still work
#
RESTORE=disabled

1.3 Change “RESTORE=disabled” to “RESTORE=server-confirms”, save the file

1.4 Restart urbackupclient

1.5 Check if we now have the “Restore” button available in UrBackup server web gui, if not, restart UrBackup server as well

2 For Windows

When browsing backups the web interface will show a restore button if the client is online. The restore will ask for user confirmation. If the client includes a GUI component (tray icon), the user confirmation will popup for all active users on the client to be restored. If not acknowledged in time (timeout) or if declined the restore will fail. You can change this behaviour in C:\Program files \UrBackup \args.txt by changing “default” to “server-confirms” on Windows, or by changing the restore setting in /etc/default/urbackupclient or /etc/sysconfig/urbackupclient on Linux.

Warning

UrBackup is setup this way because a theoretical data loss scenario is an attacker taking control of your backup server, deleting all backups and then deleting all files on the clients via restores.

On Linux (and the other operating systems) you can also restore via command line from the client using urbackupclientctl browse and urbackupclientctl restore-start. [1]

Referenses

[1] “UrBackup – Server administration manual”, Urbackup.org, 2020. [Online]. Available: https://www.urbackup.org/administration_manual.html#x1-860009.2

How to: Use data disks for Virtual Machine Storage/Virtual Disks with Cockpit with OMV 5 (Rather than the default storage folder on the system drive)

The Issue

When we create Virtual Machine with Cockpit on OMV, by default it will create a default storage for saving virtual machine’s virtual hard drives which on the system drive where OMV is installed

The Fix

To make sure the virtual machine’s virtual hard drive files is saved to our data partition/disk, we need to do following things.

1 Login to Cockpit

2 Find “Virtual Machine” Tab and click on it

3 Find “Storage” the the top of the screen, click on it.

4 Here we will need to create a folder for storing virtual hard drives, make sure you get the storage places right. For how to find the path for data drive, refer to this guide: How to: Install docker on OpenMediaVault 5 (OMV5) easily & How to: Configure docker (Docker Storage) to use specific location to store files/container/images other than default location easily (Do not follow Docker installation part, unless you want to install docker too)

Note: If you know the exact path you want to use on data drive, you do not need to follow the guide from step 4 for how to find the path.

5 Fill the full path correctly, make sure you name it “default”, that way, Cockpit will use this storage, otherwise Cockpit will create another storage folder and name it “default” to be used for new virtual machines


How to: Shrink/Reclaim free virtual disk space from Virtual Machines on Proxmox VE (PVE) (Windows/Linux/Debian/Ubuntu/Kali Linux/RHEL/CentOS/Fedora etc.)

Pre-requirements

Following method only works for virtual machines (VM) that are satisfying these pre-requirements:

  • Thin-provisioned backing storage (qcow2 disk, thin-lvm, zfs, …)
  • Virtio-SCSI controller configured on guest.
  • Guest scsi disks with the discard option enabled [1]

Note: While changing provisioning types and Virtio-SCSI driver are not easy with existing virtual machines, but changing VM scsi disk’s discard options is simple, that means, if we appear to have an existing VM that is using thin-provisioned backing storage and Virtio-SCSI but “discard” options is not enabled/checked, we can simply find that VM and check that option, then we are good to follow the reset of this guide.

The Issue

When we are using qcow2 sparse virtual disks, we can reclaim free disk spaces which not used by the virtual machine. How to trigger the VM/guest operating system to reclaim it for us though?

The Fix

1 Login to Proxmox VE web gui

2 Find the VM we want to reclaim the unused disk space for and click on it

3 Click on Hardware

4 Double click on the virtual hard’s virtual hard drive we want to reclaim unused space for

5 Make sure the “Discard” is checked

Proxmox VE - Discard option
Proxmox VE – Discard option

6 Start the VM

Once the VM is fully booted

6a For Linux/Debian/Ubuntu/Kali Linux/CentOS/RHEL/Fedora etc.

6a.1 We use following command to reclaim the unused disk space from a terminal

sudo fstrim -av

Once it’s done, we should be able to see the reclaimed disk space from Proxmox VE host (Only if there is unused space, if there is no unused space, we will not see any changes from Proxmox VE host’s disk space)

6a.2 We can also enable the automatic fstrim from the VM, so we do not need to do it manually everytime. Use following command to enable this feature

sudo systemctl enable fstrim.timer

6b For Windows

Usually the trim is enabled by default on Windows (Windows 7/2008R2 and up), we should not need to modify anything.

We can check if TRIM is enabled or not by using following command

fsutil behavior query DisableDeleteNotify

The output should be 0, otherwise, we can set it manually

fsutil behavior set DisableDeleteNotify 0

We can also trigger it manually, here is how.

First, we need to shutdown the Windows VM.

Then from the Proxmox VE web gui, find the Windows VM, Navigate to “Hardware”, double click on the virtual hard drive that we want to reclaim unused space from, make sure the “Discard” and “SSD emulation” are both checked, now start the Windows VM

Proxmox VE - Discard and SSD emulation checked
Proxmox VE – Discard and SSD emulation checked

When the Windows booted, we type “defrag” in start menu to search for “Defragment and Optimize Drives” program.

Windows 10 - Defragment and Optimize Drives
Windows 10 – Defragment and Optimize Drives

Click on it to launch it, then select the drive which we want to claim unused space from, click on “Optimize” button.

We now have manually reclaimed unused space from Windows VM

References

[1] “Shrink Qcow2 Disk Files – Proxmox VE”, Pve.proxmox.com, 2019. [Online]. Available: https://pve.proxmox.com/wiki/Shrink_Qcow2_Disk_Files


How to: Upload ISO files to Proxmox VE (PVE)

So that we can install operating systems 😉

1 Login to Proxmox VE web gui

2 Find the storage with “ISO image” listed in “Content”

Proxmox VE Storage View
Proxmox VE Storage View
Proxmox VE Storage View - Summary - Content - ISO Image
Proxmox VE Storage View – Summary – Content – ISO Image

Note: If the “ISO image” is not listed, that means we can not upload ISO to that storage location (Usually we can create an folder on that storage, make sure “ISO image” is selected during Directory creation, then we can upload ISO files to that storage location)

3 Click on “Content”

4 Click on “Upload” button at the top

5 Make sure “ISO image” is selected for “Content”

6 Now we can upload ISO files to Proxmox VE

7 The rest will be easy, click on “Select File…” button, select the ISO file we want to upload, click on “Upload” button to begin uploading, do not close the page until it’s finished

8 Now we can start to use it to install operating system.