<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>DevMemo – proxmox</title><link>https://devmemo.gitlab.io/tags/proxmox/</link><description>Recent content in proxmox on DevMemo</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Mon, 06 Feb 2023 15:10:26 -0800</lastBuildDate><atom:link href="https://devmemo.gitlab.io/tags/proxmox/index.xml" rel="self" type="application/rss+xml"/><item><title>Blog: Automate Proxmox VM Creation With Cloud-Init</title><link>https://devmemo.gitlab.io/blog/automate_proxmox_vm_creation_with_cloud_init/</link><pubDate>Mon, 06 Feb 2023 15:10:26 -0800</pubDate><guid>https://devmemo.gitlab.io/blog/automate_proxmox_vm_creation_with_cloud_init/</guid><description>
&lt;p>This post gives you step-by-step instructions of how to automate proxmox VM creation. I&amp;rsquo;ll use ubuntu as an example.&lt;/p>
&lt;h2 id="overview">Overview&lt;/h2>
&lt;p>The overall strategy is to use the &lt;a href="https://cloud-images.ubuntu.com/">ubuntu cloud image&lt;/a> to create a Proxmox VM template, and attach a cloud-init disk to it. After that, we can clone the template to create new VM, and new VM will automatically bootstrap itself, e.g., changing the hostname.&lt;/p>
&lt;h2 id="prepare-tools">Prepare tools&lt;/h2>
&lt;p>Install &lt;code>virt-customize&lt;/code>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>apt-get install libguestfs-tools
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="prepare-the-ubuntu-cloud-image">Prepare The Ubuntu Cloud Image&lt;/h2>
&lt;p>Use the following commands to prepare the ubuntu cloud image:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Create a new directory for our image building.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>mkdir ubuntu-cloud-image
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>cd ubuntu-cloud-image
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Download the cloud image.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Resize the image to 16GB. Feel free to change it to your desired size.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>qemu-img resize noble-server-cloudimg-amd64.img 16G
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Install avahi-deamon for mdns.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>virt-customize -a noble-server-cloudimg-amd64.img --run-command &lt;span style="color:#e6db74">&amp;#39;apt update &amp;amp;&amp;amp; apt install avahi-daemon -y &amp;amp;&amp;amp; cloud-init clean --logs --machine-id --configs all --reboot &amp;amp;&amp;amp; sudo truncate -s 0 /etc/machine-id /var/lib/dbus/machine-id&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="prepare-the-proxmox-vm-template">Prepare The Proxmox VM Template&lt;/h2>
&lt;p>Then, we prepare the Proxmox VM template with the following steps.&lt;/p>
&lt;h3 id="create-a-temporary-vm">Create A Temporary VM&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Create a VM with the following configuration:&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># * vmid: 1000 (feel free to change this)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># * memory: 4GB&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># * network: attached to bridge vmbr0&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>qm create &lt;span style="color:#ae81ff">1000&lt;/span> --name ubuntu-noble-template --memory &lt;span style="color:#ae81ff">4096&lt;/span> --net0 virtio,bridge&lt;span style="color:#f92672">=&lt;/span>vmbr0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="attach-the-ubuntu-cloud-image">Attach The Ubuntu Cloud Image&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Attach the ubuntu cloud image onto the VM.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Note that here ssd is my storage name. You&amp;#39;ll need to replace it with yours.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>qm importdisk &lt;span style="color:#ae81ff">1000&lt;/span> noble-server-cloudimg-amd64.img ssd
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Make the attached disk scsi0.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>qm set &lt;span style="color:#ae81ff">1000&lt;/span> --scsihw virtio-scsi-pci --scsi0 ssd:vm-1000-disk-0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Set scsi0 as the first boot device.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>qm set &lt;span style="color:#ae81ff">1000&lt;/span> --boot c --bootdisk scsi0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="create-a-cloud-init-drive">Create A Cloud-init Drive&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Create a cloud-init drive.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>qm set &lt;span style="color:#ae81ff">1000&lt;/span> --ide2 ssd:cloudinit
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Configure your cloud-init drive. Replace the username, password and sshkeys for your case.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>qm set &lt;span style="color:#ae81ff">1000&lt;/span> --ciuser swe --cipassword swe-passwd --sshkeys ~/.ssh/id_rsa.pub --ipconfig0 ip&lt;span style="color:#f92672">=&lt;/span>dhcp
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="convert-the-vm-into-a-template">Convert The VM Into A Template&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Convert the VM into a template.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>qm template &lt;span style="color:#ae81ff">1000&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="create-vm">Create VM&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Create a VM using the template, and set the name to ubuntu-vm1.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>qm clone &lt;span style="color:#ae81ff">1000&lt;/span> &lt;span style="color:#ae81ff">1101&lt;/span> --full --name ubuntu-vm1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Create another VM using the template, and set the name to ubuntu-vm2.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>qm clone &lt;span style="color:#ae81ff">1000&lt;/span> &lt;span style="color:#ae81ff">1102&lt;/span> --full --name ubuntu-vm2
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>To access these VMs, you can do&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Use the following command to access ubuntu-vm1 if you have mdns included in your template, and you are within the same LAN as ubuntu-vm1.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ssh swe@ubuntu-vm1.local
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Use the following command to access ubuntu-vm2 if you have mdns included in your template, and you are within the same LAN as ubuntu-vm2.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ssh swe@ubuntu-vm2.local
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Blog: Using LVM For Proxmox</title><link>https://devmemo.gitlab.io/blog/using_lvm_for_proxmox/</link><pubDate>Thu, 19 Jan 2023 15:02:22 -0800</pubDate><guid>https://devmemo.gitlab.io/blog/using_lvm_for_proxmox/</guid><description>
&lt;p>If you are trying to use Proxmox to set up a homelab for the first time, it must be very confusing to see all the storage related terms, e.g., LVM, LVM-Thin. This post talks about everything you need to know to understand how Proxmox uses LVM as its storage infrastructure.&lt;/p>
&lt;h2 id="lvm-basics">LVM Basics&lt;/h2>
&lt;p>LVM (Logical Volume Management) is actually a Linux technology. It is not Proxmox proprietary. Proxmox can leverage LVM as its storage infrastructure, but LVM itself is not part of Proxmox.&lt;/p>
&lt;p>Let&amp;rsquo;s try to understand the basics of LVM, and then we try to understand how Proxmox uses it.&lt;/p>
&lt;h3 id="what-is-lvm">What Is LVM?&lt;/h3>
&lt;p>The overall goal of LVM is to create a virtual storage layer on top of the physical storage layer, so that the storage usage can be more flexible.&lt;/p>
&lt;p>For example, if you have two 1TB disks, but you want to use them together as your root directory. LVM provides a solution to this.&lt;/p>
&lt;h3 id="how-does-lvm-work">How Does LVM Work?&lt;/h3>
&lt;p>The following image presents the overall architecture of LVM. (The image comes from &lt;a href="https://wiki.itcollege.ee/index.php?title=File:Lvm%271.jpg">wikipedia&lt;/a>)&lt;/p>
&lt;p align="center">
&lt;img src="https://devmemo.gitlab.io/blog/images/using_lvm_for_proxmox/lvm.jpg" style="width:70%" alt="lvm"/>
&lt;/p>
&lt;p>There are a couple of layers involved (from bottom to top):&lt;/p>
&lt;ul>
&lt;li>On the bottom layer, we have the physical disk itself. These are your hard drives.&lt;/li>
&lt;li>Above the hard drives, we have partitions. Each hard drive is splitted into a few partitions.&lt;/li>
&lt;li>PV (physical volume) is a LVM concept. It is a representation of a physical volume. It is mapped to a single disk partition.&lt;/li>
&lt;li>VG (volume group) is also a LVM concept. A VG contains a couple of PVs.&lt;/li>
&lt;li>LV (logical volume) is a logical volume, which is basically a virtual volume.&lt;/li>
&lt;li>On top of each LV, a file system can be created, and the LV device can be mounted to an accessible directory.&lt;/li>
&lt;/ul>
&lt;p>In this design, logical volume does not have to tie to a single physical disk. Logical volume can be created over multiple physical disks.&lt;/p>
&lt;h3 id="installation-lvm">Installation LVM&lt;/h3>
&lt;p>On debian and ubuntu, you can do&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo apt install lvm2
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="how-to-use-lvm">How To Use LVM?&lt;/h3>
&lt;p>Here are some commands to manage PV, VG and LV.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Create a PV&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>pvcreate &amp;lt;disk-device-name&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Remove a PV&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>pvremove &amp;lt;disk-device-name&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># List all PVs&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>pvs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Create a VG&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>vgcreate &amp;lt;vg-name&amp;gt; &amp;lt;disk-device-name&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Remove a VG&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>vgremove &amp;lt;vg-name&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># List all VGs&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>vgs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Create a LV&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>lvcreate -L &amp;lt;lv-size&amp;gt; -n &amp;lt;lv-name&amp;gt; &amp;lt;vg-name&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Remove a LV&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>lvremove &amp;lt;vg-name&amp;gt;/&amp;lt;lv-name&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># List all LVs&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>lvs
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="an-example">An Example&lt;/h4>
&lt;p>For example, I have a empty &lt;code>/dev/sdb&lt;/code> device,&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$ lsblk
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop0 7:0 &lt;span style="color:#ae81ff">0&lt;/span> 63.3M &lt;span style="color:#ae81ff">1&lt;/span> loop /snap/core20/1778
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop1 7:1 &lt;span style="color:#ae81ff">0&lt;/span> 141.4M &lt;span style="color:#ae81ff">1&lt;/span> loop /snap/docker/2285
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop2 7:2 &lt;span style="color:#ae81ff">0&lt;/span> 55.6M &lt;span style="color:#ae81ff">1&lt;/span> loop /snap/core18/2667
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop3 7:3 &lt;span style="color:#ae81ff">0&lt;/span> 55.4M &lt;span style="color:#ae81ff">1&lt;/span> loop /snap/core18/2066
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop5 7:5 &lt;span style="color:#ae81ff">0&lt;/span> 67.6M &lt;span style="color:#ae81ff">1&lt;/span> loop /snap/lxd/20326
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop6 7:6 &lt;span style="color:#ae81ff">0&lt;/span> 49.6M &lt;span style="color:#ae81ff">1&lt;/span> loop /snap/snapd/17883
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop7 7:7 &lt;span style="color:#ae81ff">0&lt;/span> 49.8M &lt;span style="color:#ae81ff">1&lt;/span> loop /snap/snapd/17950
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop8 7:8 &lt;span style="color:#ae81ff">0&lt;/span> 91.9M &lt;span style="color:#ae81ff">1&lt;/span> loop /snap/lxd/24061
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop9 7:9 &lt;span style="color:#ae81ff">0&lt;/span> 139.4M &lt;span style="color:#ae81ff">1&lt;/span> loop /snap/docker/2343
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sda 8:0 &lt;span style="color:#ae81ff">0&lt;/span> 32G &lt;span style="color:#ae81ff">0&lt;/span> disk
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>├─sda1 8:1 &lt;span style="color:#ae81ff">0&lt;/span> 1M &lt;span style="color:#ae81ff">0&lt;/span> part
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>└─sda2 8:2 &lt;span style="color:#ae81ff">0&lt;/span> 32G &lt;span style="color:#ae81ff">0&lt;/span> part /
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sdb 8:16 &lt;span style="color:#ae81ff">0&lt;/span> 32G &lt;span style="color:#ae81ff">0&lt;/span> disk
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sr0 11:0 &lt;span style="color:#ae81ff">1&lt;/span> 4M &lt;span style="color:#ae81ff">0&lt;/span> rom
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sr1 11:1 &lt;span style="color:#ae81ff">1&lt;/span> 1024M &lt;span style="color:#ae81ff">0&lt;/span> rom
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>let&amp;rsquo;s create a PV on it&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$ sudo pvcreate /dev/sdb
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Physical volume &lt;span style="color:#e6db74">&amp;#34;/dev/sdb&amp;#34;&lt;/span> successfully created.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$ sudo pvs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> PV VG Fmt Attr PSize PFree
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> /dev/sdb lvm2 --- 32.00g 32.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>and then create a VG on the PV&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$ sudo vgcreate test-vg /dev/sdb
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Volume group &lt;span style="color:#e6db74">&amp;#34;test-vg&amp;#34;&lt;/span> successfully created
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$ sudo vgs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> VG &lt;span style="color:#75715e">#PV #LV #SN Attr VSize VFree&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> test-vg &lt;span style="color:#ae81ff">1&lt;/span> &lt;span style="color:#ae81ff">0&lt;/span> &lt;span style="color:#ae81ff">0&lt;/span> wz--n- &amp;lt;32.00g &amp;lt;32.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>and then create a LV on the VG&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$ sudo lvcreate -L 10G -n test-lv test-vg
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Logical volume &lt;span style="color:#e6db74">&amp;#34;test-lv&amp;#34;&lt;/span> created.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$ sudo lvs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> test-lv test-vg -wi-a----- 10.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now we can create a file system on the LG, and mount it for real usage:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$ sudo mkfs.ext4 /dev/test-vg/test-lv
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>mke2fs 1.45.5 &lt;span style="color:#f92672">(&lt;/span>07-Jan-2020&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Discarding device blocks: &lt;span style="color:#66d9ef">done&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Creating filesystem with &lt;span style="color:#ae81ff">2621440&lt;/span> 4k blocks and &lt;span style="color:#ae81ff">655360&lt;/span> inodes
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Filesystem UUID: 5c329fcf-76ec-450a-8d96-dfb816538e3e
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Superblock backups stored on blocks:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> 32768, 98304, 163840, 229376, 294912, 819200, 884736, &lt;span style="color:#ae81ff">1605632&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Allocating group tables: &lt;span style="color:#66d9ef">done&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Writing inode tables: &lt;span style="color:#66d9ef">done&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Creating journal &lt;span style="color:#f92672">(&lt;/span>&lt;span style="color:#ae81ff">16384&lt;/span> blocks&lt;span style="color:#f92672">)&lt;/span>: &lt;span style="color:#66d9ef">done&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Writing superblocks and filesystem accounting information: &lt;span style="color:#66d9ef">done&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:~$ cd /
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:/$ sudo mkdir mount
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:/$ sudo mount /dev/test-vg/test-lv /mount
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:/$ cd mount/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:/mount$ ls
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>lost+found
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:/mount$
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now, we have an ext4 filesystem on the LV:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>swe@ubuntu-server:/mount$ lsblk -f
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop0 squashfs &lt;span style="color:#ae81ff">0&lt;/span> 100% /snap/core20/1778
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop1 squashfs &lt;span style="color:#ae81ff">0&lt;/span> 100% /snap/docker/2285
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop2 squashfs &lt;span style="color:#ae81ff">0&lt;/span> 100% /snap/core18/2667
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop3 squashfs &lt;span style="color:#ae81ff">0&lt;/span> 100% /snap/core18/2066
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop5 squashfs &lt;span style="color:#ae81ff">0&lt;/span> 100% /snap/lxd/20326
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop6 squashfs &lt;span style="color:#ae81ff">0&lt;/span> 100% /snap/snapd/17883
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop7 squashfs &lt;span style="color:#ae81ff">0&lt;/span> 100% /snap/snapd/17950
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop8 squashfs &lt;span style="color:#ae81ff">0&lt;/span> 100% /snap/lxd/24061
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>loop9 squashfs &lt;span style="color:#ae81ff">0&lt;/span> 100% /snap/docker/2343
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sda
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>├─sda1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>└─sda2 ext4 761b4178-9020-4642-ac79-d172a2a0a06d 21G 28% /
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sdb LVM2_member biMIK2-WI2D-ypLl-tVGw-p8hZ-CynW-vo8swy
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>└─test--vg-test--lv ext4 5c329fcf-76ec-450a-8d96-dfb816538e3e 9.2G 0% /mount
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sr0 iso9660 cidata 2023-01-12-13-13-29-00
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sr1
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="how-does-proxmox-use-lvm">How Does Proxmox Use LVM?&lt;/h2>
&lt;p>Now you have a basic understanding of LVM. So how does Proxmox use LVM as its storage infrastructure?&lt;/p>
&lt;p>In a few words, Proxmox uses LVs for two purposes:&lt;/p>
&lt;ul>
&lt;li>Use LVs as the client OS disks.&lt;/li>
&lt;li>Use a LV as the host OS root directory.&lt;/li>
&lt;/ul>
&lt;p>For example,&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>root@host3:~$ pvs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> PV VG Fmt Attr PSize PFree
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> /dev/nvme0n1p3 ssd lvm2 a-- &amp;lt;1.82t 738.50g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>root@host3:~$
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>root@host3:~$ vgs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> VG &lt;span style="color:#75715e">#PV #LV #SN Attr VSize VFree&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ssd &lt;span style="color:#ae81ff">1&lt;/span> &lt;span style="color:#ae81ff">13&lt;/span> &lt;span style="color:#ae81ff">0&lt;/span> wz--n- &amp;lt;1.82t 738.50g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>root@host3:~$
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>root@host3:~$ lvs
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> root ssd -wi-ao---- 96.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-1001-disk-0 ssd -wi-ao---- 16.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-2000-cloudinit ssd -wi-ao---- 4.00m
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-2000-disk-0 ssd -wi-ao---- 16.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-2002-cloudinit ssd -wi-ao---- 4.00m
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-2002-disk-0 ssd -wi-ao---- 16.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-5000-disk-0 ssd -wi-ao---- 200.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-7000-disk-0 ssd -wi-a----- 16.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-7000-disk-1 ssd -wi-a----- 500.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-8000-cloudinit ssd -wi-a----- 4.00m
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-8000-disk-0 ssd -wi-a----- 32.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-8000-disk-1 ssd -wi-a----- 200.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> vm-8001-disk-0 ssd -wi-a----- 32.00g
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>root@host3:~$
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The above commands shows that on one of my Proxmox servers, I have a PV, &lt;code>/dev/nvme0n1p3&lt;/code>, a VG, &lt;code>ssd&lt;/code>, and a few LVs. Each of the client OS has its own LVs.&lt;/p>
&lt;p>Using LV as the host OS storage device makes a lot of sense, which is the whole point of LVM.&lt;/p>
&lt;h2 id="lvm-thin">LVM-Thin&lt;/h2>
&lt;p>By default, Proxmox does not use LVM. Instead, it uses LVM-thin. The difference between LVM-thin and LVM is that:&lt;/p>
&lt;ul>
&lt;li>LVM allocates your storage blocks when you create LVs. With LVM, your LV&amp;rsquo;s storage is guaranteed for your use.&lt;/li>
&lt;li>LVM-thin allocates your storage blocks when you write data to LVs. LVM-thin provides a higher disk utilization, but it can&amp;rsquo;t guarantee you can use all your LV storage.&lt;/li>
&lt;/ul></description></item></channel></rss>