{"id":1226,"date":"2019-06-04T13:03:19","date_gmt":"2019-06-04T05:03:19","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=1226"},"modified":"2019-06-04T13:03:19","modified_gmt":"2019-06-04T05:03:19","slug":"pve-proxmox-tips","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=1226","title":{"rendered":"PVE Proxmox Tips"},"content":{"rendered":"\n<p>PVE Proxmox is Linux + KVM (or LXC) virtualization. It is freely\navailable from: <a href=\"https:\/\/www.proxmox.com\/en\/downloads\">https:\/\/www.proxmox.com\/en\/downloads<\/a><\/p>\n\n\n\n<p>Tested version:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pveversion\n   pve-manager\/5.1-41\/0b958203 (running kernel: 4.13.13-2-pve)<\/pre>\n\n\n\n<p>Notable highlights:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>HTML5\/js web client &#8211; works from both Linux and Windows. The only exception is\nSPICE console (requires native binary <code>virt-viewer<\/code>). However you can always use VNC as fallback<\/li><li>KVM\/QEMU supports memory overcommit well &#8211; see <a href=\"https:\/\/github.com\/hpaluch\/hpaluch.github.io\/wiki\/Hypervisor-Memory-overcommit-tests\">Hypervisor Memory overcommit tests<\/a>. The only\ncomparable hypervisor (in this respect)\nis <a href=\"https:\/\/www.vmware.com\/products\/esxi-and-esx.html\">ESXi<\/a> from VMware.<\/li><li>also supports LXC containers (no HW virtualization needed &#8211; least possible overhead)<\/li><li>also supports Software QEMU mode (slow, but useful when you have no HW virtualization &#8211; for example\nwhen running as nested VM on older CPU).<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\n<a href=\"https:\/\/github.com\/hpaluch\/hpaluch.github.io\/wiki\/PVE-Proxmox-Tips#putty-ssh-ciphers-error\"><\/a>Putty SSH ciphers error<\/h2>\n\n\n\n<p>If you get SSH connection error like\n<code>Couldn't agree a client-to-server cipher ...<\/code>\nthen you need to upgrade your Putty client (had success with <code>putty-64bit-0.70-installer.msi<\/code> from <a href=\"https:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/latest.html\">https:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/latest.html<\/a>)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\n<a href=\"https:\/\/github.com\/hpaluch\/hpaluch.github.io\/wiki\/PVE-Proxmox-Tips#list-and-download-pve-lxc-appliances\"><\/a>List and download PVE LXC appliances<\/h2>\n\n\n\n<p>To use Linux containers (LXC based) you need to download appliance filesystem archive<\/p>\n\n\n\n<p>Use this command to list LXC appliances:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pveam available<\/pre>\n\n\n\n<p>Use this command to download specific appliance:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pveam download local debian-9.0-standard_9.3-1_amd64.tar.gz<\/pre>\n\n\n\n<p>NOTE:<\/p>\n\n\n\n<p>The <code>local<\/code> argument is your storage name. You can list available storages using command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pvesm status<\/pre>\n\n\n\n<p>You can then create new LXC container using this template.\nExample using Web UI:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>logon to your Proxmox Web UI at <code>https:\/\/IP_ADDRESS:8006<\/code>\n<\/li><li>click on &#8220;Create CT&#8221; (blue button at right-top corner of webpage)<\/li><li>on &#8220;General&#8221; tab fill:\n<ul><li>&#8220;Password&#8221;<\/li><li>&#8220;Confirm Password&#8221;<\/li><\/ul>\n<\/li><li>on &#8220;Template&#8221; tab fill:\n<ul><li>&#8220;Storage&#8221; &#8211; keep &#8220;local&#8221; if possible<\/li><li>&#8220;Template&#8221; &#8211; there should be only option &#8211; previously downloaded <code>debian-9.0-standard_9.3-1_amd64.tar.gz<\/code>\n<\/li><\/ul>\n<\/li><li>keep defaults on &#8220;Root Disk&#8221; (lvm-thin), &#8220;CPU&#8221; and &#8220;Memory&#8221; tabs<\/li><li>on &#8220;Network&#8221; tab remember to either fill IPv4 (or IPv6) address or choice DHCP (if you have DHCP server on your network)<\/li><li>&#8220;DNS&#8221; &#8211; I have available &#8220;use host settings&#8221; only so it is easy<\/li><li>click on &#8220;Confirm&#8221; tab and then click on &#8220;Finish&#8221; button<\/li><li>wait for creation to complete:\n<ul><li>on &#8220;Status&#8221; tab you should see &#8220;stopped: OK&#8221;<\/li><\/ul>\n<\/li><\/ul>\n\n\n\n<p>Now you can expand in tree<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\n&#8220;Data Center&#8221; -&gt; &#8220;pve&#8221; -&gt; &#8220;100 (CT100)&#8221;\n<\/li><li>\nclick on &#8220;Start&#8221; button\n<\/li><li>\nyou can click on &#8220;Console&#8221; (or &#8220;Console JS&#8221;) to login to your container\n<\/li><li>\nin case or our Debian you can query container ip address using command:\nip addr\n<\/li><\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>NOTE: above Debian 9 image does not allow root to log via SSH &#8211; so you need to either\ncreate non-root user to login, or <code>PermitRootLogin yes<\/code> in <code>\/etc\/ssh\/sshd_config<\/code> of your LXC<\/p><\/blockquote>\n\n\n\n<p>Getting container info from Proxmox SSH connection:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\nlist LXC containers:\nlxc-ls\n   100\n<\/li><li>\nlist information about container <code>100<\/code>:\nlxc-info &#8211;name 100\n<\/li><\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>NOTE: grep <code>IP:<\/code> column to get IP address of container.<\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\n<a href=\"https:\/\/github.com\/hpaluch\/hpaluch.github.io\/wiki\/PVE-Proxmox-Tips#quick-download-of-iso-vm\"><\/a>Quick Download of ISO vm<\/h2>\n\n\n\n<p>To have new VM you typically need installation ISO. You can use either\nweb UI to upload ISO this way:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>logon to your Proxmox Web UI at <code>https:\/\/IP_ADDRESS:8006<\/code>\n<\/li><li>expand\/click on &#8220;Datacenter&#8221; -&gt; &#8220;pve&#8221; -&gt; &#8220;local&#8221;<\/li><li>clock on &#8220;Upload&#8221; on right-pane to Upload your ISO<\/li><\/ul>\n\n\n\n<p>Or you can download ISO image directly to your proxmox storage:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>SSH to your Proxmox<\/li><li>cd to ISO directory and download installation ISO image, for example:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/var\/lib\/vz\/template\/iso\nwget http:\/\/ftp.linux.cz\/pub\/linux\/debian-cd\/9.4.0\/amd64\/iso-cd\/debian-9.4.0-amd64-netinst.iso<\/pre>\n\n\n\n<p>NOTE: If your download fail you can continue it (without need to download whole file again)\nusing <code>-c<\/code> argument for example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wget -c http:\/\/ftp.linux.cz\/pub\/linux\/debian-cd\/9.4.0\/amd64\/iso-cd\/debian-9.4.0-amd64-netinst.iso<\/pre>\n\n\n\n<p>Now you can create your first VM using this ISO, for example:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>logon to your Proxmox Web UI at <code>https:\/\/IP_ADDRESS:8006<\/code>\n<\/li><li>click on &#8220;Create VM&#8221; blue button at the right-top of web page<\/li><li>click on &#8220;OS&#8221; tab\n<ul><li>select your &#8220;Iso image:&#8221; &#8211; <code>debian-9.4.0-amd64-netinst.iso<\/code>\n<\/li><\/ul>\n<\/li><li>click on &#8220;Hard Disk&#8221;, &#8220;CPU&#8221;, &#8220;Memory&#8221;, &#8220;Network&#8221;, &#8220;Confirm&#8221; tabs and on &#8220;Finish&#8221; button.<\/li><li>expand &#8220;Data Center&#8221; -&gt; &#8220;pve&#8221; -&gt; &#8220;101 (VM 101)&#8221;<\/li><li>click on &#8220;Start&#8221;<\/li><li>click on &#8220;Console&#8221; and follow standard Debian installation<\/li><\/ul>\n\n\n\n<p>PVE SSH commands to get basic info about VMs:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">qm list\n\n# 101 is VMID from \"qm list\"\nqm config 101<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\n<a href=\"https:\/\/github.com\/hpaluch\/hpaluch.github.io\/wiki\/PVE-Proxmox-Tips#listing-available-templates\"><\/a>Listing available templates<\/h2>\n\n\n\n<p>Use this command to list installed LXC and ISO templates:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># note: \"local\" is storage name\npvesm list local<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\n<a href=\"https:\/\/github.com\/hpaluch\/hpaluch.github.io\/wiki\/PVE-Proxmox-Tips#install-qemu-agent\"><\/a>Install QEMU Agent<\/h2>\n\n\n\n<p>QEMU Agent is used to run commands (for example shutdown&#8230;) in guest from Host.<\/p>\n\n\n\n<p>Please see <a href=\"https:\/\/pve.proxmox.com\/wiki\/Qemu-guest-agent\">https:\/\/pve.proxmox.com\/wiki\/Qemu-guest-agent<\/a> for guide.<\/p>\n\n\n\n<p>You can then run Agent commands from Proxmox SSH, for example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">qm agent 101 network-get-interfaces<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\n<a href=\"https:\/\/github.com\/hpaluch\/hpaluch.github.io\/wiki\/PVE-Proxmox-Tips#enable-backups-for-local-storage\"><\/a>Enable backups for local storage<\/h2>\n\n\n\n<p>It is two step operation:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>enable backup for <code>local<\/code> storage:\npvesm set local &#8211;content rootdir,images,backup,iso\n<\/li><li>set maximum number of backups to 99 (should be more than enough):\npvesm set local &#8211;maxfiles 99\n<\/li><\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">\n<a href=\"https:\/\/github.com\/hpaluch\/hpaluch.github.io\/wiki\/PVE-Proxmox-Tips#set-of-misc-scripts\"><\/a>Set of misc. scripts<\/h1>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>WARNING! <strong>Always<\/strong> customize and\/or double-check these scripts before running them !!!<\/p><\/blockquote>\n\n\n\n<p>Script  <code>batch_create.sh<\/code> to create multiple VMs from single backup (&#8220;full clone&#8221; from backup):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#!\/bin\/bash\nset -e\nfor i in `seq 2 15`\ndo\nvmid=$((100 + $i))\nset -x\nqm create $vmid \\\n    --archive \/var\/lib\/vz\/dump\/vzdump-qemu-101-2018_05_09-17_07_13.vma.lzo \\\n    --unique 1\n# --name can't be specify with --archive option...\nqm set $vmid --name \"CentOS7.4MariaBench-$i\"\nset +x\ndone\necho \"ALL Done\"\nexit 0<\/pre>\n\n\n\n<p>Script <code>batch_remove.sh<\/code> to  quickly remove VMs from 102 to 112(!):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#!\/bin\/bash\nset -e\nfor i in `seq 2 12`\ndo\nvmid=$((100 + $i))\nset -x\nqm destroy $vmid\nset +x\ndone\necho \"ALL DONE\"\nexit 0<\/pre>\n\n\n\n<p>Script <code>batch_start_and_wait.sh<\/code> to start and wait (till QEMU agent responds) sequence of VMs:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\n#!\/bin\/bash\nt1=`mktemp`\nset -e\nfor i in `seq 106 110`\ndo\n        echo -n \"Starting $i: \"\n        qm start $i\n        while true\n        do\n                if qm agent $i ping 2&gt; $t1\n                then\n                        echo\n                        break\n                fi\n                fgrep -q timeout $t1\n                echo -n \".\"\n                sleep 1\n        done\ndone\necho \"All done\"\nexit 0<\/pre>\n\n\n\n<p>Script <code>shutdown_all_running.sh<\/code> to shutdown all running VMs using QEMU Guest Agent&#8217;s Shutdown command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#!\/bin\/bash\nset -e\nfor i in `qm list | grep ' running ' | awk '{print $1}'`\ndo\nset -x\nqm agent $i shutdown\nset +x\ndone\necho \"All running VMs were shut down\"\nexit 0<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PVE Proxmox is Linux + KVM (or LXC) virtualization. It is freely available from: https:\/\/www.proxmox.com\/en\/downloads Tested version: pveversion pve-manager\/5.1-41\/0b958203 (running [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1226","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/1226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1226"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/1226\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}