Wednesday, February 26, 2020

Converting LVM to LVM Thin so Proxmox PVE will support Snapshot Backup and Thin Provisioning

I have been using Proxmox PVE since version 2.x.  Back in Proxmox version 2 and 3, a regular LVM partition with enough free space in its LVM Volume Group would be enough for Proxmox Backup Snapshot function to work.  However starting Proxmox version 5 you have to use LVM Thin (thin provisioning) in order to make backup with snapshot to work and support over provisioning.

Backup with snapshot is important because it allows the VM or CT to continue working during the backup process (uninterrupted).  This is crucial and makes backup seamless and effortless without downtime.

Over provisioning allow you to create VM and CT without actually taking up the storage size specified in the VM or CT.  For example, lets say you create a CT with 100GB storage, however the CT actually only use 20GB, with thin provisioning the LVM Thin will only take up 20GB instead of 100GB therefore allowing you to assign / provision more storage and you actually physically have capacity of.  Of course if all your CT / VM actually takes up 100% of their capacity and you over provision all your CT / VM you will run out of space!

Here are the steps I have done to convert my existing partition (/dev/md0) from typical ext4 mounted as a directory to my Proxmox (which currently does not work for backup with snapshot) and converting it to LVM Thin:


STEP 1 - Move all your VM and CT

First you need to empty and remove all your VM and CT if the partition you are working on is being used by some VM / CT.  I simply just STOP them and back them up one at a time and restore at a different proxmox server.   If you backup and restore, you will then still have to remove all the VM and CT in the hardware node you are working on.  The point here is, you have to empty the partition we will be converting to LVM Thin (because the data will be erased during the process).


STEP 2 - UNMOUNT THE PARTITION

Unmount the partition using the command:

umount /mnt/md0

in case the above fails you can try using 'force':

umount -f /mnt/md0


STEP 3 - CHANGE PARTITION TYPE TO LVM

See the list of devices recognize by fdisk and find the device ID you are working on:

fdisk -l

My device ID is /dev/md127

Next, I will use fdisk to create a new single partition (100% size) and change its type to LVM

fdisk /dev/md127

Type command 'n' to create new partition, select default options (press enter a few times to select default) until the partition has been created.

Type command 't' to change its type, type '8e' to select Linux LVM

Type command 'w' to commit changes.


STEP 4 - CREATE PHYSICAL VOLUME AND VOLUME GROUP

Use fdisk again to find the newly created LVM partition:

fdisk -l

My new device ID for the partition is /dev/md127p1

Create physical volume first:

pvcreate /dev/md127p1

Check to make sure physical volume has been created:

pvdisplay



Then create volume group, I would like to call my volume group local_md0

vgcreate local_md0 /dev/md127p1

Check to make sure volume group has been created:



STEP 5 - CREATE LOGICAL VOLUME WITH THIN OPTION

The lvcreate command below will create a THIN logical volume because of the -T option and will leave 5% of the volume group free.  The 5% is enough in my case because this is a 2TB partition.  You only need to reserve enough space for snapshot changes during backup operation.  Meaning lets say your backup takes 30 min, during that 30 min time, is your 5% free space enough to record all the changes that may happen within that 30 min window?

lvcreate -T -n local_md0 -l 95%FREE local_md0


STEP 6 - ADD STORAGE IN PROMOX PVE AS LVM THIN


Click on Datacenter > Storage > Add




STEP 7 - CONFIRM IT HAS BEEN ADDED AS STORAGE






Congratulations!  You know have LVM Thin which means you can do Backup with Snapshot and your VM and CT can be over provisioned!


Monday, December 2, 2019

Clean up logs, cache, docs, man files from Proxmox pve-root to free up disk space

My main pve-root partition was getting full (I only reserved 4GB, I should have reserved more space here, at least 8GB). I searched and found many areas where I can remove files to gain back a few megabytes.

DELETING UN-NEEDED FILES IN /usr/share/doc

cd /usr/share/doc
rm -rf *


DELETING UN-NEEDED FILES IN /usr/share/man

cd /usr/share/man
rm -rf *


CLEAN UP JOURNAL LOGS FROM /run/log/journal

journalctl --disk-usage
nano /etc/systemd/journald.conf
     add or edit this line:  SystemMaxUse=50M
Signal or restart systemd-journald service:
     systemctl kill --kill-who=main --signal=SIGUSR2 systemd-journald.service
       -or-
     systemctl restart systemd-journald.service


CLEAN UP /var/cache/apt

apt clean
apt purge
apt autoclean

SUMMARY

The commands above freed up about 650MB of space in my Proxmox PVE 5.1
I hope this article has been useful for you.

Tuesday, September 10, 2019

[EASY 5 MIN] Install Ubiquiti Unifi Controller on Proxmox VE LXC Container





This is a detailed video to show you how to setup/install Ubiquiti Unifi Controller on Proxmox VE LXC Container. I am using Ubuntu 16.04 / 18.04 in this video. This method is very fast, only takes about 5 min to do.

Help support my channel, if you are looking to buy ubiquiti products please use my Amazon link below:

https://amzn.to/2N8Ihro

#unifi #ubiquiti #unificontroller


Monday, September 9, 2019

Installing Ubiquiti UNIFI controller as a Proxmox VE LXC Container

This guide will help you Install a Ubiquiti UNIFI controller as a Proxmox LXC Container.

There are many benefits of having an always ONLINE Unifi controller, one of them that I am interested in is the Hot Spot / Captive Portal landing page customization.

Since I already have a Proxmox VE server running, I thought this will be the best method for me to have a Ubiquiti Unifi controller 24/7.


STEP 1 - Download Template for Ubuntu 18.04

Go to your Proxmox VE, go to your storage, and make sure you have downloaded a template for Ubuntu 18.04 Standard

STEP 2 - Create the LXC Container

Create an LXC container using the following settings:
Hostname: unifi
Disk size: 32GB
Memory: 2GB (but 1GB is also okay)
Network:  192.168.8.4/24

STEP 3 - Login to your container and Update APT

sudo apt update

STEP 4 - Installing CA Certificates

sudo apt-get install ca-certificates wget -y

STEP 5 - Download installation script


wget https://get.glennr.nl/unifi/install/unifi-5.11.39.sh

STEP 6 - Make the script executable (change filename to the script version you downloaded)

chmod +x unifi-5.11.39.sh

STEP 6 - Run the Install Script

./unifi-5.11.39.sh

STEP 7 - When finish installing go to your browser and type in

https://ip.of.your.server:8443

----------------------------------------

Thank you for using this guide.

Please help me support this blog by purchasing your Ubiquiti products from Amazon using my link below:

https://amzn.to/2A4WdtW

Much appreciated! :-)




Wednesday, July 10, 2019

[SOLVED] Mounting external USB drive to Proxmox LXC Container

I needed to mount an external USB drive directly to an LXC container.  On initial research, this process seems simple enough.

I am using Ubuntu / Debian for this guide.

Basically I do the following to get it mounted on the Proxmox Hardware Node first:

mkdir /mnt/mountpoint
chmod -R 777 /mnt/mountpoint (this is optional)
mount /dev/bus/usb/001/004 /mnt/mountpoint

BUT! when I tried to use it in the LXC container I got 'READ ONLY' permission issues. Some error message like this:

Read only filesystem!

So I did a lot more research and found many people have similar issues. I wasted 30 minutes trying different suggestions until I found one that worked.  The solution is the fact that linux was mounting the partition as fat32 / exfat. Therefore it could not perform Read and Write.  Here is the solution that worked for me...

STEP 1 - INSTALL ntfs-3g

sudo apt-get update
sudo apt-get install ntfs-3g

STEP 2 - MOUNT using NTFS file system type (my usb drive is at USB 001:004)

mkdir /mnt/mountpoint
chmod -R 777 /mnt/mountpoint (this is optional)
mount -t ntfs-3 /dev/bus/usb/001/004 /mnt/mountpoint

STEP 3 - CHECK IF YOU CAN READ & WRITE

cd /mnt/mountpoint
touch test

If step 3 did not produce any error and you can clearly see file 'test' being created, then you are good to go.

Next you just need to add one line to your LXC container configuration to set the mountpoint.

nano /etc/pve/lxc/123.conf   (assuming 123 is your CT ID)

Tuesday, May 21, 2019

How to mount NFS share to Proxmox LXC container

This is a quick how to guide to mount NFS share to your Proxmox VE LXC container.

If you are experiencing permission issue, you may want to read this article:

for example: May 21 12:42:31 e7 systemd[1]: Failed to start PVE LXC Container: 164.

Enabling NFS sharing mount bind in Proxmox

STEP 1 - EDIT YOUR LXC CONTAINER CONFIGURATION

nano /etc/pve/lxc/[CTID].conf


STEP 2 - ADD THE FOLLOWING LINE TO END OF CONFIGURATION FILE


mp0: [/host/nfs/shared_path],mp=[/lxc/container/mount_point_path]

for example:

mp0: /mnt/pve/nfs_share/,mp=/data_shared


(note: please make sure you pre-created the /data_shared (mount point) directory in your LXC container first)

STEP 3 - RESTART YOUR LXC


pct shutdown [CTID]
pct start [CTID]


Unlike openvz you do not have to edit / add anything to your fstab file. The next time you enter your container, you will have the NFS share automatically mounted.

Enabling NFS sharing (mount bind) for mounting NFS shares into LXC container

If you are running Proxmox 5.x and you are trying to mount an NFS share to your LXC container you may encounter permission denied issues.

such as:
May 21 12:42:31 e7 systemd[1]: Failed to start PVE LXC Container: 164.


This issue is caused by security permission in apparmor. We just need to reconfigure it so that it will support NFS shares.

This article will describe how to overcome this issue permission issue.

STEP 1 - COPY APPARMOR CONFIGURATION (on Proxmox Host)

cd /etc/apparmor.d/lxc
cp lxc-default-cgns lxc-container-default-with-nfs
nano lxc-container-default-with-nfs

Change lxc-container-default-cgns with lxc-container-default-with-nfs

Add the following lines right before the } (closing curly brace)

  mount fstype=nfs*,
  mount fstype=rpc_pipefs,


STEP 2 - RELOAD APPARMOR

systemctl reload apparmor



The above 2 steps will fix the AppArmor permission issues.

Next, you may want to know how to Bind Mount your NFS share to your LXC container, please click on the next article How to mount NFS share to Proxmox LXC container.



SAMPLE OF MY LXC CONFIGURATION FILE:


arch: amd64
cores: 4
hostname: blahblah
memory: 8192
nameserver: 10.0.0.1 8.8.8.8 4.4.4.4
net0: name=eth0,bridge=vmbr0,gw=10.0.0.1,hwaddr=_______________,ip=10.0.110.42/16,type=veth
ostype: ubuntu
rootfs: local_md0:164/vm-164-disk-1.raw,size=64G
searchdomain: localhost
swap: 8192
lxc.apparmor.profile: lxc-container-default-with-nfs
mp0: /mnt/pve/vepublicb1/tf/data_shared,mp=/data_shared