[{"data":1,"prerenderedAt":11342},["ShallowReactive",2],{"breadcrumb-title:/library/wordpress/useful-things/":3,"navigation":4,"contentData":93,"library":633},"A collection of WordPress Scripts",[5],{"title":6,"path":7,"stem":8,"children":9,"page":19},"Library","/library","library",[10,20,37,46,55,68,81],{"title":11,"path":12,"stem":13,"children":14,"page":19},"Linux","/library/linux","library/Linux",[15],{"title":16,"path":17,"stem":18},"Creating a swap partition in Linux","/library/linux/creating-a-swap-partition-on-linux","library/Linux/creating-a-swap-partition-on-linux",false,{"title":21,"path":22,"stem":23,"children":24,"page":19},"Dataflex","/library/dataflex","library/dataflex",[25,29,33],{"title":26,"path":27,"stem":28},"DataFlex - Clear a data dictionary but keep its parents","/library/dataflex/clear-data-dictionary-keep-parents","library/dataflex/clear-data-dictionary-keep-parents",{"title":30,"path":31,"stem":32},"Beginner DataFlex errors everyone makes","/library/dataflex/most-common-beginner-dataflex-errors","library/dataflex/most-common-beginner-dataflex-errors",{"title":34,"path":35,"stem":36},"Essential Security Headers in IIS: Referrer-Policy and More","/library/dataflex/security-headers-for-iis","library/dataflex/security-headers-for-iis",{"title":38,"path":39,"stem":40,"children":41,"page":19},"Networking","/library/networking","library/networking",[42],{"title":43,"path":44,"stem":45},"Fixing MTU, Path MTU Discovery and MSS Clamping Issues","/library/networking/understanding-and-fixing-mtu-mss","library/networking/understanding-and-fixing-mtu-mss",{"title":47,"path":48,"stem":49,"children":50,"page":19},"Postgresql","/library/postgresql","library/postgresql",[51],{"title":52,"path":53,"stem":54},"Handy PostgreSQL Snippets","/library/postgresql/a-collection-of-useful-snippets","library/postgresql/a-collection-of-useful-snippets",{"title":56,"path":57,"stem":58,"children":59,"page":19},"Proxmox","/library/proxmox","library/proxmox",[60,64],{"title":61,"path":62,"stem":63},"Encrypting Proxmox VMs with ZFS for Secure Virtualization","/library/proxmox/proxmox-encrypted-vms-with-zfs","library/proxmox/proxmox-encrypted-vms-with-zfs",{"title":65,"path":66,"stem":67},"Proxmox Monitoring with Grafana and Prometheus","/library/proxmox/proxmox-monitoring-with-grafana","library/proxmox/proxmox-monitoring-with-grafana",{"title":69,"path":70,"stem":71,"children":72,"page":19},"Windows","/library/windows","library/windows",[73,77],{"title":74,"path":75,"stem":76},"Windows Subsystem for Linux","/library/windows/windows-subsystem-for-linux","library/windows/Windows-Subsystem-for-Linux",{"title":78,"path":79,"stem":80},"A collection of Powershell Scripts","/library/windows/handy-powershell-scripts","library/windows/handy-powershell-scripts",{"title":82,"path":83,"stem":84,"children":85,"page":19},"Wordpress","/library/wordpress","library/wordpress",[86,90],{"title":87,"path":88,"stem":89},"How to install WordPress in XAMPP with vhost on Windows","/library/wordpress/how-to-install-wordpress-in-xampp-with-vhost","library/wordpress/how-to-install-wordpress-in-xampp-with-vhost",{"title":3,"path":91,"stem":92},"/library/wordpress/useful-things","library/wordpress/useful-things",{"id":94,"title":3,"body":95,"categories":621,"description":623,"extension":624,"meta":625,"navigation":218,"ogImage":627,"path":91,"publish_at":628,"seo":629,"stem":92,"tags":630,"__hash__":632},"library/library/wordpress/useful-things.md",{"type":96,"value":97,"toc":616},"minimark",[98,103,107,285,289,292,295,324,328,331,612],[99,100,102],"h2",{"id":101},"generate-wp-configphp-salts","Generate wp-config.php salts",[104,105,106],"p",{},"This is used to generate a unique set of salts, written in Ruby. Simply copy the output and paste in your wp-config.php",[108,109,114],"pre",{"className":110,"code":111,"language":112,"meta":113,"style":113},"language-ruby shiki shiki-themes github-dark","function generate_key() {\n  echo -n \"${1}: '\"\n  tr -dc 'A-Za-z0-9!\"#$%&()*+,-./:;\u003C=>?@[\\]^_`{|}~' \u003C/dev/urandom | head -c 64  ; echo -n\n  echo \"'\"\n}\n\ngenerate_key \"auth_key\"\ngenerate_key \"secure_auth_key\"\ngenerate_key \"logged_in_key\"\ngenerate_key \"nonce_key\"\ngenerate_key \"auth_salt\"\ngenerate_key \"secure_auth_salt\"\ngenerate_key \"logged_in_salt\"\ngenerate_key \"nonce_salt\"\n","ruby","",[115,116,117,133,150,199,207,213,220,229,237,245,253,261,269,277],"code",{"__ignoreMap":113},[118,119,122,126,130],"span",{"class":120,"line":121},"line",1,[118,123,125],{"class":124},"s95oV","function ",[118,127,129],{"class":128},"svObZ","generate_key",[118,131,132],{"class":124},"() {\n",[118,134,136,139,143,146],{"class":120,"line":135},2,[118,137,138],{"class":124},"  echo ",[118,140,142],{"class":141},"snl16","-",[118,144,145],{"class":124},"n ",[118,147,149],{"class":148},"sU2Wk","\"${1}: '\"\n",[118,151,153,156,158,161,164,167,170,173,176,179,182,184,187,191,194,196],{"class":120,"line":152},3,[118,154,155],{"class":124},"  tr ",[118,157,142],{"class":141},[118,159,160],{"class":124},"dc ",[118,162,163],{"class":148},"'A-Za-z0-9!\"#$%&()*+,-./:;\u003C=>?@[\\]^_`{|}~'",[118,165,166],{"class":141}," \u003C/",[118,168,169],{"class":124},"dev",[118,171,172],{"class":141},"/",[118,174,175],{"class":124},"urandom ",[118,177,178],{"class":141},"|",[118,180,181],{"class":124}," head ",[118,183,142],{"class":141},[118,185,186],{"class":124},"c ",[118,188,190],{"class":189},"sDLfK","64",[118,192,193],{"class":124},"  ; echo ",[118,195,142],{"class":141},[118,197,198],{"class":124},"n\n",[118,200,202,204],{"class":120,"line":201},4,[118,203,138],{"class":124},[118,205,206],{"class":148},"\"'\"\n",[118,208,210],{"class":120,"line":209},5,[118,211,212],{"class":124},"}\n",[118,214,216],{"class":120,"line":215},6,[118,217,219],{"emptyLinePlaceholder":218},true,"\n",[118,221,223,226],{"class":120,"line":222},7,[118,224,225],{"class":124},"generate_key ",[118,227,228],{"class":148},"\"auth_key\"\n",[118,230,232,234],{"class":120,"line":231},8,[118,233,225],{"class":124},[118,235,236],{"class":148},"\"secure_auth_key\"\n",[118,238,240,242],{"class":120,"line":239},9,[118,241,225],{"class":124},[118,243,244],{"class":148},"\"logged_in_key\"\n",[118,246,248,250],{"class":120,"line":247},10,[118,249,225],{"class":124},[118,251,252],{"class":148},"\"nonce_key\"\n",[118,254,256,258],{"class":120,"line":255},11,[118,257,225],{"class":124},[118,259,260],{"class":148},"\"auth_salt\"\n",[118,262,264,266],{"class":120,"line":263},12,[118,265,225],{"class":124},[118,267,268],{"class":148},"\"secure_auth_salt\"\n",[118,270,272,274],{"class":120,"line":271},13,[118,273,225],{"class":124},[118,275,276],{"class":148},"\"logged_in_salt\"\n",[118,278,280,282],{"class":120,"line":279},14,[118,281,225],{"class":124},[118,283,284],{"class":148},"\"nonce_salt\"\n",[99,286,288],{"id":287},"generate-a-maintenance-file-to-turn-off-website-while-doing-updates","Generate a Maintenance file to turn off website while doing updates",[104,290,291],{},"This can be handy if you’re replacing the database or doing some other destructive work where you would like to temporarily bring down the site.",[104,293,294],{},"Create a .maintenace file in the root of your WordPress directory with the following contents",[108,296,300],{"className":297,"code":298,"language":299,"meta":113,"style":113},"language-php shiki shiki-themes github-dark","\u003C?php $upgrading = time(); ?>\n","php",[115,301,302],{"__ignoreMap":113},[118,303,304,307,309,312,315,318,321],{"class":120,"line":121},[118,305,306],{"class":141},"\u003C?",[118,308,299],{"class":189},[118,310,311],{"class":124}," $upgrading ",[118,313,314],{"class":141},"=",[118,316,317],{"class":189}," time",[118,319,320],{"class":124},"(); ",[118,322,323],{"class":141},"?>\n",[99,325,327],{"id":326},"remove-link-on-menu-items","Remove link on menu items",[104,329,330],{},"When you have a drop down menu, on phones, the top level is a link which will never allow mobile users to access the sub menu. To fix this, add the following to the functions.php file in your theme directory.",[108,332,334],{"className":297,"code":333,"language":299,"meta":113,"style":113},"add_filter( 'wp_nav_menu_items', function ( $menu ) {\n    return str_replace( '\u003Ca href=\"#\"', '\u003Ca', $menu );\n} );\nadd_action( 'wp_footer', function(){\n    ?>\n    \u003Cscript>\n    (function( $ ) {\n        var itemm = $('#primary-menu .menu-item-has-children > a');\n        itemm.click(function(e){\n            e.preventDefault();\n            document.activeElement && document.activeElement.blur();\n            $(e.target).parent('li').find('.subnav-toggle').click();\n            return false;\n        });\n    })(jQuery);\n    \u003C/script>\n\u003C?php\n }, 1, 0 );\n",[115,335,336,356,377,382,399,404,415,425,445,464,477,504,550,561,566,577,587,595],{"__ignoreMap":113},[118,337,338,341,344,347,350,353],{"class":120,"line":121},[118,339,340],{"class":128},"add_filter",[118,342,343],{"class":124},"( ",[118,345,346],{"class":148},"'wp_nav_menu_items'",[118,348,349],{"class":124},", ",[118,351,352],{"class":141},"function",[118,354,355],{"class":124}," ( $menu ) {\n",[118,357,358,361,364,366,369,371,374],{"class":120,"line":135},[118,359,360],{"class":141},"    return",[118,362,363],{"class":189}," str_replace",[118,365,343],{"class":124},[118,367,368],{"class":148},"'\u003Ca href=\"#\"'",[118,370,349],{"class":124},[118,372,373],{"class":148},"'\u003Ca'",[118,375,376],{"class":124},", $menu );\n",[118,378,379],{"class":120,"line":152},[118,380,381],{"class":124},"} );\n",[118,383,384,387,389,392,394,396],{"class":120,"line":201},[118,385,386],{"class":128},"add_action",[118,388,343],{"class":124},[118,390,391],{"class":148},"'wp_footer'",[118,393,349],{"class":124},[118,395,352],{"class":141},[118,397,398],{"class":124},"(){\n",[118,400,401],{"class":120,"line":209},[118,402,403],{"class":141},"    ?>\n",[118,405,406,409,412],{"class":120,"line":215},[118,407,408],{"class":141},"    \u003C",[118,410,411],{"class":189},"script",[118,413,414],{"class":141},">\n",[118,416,417,420,422],{"class":120,"line":222},[118,418,419],{"class":124},"    (",[118,421,352],{"class":141},[118,423,424],{"class":124},"( $ ) {\n",[118,426,427,430,433,436,439,442],{"class":120,"line":231},[118,428,429],{"class":141},"        var",[118,431,432],{"class":189}," itemm",[118,434,435],{"class":141}," =",[118,437,438],{"class":124}," $(",[118,440,441],{"class":148},"'#primary-menu .menu-item-has-children > a'",[118,443,444],{"class":124},");\n",[118,446,447,450,453,456,459,461],{"class":120,"line":239},[118,448,449],{"class":189},"        itemm",[118,451,452],{"class":141},".",[118,454,455],{"class":128},"click",[118,457,458],{"class":124},"(",[118,460,352],{"class":141},[118,462,463],{"class":124},"(e){\n",[118,465,466,469,471,474],{"class":120,"line":247},[118,467,468],{"class":189},"            e",[118,470,452],{"class":141},[118,472,473],{"class":128},"preventDefault",[118,475,476],{"class":124},"();\n",[118,478,479,482,484,487,490,493,495,497,499,502],{"class":120,"line":255},[118,480,481],{"class":189},"            document",[118,483,452],{"class":141},[118,485,486],{"class":189},"activeElement",[118,488,489],{"class":141}," &&",[118,491,492],{"class":189}," document",[118,494,452],{"class":141},[118,496,486],{"class":189},[118,498,452],{"class":141},[118,500,501],{"class":128},"blur",[118,503,476],{"class":124},[118,505,506,509,512,514,517,520,522,525,527,530,532,534,537,539,542,544,546,548],{"class":120,"line":263},[118,507,508],{"class":124},"            $(",[118,510,511],{"class":189},"e",[118,513,452],{"class":141},[118,515,516],{"class":189},"target",[118,518,519],{"class":124},")",[118,521,452],{"class":141},[118,523,524],{"class":141},"parent",[118,526,458],{"class":124},[118,528,529],{"class":148},"'li'",[118,531,519],{"class":124},[118,533,452],{"class":141},[118,535,536],{"class":128},"find",[118,538,458],{"class":124},[118,540,541],{"class":148},"'.subnav-toggle'",[118,543,519],{"class":124},[118,545,452],{"class":141},[118,547,455],{"class":128},[118,549,476],{"class":124},[118,551,552,555,558],{"class":120,"line":271},[118,553,554],{"class":141},"            return",[118,556,557],{"class":189}," false",[118,559,560],{"class":124},";\n",[118,562,563],{"class":120,"line":279},[118,564,565],{"class":124},"        });\n",[118,567,569,572,575],{"class":120,"line":568},15,[118,570,571],{"class":124},"    })(",[118,573,574],{"class":189},"jQuery",[118,576,444],{"class":124},[118,578,580,583,585],{"class":120,"line":579},16,[118,581,582],{"class":141},"    \u003C/",[118,584,411],{"class":189},[118,586,414],{"class":141},[118,588,590,592],{"class":120,"line":589},17,[118,591,306],{"class":141},[118,593,594],{"class":189},"php\n",[118,596,598,601,604,606,609],{"class":120,"line":597},18,[118,599,600],{"class":124}," }, ",[118,602,603],{"class":189},"1",[118,605,349],{"class":124},[118,607,608],{"class":189},"0",[118,610,611],{"class":124}," );\n",[613,614,615],"style",{},"html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":113,"searchDepth":135,"depth":135,"links":617},[618,619,620],{"id":101,"depth":135,"text":102},{"id":287,"depth":135,"text":288},{"id":326,"depth":135,"text":327},[622],"WordPress","WordPress runs a lot of websites around the world. As we host quite a lot, we have collected a resource of scripts we have found useful.","md",{"slug":92,"isHowTo":218,"image":626},"/images/blogs/blog1.png",null,"2024-11-08T07:09:00.000Z",{"title":3,"description":623},[631],"wordpress","B5OeNuMptKdBvY_ije4KTRG87P6PqQMIflybvR6OuNE",[634,874,917,1088,1816,2368,5773,8828,9759,9922,10483,10960],{"id":635,"title":16,"body":636,"categories":865,"description":867,"extension":624,"meta":868,"navigation":218,"ogImage":627,"path":17,"publish_at":870,"seo":871,"stem":18,"tags":872,"__hash__":873},"library/library/Linux/creating-a-swap-partition-on-linux.md",{"type":96,"value":637,"toc":856},[638,646,649,653,656,674,677,681,684,699,702,736,740,743,759,763,766,775,779,782,791,795,798,813,816,820,823,835,838,853],[104,639,640],{},[641,642],"img",{"alt":643,"src":644,"style":645},"A diagram of the linux swap and reclaiming","/images/articles/linux-disk-swap-image.png","display: block; margin: 0 auto; max-width: 700px; width: 100%;",[104,647,648],{},"This guide explains how to set up SWAP on an existing Linux system.",[99,650,652],{"id":651},"_1-check-if-swap-already-exists","1. Check if SWAP already exists",[104,654,655],{},"Run the following command to see if any swap space is currently active:",[108,657,661],{"className":658,"code":659,"language":660,"meta":113,"style":113},"language-cmd shiki shiki-themes github-dark","sudo swapon --show\n","cmd",[115,662,663],{"__ignoreMap":113},[118,664,665,668,671],{"class":120,"line":121},[118,666,667],{"class":124},"sudo swapon ",[118,669,670],{"class":141},"--",[118,672,673],{"class":124},"show\n",[104,675,676],{},"If nothing is returned, there is no active swap.",[99,678,680],{"id":679},"_2-create-the-swap-file","2. Create the SWAP file",[104,682,683],{},"Create a new swap file using fallocate:",[108,685,687],{"className":658,"code":686,"language":660,"meta":113,"style":113},"sudo fallocate -l 1G /swapfile\n",[115,688,689],{"__ignoreMap":113},[118,690,691,694,696],{"class":120,"line":121},[118,692,693],{"class":124},"sudo fallocate ",[118,695,142],{"class":141},[118,697,698],{"class":124},"l 1G /swapfile\n",[104,700,701],{},"Replace 1G with the desired size, e.g. 2G or 4G.\nIf the command fails (for example, on older filesystems), use dd instead:",[108,703,705],{"className":658,"code":704,"language":660,"meta":113,"style":113},"sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576\n",[115,706,707],{"__ignoreMap":113},[118,708,709,712,715,718,720,723,725,728,731,733],{"class":120,"line":121},[118,710,711],{"class":124},"sudo dd ",[118,713,714],{"class":141},"if=",[118,716,717],{"class":124},"/dev/zero of",[118,719,314],{"class":141},[118,721,722],{"class":124},"/swapfile bs",[118,724,314],{"class":141},[118,726,727],{"class":189},"1024",[118,729,730],{"class":124}," count",[118,732,314],{"class":141},[118,734,735],{"class":189},"1048576\n",[99,737,739],{"id":738},"_3-secure-the-swap-file","3. Secure the SWAP file",[104,741,742],{},"Restrict access so only root can read and write to it:",[108,744,746],{"className":658,"code":745,"language":660,"meta":113,"style":113},"sudo chmod 600 /swapfile\n",[115,747,748],{"__ignoreMap":113},[118,749,750,753,756],{"class":120,"line":121},[118,751,752],{"class":124},"sudo chmod ",[118,754,755],{"class":189},"600",[118,757,758],{"class":124}," /swapfile\n",[99,760,762],{"id":761},"_4-set-up-the-swap-area","4. Set up the swap area",[104,764,765],{},"Initialize the file as swap space:",[108,767,769],{"className":658,"code":768,"language":660,"meta":113,"style":113},"sudo mkswap /swapfile\n",[115,770,771],{"__ignoreMap":113},[118,772,773],{"class":120,"line":121},[118,774,768],{"class":124},[99,776,778],{"id":777},"_5-activate-the-swap","5. Activate the SWAP",[104,780,781],{},"Enable the swap file immediately:",[108,783,785],{"className":658,"code":784,"language":660,"meta":113,"style":113},"sudo swapon /swapfile\n",[115,786,787],{"__ignoreMap":113},[118,788,789],{"class":120,"line":121},[118,790,784],{"class":124},[99,792,794],{"id":793},"_6-make-the-change-permanent","6. Make the change permanent",[104,796,797],{},"Edit /etc/fstab and add the following line:",[108,799,801],{"className":658,"code":800,"language":660,"meta":113,"style":113},"/swapfile swap swap defaults 0 0\n",[115,802,803],{"__ignoreMap":113},[118,804,805,808,810],{"class":120,"line":121},[118,806,807],{"class":124},"/swapfile swap swap defaults ",[118,809,608],{"class":189},[118,811,812],{"class":189}," 0\n",[104,814,815],{},"This ensures the swap file is automatically enabled at boot.",[99,817,819],{"id":818},"_7-verify","7. Verify",[104,821,822],{},"Confirm that the swap is active:",[108,824,825],{"className":658,"code":659,"language":660,"meta":113,"style":113},[115,826,827],{"__ignoreMap":113},[118,828,829,831,833],{"class":120,"line":121},[118,830,667],{"class":124},[118,832,670],{"class":141},[118,834,673],{"class":124},[104,836,837],{},"Or check total swap space with:",[108,839,841],{"className":658,"code":840,"language":660,"meta":113,"style":113},"free -h\n",[115,842,843],{"__ignoreMap":113},[118,844,845,848,850],{"class":120,"line":121},[118,846,847],{"class":124},"free ",[118,849,142],{"class":141},[118,851,852],{"class":124},"h\n",[613,854,855],{},"html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}",{"title":113,"searchDepth":135,"depth":135,"links":857},[858,859,860,861,862,863,864],{"id":651,"depth":135,"text":652},{"id":679,"depth":135,"text":680},{"id":738,"depth":135,"text":739},{"id":761,"depth":135,"text":762},{"id":777,"depth":135,"text":778},{"id":793,"depth":135,"text":794},{"id":818,"depth":135,"text":819},[866],"linux","Step-by-step guide to adding swap space to an existing Linux system: check for swap, create and secure a swap file, activate it and make it permanent.",{"slug":869,"isHowTo":218},"library/linux/creating-a-swap-partition-on-linux","2024-11-11T19:29:00.000Z",{"title":16,"description":867},[],"F4JRKyV7YkOS0eTPlEDTaJUm4HVUYFHb5ENYFuWqM2k",{"id":875,"title":26,"body":876,"categories":910,"description":911,"extension":624,"meta":912,"navigation":218,"ogImage":627,"path":27,"publish_at":628,"seo":913,"stem":28,"tags":914,"__hash__":916},"library/library/dataflex/clear-data-dictionary-keep-parents.md",{"type":96,"value":877,"toc":906},[878,882,885,888,895,898],[99,879,881],{"id":880},"overview","Overview",[104,883,884],{},"Often you find yourself creating a collection of child records, but you want them all to have the same parents.",[104,886,887],{},"If you only have one parent, then doing Set Constrain_File to Parent.file_number will ensure the parent isn’t cleared, but then other parents are still cleared and you can only have one contrain file.",[104,889,890,452],{},[891,892,894],"a",{"href":893},"https://support.dataaccess.com/Forums/showthread.php?69537-Prevent-DataDictionary-clear&p=379020&highlight=Clear_Retain_Parents#post379020","Sourced from DataFlex forums",[99,896,897],{"id":115},"Code",[108,899,904],{"className":900,"code":902,"language":903,"meta":113},[901],"language-text","Procedure Clear_Retain_Parents\n    // The standard Clear message also clears (non-Constrained) server DDOs.\n    // This does not.\n    Handle hoServer\n    Handle[] hoServerList   // the object ids of all this DDO's servers\n    Integer iCount iMax\n    Get Data_Set_Server_Count to iMax\n    Decrement iMax\n    For iCount from 0 to iMax\n        Get Data_Set_Server 0 to hoServer\n        Move hoServer to hoServerList[iCount]\n        Send Detach_Server hoServer\n    Loop\n    Send Clear\n    For iCount from 0 to iMax\n        Move hoServerList[iCount] to hoServer\n        Send Attach_Server hoServer\n    Loop\nEnd_Procedure\n","text",[115,905,902],{"__ignoreMap":113},{"title":113,"searchDepth":135,"depth":135,"links":907},[908,909],{"id":880,"depth":135,"text":881},{"id":115,"depth":135,"text":897},[21],"A DataFlex snippet to clear a data dictionary while keeping its parent records, handy when creating many child records that share the same parents.",{"slug":28,"isHowTo":218},{"title":26,"description":911},[915],"data dictionaries","BiljqfUIcjTyy94Xlr2VAU0jCaTh6qbikP1yNqZjzu4",{"id":918,"title":30,"body":919,"categories":1080,"description":1081,"extension":624,"meta":1082,"navigation":218,"ogImage":627,"path":31,"publish_at":1083,"seo":1084,"stem":32,"tags":1085,"__hash__":1087},"library/library/dataflex/most-common-beginner-dataflex-errors.md",{"type":96,"value":920,"toc":1073},[921,924,928,931,934,938,941,944,947,974,977,987,991,994,996,1004,1009,1013,1048,1052,1055,1061,1064,1067],[104,922,923],{},"This is a collection of common errors we have come across that might stump beginners and new developers we are onboarding. We will continue adding them as new ones are found.",[99,925,927],{"id":926},"_74-entry-does-not-exist-in-filelist-table-tablenumber","74 - Entry does not exist in Filelist. Table = (\u003CTablenumber>)",[104,929,930],{},"Error: 74\nError Source = Flexdrvr.Open",[104,932,933],{},"This is usually caused by an entry to the table is missing in the Filelist. Open the filelist and confirm there is an entry.",[99,935,937],{"id":936},"_75-cant-open-table-table-tablename-tablenumber","75 - Can't open table. Table = \u003CTABLENAME> (\u003CTABLENUMBER>)",[104,939,940],{},"Error 75\nError Source = Flexdrvr.Open",[104,942,943],{},"This is usually caused by",[104,945,946],{},"When SQL",[948,949,950,963,971],"ul",{},[951,952,953,954],"li",{},"INT file missing\n",[948,955,956],{},[951,957,958,959,962],{},"Check the path for your data directory in ",[115,960,961],{},"Config.ws"," and ensure it's there.",[951,964,965,966],{},"Database table is missing\n",[948,967,968],{},[951,969,970],{},"Check your table exists in the database.",[951,972,973],{},"Check that the filelist is pointing to an INT file correctly",[104,975,976],{},"When embedded",[948,978,979,982],{},[951,980,981],{},"DAT file missing",[951,983,958,984,986],{},[115,985,961],{}," and ensure it's there",[99,988,990],{"id":989},"_72-table-not-open-tablenumber-tablenumber","72 - Table not open Tablenumber = \u003CTABLENUMBER>",[104,992,993],{},"Error: 72\nError Source = API.Get_Attribute",[104,995,943],{},[948,997,998,1001],{},[951,999,1000],{},"Using a table before it has been opened.",[951,1002,1003],{},"If using data dictionaries, ensure all open statements are at the top of the data dictionary that the Data Dictionary may use.",[104,1005,1006],{},[115,1007,1008],{},"Open \u003CTABLE>",[99,1010,1012],{"id":1011},"this-method-was-previously-defined-as-overloaded","This method was previously defined as overloaded",[948,1014,1015,1018],{},[951,1016,1017],{},"This happens when a method is defined as a different way",[951,1019,1020,1021,1024],{},"In our case, it was ",[115,1022,1023],{},"String msg",[948,1025,1026,1036,1039,1045],{},[951,1027,1028,1031,1032,1035],{},[115,1029,1030],{},"msg_"," is for procedures, like ",[115,1033,1034],{},"get_"," is for functions",[951,1037,1038],{},"This causes a conflict",[951,1040,1041,1042],{},"Change to ",[115,1043,1044],{},"_msg",[951,1046,1047],{},"No more issues",[99,1049,1051],{"id":1050},"illegal-code-placement-could-not-refind-the-original-name-in-struct-sub-definition","Illegal code placement Could not refind the original name in struct(-sub) definition.",[104,1053,1054],{},"The problem was",[108,1056,1059],{"className":1057,"code":1058,"language":903},[901],"struct tAStruct\n    Real capital\nEnd_Struct\n",[115,1060,1058],{"__ignoreMap":113},[104,1062,1063],{},"Capital is reserved, but needed for JSON. Since our JSON needs it so, we can add the meta-name value ot set it.",[104,1065,1066],{},"And the fix was",[108,1068,1071],{"className":1069,"code":1070,"language":903},[901],"struct tAStruct\n    { Name=capital }\n    Real _capital\nEnd_Struct\n",[115,1072,1070],{"__ignoreMap":113},{"title":113,"searchDepth":135,"depth":135,"links":1074},[1075,1076,1077,1078,1079],{"id":926,"depth":135,"text":927},{"id":936,"depth":135,"text":937},{"id":989,"depth":135,"text":990},{"id":1011,"depth":135,"text":1012},{"id":1050,"depth":135,"text":1051},[21],"Common DataFlex errors that stump beginners, such as table errors 72, 74 and 75 and overloaded method definitions, with their usual causes and fixes.",{"slug":32,"isHowTo":218},"2025-04-30T02:09:00.000Z",{"title":30,"description":1081},[1086],"beginner","MdrNoDvy932woYSIobrggxLBD3s4-IbsxzzaqmUMdAU",{"id":1089,"title":34,"body":1090,"categories":1804,"description":1805,"extension":624,"meta":1806,"navigation":218,"ogImage":1807,"path":35,"publish_at":1808,"seo":1809,"stem":36,"tags":1810,"__hash__":1815},"library/library/dataflex/security-headers-for-iis.md",{"type":96,"value":1091,"toc":1793},[1092,1095,1098,1101,1105,1108,1199,1204,1211,1214,1335,1339,1342,1366,1369,1393,1398,1426,1429,1435,1438,1533,1537,1545,1561,1567,1578,1584,1592,1598,1603,1608,1628,1634,1642,1648,1669,1675,1687,1691,1695,1700,1708,1716,1724,1730,1770,1776,1780,1787],[104,1093,1094],{},"Properly configuring HTTP security headers is a key part of securing any modern website.\nHeaders like Referrer-Policy, Strict-Transport-Security, and Content-Security-Policy provide critical protections by controlling how browsers handle redirects, data sharing, and embedded resources.",[104,1096,1097],{},"This snippet covers the recommended set of security headers to apply in IIS, with a focus on setting a safer Referrer-Policy (strict-origin-when-cross-origin) to minimize data exposure without impacting functionality.\nWe also outline how to add these headers manually via IIS Manager or web.config, making them easy to apply across applications or at the server level.",[104,1099,1100],{},"Use this as a checklist for quickly hardening your IIS-hosted applications.",[99,1102,1104],{"id":1103},"security-headers","Security Headers",[104,1106,1107],{},"Recommended settings",[1109,1110,1111,1124],"table",{},[1112,1113,1114],"thead",{},[1115,1116,1117,1121],"tr",{},[1118,1119,1120],"th",{},"Name",[1118,1122,1123],{},"Value",[1125,1126,1127,1136,1144,1152,1160,1168,1176,1184,1191],"tbody",{},[1115,1128,1129,1133],{},[1130,1131,1132],"td",{},"Referrer-Policy",[1130,1134,1135],{},"strict-origin-when-cross-origin",[1115,1137,1138,1141],{},[1130,1139,1140],{},"X-Content-Type-Options",[1130,1142,1143],{},"nosniff",[1115,1145,1146,1149],{},[1130,1147,1148],{},"X-Frame-Options",[1130,1150,1151],{},"SAMEORIGIN",[1115,1153,1154,1157],{},[1130,1155,1156],{},"X-XSS-Protection",[1130,1158,1159],{},"1; mode=block",[1115,1161,1162,1165],{},[1130,1163,1164],{},"Permissions-Policy",[1130,1166,1167],{},"camera=(), microphone=(), geolocation=()",[1115,1169,1170,1173],{},[1130,1171,1172],{},"Strict-Transport-Security",[1130,1174,1175],{},"max-age=31536000; includeSubDomains; preload",[1115,1177,1178,1181],{},[1130,1179,1180],{},"Cross-Origin-Resource-Policy",[1130,1182,1183],{},"same-origin",[1115,1185,1186,1189],{},[1130,1187,1188],{},"Cross-Origin-Opener-Policy",[1130,1190,1183],{},[1115,1192,1193,1196],{},[1130,1194,1195],{},"Cross-Origin-Embedder-Policy",[1130,1197,1198],{},"require-corp",[1200,1201,1203],"h3",{"id":1202},"referrer-policy","Referrer Policy",[104,1205,1206,1207,1210],{},"NOTE: DO NOT USE ",[115,1208,1209],{},"strict-origin"," they will cause weird behavior while seeming to work at first. Specifically; the URL parameters will not load anymore.",[104,1212,1213],{},"As the referrer policy caused us the most grief in deployment, a quick comparison of the options is:",[1109,1215,1216,1226],{},[1112,1217,1218],{},[1115,1219,1220,1223],{},[1118,1221,1222],{},"Policy",[1118,1224,1225],{},"Behavior",[1125,1227,1228,1247,1264,1280,1290,1307,1320],{},[1115,1229,1230,1236],{},[1130,1231,1232],{},[1233,1234,1235],"strong",{},"no-referrer",[1130,1237,1238,1239,1242,1243,1246],{},"Do ",[1233,1240,1241],{},"not send"," a ",[115,1244,1245],{},"Referer"," header at all on any request.",[1115,1248,1249,1254],{},[1130,1250,1251],{},[1233,1252,1253],{},"origin",[1130,1255,1256,1257,1260,1261,452],{},"Only send the scheme + domain (e.g., ",[115,1258,1259],{},"https://example.com","), ",[1233,1262,1263],{},"no path or query",[1115,1265,1266,1270],{},[1130,1267,1268],{},[1233,1269,1209],{},[1130,1271,1272,1273,1275,1276,1279],{},"Like ",[115,1274,1253],{},", but ",[1233,1277,1278],{},"only send"," on secure (HTTPS → HTTPS) links; send nothing if going from HTTPS → HTTP.",[1115,1281,1282,1287],{},[1130,1283,1284],{},[1233,1285,1286],{},"origin-when-cross-origin",[1130,1288,1289],{},"Full URL sent for same-origin requests; only origin sent for cross-origin requests.",[1115,1291,1292,1300],{},[1130,1293,1294,1296,1297,519],{},[1233,1295,1135],{}," (",[1233,1298,1299],{},"recommended",[1130,1301,1302,1303,1306],{},"Full URL for same-origin ",[1233,1304,1305],{},"secure"," requests; only origin sent for cross-origin. Nothing sent on HTTPS → HTTP.",[1115,1308,1309,1313],{},[1130,1310,1311],{},[1233,1312,1183],{},[1130,1314,1315,1316,1319],{},"Send full URL only when navigating ",[1233,1317,1318],{},"within the same origin","; send nothing to other sites.",[1115,1321,1322,1328],{},[1130,1323,1324,1327],{},[1233,1325,1326],{},"unsafe-url"," (⚠️ unsafe)",[1130,1329,1330,1331,1334],{},"Always send full URL (origin + path + query) to ",[1233,1332,1333],{},"any"," destination (even cross-site) — not recommended today.",[1200,1336,1338],{"id":1337},"csp-content-security-policy","CSP (Content Security Policy)",[104,1340,1341],{},"CSP can be difficult to implement but gives a lot of rewards if done right. You need to make sure you add all the external assets that your site calls.",[104,1343,1344,1347,1348,1351,1352,1355,1358,1359,1361,1362,1365],{},[1233,1345,1346],{},"Without CSP",", a malicious injected ",[115,1349,1350],{},"\u003Cscript>"," could run.",[1353,1354],"br",{},[1233,1356,1357],{},"With CSP",", even if someone injects a ",[115,1360,1350],{},", the browser ",[1233,1363,1364],{},"won't allow"," it unless it matches your allowed sources.",[104,1367,1368],{},"A baseline CSP is:",[1109,1370,1371,1381],{},[1112,1372,1373],{},[1115,1374,1375,1378],{},[1118,1376,1377],{},"Header Name",[1118,1379,1380],{},"Header Value",[1125,1382,1383],{},[1115,1384,1385,1388],{},[1130,1386,1387],{},"Content-Security-Policy",[1130,1389,1390],{},[115,1391,1392],{},"default-src 'self'; script-src 'self'; object-src 'none';",[104,1394,1395],{},[1233,1396,1397],{},"Meaning:",[948,1399,1400,1411,1420],{},[951,1401,1402,1405,1406,1410],{},[115,1403,1404],{},"default-src 'self'"," → Only allow loading resources (images, fonts, etc.) from ",[1407,1408,1409],"em",{},"this"," domain.",[951,1412,1413,1416,1417,1419],{},[115,1414,1415],{},"script-src 'self'"," → Only allow JavaScript from ",[1407,1418,1409],{}," domain (no external scripts).",[951,1421,1422,1425],{},[115,1423,1424],{},"object-src 'none'"," → Forbid Flash, Java applets, Silverlight (old, insecure stuff).",[104,1427,1428],{},"If you use external JS or assets like Google fonts, the following is an example of how to add them",[108,1430,1433],{"className":1431,"code":1432,"language":903},[901],"default-src 'self';\nscript-src 'self' https://ajax.googleapis.com;\nstyle-src 'self' https://fonts.googleapis.com;\nfont-src 'self' https://fonts.gstatic.com;\nimg-src 'self' data:;\nobject-src 'none';\n",[115,1434,1432],{"__ignoreMap":113},[104,1436,1437],{},"To help deciding what to allow:",[1109,1439,1440,1453],{},[1112,1441,1442],{},[1115,1443,1444,1447,1450],{},[1118,1445,1446],{},"Type",[1118,1448,1449],{},"CSP Directive",[1118,1451,1452],{},"Examples",[1125,1454,1455,1468,1481,1494,1507,1520],{},[1115,1456,1457,1460,1465],{},[1130,1458,1459],{},"Scripts",[1130,1461,1462],{},[115,1463,1464],{},"script-src",[1130,1466,1467],{},"self, cdn.example.com",[1115,1469,1470,1473,1478],{},[1130,1471,1472],{},"Stylesheets",[1130,1474,1475],{},[115,1476,1477],{},"style-src",[1130,1479,1480],{},"self, fonts.googleapis.com",[1115,1482,1483,1486,1491],{},[1130,1484,1485],{},"Fonts",[1130,1487,1488],{},[115,1489,1490],{},"font-src",[1130,1492,1493],{},"self, fonts.gstatic.com",[1115,1495,1496,1499,1504],{},[1130,1497,1498],{},"Images",[1130,1500,1501],{},[115,1502,1503],{},"img-src",[1130,1505,1506],{},"self, data:, cdn.example.com",[1115,1508,1509,1512,1517],{},[1130,1510,1511],{},"Frames",[1130,1513,1514],{},[115,1515,1516],{},"frame-src",[1130,1518,1519],{},"self, youtube.com",[1115,1521,1522,1525,1530],{},[1130,1523,1524],{},"Everything else",[1130,1526,1527],{},[115,1528,1529],{},"default-src",[1130,1531,1532],{},"self",[99,1534,1536],{"id":1535},"summary-about-headers","Summary about headers",[1538,1539,1541,1542],"h4",{"id":1540},"strict-transport-security-hsts","✅ ",[1233,1543,1544],{},"Strict-Transport-Security (HSTS):",[948,1546,1547,1554],{},[951,1548,1549,1550,1553],{},"Tells browsers ",[1233,1551,1552],{},"only use HTTPS"," for your domain — no accidental HTTP fallback.",[951,1555,1556,1557,1560],{},"Required if you want your domain included in Chrome’s ",[1233,1558,1559],{},"HSTS preload list"," later.",[1538,1562,1541,1564],{"id":1563},"x-frame-options",[1233,1565,1566],{},"X-Frame-Options:",[948,1568,1569,1575],{},[951,1570,1571,1572,452],{},"Stops other sites embedding your site in ",[115,1573,1574],{},"\u003Ciframe>",[951,1576,1577],{},"Blocks clickjacking attacks.",[1538,1579,1541,1581],{"id":1580},"x-content-type-options",[1233,1582,1583],{},"X-Content-Type-Options:",[948,1585,1586,1589],{},[951,1587,1588],{},"Stops browsers trying to \"guess\" content types.",[951,1590,1591],{},"Safer against content spoofing.",[1538,1593,1541,1595],{"id":1594},"x-xss-protection",[1233,1596,1597],{},"X-XSS-Protection:",[948,1599,1600],{},[951,1601,1602],{},"Old but still useful for legacy Internet Explorer and some old Edge versions.",[1538,1604,1541,1605],{"id":1202},[1233,1606,1607],{},"Referrer-Policy:",[948,1609,1610,1616,1622],{},[951,1611,1612,1615],{},[1233,1613,1614],{},"Protects sensitive data"," by preventing query strings (like reset tokens) from leaking when users click external links.",[951,1617,1618,1621],{},[1233,1619,1620],{},"Improves user privacy"," by limiting the amount of information shared across websites.",[951,1623,1624,1627],{},[1233,1625,1626],{},"Reduces security risks"," like phishing and targeted attacks by hiding detailed URL paths.",[1538,1629,1541,1631],{"id":1630},"permissions-policy",[1233,1632,1633],{},"Permissions-Policy:",[948,1635,1636,1639],{},[951,1637,1638],{},"Turns off things like mic, camera unless explicitly allowed.",[951,1640,1641],{},"Safer for apps that don't need them.",[1538,1643,1541,1645],{"id":1644},"csp",[1233,1646,1647],{},"CSP:",[948,1649,1650,1657,1663],{},[951,1651,1652,1653,1656],{},"Controls where browsers are allowed to load ",[1233,1654,1655],{},"scripts, images, CSS, fonts, frames, etc."," from.",[951,1658,1659,1662],{},[1233,1660,1661],{},"Stops most XSS attacks"," (even if your app has a bug).",[951,1664,1665,1668],{},[1233,1666,1667],{},"Boosts SEO and security scores"," dramatically (Google loves CSP).",[1538,1670,1541,1672],{"id":1671},"corp-coep-coop",[1233,1673,1674],{},"CORP / COEP / COOP:",[948,1676,1677,1684],{},[951,1678,1679,1680,1683],{},"These are newer for ",[1233,1681,1682],{},"isolation"," — help prevent side-channel leaks like Spectre-style attacks.",[951,1685,1686],{},"Important if you host sensitive data or use things like WebAssembly.",[99,1688,1690],{"id":1689},"implementation","Implementation",[1200,1692,1694],{"id":1693},"in-iis","In IIS",[104,1696,1697],{},[1233,1698,1699],{},"1. Open IIS Manager",[104,1701,1702,1705,1707],{},[1233,1703,1704],{},"2. Click on your site",[1353,1706],{},"\n(or if you want it global for all sites, click the server name at the top).",[104,1709,1710,1713,1715],{},[1233,1711,1712],{},"3. In the middle pane, double-click",[1353,1714],{},"\nHTTP Response Headers.",[104,1717,1718,1721,1723],{},[1233,1719,1720],{},"4. On the right pane (Actions), click",[1353,1722],{},"\nAdd....",[104,1725,1726,1729],{},[1233,1727,1728],{},"5. Fill in:","\nHeader : Value\nie;",[1109,1731,1732,1741],{},[1112,1733,1734],{},[1115,1735,1736,1739],{},[1118,1737,1738],{},"Field",[1118,1740,1123],{},[1125,1742,1743,1753,1763],{},[1115,1744,1745,1749],{},[1130,1746,1747],{},[1233,1748,1120],{},[1130,1750,1751],{},[115,1752,1132],{},[1115,1754,1755,1759],{},[1130,1756,1757],{},[1233,1758,1123],{},[1130,1760,1761],{},[115,1762,1135],{},[1115,1764,1765,1768],{},[1130,1766,1767],{},"✅ Then click OK.",[1130,1769],{},[104,1771,1772,1775],{},[1233,1773,1774],{},"6. (Optional)"," Restart IIS site if you want to be sure (not always needed).",[1200,1777,1779],{"id":1778},"in-the-webconfig","In the web.config",[104,1781,1782,1783,1786],{},"A full ",[115,1784,1785],{},"web.config"," could be used as",[108,1788,1791],{"className":1789,"code":1790,"language":903},[901],"\u003Cconfiguration>\n  \u003Csystem.webServer>\n    \u003ChttpProtocol>\n      \u003CcustomHeaders>\n        \u003Cadd name=\"Strict-Transport-Security\" value=\"max-age=31536000; includeSubDomains; preload\" />\n        \u003Cadd name=\"X-Frame-Options\" value=\"SAMEORIGIN\" />\n        \u003Cadd name=\"X-Content-Type-Options\" value=\"nosniff\" />\n        \u003Cadd name=\"X-XSS-Protection\" value=\"1; mode=block\" />\n        \u003Cadd name=\"Referrer-Policy\" value=\"strict-origin-when-cross-origin\" />\n        \u003Cadd name=\"Permissions-Policy\" value=\"camera=(), microphone=(), geolocation=(), interest-cohort=()\" />\n        \u003Cadd name=\"Content-Security-Policy\" value=\"default-src 'self'; script-src 'self'; object-src 'none';\" />\n        \u003Cadd name=\"Cross-Origin-Resource-Policy\" value=\"same-origin\" />\n        \u003Cadd name=\"Cross-Origin-Opener-Policy\" value=\"same-origin\" />\n        \u003Cadd name=\"Cross-Origin-Embedder-Policy\" value=\"require-corp\" />\n      \u003C/customHeaders>\n    \u003C/httpProtocol>\n  \u003C/system.webServer>\n\u003C/configuration>\n",[115,1792,1790],{"__ignoreMap":113},{"title":113,"searchDepth":135,"depth":135,"links":1794},[1795,1799,1800],{"id":1103,"depth":135,"text":1104,"children":1796},[1797,1798],{"id":1202,"depth":152,"text":1203},{"id":1337,"depth":152,"text":1338},{"id":1535,"depth":135,"text":1536},{"id":1689,"depth":135,"text":1690,"children":1801},[1802,1803],{"id":1693,"depth":152,"text":1694},{"id":1778,"depth":152,"text":1779},[21],"A practical guide to essential IIS security headers, including HSTS, CSP and Referrer-Policy, and how to add them via IIS Manager or web.config.",{"slug":36,"isHowTo":218},"/images/screenshots/iis-shot.png","2025-04-29T02:09:00.000Z",{"title":34,"description":1805},[1811,1812,1813,1814],"deployment","iis","web app","security","LBvwvwz_7Ymj0KL9ev5YD5IDPEV8bwi21Amxi_03BfU",{"id":1817,"title":43,"body":1818,"categories":2358,"description":2360,"extension":624,"meta":2361,"navigation":218,"ogImage":627,"path":44,"publish_at":2362,"seo":2363,"stem":45,"tags":2364,"__hash__":2367},"library/library/networking/understanding-and-fixing-mtu-mss.md",{"type":96,"value":1819,"toc":2348},[1820,1827,1833,1839,1842,1845,1849,1855,1901,1904,1906,1910,1916,1936,1939,1941,1945,1948,1964,1970,1973,1975,1979,1989,1992,1995,1998,2006,2009,2012,2017,2019,2025,2036,2039,2044,2074,2076,2109,2113,2146,2150,2258,2261,2265,2279,2333,2336,2339,2342,2345],[104,1821,1822],{},[641,1823],{"alt":1824,"src":1825,"style":1826},"Show the packets from a router to the internet","/images/articles/mtu-diagram.png","display: block; margin: 0 auto; max-width: 100%; width: 500px;",[99,1828,1830],{"id":1829},"understanding-and-fixing-mtu-path-mtu-discovery-and-mss-clamping-issues",[1233,1831,1832],{},"Understanding and Fixing MTU, Path MTU Discovery, and MSS Clamping Issues",[104,1834,1835,1836,452],{},"In modern networks, performance and reliability depend on more than just link speed. One of the most common, yet often overlooked, causes of slow or broken connections is an ",[1233,1837,1838],{},"MTU mismatch",[104,1840,1841],{},"This guide walks through how MTU, Path MTU Discovery (PMTUD), and MSS Clamping work, the symptoms of MTU-related issues, and how to find and fix the correct MTU on your network.",[1843,1844],"hr",{},[1200,1846,1848],{"id":1847},"what-is-mtu","What Is MTU?",[104,1850,1851,1852,1854],{},"MTU (Maximum Transmission Unit) defines the largest packet size a network interface can send in a single frame.",[1353,1853],{},"\nDifferent network technologies use different MTUs:",[1109,1856,1857,1867],{},[1112,1858,1859],{},[1115,1860,1861,1864],{},[1118,1862,1863],{},"Technology",[1118,1865,1866],{},"Typical MTU",[1125,1868,1869,1877,1885,1893],{},[1115,1870,1871,1874],{},[1130,1872,1873],{},"Ethernet",[1130,1875,1876],{},"1500 bytes",[1115,1878,1879,1882],{},[1130,1880,1881],{},"Ethernet (Jumbo Frames)",[1130,1883,1884],{},"9000–9202 bytes",[1115,1886,1887,1890],{},[1130,1888,1889],{},"PPPoE",[1130,1891,1892],{},"1492 bytes",[1115,1894,1895,1898],{},[1130,1896,1897],{},"WLAN",[1130,1899,1900],{},"2304 bytes",[104,1902,1903],{},"When a packet exceeds the MTU, it must be fragmented (split into smaller chunks) before it can be transmitted. While fragmentation allows data to move across diverse links, it adds CPU overhead, increases latency, and can lead to dropped packets or timeouts.",[1843,1905],{},[1200,1907,1909],{"id":1908},"why-mtu-matters","Why MTU Matters",[104,1911,1912,1913,1915],{},"A mismatch in MTU sizes along a route can lead to partial connections or intermittent failures.",[1353,1914],{},"\nCommon symptoms include:",[948,1917,1918,1921,1924,1927,1933],{},[951,1919,1920],{},"SSH or SCP sessions timing out",[951,1922,1923],{},"Websites that partially load or hang",[951,1925,1926],{},"Chat applications unable to send messages",[951,1928,1929,1930,519],{},"SSL/TLS negotiation failures (e.g., connecting to ",[115,1931,1932],{},"packages.gitlab.com",[951,1934,1935],{},"Random client disconnections",[104,1937,1938],{},"If these issues seem familiar, MTU could be the culprit.",[1843,1940],{},[1200,1942,1944],{"id":1943},"how-path-mtu-discovery-works","How Path MTU Discovery Works",[104,1946,1947],{},"Path MTU Discovery (PMTUD) determines the smallest MTU across all hops between source and destination. It works like this:",[1949,1950,1951,1954,1961],"ol",{},[951,1952,1953],{},"The sender transmits packets with the \"Don’t Fragment (DF)\" bit set.",[951,1955,1956,1957,1960],{},"If a router along the path cannot forward the packet due to size, it replies with an ",[1233,1958,1959],{},"ICMP \"Fragmentation needed\""," message.",[951,1962,1963],{},"The sender lowers its packet size and retries until it reaches the destination successfully.",[104,1965,1966,1967,452],{},"This automatic negotiation keeps communication efficient, as long as ",[1233,1968,1969],{},"ICMP messages aren’t blocked",[104,1971,1972],{},"If a firewall or router filters ICMP, PMTUD breaks. You’ll notice excessive SYN retransmissions and sessions that hang indefinitely.",[1843,1974],{},[1200,1976,1978],{"id":1977},"mss-clamping-a-practical-fix","MSS Clamping: A Practical Fix",[104,1980,1981,1982,1984,1985,1988],{},"When ICMP messages are dropped, PMTUD fails.",[1353,1983],{},"\nTo prevent this, routers and firewalls can use ",[1233,1986,1987],{},"MSS Clamping",", a method to control the TCP segment size at the start of a connection.",[104,1990,1991],{},"MSS (Maximum Segment Size) defines how much data (excluding headers) a device can receive in one TCP segment:",[104,1993,1994],{},"MSS = MTU - IP Header (20 bytes) - TCP Header (20 bytes)",[104,1996,1997],{},"For example:",[948,1999,2000,2003],{},[951,2001,2002],{},"Ethernet MTU 1500 → MSS = 1460",[951,2004,2005],{},"PPPoE MTU 1492 → MSS = 1452",[104,2007,2008],{},"By automatically clamping MSS values, you ensure packets never exceed the actual path MTU, avoiding fragmentation and broken connections.",[104,2010,2011],{},"In pfSense, this can be configured under:",[104,2013,2014],{},[1233,2015,2016],{},"Firewall > NAT > Outbound > Edit Rule → TCP MSS → Enable MSS clamping and set value (e.g., 1452)",[1843,2018],{},[1200,2020,2022],{"id":2021},"finding-the-correct-mtu",[1233,2023,2024],{},"Finding the Correct MTU",[104,2026,2027,2028,2031,2032,2035],{},"You can manually test the proper MTU using the ",[1233,2029,2030],{},"ping"," command with the ",[1233,2033,2034],{},"Don’t Fragment (DF)"," flag.",[104,2037,2038],{},"Reduce the packet size until the ping succeeds, then add 28 bytes for IP + ICMP headers to find your true MTU.",[1538,2040,2042],{"id":2041},"windows",[1233,2043,69],{},[108,2045,2047],{"className":658,"code":2046,"language":660,"meta":113,"style":113},"ping -n 1 -l 1500 -f www.example.com\n",[115,2048,2049],{"__ignoreMap":113},[118,2050,2051,2054,2056,2058,2060,2063,2066,2069,2071],{"class":120,"line":121},[118,2052,2053],{"class":124},"ping ",[118,2055,142],{"class":141},[118,2057,145],{"class":124},[118,2059,603],{"class":189},[118,2061,2062],{"class":141}," -",[118,2064,2065],{"class":124},"l ",[118,2067,2068],{"class":189},"1500",[118,2070,2062],{"class":141},[118,2072,2073],{"class":124},"f www.example.com\n",[1538,2075,11],{"id":866},[108,2077,2079],{"className":658,"code":2078,"language":660,"meta":113,"style":113},"ping -M do -s 1500 -c 1 www.example.com\n",[115,2080,2081],{"__ignoreMap":113},[118,2082,2083,2085,2087,2090,2093,2095,2098,2100,2102,2104,2106],{"class":120,"line":121},[118,2084,2053],{"class":124},[118,2086,142],{"class":141},[118,2088,2089],{"class":124},"M ",[118,2091,2092],{"class":141},"do",[118,2094,2062],{"class":141},[118,2096,2097],{"class":124},"s ",[118,2099,2068],{"class":189},[118,2101,2062],{"class":141},[118,2103,186],{"class":124},[118,2105,603],{"class":189},[118,2107,2108],{"class":124}," www.example.com\n",[1538,2110,2112],{"id":2111},"macos","macOS",[108,2114,2116],{"className":658,"code":2115,"language":660,"meta":113,"style":113},"ping -D -v -s 1500 -c 1 www.example.com\n",[115,2117,2118],{"__ignoreMap":113},[118,2119,2120,2122,2124,2127,2129,2132,2134,2136,2138,2140,2142,2144],{"class":120,"line":121},[118,2121,2053],{"class":124},[118,2123,142],{"class":141},[118,2125,2126],{"class":124},"D ",[118,2128,142],{"class":141},[118,2130,2131],{"class":124},"v ",[118,2133,142],{"class":141},[118,2135,2097],{"class":124},[118,2137,2068],{"class":189},[118,2139,2062],{"class":141},[118,2141,186],{"class":124},[118,2143,603],{"class":189},[118,2145,2108],{"class":124},[1538,2147,2149],{"id":2148},"example","Example",[108,2151,2153],{"className":658,"code":2152,"language":660,"meta":113,"style":113},"C:\\> ping -n 1 -l 1382 -f www.google.com\nPacket needs to be fragmented but DF set.\n\nC:\\> ping -n 1 -l 1372 -f www.google.com\nReply from 172.217.25.164: bytes=68 time=25ms TTL=247\n",[115,2154,2155,2184,2201,2205,2230],{"__ignoreMap":113},[118,2156,2157,2160,2163,2166,2168,2170,2172,2174,2176,2179,2181],{"class":120,"line":121},[118,2158,2159],{"class":124},"C:\\",[118,2161,2162],{"class":141},">",[118,2164,2165],{"class":124}," ping ",[118,2167,142],{"class":141},[118,2169,145],{"class":124},[118,2171,603],{"class":189},[118,2173,2062],{"class":141},[118,2175,2065],{"class":124},[118,2177,2178],{"class":189},"1382",[118,2180,2062],{"class":141},[118,2182,2183],{"class":124},"f www.google.com\n",[118,2185,2186,2189,2192,2195,2198],{"class":120,"line":135},[118,2187,2188],{"class":124},"Packet needs ",[118,2190,2191],{"class":141},"to",[118,2193,2194],{"class":124}," be fragmented but DF",[118,2196,2197],{"class":141}," set",[118,2199,2200],{"class":124},".\n",[118,2202,2203],{"class":120,"line":152},[118,2204,219],{"emptyLinePlaceholder":218},[118,2206,2207,2209,2211,2213,2215,2217,2219,2221,2223,2226,2228],{"class":120,"line":201},[118,2208,2159],{"class":124},[118,2210,2162],{"class":141},[118,2212,2165],{"class":124},[118,2214,142],{"class":141},[118,2216,145],{"class":124},[118,2218,603],{"class":189},[118,2220,2062],{"class":141},[118,2222,2065],{"class":124},[118,2224,2225],{"class":189},"1372",[118,2227,2062],{"class":141},[118,2229,2183],{"class":124},[118,2231,2232,2235,2238,2241,2243,2246,2248,2250,2253,2255],{"class":120,"line":209},[118,2233,2234],{"class":124},"Reply from ",[118,2236,2237],{"class":189},"172.217.25.164",[118,2239,2240],{"class":124},": bytes",[118,2242,314],{"class":141},[118,2244,2245],{"class":189},"68",[118,2247,317],{"class":189},[118,2249,314],{"class":141},[118,2251,2252],{"class":124},"25ms TTL",[118,2254,314],{"class":141},[118,2256,2257],{"class":189},"247\n",[104,2259,2260],{},"Correct MTU = 1372 + 28 = 1400",[1200,2262,2264],{"id":2263},"summary","Summary",[948,2266,2267,2270,2273,2276],{},[951,2268,2269],{},"VPN Connections: Reduce MTU to 1400–1472 to account for encapsulation overhead.",[951,2271,2272],{},"PPPoE WAN Links: Set MTU to 1492 and clamp MSS to 1452.",[951,2274,2275],{},"Virtual Networks (Proxmox, QEMU, VMware): Ensure bridges and vNICs share consistent MTU settings.",[951,2277,2278],{},"Firewalls and Routers: Always allow ICMP Type 3, Code 4 (Fragmentation Needed) for PMTUD to function properly.",[1109,2280,2281,2291],{},[1112,2282,2283],{},[1115,2284,2285,2288],{},[1118,2286,2287],{},"Setting",[1118,2289,2290],{},"Recommended Action",[1125,2292,2293,2301,2309,2317,2325],{},[1115,2294,2295,2298],{},[1130,2296,2297],{},"Ethernet WAN",[1130,2299,2300],{},"Keep MTU at 1500, MSS 1460",[1115,2302,2303,2306],{},[1130,2304,2305],{},"PPPoE WAN",[1130,2307,2308],{},"MTU 1492, MSS 1452",[1115,2310,2311,2314],{},[1130,2312,2313],{},"VPN Tunnel",[1130,2315,2316],{},"MTU 1400–1472, MSS 1360–1432",[1115,2318,2319,2322],{},[1130,2320,2321],{},"Blocked ICMP",[1130,2323,2324],{},"Enable MSS Clamping",[1115,2326,2327,2330],{},[1130,2328,2329],{},"Path MTU Issues",[1130,2331,2332],{},"Use ping testing to find optimal MTU",[104,2334,2335],{},"MTU issues can mimic countless other problems, from broken VPNs to partial web pages. Understanding how MTU, PMTUD, and MSS Clamping interact gives you the tools to troubleshoot efficiently and stabilize network performance.",[104,2337,2338],{},"Whether you’re tuning a pfSense firewall, a Proxmox-hosted router, or a cloud VM, setting MTU and MSS correctly can eliminate frustrating, intermittent connection pr",[104,2340,2341],{},"Need help diagnosing MTU or network performance issues?",[104,2343,2344],{},"Our team can audit, optimize, and secure your connectivity, from edge routers to virtual infrastructure.\nContact us to learn more about our managed network solutions and performance tuning services.",[613,2346,2347],{},"html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":113,"searchDepth":135,"depth":135,"links":2349},[2350],{"id":1829,"depth":135,"text":1832,"children":2351},[2352,2353,2354,2355,2356,2357],{"id":1847,"depth":152,"text":1848},{"id":1908,"depth":152,"text":1909},{"id":1943,"depth":152,"text":1944},{"id":1977,"depth":152,"text":1978},{"id":2021,"depth":152,"text":2024},{"id":2263,"depth":152,"text":2264},[2359],"networking","How MTU, Path MTU Discovery and MSS clamping work, the symptoms of MTU mismatches such as dropping VPN connections, and how to find the right MTU.",{"slug":45,"isHowTo":218},"2025-11-11T02:00:00.000Z",{"title":43,"description":2360},[2365,2366],"troubleshooting","osi","zgwjlZvISbhXX4lrJJBpUfm7yYllmiYKEPOSZIyRr14",{"id":2369,"title":52,"body":2370,"categories":5765,"description":5767,"extension":624,"meta":5768,"navigation":218,"ogImage":627,"path":53,"publish_at":5769,"seo":5770,"stem":54,"tags":5771,"__hash__":5772},"library/library/postgresql/a-collection-of-useful-snippets.md",{"type":96,"value":2371,"toc":5728},[2372,2375,2379,2382,2386,2516,2520,2677,2681,2684,2753,2757,2887,2891,2901,3142,3146,3160,3173,3177,3199,3203,3215,3219,3379,3383,3500,3504,3516,3520,3532,3536,3539,3600,3604,3606,3655,3659,3717,3721,3726,3919,3923,3927,4187,4191,4195,4686,4690,4845,4849,4852,4895,4899,4902,4947,4951,4954,5010,5013,5052,5055,5128,5132,5135,5395,5399,5406,5410,5457,5461,5506,5510,5513,5591,5595,5598,5640,5643,5680,5687,5690,5725],[104,2373,2374],{},"A collection of PostgreSQL snippets we have found handy!",[99,2376,2378],{"id":2377},"generate-lowercase-table-names-and-column-alter-statements","Generate lowercase table names and column alter statements",[104,2380,2381],{},"With PostgreSQL if you create a table with quotes, it becomes case sensitive. This will rename them so they are lowered.",[1200,2383,2385],{"id":2384},"change-table-names","Change table names",[108,2387,2391],{"className":2388,"code":2389,"language":2390,"meta":113,"style":113},"language-sql shiki shiki-themes github-dark","select\n    'ALTER TABLE ' || psat.schemaname || '.\"' || psat.relname ||'\" RENAME TO \"' || lower(psat.relname) ||'\";'\nfrom\n    pg_catalog.pg_stat_all_tables psat\nwhere\n    schemaname = 'public'\n    and psat.relname \u003C> lower(psat.relname)\n","sql",[115,2392,2393,2398,2456,2461,2474,2479,2489],{"__ignoreMap":113},[118,2394,2395],{"class":120,"line":121},[118,2396,2397],{"class":141},"select\n",[118,2399,2400,2403,2406,2409,2411,2414,2416,2419,2421,2423,2425,2428,2430,2433,2435,2438,2440,2443,2445,2447,2450,2453],{"class":120,"line":135},[118,2401,2402],{"class":148},"    'ALTER TABLE '",[118,2404,2405],{"class":141}," ||",[118,2407,2408],{"class":189}," psat",[118,2410,452],{"class":124},[118,2412,2413],{"class":189},"schemaname",[118,2415,2405],{"class":141},[118,2417,2418],{"class":148}," '.\"'",[118,2420,2405],{"class":141},[118,2422,2408],{"class":189},[118,2424,452],{"class":124},[118,2426,2427],{"class":189},"relname",[118,2429,2405],{"class":141},[118,2431,2432],{"class":148},"'\" RENAME TO \"'",[118,2434,2405],{"class":141},[118,2436,2437],{"class":189}," lower",[118,2439,458],{"class":124},[118,2441,2442],{"class":189},"psat",[118,2444,452],{"class":124},[118,2446,2427],{"class":189},[118,2448,2449],{"class":124},") ",[118,2451,2452],{"class":141},"||",[118,2454,2455],{"class":148},"'\";'\n",[118,2457,2458],{"class":120,"line":152},[118,2459,2460],{"class":141},"from\n",[118,2462,2463,2466,2468,2471],{"class":120,"line":201},[118,2464,2465],{"class":189},"    pg_catalog",[118,2467,452],{"class":124},[118,2469,2470],{"class":189},"pg_stat_all_tables",[118,2472,2473],{"class":124}," psat\n",[118,2475,2476],{"class":120,"line":209},[118,2477,2478],{"class":141},"where\n",[118,2480,2481,2484,2486],{"class":120,"line":215},[118,2482,2483],{"class":124},"    schemaname ",[118,2485,314],{"class":141},[118,2487,2488],{"class":148}," 'public'\n",[118,2490,2491,2494,2496,2498,2500,2503,2505,2507,2509,2511,2513],{"class":120,"line":222},[118,2492,2493],{"class":141},"    and",[118,2495,2408],{"class":189},[118,2497,452],{"class":124},[118,2499,2427],{"class":189},[118,2501,2502],{"class":141}," \u003C>",[118,2504,2437],{"class":189},[118,2506,458],{"class":124},[118,2508,2442],{"class":189},[118,2510,452],{"class":124},[118,2512,2427],{"class":189},[118,2514,2515],{"class":124},")\n",[1200,2517,2519],{"id":2518},"change-column-names","Change column names",[108,2521,2523],{"className":2388,"code":2522,"language":2390,"meta":113,"style":113},"select\n    'ALTER TABLE ' || psat.schemaname || '.\"' || psat.relname ||'\" RENAME COLUMN \"' || pa.attname || '\" TO \"' || lower(pa.attname) ||'\";'\nfrom\n    pg_catalog.pg_stat_all_tables psat,\n    pg_catalog.pg_attribute pa\nwhere\n    psat.relid = pa.attrelid\n    and schemaname = 'public'\n    and pa.attname \u003C> lower(pa.attname)\n",[115,2524,2525,2529,2592,2596,2607,2619,2623,2642,2653],{"__ignoreMap":113},[118,2526,2527],{"class":120,"line":121},[118,2528,2397],{"class":141},[118,2530,2531,2533,2535,2537,2539,2541,2543,2545,2547,2549,2551,2553,2555,2558,2560,2563,2565,2568,2570,2573,2575,2577,2579,2582,2584,2586,2588,2590],{"class":120,"line":135},[118,2532,2402],{"class":148},[118,2534,2405],{"class":141},[118,2536,2408],{"class":189},[118,2538,452],{"class":124},[118,2540,2413],{"class":189},[118,2542,2405],{"class":141},[118,2544,2418],{"class":148},[118,2546,2405],{"class":141},[118,2548,2408],{"class":189},[118,2550,452],{"class":124},[118,2552,2427],{"class":189},[118,2554,2405],{"class":141},[118,2556,2557],{"class":148},"'\" RENAME COLUMN \"'",[118,2559,2405],{"class":141},[118,2561,2562],{"class":189}," pa",[118,2564,452],{"class":124},[118,2566,2567],{"class":189},"attname",[118,2569,2405],{"class":141},[118,2571,2572],{"class":148}," '\" TO \"'",[118,2574,2405],{"class":141},[118,2576,2437],{"class":189},[118,2578,458],{"class":124},[118,2580,2581],{"class":189},"pa",[118,2583,452],{"class":124},[118,2585,2567],{"class":189},[118,2587,2449],{"class":124},[118,2589,2452],{"class":141},[118,2591,2455],{"class":148},[118,2593,2594],{"class":120,"line":152},[118,2595,2460],{"class":141},[118,2597,2598,2600,2602,2604],{"class":120,"line":201},[118,2599,2465],{"class":189},[118,2601,452],{"class":124},[118,2603,2470],{"class":189},[118,2605,2606],{"class":124}," psat,\n",[118,2608,2609,2611,2613,2616],{"class":120,"line":209},[118,2610,2465],{"class":189},[118,2612,452],{"class":124},[118,2614,2615],{"class":189},"pg_attribute",[118,2617,2618],{"class":124}," pa\n",[118,2620,2621],{"class":120,"line":215},[118,2622,2478],{"class":141},[118,2624,2625,2628,2630,2633,2635,2637,2639],{"class":120,"line":222},[118,2626,2627],{"class":189},"    psat",[118,2629,452],{"class":124},[118,2631,2632],{"class":189},"relid",[118,2634,435],{"class":141},[118,2636,2562],{"class":189},[118,2638,452],{"class":124},[118,2640,2641],{"class":189},"attrelid\n",[118,2643,2644,2646,2649,2651],{"class":120,"line":231},[118,2645,2493],{"class":141},[118,2647,2648],{"class":124}," schemaname ",[118,2650,314],{"class":141},[118,2652,2488],{"class":148},[118,2654,2655,2657,2659,2661,2663,2665,2667,2669,2671,2673,2675],{"class":120,"line":239},[118,2656,2493],{"class":141},[118,2658,2562],{"class":189},[118,2660,452],{"class":124},[118,2662,2567],{"class":189},[118,2664,2502],{"class":141},[118,2666,2437],{"class":189},[118,2668,458],{"class":124},[118,2670,2581],{"class":189},[118,2672,452],{"class":124},[118,2674,2567],{"class":189},[118,2676,2515],{"class":124},[99,2678,2680],{"id":2679},"close-all-connections-to-a-database","Close all connections to a database",[104,2682,2683],{},"This is handy if you are developing locally, or need to restore a production backup, but you can't find everything accessing the application. Run the query with the delete right after it if the apps auto reconnect.",[108,2685,2687],{"className":2388,"code":2686,"language":2390,"meta":113,"style":113},"SELECT\n    pg_terminate_backend(pg_stat_activity.pid)\nFROM\n    pg_stat_activity\nWHERE\n    pg_stat_activity.datname = '\u003Cdb_name>'\n    AND pid \u003C> pg_backend_pid();\n",[115,2688,2689,2694,2709,2714,2719,2724,2739],{"__ignoreMap":113},[118,2690,2691],{"class":120,"line":121},[118,2692,2693],{"class":141},"SELECT\n",[118,2695,2696,2699,2702,2704,2707],{"class":120,"line":135},[118,2697,2698],{"class":124},"    pg_terminate_backend(",[118,2700,2701],{"class":189},"pg_stat_activity",[118,2703,452],{"class":124},[118,2705,2706],{"class":189},"pid",[118,2708,2515],{"class":124},[118,2710,2711],{"class":120,"line":152},[118,2712,2713],{"class":141},"FROM\n",[118,2715,2716],{"class":120,"line":201},[118,2717,2718],{"class":124},"    pg_stat_activity\n",[118,2720,2721],{"class":120,"line":209},[118,2722,2723],{"class":141},"WHERE\n",[118,2725,2726,2729,2731,2734,2736],{"class":120,"line":215},[118,2727,2728],{"class":189},"    pg_stat_activity",[118,2730,452],{"class":124},[118,2732,2733],{"class":189},"datname",[118,2735,435],{"class":141},[118,2737,2738],{"class":148}," '\u003Cdb_name>'\n",[118,2740,2741,2744,2747,2750],{"class":120,"line":222},[118,2742,2743],{"class":141},"    AND",[118,2745,2746],{"class":124}," pid ",[118,2748,2749],{"class":141},"\u003C>",[118,2751,2752],{"class":124}," pg_backend_pid();\n",[1200,2754,2756],{"id":2755},"if-you-are-trying-to-recret-a-database-this-works-nicely-too","If you are trying to recret a database, this works nicely too",[108,2758,2762],{"className":2759,"code":2760,"language":2761,"meta":113,"style":113},"language-bash shiki shiki-themes github-dark","#!/bin/bash\n# usage: ./recreate_database \u003Cdbname>\n\npsql -h \u003Chost> postgres postgres -c \"UPDATE pg_database SET datallowconn = 'false' WHERE datname = '$1';\"\npsql -h \u003Chost> postgres postgres -c \"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '$1';\"\ndropdb -h \u003Chost> -U postgres $1\ncreatedb -h \u003Chost> -U postgres $1\n","bash",[115,2763,2764,2770,2775,2779,2815,2842,2866],{"__ignoreMap":113},[118,2765,2766],{"class":120,"line":121},[118,2767,2769],{"class":2768},"sAwPA","#!/bin/bash\n",[118,2771,2772],{"class":120,"line":135},[118,2773,2774],{"class":2768},"# usage: ./recreate_database \u003Cdbname>\n",[118,2776,2777],{"class":120,"line":152},[118,2778,219],{"emptyLinePlaceholder":218},[118,2780,2781,2784,2787,2790,2793,2796,2798,2801,2803,2806,2809,2812],{"class":120,"line":201},[118,2782,2783],{"class":128},"psql",[118,2785,2786],{"class":189}," -h",[118,2788,2789],{"class":141}," \u003C",[118,2791,2792],{"class":148},"hos",[118,2794,2795],{"class":124},"t",[118,2797,2162],{"class":141},[118,2799,2800],{"class":148}," postgres",[118,2802,2800],{"class":148},[118,2804,2805],{"class":189}," -c",[118,2807,2808],{"class":148}," \"UPDATE pg_database SET datallowconn = 'false' WHERE datname = '",[118,2810,2811],{"class":189},"$1",[118,2813,2814],{"class":148},"';\"\n",[118,2816,2817,2819,2821,2823,2825,2827,2829,2831,2833,2835,2838,2840],{"class":120,"line":209},[118,2818,2783],{"class":128},[118,2820,2786],{"class":189},[118,2822,2789],{"class":141},[118,2824,2792],{"class":148},[118,2826,2795],{"class":124},[118,2828,2162],{"class":141},[118,2830,2800],{"class":148},[118,2832,2800],{"class":148},[118,2834,2805],{"class":189},[118,2836,2837],{"class":148}," \"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '",[118,2839,2811],{"class":189},[118,2841,2814],{"class":148},[118,2843,2844,2847,2849,2851,2853,2855,2857,2860,2862],{"class":120,"line":215},[118,2845,2846],{"class":128},"dropdb",[118,2848,2786],{"class":189},[118,2850,2789],{"class":141},[118,2852,2792],{"class":148},[118,2854,2795],{"class":124},[118,2856,2162],{"class":141},[118,2858,2859],{"class":189}," -U",[118,2861,2800],{"class":148},[118,2863,2865],{"class":2864},"s9osk"," $1\n",[118,2867,2868,2871,2873,2875,2877,2879,2881,2883,2885],{"class":120,"line":222},[118,2869,2870],{"class":128},"createdb",[118,2872,2786],{"class":189},[118,2874,2789],{"class":141},[118,2876,2792],{"class":148},[118,2878,2795],{"class":124},[118,2880,2162],{"class":141},[118,2882,2859],{"class":189},[118,2884,2800],{"class":148},[118,2886,2865],{"class":2864},[99,2888,2890],{"id":2889},"change-all-permissions-on-a-database-to-a-user","Change all permissions on a database to a user",[104,2892,2893,2894,2897,2898],{},"Run this as a bash script like ",[115,2895,2896],{},"database_permissions.sh"," as the ",[115,2899,2900],{},"postgres",[108,2902,2904],{"className":2759,"code":2903,"language":2761,"meta":113,"style":113},"#!/bin/bash\n# usage: ./database_permissions.sh database username\n\nfor tbl in `psql -qAt -c \"select tablename from pg_tables where schemaname = 'public';\" $1` ; do  psql -c \"alter table \\\"$tbl\\\" owner to \\\"$2\\\"\" $1 ; done\nfor tbl in `psql -qAt -c \"select sequence_name from information_schema.sequences where sequence_schema = 'public';\" $1` ; do  psql -c \"alter sequence \\\"$tbl\\\" owner to \\\"$2\\\"\" $1 ; done\nfor tbl in `psql -qAt -c \"select table_name from information_schema.views where table_schema = 'public';\" $1` ; do  psql -c \"alter view \\\"$tbl\\\" owner to \\\"$2\\\"\" $1 ; done\nfor tbl in `psql -qAt -c \"select matviewname from pg_matviews where schemaname = 'public';\" $1` ; do  psql -c \"alter materialized view \\\"$tbl\\\" owner to \\\"$2\\\"\" $1 ; done\n",[115,2905,2906,2910,2915,2919,2986,3038,3090],{"__ignoreMap":113},[118,2907,2908],{"class":120,"line":121},[118,2909,2769],{"class":2768},[118,2911,2912],{"class":120,"line":135},[118,2913,2914],{"class":2768},"# usage: ./database_permissions.sh database username\n",[118,2916,2917],{"class":120,"line":152},[118,2918,219],{"emptyLinePlaceholder":218},[118,2920,2921,2924,2927,2930,2933,2935,2938,2940,2943,2945,2948,2951,2953,2956,2958,2961,2964,2967,2969,2972,2975,2978,2981,2983],{"class":120,"line":201},[118,2922,2923],{"class":141},"for",[118,2925,2926],{"class":124}," tbl ",[118,2928,2929],{"class":141},"in",[118,2931,2932],{"class":148}," `",[118,2934,2783],{"class":128},[118,2936,2937],{"class":189}," -qAt",[118,2939,2805],{"class":189},[118,2941,2942],{"class":148}," \"select tablename from pg_tables where schemaname = 'public';\" ",[118,2944,2811],{"class":189},[118,2946,2947],{"class":148},"`",[118,2949,2950],{"class":124}," ; ",[118,2952,2092],{"class":141},[118,2954,2955],{"class":128},"  psql",[118,2957,2805],{"class":189},[118,2959,2960],{"class":148}," \"alter table ",[118,2962,2963],{"class":189},"\\\"",[118,2965,2966],{"class":124},"$tbl",[118,2968,2963],{"class":189},[118,2970,2971],{"class":148}," owner to ",[118,2973,2974],{"class":189},"\\\"$2\\\"",[118,2976,2977],{"class":148},"\"",[118,2979,2980],{"class":2864}," $1",[118,2982,2950],{"class":124},[118,2984,2985],{"class":141},"done\n",[118,2987,2988,2990,2992,2994,2996,2998,3000,3002,3005,3007,3009,3011,3013,3015,3017,3020,3022,3024,3026,3028,3030,3032,3034,3036],{"class":120,"line":209},[118,2989,2923],{"class":141},[118,2991,2926],{"class":124},[118,2993,2929],{"class":141},[118,2995,2932],{"class":148},[118,2997,2783],{"class":128},[118,2999,2937],{"class":189},[118,3001,2805],{"class":189},[118,3003,3004],{"class":148}," \"select sequence_name from information_schema.sequences where sequence_schema = 'public';\" ",[118,3006,2811],{"class":189},[118,3008,2947],{"class":148},[118,3010,2950],{"class":124},[118,3012,2092],{"class":141},[118,3014,2955],{"class":128},[118,3016,2805],{"class":189},[118,3018,3019],{"class":148}," \"alter sequence ",[118,3021,2963],{"class":189},[118,3023,2966],{"class":124},[118,3025,2963],{"class":189},[118,3027,2971],{"class":148},[118,3029,2974],{"class":189},[118,3031,2977],{"class":148},[118,3033,2980],{"class":2864},[118,3035,2950],{"class":124},[118,3037,2985],{"class":141},[118,3039,3040,3042,3044,3046,3048,3050,3052,3054,3057,3059,3061,3063,3065,3067,3069,3072,3074,3076,3078,3080,3082,3084,3086,3088],{"class":120,"line":215},[118,3041,2923],{"class":141},[118,3043,2926],{"class":124},[118,3045,2929],{"class":141},[118,3047,2932],{"class":148},[118,3049,2783],{"class":128},[118,3051,2937],{"class":189},[118,3053,2805],{"class":189},[118,3055,3056],{"class":148}," \"select table_name from information_schema.views where table_schema = 'public';\" ",[118,3058,2811],{"class":189},[118,3060,2947],{"class":148},[118,3062,2950],{"class":124},[118,3064,2092],{"class":141},[118,3066,2955],{"class":128},[118,3068,2805],{"class":189},[118,3070,3071],{"class":148}," \"alter view ",[118,3073,2963],{"class":189},[118,3075,2966],{"class":124},[118,3077,2963],{"class":189},[118,3079,2971],{"class":148},[118,3081,2974],{"class":189},[118,3083,2977],{"class":148},[118,3085,2980],{"class":2864},[118,3087,2950],{"class":124},[118,3089,2985],{"class":141},[118,3091,3092,3094,3096,3098,3100,3102,3104,3106,3109,3111,3113,3115,3117,3119,3121,3124,3126,3128,3130,3132,3134,3136,3138,3140],{"class":120,"line":222},[118,3093,2923],{"class":141},[118,3095,2926],{"class":124},[118,3097,2929],{"class":141},[118,3099,2932],{"class":148},[118,3101,2783],{"class":128},[118,3103,2937],{"class":189},[118,3105,2805],{"class":189},[118,3107,3108],{"class":148}," \"select matviewname from pg_matviews where schemaname = 'public';\" ",[118,3110,2811],{"class":189},[118,3112,2947],{"class":148},[118,3114,2950],{"class":124},[118,3116,2092],{"class":141},[118,3118,2955],{"class":128},[118,3120,2805],{"class":189},[118,3122,3123],{"class":148}," \"alter materialized view ",[118,3125,2963],{"class":189},[118,3127,2966],{"class":124},[118,3129,2963],{"class":189},[118,3131,2971],{"class":148},[118,3133,2974],{"class":189},[118,3135,2977],{"class":148},[118,3137,2980],{"class":2864},[118,3139,2950],{"class":124},[118,3141,2985],{"class":141},[99,3143,3145],{"id":3144},"performance","Performance",[104,3147,3148,3149,3152,3153,3156,3157],{},"Add ",[115,3150,3151],{},"pg_stat_statements"," to ",[115,3154,3155],{},"shared_preload_libraries"," inside ",[115,3158,3159],{},"postgresql.conf",[108,3161,3163],{"className":2388,"code":3162,"language":2390,"meta":113,"style":113},"CREATE EXTENSION pg_stat_statements;\n",[115,3164,3165],{"__ignoreMap":113},[118,3166,3167,3170],{"class":120,"line":121},[118,3168,3169],{"class":141},"CREATE",[118,3171,3172],{"class":124}," EXTENSION pg_stat_statements;\n",[1200,3174,3176],{"id":3175},"columns","Columns",[108,3178,3180],{"className":2388,"code":3179,"language":2390,"meta":113,"style":113},"select query,calls,total_time,min_time,max_time,mean_time,stddev_time,rows from pg_stat_statements;\n",[115,3181,3182],{"__ignoreMap":113},[118,3183,3184,3187,3190,3193,3196],{"class":120,"line":121},[118,3185,3186],{"class":141},"select",[118,3188,3189],{"class":124}," query,calls,total_time,min_time,max_time,mean_time,stddev_time,",[118,3191,3192],{"class":141},"rows",[118,3194,3195],{"class":141}," from",[118,3197,3198],{"class":124}," pg_stat_statements;\n",[1200,3200,3202],{"id":3201},"to-reset-stats","To reset stats",[108,3204,3206],{"className":2388,"code":3205,"language":2390,"meta":113,"style":113},"select pg_stat_statements_reset();\n",[115,3207,3208],{"__ignoreMap":113},[118,3209,3210,3212],{"class":120,"line":121},[118,3211,3186],{"class":141},[118,3213,3214],{"class":124}," pg_stat_statements_reset();\n",[1200,3216,3218],{"id":3217},"most-cpu-usage-queries","Most CPU usage queries",[108,3220,3222],{"className":2388,"code":3221,"language":2390,"meta":113,"style":113},"SELECT datname, query,\n  round(total_time::numeric, 2) AS total_time,\n  calls,\n  round(mean_time::numeric, 2) AS mean,\n  round((100 * total_time / sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_cpu\nFROM pg_stat_statements\nJOIN pg_database ON dbid = pg_database.oid\nORDER BY total_time DESC\nLIMIT 20;\n",[115,3223,3224,3232,3256,3261,3281,3327,3335,3359,3369],{"__ignoreMap":113},[118,3225,3226,3229],{"class":120,"line":121},[118,3227,3228],{"class":141},"SELECT",[118,3230,3231],{"class":124}," datname, query,\n",[118,3233,3234,3237,3240,3243,3245,3248,3250,3253],{"class":120,"line":135},[118,3235,3236],{"class":189},"  round",[118,3238,3239],{"class":124},"(total_time::",[118,3241,3242],{"class":141},"numeric",[118,3244,349],{"class":124},[118,3246,3247],{"class":189},"2",[118,3249,2449],{"class":124},[118,3251,3252],{"class":141},"AS",[118,3254,3255],{"class":124}," total_time,\n",[118,3257,3258],{"class":120,"line":152},[118,3259,3260],{"class":124},"  calls,\n",[118,3262,3263,3265,3268,3270,3272,3274,3276,3278],{"class":120,"line":201},[118,3264,3236],{"class":189},[118,3266,3267],{"class":124},"(mean_time::",[118,3269,3242],{"class":141},[118,3271,349],{"class":124},[118,3273,3247],{"class":189},[118,3275,2449],{"class":124},[118,3277,3252],{"class":141},[118,3279,3280],{"class":124}," mean,\n",[118,3282,3283,3285,3288,3291,3294,3297,3299,3302,3304,3306,3308,3311,3314,3316,3318,3320,3322,3324],{"class":120,"line":209},[118,3284,3236],{"class":189},[118,3286,3287],{"class":124},"((",[118,3289,3290],{"class":189},"100",[118,3292,3293],{"class":141}," *",[118,3295,3296],{"class":124}," total_time ",[118,3298,172],{"class":141},[118,3300,3301],{"class":189}," sum",[118,3303,3239],{"class":124},[118,3305,3242],{"class":141},[118,3307,2449],{"class":124},[118,3309,3310],{"class":141},"OVER",[118,3312,3313],{"class":124}," ())::",[118,3315,3242],{"class":141},[118,3317,349],{"class":124},[118,3319,3247],{"class":189},[118,3321,2449],{"class":124},[118,3323,3252],{"class":141},[118,3325,3326],{"class":124}," percentage_cpu\n",[118,3328,3329,3332],{"class":120,"line":215},[118,3330,3331],{"class":141},"FROM",[118,3333,3334],{"class":124}," pg_stat_statements\n",[118,3336,3337,3340,3343,3346,3349,3351,3354,3356],{"class":120,"line":222},[118,3338,3339],{"class":141},"JOIN",[118,3341,3342],{"class":124}," pg_database ",[118,3344,3345],{"class":141},"ON",[118,3347,3348],{"class":141}," dbid",[118,3350,435],{"class":141},[118,3352,3353],{"class":189}," pg_database",[118,3355,452],{"class":124},[118,3357,3358],{"class":189},"oid\n",[118,3360,3361,3364,3366],{"class":120,"line":231},[118,3362,3363],{"class":141},"ORDER BY",[118,3365,3296],{"class":124},[118,3367,3368],{"class":141},"DESC\n",[118,3370,3371,3374,3377],{"class":120,"line":239},[118,3372,3373],{"class":141},"LIMIT",[118,3375,3376],{"class":189}," 20",[118,3378,560],{"class":124},[1200,3380,3382],{"id":3381},"running-queries","Running queries",[108,3384,3386],{"className":2388,"code":3385,"language":2390,"meta":113,"style":113},"-- show running queries (pre 9.2)\nSELECT procpid, age(clock_timestamp(), query_start), usename, current_query\nFROM pg_stat_activity\nWHERE current_query != '\u003CIDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'\nORDER BY query_start desc;\n\n-- show running queries (9.2)\nSELECT pid, age(clock_timestamp(), query_start), usename, query\nFROM pg_stat_activity\nWHERE query != '\u003CIDLE>' AND query NOT ILIKE '%pg_stat_activity%'\nORDER BY query_start desc;\n",[115,3387,3388,3393,3400,3407,3435,3447,3451,3456,3463,3469,3490],{"__ignoreMap":113},[118,3389,3390],{"class":120,"line":121},[118,3391,3392],{"class":2768},"-- show running queries (pre 9.2)\n",[118,3394,3395,3397],{"class":120,"line":135},[118,3396,3228],{"class":141},[118,3398,3399],{"class":124}," procpid, age(clock_timestamp(), query_start), usename, current_query\n",[118,3401,3402,3404],{"class":120,"line":152},[118,3403,3331],{"class":141},[118,3405,3406],{"class":124}," pg_stat_activity\n",[118,3408,3409,3412,3415,3418,3421,3424,3426,3429,3432],{"class":120,"line":201},[118,3410,3411],{"class":141},"WHERE",[118,3413,3414],{"class":124}," current_query ",[118,3416,3417],{"class":141},"!=",[118,3419,3420],{"class":148}," '\u003CIDLE>'",[118,3422,3423],{"class":141}," AND",[118,3425,3414],{"class":124},[118,3427,3428],{"class":141},"NOT",[118,3430,3431],{"class":124}," ILIKE ",[118,3433,3434],{"class":148},"'%pg_stat_activity%'\n",[118,3436,3437,3439,3442,3445],{"class":120,"line":209},[118,3438,3363],{"class":141},[118,3440,3441],{"class":124}," query_start ",[118,3443,3444],{"class":141},"desc",[118,3446,560],{"class":124},[118,3448,3449],{"class":120,"line":215},[118,3450,219],{"emptyLinePlaceholder":218},[118,3452,3453],{"class":120,"line":222},[118,3454,3455],{"class":2768},"-- show running queries (9.2)\n",[118,3457,3458,3460],{"class":120,"line":231},[118,3459,3228],{"class":141},[118,3461,3462],{"class":124}," pid, age(clock_timestamp(), query_start), usename, query\n",[118,3464,3465,3467],{"class":120,"line":239},[118,3466,3331],{"class":141},[118,3468,3406],{"class":124},[118,3470,3471,3473,3476,3478,3480,3482,3484,3486,3488],{"class":120,"line":247},[118,3472,3411],{"class":141},[118,3474,3475],{"class":124}," query ",[118,3477,3417],{"class":141},[118,3479,3420],{"class":148},[118,3481,3423],{"class":141},[118,3483,3475],{"class":124},[118,3485,3428],{"class":141},[118,3487,3431],{"class":124},[118,3489,3434],{"class":148},[118,3491,3492,3494,3496,3498],{"class":120,"line":255},[118,3493,3363],{"class":141},[118,3495,3441],{"class":124},[118,3497,3444],{"class":141},[118,3499,560],{"class":124},[1200,3501,3503],{"id":3502},"kill-running-query","Kill running query",[108,3505,3507],{"className":2388,"code":3506,"language":2390,"meta":113,"style":113},"SELECT pg_cancel_backend(procpid);\n",[115,3508,3509],{"__ignoreMap":113},[118,3510,3511,3513],{"class":120,"line":121},[118,3512,3228],{"class":141},[118,3514,3515],{"class":124}," pg_cancel_backend(procpid);\n",[1200,3517,3519],{"id":3518},"kill-idle-query","Kill idle query",[108,3521,3523],{"className":2388,"code":3522,"language":2390,"meta":113,"style":113},"SELECT pg_terminate_backend(procpid);\n",[115,3524,3525],{"__ignoreMap":113},[118,3526,3527,3529],{"class":120,"line":121},[118,3528,3228],{"class":141},[118,3530,3531],{"class":124}," pg_terminate_backend(procpid);\n",[1200,3533,3535],{"id":3534},"cache-hit-rate","Cache hit rate",[104,3537,3538],{},"Should not be less then 0.99",[108,3540,3542],{"className":2388,"code":3541,"language":2390,"meta":113,"style":113},"SELECT sum(heap_blks_read) as heap_read, sum(heap_blks_hit)  as heap_hit, (sum(heap_blks_hit) - sum(heap_blks_read)) / sum(heap_blks_hit) as ratio\nFROM pg_statio_user_tables;\n",[115,3543,3544,3593],{"__ignoreMap":113},[118,3545,3546,3548,3550,3553,3556,3559,3562,3565,3567,3570,3572,3575,3577,3579,3582,3584,3586,3588,3590],{"class":120,"line":121},[118,3547,3228],{"class":141},[118,3549,3301],{"class":189},[118,3551,3552],{"class":124},"(heap_blks_read) ",[118,3554,3555],{"class":141},"as",[118,3557,3558],{"class":124}," heap_read, ",[118,3560,3561],{"class":189},"sum",[118,3563,3564],{"class":124},"(heap_blks_hit)  ",[118,3566,3555],{"class":141},[118,3568,3569],{"class":124}," heap_hit, (",[118,3571,3561],{"class":189},[118,3573,3574],{"class":124},"(heap_blks_hit) ",[118,3576,142],{"class":141},[118,3578,3301],{"class":189},[118,3580,3581],{"class":124},"(heap_blks_read)) ",[118,3583,172],{"class":141},[118,3585,3301],{"class":189},[118,3587,3574],{"class":124},[118,3589,3555],{"class":141},[118,3591,3592],{"class":124}," ratio\n",[118,3594,3595,3597],{"class":120,"line":135},[118,3596,3331],{"class":141},[118,3598,3599],{"class":124}," pg_statio_user_tables;\n",[1200,3601,3603],{"id":3602},"table-index-usage-rates","Table index usage rates",[104,3605,3538],{},[108,3607,3609],{"className":2388,"code":3608,"language":2390,"meta":113,"style":113},"SELECT relname, 100 * idx_scan / (seq_scan + idx_scan) percent_of_times_index_used, n_live_tup rows_in_table\nFROM pg_stat_user_tables\nORDER BY n_live_tup DESC;\n",[115,3610,3611,3636,3643],{"__ignoreMap":113},[118,3612,3613,3615,3618,3620,3622,3625,3627,3630,3633],{"class":120,"line":121},[118,3614,3228],{"class":141},[118,3616,3617],{"class":124}," relname, ",[118,3619,3290],{"class":189},[118,3621,3293],{"class":141},[118,3623,3624],{"class":124}," idx_scan ",[118,3626,172],{"class":141},[118,3628,3629],{"class":124}," (seq_scan ",[118,3631,3632],{"class":141},"+",[118,3634,3635],{"class":124}," idx_scan) percent_of_times_index_used, n_live_tup rows_in_table\n",[118,3637,3638,3640],{"class":120,"line":135},[118,3639,3331],{"class":141},[118,3641,3642],{"class":124}," pg_stat_user_tables\n",[118,3644,3645,3647,3650,3653],{"class":120,"line":152},[118,3646,3363],{"class":141},[118,3648,3649],{"class":124}," n_live_tup ",[118,3651,3652],{"class":141},"DESC",[118,3654,560],{"class":124},[1200,3656,3658],{"id":3657},"how-many-indexes-are-in-cache","How many indexes are in cache",[108,3660,3662],{"className":2388,"code":3661,"language":2390,"meta":113,"style":113},"SELECT sum(idx_blks_read) as idx_read, sum(idx_blks_hit)  as idx_hit, (sum(idx_blks_hit) - sum(idx_blks_read)) / sum(idx_blks_hit) as ratio\nFROM pg_statio_user_indexes;\n",[115,3663,3664,3710],{"__ignoreMap":113},[118,3665,3666,3668,3670,3673,3675,3678,3680,3683,3685,3688,3690,3693,3695,3697,3700,3702,3704,3706,3708],{"class":120,"line":121},[118,3667,3228],{"class":141},[118,3669,3301],{"class":189},[118,3671,3672],{"class":124},"(idx_blks_read) ",[118,3674,3555],{"class":141},[118,3676,3677],{"class":124}," idx_read, ",[118,3679,3561],{"class":189},[118,3681,3682],{"class":124},"(idx_blks_hit)  ",[118,3684,3555],{"class":141},[118,3686,3687],{"class":124}," idx_hit, (",[118,3689,3561],{"class":189},[118,3691,3692],{"class":124},"(idx_blks_hit) ",[118,3694,142],{"class":141},[118,3696,3301],{"class":189},[118,3698,3699],{"class":124},"(idx_blks_read)) ",[118,3701,172],{"class":141},[118,3703,3301],{"class":189},[118,3705,3692],{"class":124},[118,3707,3555],{"class":141},[118,3709,3592],{"class":124},[118,3711,3712,3714],{"class":120,"line":135},[118,3713,3331],{"class":141},[118,3715,3716],{"class":124}," pg_statio_user_indexes;\n",[1200,3718,3720],{"id":3719},"find-tables-with-missing-primary-keys","Find tables with missing primary keys",[104,3722,3723],{},[891,3724,3725],{"href":3725},"https://www.postgresonline.com/article_pfriendly/65.html",[108,3727,3729],{"className":2388,"code":3728,"language":2390,"meta":113,"style":113},"SELECT c.table_schema, c.table_name, c.table_type\nFROM information_schema.tables c\nWHERE c.table_type = 'BASE TABLE' AND c.table_schema NOT IN('information_schema', 'pg_catalog')\nAND\nNOT EXISTS (SELECT cu.table_name\n                FROM information_schema.key_column_usage cu\n                WHERE cu.table_schema = c.table_schema AND\n                    cu.table_name = c.table_name)\nORDER BY c.table_schema, c.table_name;\n",[115,3730,3731,3762,3777,3819,3824,3843,3858,3880,3899],{"__ignoreMap":113},[118,3732,3733,3735,3738,3740,3743,3745,3748,3750,3753,3755,3757,3759],{"class":120,"line":121},[118,3734,3228],{"class":141},[118,3736,3737],{"class":189}," c",[118,3739,452],{"class":124},[118,3741,3742],{"class":189},"table_schema",[118,3744,349],{"class":124},[118,3746,3747],{"class":189},"c",[118,3749,452],{"class":124},[118,3751,3752],{"class":189},"table_name",[118,3754,349],{"class":124},[118,3756,3747],{"class":189},[118,3758,452],{"class":124},[118,3760,3761],{"class":189},"table_type\n",[118,3763,3764,3766,3769,3771,3774],{"class":120,"line":135},[118,3765,3331],{"class":141},[118,3767,3768],{"class":189}," information_schema",[118,3770,452],{"class":124},[118,3772,3773],{"class":189},"tables",[118,3775,3776],{"class":124}," c\n",[118,3778,3779,3781,3783,3785,3788,3790,3793,3795,3797,3799,3801,3804,3807,3809,3812,3814,3817],{"class":120,"line":152},[118,3780,3411],{"class":141},[118,3782,3737],{"class":189},[118,3784,452],{"class":124},[118,3786,3787],{"class":189},"table_type",[118,3789,435],{"class":141},[118,3791,3792],{"class":148}," 'BASE TABLE'",[118,3794,3423],{"class":141},[118,3796,3737],{"class":189},[118,3798,452],{"class":124},[118,3800,3742],{"class":189},[118,3802,3803],{"class":141}," NOT",[118,3805,3806],{"class":141}," IN",[118,3808,458],{"class":124},[118,3810,3811],{"class":148},"'information_schema'",[118,3813,349],{"class":124},[118,3815,3816],{"class":148},"'pg_catalog'",[118,3818,2515],{"class":124},[118,3820,3821],{"class":120,"line":201},[118,3822,3823],{"class":141},"AND\n",[118,3825,3826,3828,3831,3833,3835,3838,3840],{"class":120,"line":209},[118,3827,3428],{"class":141},[118,3829,3830],{"class":141}," EXISTS",[118,3832,1296],{"class":124},[118,3834,3228],{"class":141},[118,3836,3837],{"class":189}," cu",[118,3839,452],{"class":124},[118,3841,3842],{"class":189},"table_name\n",[118,3844,3845,3848,3850,3852,3855],{"class":120,"line":215},[118,3846,3847],{"class":141},"                FROM",[118,3849,3768],{"class":189},[118,3851,452],{"class":124},[118,3853,3854],{"class":189},"key_column_usage",[118,3856,3857],{"class":124}," cu\n",[118,3859,3860,3863,3865,3867,3869,3871,3873,3875,3877],{"class":120,"line":222},[118,3861,3862],{"class":141},"                WHERE",[118,3864,3837],{"class":189},[118,3866,452],{"class":124},[118,3868,3742],{"class":189},[118,3870,435],{"class":141},[118,3872,3737],{"class":189},[118,3874,452],{"class":124},[118,3876,3742],{"class":189},[118,3878,3879],{"class":141}," AND\n",[118,3881,3882,3885,3887,3889,3891,3893,3895,3897],{"class":120,"line":231},[118,3883,3884],{"class":189},"                    cu",[118,3886,452],{"class":124},[118,3888,3752],{"class":189},[118,3890,435],{"class":141},[118,3892,3737],{"class":189},[118,3894,452],{"class":124},[118,3896,3752],{"class":189},[118,3898,2515],{"class":124},[118,3900,3901,3903,3905,3907,3909,3911,3913,3915,3917],{"class":120,"line":239},[118,3902,3363],{"class":141},[118,3904,3737],{"class":189},[118,3906,452],{"class":124},[118,3908,3742],{"class":189},[118,3910,349],{"class":124},[118,3912,3747],{"class":189},[118,3914,452],{"class":124},[118,3916,3752],{"class":189},[118,3918,560],{"class":124},[1200,3920,3922],{"id":3921},"find-all-tables-missing-primary-keys-and-have-no-unique-indexes","Find all tables missing primary keys and have no unique indexes",[104,3924,3925],{},[891,3926,3725],{"href":3725},[108,3928,3930],{"className":2388,"code":3929,"language":2390,"meta":113,"style":113},"SELECT c.table_schema, c.table_name, c.table_type\nFROM information_schema.tables c\nWHERE  c.table_schema NOT IN('information_schema', 'pg_catalog') AND c.table_type = 'BASE TABLE'\nAND NOT EXISTS(SELECT i.tablename\n                FROM pg_catalog.pg_indexes i\n            WHERE i.schemaname = c.table_schema\n                AND i.tablename = c.table_name AND indexdef LIKE '%UNIQUE%')\nAND\nNOT EXISTS (SELECT cu.table_name\n                FROM information_schema.key_column_usage cu\n                WHERE cu.table_schema = c.table_schema AND\n                    cu.table_name = c.table_name)\nORDER BY c.table_schema, c.table_name;\n",[115,3931,3932,3958,3970,4009,4029,4044,4064,4097,4101,4117,4129,4149,4167],{"__ignoreMap":113},[118,3933,3934,3936,3938,3940,3942,3944,3946,3948,3950,3952,3954,3956],{"class":120,"line":121},[118,3935,3228],{"class":141},[118,3937,3737],{"class":189},[118,3939,452],{"class":124},[118,3941,3742],{"class":189},[118,3943,349],{"class":124},[118,3945,3747],{"class":189},[118,3947,452],{"class":124},[118,3949,3752],{"class":189},[118,3951,349],{"class":124},[118,3953,3747],{"class":189},[118,3955,452],{"class":124},[118,3957,3761],{"class":189},[118,3959,3960,3962,3964,3966,3968],{"class":120,"line":135},[118,3961,3331],{"class":141},[118,3963,3768],{"class":189},[118,3965,452],{"class":124},[118,3967,3773],{"class":189},[118,3969,3776],{"class":124},[118,3971,3972,3974,3977,3979,3981,3983,3985,3987,3989,3991,3993,3995,3998,4000,4002,4004,4006],{"class":120,"line":152},[118,3973,3411],{"class":141},[118,3975,3976],{"class":189},"  c",[118,3978,452],{"class":124},[118,3980,3742],{"class":189},[118,3982,3803],{"class":141},[118,3984,3806],{"class":141},[118,3986,458],{"class":124},[118,3988,3811],{"class":148},[118,3990,349],{"class":124},[118,3992,3816],{"class":148},[118,3994,2449],{"class":124},[118,3996,3997],{"class":141},"AND",[118,3999,3737],{"class":189},[118,4001,452],{"class":124},[118,4003,3787],{"class":189},[118,4005,435],{"class":141},[118,4007,4008],{"class":148}," 'BASE TABLE'\n",[118,4010,4011,4013,4015,4017,4019,4021,4024,4026],{"class":120,"line":201},[118,4012,3997],{"class":141},[118,4014,3803],{"class":141},[118,4016,3830],{"class":141},[118,4018,458],{"class":124},[118,4020,3228],{"class":141},[118,4022,4023],{"class":189}," i",[118,4025,452],{"class":124},[118,4027,4028],{"class":189},"tablename\n",[118,4030,4031,4033,4036,4038,4041],{"class":120,"line":209},[118,4032,3847],{"class":141},[118,4034,4035],{"class":189}," pg_catalog",[118,4037,452],{"class":124},[118,4039,4040],{"class":189},"pg_indexes",[118,4042,4043],{"class":124}," i\n",[118,4045,4046,4049,4051,4053,4055,4057,4059,4061],{"class":120,"line":215},[118,4047,4048],{"class":141},"            WHERE",[118,4050,4023],{"class":189},[118,4052,452],{"class":124},[118,4054,2413],{"class":189},[118,4056,435],{"class":141},[118,4058,3737],{"class":189},[118,4060,452],{"class":124},[118,4062,4063],{"class":189},"table_schema\n",[118,4065,4066,4069,4071,4073,4076,4078,4080,4082,4084,4086,4089,4092,4095],{"class":120,"line":222},[118,4067,4068],{"class":141},"                AND",[118,4070,4023],{"class":189},[118,4072,452],{"class":124},[118,4074,4075],{"class":189},"tablename",[118,4077,435],{"class":141},[118,4079,3737],{"class":189},[118,4081,452],{"class":124},[118,4083,3752],{"class":189},[118,4085,3423],{"class":141},[118,4087,4088],{"class":124}," indexdef ",[118,4090,4091],{"class":141},"LIKE",[118,4093,4094],{"class":148}," '%UNIQUE%'",[118,4096,2515],{"class":124},[118,4098,4099],{"class":120,"line":231},[118,4100,3823],{"class":141},[118,4102,4103,4105,4107,4109,4111,4113,4115],{"class":120,"line":239},[118,4104,3428],{"class":141},[118,4106,3830],{"class":141},[118,4108,1296],{"class":124},[118,4110,3228],{"class":141},[118,4112,3837],{"class":189},[118,4114,452],{"class":124},[118,4116,3842],{"class":189},[118,4118,4119,4121,4123,4125,4127],{"class":120,"line":247},[118,4120,3847],{"class":141},[118,4122,3768],{"class":189},[118,4124,452],{"class":124},[118,4126,3854],{"class":189},[118,4128,3857],{"class":124},[118,4130,4131,4133,4135,4137,4139,4141,4143,4145,4147],{"class":120,"line":255},[118,4132,3862],{"class":141},[118,4134,3837],{"class":189},[118,4136,452],{"class":124},[118,4138,3742],{"class":189},[118,4140,435],{"class":141},[118,4142,3737],{"class":189},[118,4144,452],{"class":124},[118,4146,3742],{"class":189},[118,4148,3879],{"class":141},[118,4150,4151,4153,4155,4157,4159,4161,4163,4165],{"class":120,"line":263},[118,4152,3884],{"class":189},[118,4154,452],{"class":124},[118,4156,3752],{"class":189},[118,4158,435],{"class":141},[118,4160,3737],{"class":189},[118,4162,452],{"class":124},[118,4164,3752],{"class":189},[118,4166,2515],{"class":124},[118,4168,4169,4171,4173,4175,4177,4179,4181,4183,4185],{"class":120,"line":271},[118,4170,3363],{"class":141},[118,4172,3737],{"class":189},[118,4174,452],{"class":124},[118,4176,3742],{"class":189},[118,4178,349],{"class":124},[118,4180,3747],{"class":189},[118,4182,452],{"class":124},[118,4184,3752],{"class":189},[118,4186,560],{"class":124},[99,4188,4190],{"id":4189},"find-database-size-usage","Find database size usage",[1200,4192,4194],{"id":4193},"index-sizes","Index Sizes",[108,4196,4198],{"className":2388,"code":4197,"language":2390,"meta":113,"style":113},"SELECT\n    pt.tablename AS TableName\n    ,t.indexname AS IndexName\n    ,to_char(pc.reltuples, '999,999,999,999') AS TotalRows\n    ,pg_size_pretty(pg_relation_size(quote_ident(pt.tablename)::text)) AS TableSize\n    ,pg_size_pretty(pg_relation_size(quote_ident(t.indexrelname)::text)) AS IndexSize\n    ,to_char(t.idx_scan, '999,999,999,999') AS TotalNumberOfScan\n    ,to_char(t.idx_tup_read, '999,999,999,999') AS TotalTupleRead\n    ,to_char(t.idx_tup_fetch, '999,999,999,999') AS TotalTupleFetched\nFROM pg_tables AS pt\nLEFT OUTER JOIN pg_class AS pc\n    ON pt.tablename=pc.relname\nLEFT OUTER JOIN\n(\n    SELECT\n        pc.relname AS TableName\n        ,pc2.relname AS IndexName\n        ,psai.idx_scan\n        ,psai.idx_tup_read\n        ,psai.idx_tup_fetch\n        ,psai.indexrelname\n    FROM pg_index AS pi\n    JOIN pg_class AS pc\n        ON pc.oid = pi.indrelid\n    JOIN pg_class AS pc2\n        ON pc2.oid = pi.indexrelid\n    JOIN pg_stat_all_indexes AS psai\n        ON pi.indexrelid = psai.indexrelid\n)AS T\n    ON pt.tablename = T.TableName\nWHERE pt.schemaname='public'\nORDER BY 1;\n",[115,4199,4200,4204,4219,4236,4261,4286,4308,4330,4352,4374,4386,4399,4420,4425,4430,4435,4448,4464,4476,4488,4500,4512,4526,4538,4562,4574,4595,4608,4629,4639,4660,4676],{"__ignoreMap":113},[118,4201,4202],{"class":120,"line":121},[118,4203,2693],{"class":141},[118,4205,4206,4209,4211,4213,4216],{"class":120,"line":135},[118,4207,4208],{"class":189},"    pt",[118,4210,452],{"class":124},[118,4212,4075],{"class":189},[118,4214,4215],{"class":141}," AS",[118,4217,4218],{"class":124}," TableName\n",[118,4220,4221,4224,4226,4228,4231,4233],{"class":120,"line":152},[118,4222,4223],{"class":124},"    ,",[118,4225,2795],{"class":189},[118,4227,452],{"class":124},[118,4229,4230],{"class":189},"indexname",[118,4232,4215],{"class":141},[118,4234,4235],{"class":124}," IndexName\n",[118,4237,4238,4241,4244,4246,4249,4251,4254,4256,4258],{"class":120,"line":201},[118,4239,4240],{"class":124},"    ,to_char(",[118,4242,4243],{"class":189},"pc",[118,4245,452],{"class":124},[118,4247,4248],{"class":189},"reltuples",[118,4250,349],{"class":124},[118,4252,4253],{"class":148},"'999,999,999,999'",[118,4255,2449],{"class":124},[118,4257,3252],{"class":141},[118,4259,4260],{"class":124}," TotalRows\n",[118,4262,4263,4266,4269,4271,4273,4276,4278,4281,4283],{"class":120,"line":209},[118,4264,4265],{"class":124},"    ,pg_size_pretty(pg_relation_size(quote_ident(",[118,4267,4268],{"class":189},"pt",[118,4270,452],{"class":124},[118,4272,4075],{"class":189},[118,4274,4275],{"class":124},")::",[118,4277,903],{"class":141},[118,4279,4280],{"class":124},")) ",[118,4282,3252],{"class":141},[118,4284,4285],{"class":124}," TableSize\n",[118,4287,4288,4290,4292,4294,4297,4299,4301,4303,4305],{"class":120,"line":215},[118,4289,4265],{"class":124},[118,4291,2795],{"class":189},[118,4293,452],{"class":124},[118,4295,4296],{"class":189},"indexrelname",[118,4298,4275],{"class":124},[118,4300,903],{"class":141},[118,4302,4280],{"class":124},[118,4304,3252],{"class":141},[118,4306,4307],{"class":124}," IndexSize\n",[118,4309,4310,4312,4314,4316,4319,4321,4323,4325,4327],{"class":120,"line":222},[118,4311,4240],{"class":124},[118,4313,2795],{"class":189},[118,4315,452],{"class":124},[118,4317,4318],{"class":189},"idx_scan",[118,4320,349],{"class":124},[118,4322,4253],{"class":148},[118,4324,2449],{"class":124},[118,4326,3252],{"class":141},[118,4328,4329],{"class":124}," TotalNumberOfScan\n",[118,4331,4332,4334,4336,4338,4341,4343,4345,4347,4349],{"class":120,"line":231},[118,4333,4240],{"class":124},[118,4335,2795],{"class":189},[118,4337,452],{"class":124},[118,4339,4340],{"class":189},"idx_tup_read",[118,4342,349],{"class":124},[118,4344,4253],{"class":148},[118,4346,2449],{"class":124},[118,4348,3252],{"class":141},[118,4350,4351],{"class":124}," TotalTupleRead\n",[118,4353,4354,4356,4358,4360,4363,4365,4367,4369,4371],{"class":120,"line":239},[118,4355,4240],{"class":124},[118,4357,2795],{"class":189},[118,4359,452],{"class":124},[118,4361,4362],{"class":189},"idx_tup_fetch",[118,4364,349],{"class":124},[118,4366,4253],{"class":148},[118,4368,2449],{"class":124},[118,4370,3252],{"class":141},[118,4372,4373],{"class":124}," TotalTupleFetched\n",[118,4375,4376,4378,4381,4383],{"class":120,"line":247},[118,4377,3331],{"class":141},[118,4379,4380],{"class":124}," pg_tables ",[118,4382,3252],{"class":141},[118,4384,4385],{"class":124}," pt\n",[118,4387,4388,4391,4394,4396],{"class":120,"line":255},[118,4389,4390],{"class":141},"LEFT OUTER JOIN",[118,4392,4393],{"class":124}," pg_class ",[118,4395,3252],{"class":141},[118,4397,4398],{"class":124}," pc\n",[118,4400,4401,4404,4407,4409,4411,4413,4415,4417],{"class":120,"line":263},[118,4402,4403],{"class":141},"    ON",[118,4405,4406],{"class":189}," pt",[118,4408,452],{"class":124},[118,4410,4075],{"class":189},[118,4412,314],{"class":141},[118,4414,4243],{"class":189},[118,4416,452],{"class":124},[118,4418,4419],{"class":189},"relname\n",[118,4421,4422],{"class":120,"line":271},[118,4423,4424],{"class":141},"LEFT OUTER JOIN\n",[118,4426,4427],{"class":120,"line":279},[118,4428,4429],{"class":124},"(\n",[118,4431,4432],{"class":120,"line":568},[118,4433,4434],{"class":141},"    SELECT\n",[118,4436,4437,4440,4442,4444,4446],{"class":120,"line":579},[118,4438,4439],{"class":189},"        pc",[118,4441,452],{"class":124},[118,4443,2427],{"class":189},[118,4445,4215],{"class":141},[118,4447,4218],{"class":124},[118,4449,4450,4453,4456,4458,4460,4462],{"class":120,"line":589},[118,4451,4452],{"class":124},"        ,",[118,4454,4455],{"class":189},"pc2",[118,4457,452],{"class":124},[118,4459,2427],{"class":189},[118,4461,4215],{"class":141},[118,4463,4235],{"class":124},[118,4465,4466,4468,4471,4473],{"class":120,"line":597},[118,4467,4452],{"class":124},[118,4469,4470],{"class":189},"psai",[118,4472,452],{"class":124},[118,4474,4475],{"class":189},"idx_scan\n",[118,4477,4479,4481,4483,4485],{"class":120,"line":4478},19,[118,4480,4452],{"class":124},[118,4482,4470],{"class":189},[118,4484,452],{"class":124},[118,4486,4487],{"class":189},"idx_tup_read\n",[118,4489,4491,4493,4495,4497],{"class":120,"line":4490},20,[118,4492,4452],{"class":124},[118,4494,4470],{"class":189},[118,4496,452],{"class":124},[118,4498,4499],{"class":189},"idx_tup_fetch\n",[118,4501,4503,4505,4507,4509],{"class":120,"line":4502},21,[118,4504,4452],{"class":124},[118,4506,4470],{"class":189},[118,4508,452],{"class":124},[118,4510,4511],{"class":189},"indexrelname\n",[118,4513,4515,4518,4521,4523],{"class":120,"line":4514},22,[118,4516,4517],{"class":141},"    FROM",[118,4519,4520],{"class":124}," pg_index ",[118,4522,3252],{"class":141},[118,4524,4525],{"class":124}," pi\n",[118,4527,4529,4532,4534,4536],{"class":120,"line":4528},23,[118,4530,4531],{"class":141},"    JOIN",[118,4533,4393],{"class":124},[118,4535,3252],{"class":141},[118,4537,4398],{"class":124},[118,4539,4541,4544,4547,4549,4552,4554,4557,4559],{"class":120,"line":4540},24,[118,4542,4543],{"class":141},"        ON",[118,4545,4546],{"class":189}," pc",[118,4548,452],{"class":124},[118,4550,4551],{"class":189},"oid",[118,4553,435],{"class":141},[118,4555,4556],{"class":189}," pi",[118,4558,452],{"class":124},[118,4560,4561],{"class":189},"indrelid\n",[118,4563,4565,4567,4569,4571],{"class":120,"line":4564},25,[118,4566,4531],{"class":141},[118,4568,4393],{"class":124},[118,4570,3252],{"class":141},[118,4572,4573],{"class":124}," pc2\n",[118,4575,4577,4579,4582,4584,4586,4588,4590,4592],{"class":120,"line":4576},26,[118,4578,4543],{"class":141},[118,4580,4581],{"class":189}," pc2",[118,4583,452],{"class":124},[118,4585,4551],{"class":189},[118,4587,435],{"class":141},[118,4589,4556],{"class":189},[118,4591,452],{"class":124},[118,4593,4594],{"class":189},"indexrelid\n",[118,4596,4598,4600,4603,4605],{"class":120,"line":4597},27,[118,4599,4531],{"class":141},[118,4601,4602],{"class":124}," pg_stat_all_indexes ",[118,4604,3252],{"class":141},[118,4606,4607],{"class":124}," psai\n",[118,4609,4611,4613,4615,4617,4620,4622,4625,4627],{"class":120,"line":4610},28,[118,4612,4543],{"class":141},[118,4614,4556],{"class":189},[118,4616,452],{"class":124},[118,4618,4619],{"class":189},"indexrelid",[118,4621,435],{"class":141},[118,4623,4624],{"class":189}," psai",[118,4626,452],{"class":124},[118,4628,4594],{"class":189},[118,4630,4632,4634,4636],{"class":120,"line":4631},29,[118,4633,519],{"class":124},[118,4635,3252],{"class":141},[118,4637,4638],{"class":124}," T\n",[118,4640,4642,4644,4646,4648,4650,4652,4655,4657],{"class":120,"line":4641},30,[118,4643,4403],{"class":141},[118,4645,4406],{"class":189},[118,4647,452],{"class":124},[118,4649,4075],{"class":189},[118,4651,435],{"class":141},[118,4653,4654],{"class":189}," T",[118,4656,452],{"class":124},[118,4658,4659],{"class":189},"TableName\n",[118,4661,4663,4665,4667,4669,4671,4673],{"class":120,"line":4662},31,[118,4664,3411],{"class":141},[118,4666,4406],{"class":189},[118,4668,452],{"class":124},[118,4670,2413],{"class":189},[118,4672,314],{"class":141},[118,4674,4675],{"class":148},"'public'\n",[118,4677,4679,4681,4684],{"class":120,"line":4678},32,[118,4680,3363],{"class":141},[118,4682,4683],{"class":189}," 1",[118,4685,560],{"class":124},[1200,4687,4689],{"id":4688},"table-sizes","Table Sizes",[108,4691,4693],{"className":2388,"code":4692,"language":2390,"meta":113,"style":113},"SELECT nspname || '.' || relname AS \"relation\",\n    pg_size_pretty(pg_total_relation_size(C.oid)) AS \"total_size\"\n  FROM pg_class C\n  LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)\n  WHERE nspname NOT IN ('pg_catalog', 'information_schema')\n    AND C.relkind \u003C> 'i'\n    AND nspname !~ '^pg_toast'\n  ORDER BY pg_total_relation_size(C.oid) DESC;\n",[115,4694,4695,4720,4739,4747,4778,4799,4815,4825],{"__ignoreMap":113},[118,4696,4697,4699,4702,4704,4707,4709,4712,4714,4717],{"class":120,"line":121},[118,4698,3228],{"class":141},[118,4700,4701],{"class":124}," nspname ",[118,4703,2452],{"class":141},[118,4705,4706],{"class":148}," '.'",[118,4708,2405],{"class":141},[118,4710,4711],{"class":124}," relname ",[118,4713,3252],{"class":141},[118,4715,4716],{"class":148}," \"relation\"",[118,4718,4719],{"class":124},",\n",[118,4721,4722,4725,4728,4730,4732,4734,4736],{"class":120,"line":135},[118,4723,4724],{"class":124},"    pg_size_pretty(pg_total_relation_size(",[118,4726,4727],{"class":189},"C",[118,4729,452],{"class":124},[118,4731,4551],{"class":189},[118,4733,4280],{"class":124},[118,4735,3252],{"class":141},[118,4737,4738],{"class":148}," \"total_size\"\n",[118,4740,4741,4744],{"class":120,"line":152},[118,4742,4743],{"class":141},"  FROM",[118,4745,4746],{"class":124}," pg_class C\n",[118,4748,4749,4752,4755,4757,4759,4762,4764,4766,4768,4771,4773,4776],{"class":120,"line":201},[118,4750,4751],{"class":141},"  LEFT JOIN",[118,4753,4754],{"class":124}," pg_namespace N ",[118,4756,3345],{"class":141},[118,4758,1296],{"class":124},[118,4760,4761],{"class":189},"N",[118,4763,452],{"class":124},[118,4765,4551],{"class":189},[118,4767,435],{"class":141},[118,4769,4770],{"class":189}," C",[118,4772,452],{"class":124},[118,4774,4775],{"class":189},"relnamespace",[118,4777,2515],{"class":124},[118,4779,4780,4783,4785,4787,4789,4791,4793,4795,4797],{"class":120,"line":209},[118,4781,4782],{"class":141},"  WHERE",[118,4784,4701],{"class":124},[118,4786,3428],{"class":141},[118,4788,3806],{"class":141},[118,4790,1296],{"class":124},[118,4792,3816],{"class":148},[118,4794,349],{"class":124},[118,4796,3811],{"class":148},[118,4798,2515],{"class":124},[118,4800,4801,4803,4805,4807,4810,4812],{"class":120,"line":215},[118,4802,2743],{"class":141},[118,4804,4770],{"class":189},[118,4806,452],{"class":124},[118,4808,4809],{"class":189},"relkind",[118,4811,2502],{"class":141},[118,4813,4814],{"class":148}," 'i'\n",[118,4816,4817,4819,4822],{"class":120,"line":222},[118,4818,2743],{"class":141},[118,4820,4821],{"class":124}," nspname !~ ",[118,4823,4824],{"class":148},"'^pg_toast'\n",[118,4826,4827,4830,4833,4835,4837,4839,4841,4843],{"class":120,"line":231},[118,4828,4829],{"class":141},"  ORDER BY",[118,4831,4832],{"class":124}," pg_total_relation_size(",[118,4834,4727],{"class":189},[118,4836,452],{"class":124},[118,4838,4551],{"class":189},[118,4840,2449],{"class":124},[118,4842,3652],{"class":141},[118,4844,560],{"class":124},[1200,4846,4848],{"id":4847},"find-tables-with-a-high-sequential-scan","Find tables with a high sequential scan",[104,4850,4851],{},"If the table is large, this might mean an index isn't being used",[108,4853,4855],{"className":2388,"code":4854,"language":2390,"meta":113,"style":113},"SELECT relname AS table_name, seq_scan, seq_tup_read, idx_scan\nFROM pg_stat_user_tables\nWHERE seq_scan > 0\nORDER BY seq_scan DESC;\n",[115,4856,4857,4868,4874,4885],{"__ignoreMap":113},[118,4858,4859,4861,4863,4865],{"class":120,"line":121},[118,4860,3228],{"class":141},[118,4862,4711],{"class":124},[118,4864,3252],{"class":141},[118,4866,4867],{"class":124}," table_name, seq_scan, seq_tup_read, idx_scan\n",[118,4869,4870,4872],{"class":120,"line":135},[118,4871,3331],{"class":141},[118,4873,3642],{"class":124},[118,4875,4876,4878,4881,4883],{"class":120,"line":152},[118,4877,3411],{"class":141},[118,4879,4880],{"class":124}," seq_scan ",[118,4882,2162],{"class":141},[118,4884,812],{"class":189},[118,4886,4887,4889,4891,4893],{"class":120,"line":201},[118,4888,3363],{"class":141},[118,4890,4880],{"class":124},[118,4892,3652],{"class":141},[118,4894,560],{"class":124},[1200,4896,4898],{"id":4897},"find-indexes-that-are-never-used","Find indexes that are never used",[104,4900,4901],{},"This slows down writes as it needs to insert in all the indexes for a table.",[108,4903,4905],{"className":2388,"code":4904,"language":2390,"meta":113,"style":113},"SELECT relname AS table_name, indexrelname AS index_name, idx_scan, idx_tup_read, idx_tup_fetch\nFROM pg_stat_user_indexes\nWHERE idx_scan = 0\nORDER BY table_name;\n",[115,4906,4907,4923,4930,4940],{"__ignoreMap":113},[118,4908,4909,4911,4913,4915,4918,4920],{"class":120,"line":121},[118,4910,3228],{"class":141},[118,4912,4711],{"class":124},[118,4914,3252],{"class":141},[118,4916,4917],{"class":124}," table_name, indexrelname ",[118,4919,3252],{"class":141},[118,4921,4922],{"class":124}," index_name, idx_scan, idx_tup_read, idx_tup_fetch\n",[118,4924,4925,4927],{"class":120,"line":135},[118,4926,3331],{"class":141},[118,4928,4929],{"class":124}," pg_stat_user_indexes\n",[118,4931,4932,4934,4936,4938],{"class":120,"line":152},[118,4933,3411],{"class":141},[118,4935,3624],{"class":124},[118,4937,314],{"class":141},[118,4939,812],{"class":189},[118,4941,4942,4944],{"class":120,"line":201},[118,4943,3363],{"class":141},[118,4945,4946],{"class":124}," table_name;\n",[1200,4948,4950],{"id":4949},"see-connection-count","See connection count",[104,4952,4953],{},"Use this to detect if it's using connection pooling.",[108,4955,4957],{"className":2388,"code":4956,"language":2390,"meta":113,"style":113},"SELECT COUNT(*) AS connection_count\nFROM pg_stat_activity\nWHERE backend_start >= NOW() - INTERVAL '120 minutes';\n",[115,4958,4959,4978,4984],{"__ignoreMap":113},[118,4960,4961,4963,4966,4968,4971,4973,4975],{"class":120,"line":121},[118,4962,3228],{"class":141},[118,4964,4965],{"class":189}," COUNT",[118,4967,458],{"class":124},[118,4969,4970],{"class":141},"*",[118,4972,2449],{"class":124},[118,4974,3252],{"class":141},[118,4976,4977],{"class":124}," connection_count\n",[118,4979,4980,4982],{"class":120,"line":135},[118,4981,3331],{"class":141},[118,4983,3406],{"class":124},[118,4985,4986,4988,4991,4994,4997,5000,5002,5005,5008],{"class":120,"line":152},[118,4987,3411],{"class":141},[118,4989,4990],{"class":124}," backend_start ",[118,4992,4993],{"class":141},">=",[118,4995,4996],{"class":141}," NOW",[118,4998,4999],{"class":124},"() ",[118,5001,142],{"class":141},[118,5003,5004],{"class":124}," INTERVAL ",[118,5006,5007],{"class":148},"'120 minutes'",[118,5009,560],{"class":124},[104,5011,5012],{},"or with a bit more detail",[108,5014,5016],{"className":2388,"code":5015,"language":2390,"meta":113,"style":113},"SELECT pid, usename, application_name, client_addr, backend_start\nFROM pg_stat_activity\nWHERE backend_start >= NOW() - INTERVAL '200 minutes';\n",[115,5017,5018,5025,5031],{"__ignoreMap":113},[118,5019,5020,5022],{"class":120,"line":121},[118,5021,3228],{"class":141},[118,5023,5024],{"class":124}," pid, usename, application_name, client_addr, backend_start\n",[118,5026,5027,5029],{"class":120,"line":135},[118,5028,3331],{"class":141},[118,5030,3406],{"class":124},[118,5032,5033,5035,5037,5039,5041,5043,5045,5047,5050],{"class":120,"line":152},[118,5034,3411],{"class":141},[118,5036,4990],{"class":124},[118,5038,4993],{"class":141},[118,5040,4996],{"class":141},[118,5042,4999],{"class":124},[118,5044,142],{"class":141},[118,5046,5004],{"class":124},[118,5048,5049],{"class":148},"'200 minutes'",[118,5051,560],{"class":124},[104,5053,5054],{},"or to see how many active connections there are. We have Active, Idle and NULL",[108,5056,5058],{"className":2388,"code":5057,"language":2390,"meta":113,"style":113},"SELECT pid, usename, application_name, client_addr, backend_start at time zone 'Australia/Adelaide', state, query, *\nFROM pg_stat_activity\nWHERE state in ('active', 'idle')\nORDER BY backend_start ASC;\n",[115,5059,5060,5089,5095,5117],{"__ignoreMap":113},[118,5061,5062,5064,5067,5070,5072,5075,5078,5080,5083,5086],{"class":120,"line":121},[118,5063,3228],{"class":141},[118,5065,5066],{"class":124}," pid, usename, application_name, client_addr, backend_start ",[118,5068,5069],{"class":141},"at",[118,5071,317],{"class":141},[118,5073,5074],{"class":141}," zone",[118,5076,5077],{"class":148}," 'Australia/Adelaide'",[118,5079,349],{"class":124},[118,5081,5082],{"class":141},"state",[118,5084,5085],{"class":124},", query, ",[118,5087,5088],{"class":141},"*\n",[118,5090,5091,5093],{"class":120,"line":135},[118,5092,3331],{"class":141},[118,5094,3406],{"class":124},[118,5096,5097,5099,5102,5105,5107,5110,5112,5115],{"class":120,"line":152},[118,5098,3411],{"class":141},[118,5100,5101],{"class":141}," state",[118,5103,5104],{"class":141}," in",[118,5106,1296],{"class":124},[118,5108,5109],{"class":148},"'active'",[118,5111,349],{"class":124},[118,5113,5114],{"class":148},"'idle'",[118,5116,2515],{"class":124},[118,5118,5119,5121,5123,5126],{"class":120,"line":201},[118,5120,3363],{"class":141},[118,5122,4990],{"class":124},[118,5124,5125],{"class":141},"ASC",[118,5127,560],{"class":124},[99,5129,5131],{"id":5130},"update-all-sequences-to-be-inline-with-the-max-value-of-the-id","Update all sequences to be inline with the max value of the ID",[104,5133,5134],{},"This assumes a lot of things about your database, but for standard tables with an ID that is an integer, it should work.",[108,5136,5138],{"className":2388,"code":5137,"language":2390,"meta":113,"style":113},"with sequences as (\n  select *\n  from (\n    select table_schema,\n           table_name,\n           column_name,\n           pg_get_serial_sequence(format('%I.%I', table_schema, table_name), column_name) as col_sequence\n    from information_schema.columns\n    where table_schema not in ('pg_catalog', 'information_schema')\n  ) t\n  where col_sequence is not null\n), maxvals as (\n  select table_schema, table_name, column_name, col_sequence,\n          (xpath('/row/max/text()',\n             query_to_xml(format('select max(%I) from %I.%I', column_name, table_schema, table_name), true, true, ''))\n          )[1]::text::bigint as max_val\n  from sequences\n)\nselect table_schema,\n       table_name,\n       column_name,\n       col_sequence,\n       coalesce(max_val, 0) as max_val,\n       setval(col_sequence, coalesce(max_val, 1))\nfrom maxvals;\n",[115,5139,5140,5153,5161,5168,5176,5181,5186,5207,5219,5242,5247,5258,5267,5274,5284,5305,5324,5331,5335,5341,5346,5351,5356,5373,5387],{"__ignoreMap":113},[118,5141,5142,5145,5148,5150],{"class":120,"line":121},[118,5143,5144],{"class":141},"with",[118,5146,5147],{"class":124}," sequences ",[118,5149,3555],{"class":141},[118,5151,5152],{"class":124}," (\n",[118,5154,5155,5158],{"class":120,"line":135},[118,5156,5157],{"class":141},"  select",[118,5159,5160],{"class":141}," *\n",[118,5162,5163,5166],{"class":120,"line":152},[118,5164,5165],{"class":141},"  from",[118,5167,5152],{"class":124},[118,5169,5170,5173],{"class":120,"line":201},[118,5171,5172],{"class":141},"    select",[118,5174,5175],{"class":124}," table_schema,\n",[118,5177,5178],{"class":120,"line":209},[118,5179,5180],{"class":124},"           table_name,\n",[118,5182,5183],{"class":120,"line":215},[118,5184,5185],{"class":124},"           column_name,\n",[118,5187,5188,5191,5194,5196,5199,5202,5204],{"class":120,"line":222},[118,5189,5190],{"class":124},"           pg_get_serial_sequence(",[118,5192,5193],{"class":189},"format",[118,5195,458],{"class":124},[118,5197,5198],{"class":148},"'%I.%I'",[118,5200,5201],{"class":124},", table_schema, table_name), column_name) ",[118,5203,3555],{"class":141},[118,5205,5206],{"class":124}," col_sequence\n",[118,5208,5209,5212,5214,5216],{"class":120,"line":231},[118,5210,5211],{"class":141},"    from",[118,5213,3768],{"class":189},[118,5215,452],{"class":124},[118,5217,5218],{"class":189},"columns\n",[118,5220,5221,5224,5227,5230,5232,5234,5236,5238,5240],{"class":120,"line":239},[118,5222,5223],{"class":141},"    where",[118,5225,5226],{"class":124}," table_schema ",[118,5228,5229],{"class":141},"not",[118,5231,5104],{"class":141},[118,5233,1296],{"class":124},[118,5235,3816],{"class":148},[118,5237,349],{"class":124},[118,5239,3811],{"class":148},[118,5241,2515],{"class":124},[118,5243,5244],{"class":120,"line":247},[118,5245,5246],{"class":124},"  ) t\n",[118,5248,5249,5252,5255],{"class":120,"line":255},[118,5250,5251],{"class":141},"  where",[118,5253,5254],{"class":124}," col_sequence ",[118,5256,5257],{"class":141},"is not null\n",[118,5259,5260,5263,5265],{"class":120,"line":263},[118,5261,5262],{"class":124},"), maxvals ",[118,5264,3555],{"class":141},[118,5266,5152],{"class":124},[118,5268,5269,5271],{"class":120,"line":271},[118,5270,5157],{"class":141},[118,5272,5273],{"class":124}," table_schema, table_name, column_name, col_sequence,\n",[118,5275,5276,5279,5282],{"class":120,"line":279},[118,5277,5278],{"class":124},"          (xpath(",[118,5280,5281],{"class":148},"'/row/max/text()'",[118,5283,4719],{"class":124},[118,5285,5286,5289,5291,5293,5296,5299,5302],{"class":120,"line":568},[118,5287,5288],{"class":124},"             query_to_xml(",[118,5290,5193],{"class":189},[118,5292,458],{"class":124},[118,5294,5295],{"class":148},"'select max(%I) from %I.%I'",[118,5297,5298],{"class":124},", column_name, table_schema, table_name), true, true, ",[118,5300,5301],{"class":148},"''",[118,5303,5304],{"class":124},"))\n",[118,5306,5307,5310,5312,5315,5318,5321],{"class":120,"line":579},[118,5308,5309],{"class":124},"          )[1]::",[118,5311,903],{"class":141},[118,5313,5314],{"class":124},"::",[118,5316,5317],{"class":141},"bigint",[118,5319,5320],{"class":141}," as",[118,5322,5323],{"class":124}," max_val\n",[118,5325,5326,5328],{"class":120,"line":589},[118,5327,5165],{"class":141},[118,5329,5330],{"class":124}," sequences\n",[118,5332,5333],{"class":120,"line":597},[118,5334,2515],{"class":124},[118,5336,5337,5339],{"class":120,"line":4478},[118,5338,3186],{"class":141},[118,5340,5175],{"class":124},[118,5342,5343],{"class":120,"line":4490},[118,5344,5345],{"class":124},"       table_name,\n",[118,5347,5348],{"class":120,"line":4502},[118,5349,5350],{"class":124},"       column_name,\n",[118,5352,5353],{"class":120,"line":4514},[118,5354,5355],{"class":124},"       col_sequence,\n",[118,5357,5358,5361,5364,5366,5368,5370],{"class":120,"line":4528},[118,5359,5360],{"class":189},"       coalesce",[118,5362,5363],{"class":124},"(max_val, ",[118,5365,608],{"class":189},[118,5367,2449],{"class":124},[118,5369,3555],{"class":141},[118,5371,5372],{"class":124}," max_val,\n",[118,5374,5375,5378,5381,5383,5385],{"class":120,"line":4540},[118,5376,5377],{"class":124},"       setval(col_sequence, ",[118,5379,5380],{"class":189},"coalesce",[118,5382,5363],{"class":124},[118,5384,603],{"class":189},[118,5386,5304],{"class":124},[118,5388,5389,5392],{"class":120,"line":4564},[118,5390,5391],{"class":141},"from",[118,5393,5394],{"class":124}," maxvals;\n",[99,5396,5398],{"id":5397},"backup-restore","Backup / Restore",[104,5400,5401,5402,5405],{},"When converting between different databases it might be safer to use ",[115,5403,5404],{},".sql"," depending on version difference.",[1200,5407,5409],{"id":5408},"dump-remote-database","Dump remote database",[108,5411,5413],{"className":2759,"code":5412,"language":2761,"meta":113,"style":113},"pg_dump -U \u003Cuser> -h \u003Chost> \u003Cdatabase> > dump.sql\n",[115,5414,5415],{"__ignoreMap":113},[118,5416,5417,5420,5422,5424,5427,5430,5432,5434,5436,5438,5440,5442,5444,5447,5449,5451,5454],{"class":120,"line":121},[118,5418,5419],{"class":128},"pg_dump",[118,5421,2859],{"class":189},[118,5423,2789],{"class":141},[118,5425,5426],{"class":148},"use",[118,5428,5429],{"class":124},"r",[118,5431,2162],{"class":141},[118,5433,2786],{"class":189},[118,5435,2789],{"class":141},[118,5437,2792],{"class":148},[118,5439,2795],{"class":124},[118,5441,2162],{"class":141},[118,5443,2789],{"class":141},[118,5445,5446],{"class":148},"databas",[118,5448,511],{"class":124},[118,5450,2162],{"class":141},[118,5452,5453],{"class":141}," >",[118,5455,5456],{"class":148}," dump.sql\n",[1200,5458,5460],{"id":5459},"restore-remote-database","Restore remote database",[108,5462,5464],{"className":2759,"code":5463,"language":2761,"meta":113,"style":113},"psql -U \u003Cuser> -h \u003Chost> -d \u003Cdatabase> -f dump.sql\n",[115,5465,5466],{"__ignoreMap":113},[118,5467,5468,5470,5472,5474,5476,5478,5480,5482,5484,5486,5488,5490,5493,5495,5497,5499,5501,5504],{"class":120,"line":121},[118,5469,2783],{"class":128},[118,5471,2859],{"class":189},[118,5473,2789],{"class":141},[118,5475,5426],{"class":148},[118,5477,5429],{"class":124},[118,5479,2162],{"class":141},[118,5481,2786],{"class":189},[118,5483,2789],{"class":141},[118,5485,2792],{"class":148},[118,5487,2795],{"class":124},[118,5489,2162],{"class":141},[118,5491,5492],{"class":189}," -d",[118,5494,2789],{"class":141},[118,5496,5446],{"class":148},[118,5498,511],{"class":124},[118,5500,2162],{"class":141},[118,5502,5503],{"class":189}," -f",[118,5505,5456],{"class":148},[1200,5507,5509],{"id":5508},"dropping-a-database-with-connections","Dropping a database with connections",[104,5511,5512],{},"This is useful when doing development or staging environments where it's hard to get all connections dropped.",[108,5514,5516],{"className":2388,"code":5515,"language":2390,"meta":113,"style":113},"SELECT\n    pg_terminate_backend(pg_stat_activity.pid)\nFROM\n    pg_stat_activity\nWHERE\n    pg_stat_activity.datname = 'ifas'\n    AND pid \u003C> pg_backend_pid();\nDROP DATABASE ifas;\nCREATE DATABASE ifas;\n",[115,5517,5518,5522,5534,5538,5542,5546,5559,5569,5580],{"__ignoreMap":113},[118,5519,5520],{"class":120,"line":121},[118,5521,2693],{"class":141},[118,5523,5524,5526,5528,5530,5532],{"class":120,"line":135},[118,5525,2698],{"class":124},[118,5527,2701],{"class":189},[118,5529,452],{"class":124},[118,5531,2706],{"class":189},[118,5533,2515],{"class":124},[118,5535,5536],{"class":120,"line":152},[118,5537,2713],{"class":141},[118,5539,5540],{"class":120,"line":201},[118,5541,2718],{"class":124},[118,5543,5544],{"class":120,"line":209},[118,5545,2723],{"class":141},[118,5547,5548,5550,5552,5554,5556],{"class":120,"line":215},[118,5549,2728],{"class":189},[118,5551,452],{"class":124},[118,5553,2733],{"class":189},[118,5555,435],{"class":141},[118,5557,5558],{"class":148}," 'ifas'\n",[118,5560,5561,5563,5565,5567],{"class":120,"line":222},[118,5562,2743],{"class":141},[118,5564,2746],{"class":124},[118,5566,2749],{"class":141},[118,5568,2752],{"class":124},[118,5570,5571,5574,5577],{"class":120,"line":231},[118,5572,5573],{"class":141},"DROP",[118,5575,5576],{"class":141}," DATABASE",[118,5578,5579],{"class":124}," ifas;\n",[118,5581,5582,5584,5586,5589],{"class":120,"line":239},[118,5583,3169],{"class":141},[118,5585,5576],{"class":141},[118,5587,5588],{"class":128}," ifas",[118,5590,560],{"class":124},[99,5592,5594],{"id":5593},"identity-columns","Identity Columns",[104,5596,5597],{},"To turn an existing column into an identity column you can use:",[108,5599,5601],{"className":2388,"code":5600,"language":2390,"meta":113,"style":113},"ALTER TABLE table_name\n   ALTER COLUMN id_column\n   ADD GENERATED ALWAYS AS IDENTITY;\n",[115,5602,5603,5614,5622],{"__ignoreMap":113},[118,5604,5605,5608,5611],{"class":120,"line":121},[118,5606,5607],{"class":141},"ALTER",[118,5609,5610],{"class":141}," TABLE",[118,5612,5613],{"class":124}," table_name\n",[118,5615,5616,5619],{"class":120,"line":135},[118,5617,5618],{"class":141},"   ALTER",[118,5620,5621],{"class":124}," COLUMN id_column\n",[118,5623,5624,5627,5630,5633,5635,5638],{"class":120,"line":152},[118,5625,5626],{"class":141},"   ADD",[118,5628,5629],{"class":141}," GENERATED",[118,5631,5632],{"class":141}," ALWAYS",[118,5634,4215],{"class":141},[118,5636,5637],{"class":141}," IDENTITY",[118,5639,560],{"class":124},[104,5641,5642],{},"or",[108,5644,5646],{"className":2388,"code":5645,"language":2390,"meta":113,"style":113},"ALTER TABLE table_name\n   ALTER COLUMN id_column\n   ADD GENERATED BY DEFAULT AS IDENTITY;\n",[115,5647,5648,5656,5662],{"__ignoreMap":113},[118,5649,5650,5652,5654],{"class":120,"line":121},[118,5651,5607],{"class":141},[118,5653,5610],{"class":141},[118,5655,5613],{"class":124},[118,5657,5658,5660],{"class":120,"line":135},[118,5659,5618],{"class":141},[118,5661,5621],{"class":124},[118,5663,5664,5666,5668,5671,5674,5676,5678],{"class":120,"line":152},[118,5665,5626],{"class":141},[118,5667,5629],{"class":141},[118,5669,5670],{"class":141}," BY",[118,5672,5673],{"class":141}," DEFAULT",[118,5675,4215],{"class":141},[118,5677,5637],{"class":141},[118,5679,560],{"class":124},[104,5681,5682,5683,5686],{},"I prefer the ",[115,5684,5685],{},"generated always"," as it will throw an error if you try to bypass the automatic generation of values.",[104,5688,5689],{},"If the table already contains data, you need to synchronized the underlying sequence with the values in the table:",[108,5691,5693],{"className":2388,"code":5692,"language":2390,"meta":113,"style":113},"select setval(pg_get_serial_sequence('the_table', 'id_column'), max(id))\nfrom the_table;\n",[115,5694,5695,5718],{"__ignoreMap":113},[118,5696,5697,5699,5702,5705,5707,5710,5712,5715],{"class":120,"line":121},[118,5698,3186],{"class":141},[118,5700,5701],{"class":124}," setval(pg_get_serial_sequence(",[118,5703,5704],{"class":148},"'the_table'",[118,5706,349],{"class":124},[118,5708,5709],{"class":148},"'id_column'",[118,5711,1260],{"class":124},[118,5713,5714],{"class":189},"max",[118,5716,5717],{"class":124},"(id))\n",[118,5719,5720,5722],{"class":120,"line":135},[118,5721,5391],{"class":141},[118,5723,5724],{"class":124}," the_table;\n",[613,5726,5727],{},"html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .s9osk, html code.shiki .s9osk{--shiki-default:#FFAB70}",{"title":113,"searchDepth":135,"depth":135,"links":5729},[5730,5734,5737,5738,5751,5758,5759,5764],{"id":2377,"depth":135,"text":2378,"children":5731},[5732,5733],{"id":2384,"depth":152,"text":2385},{"id":2518,"depth":152,"text":2519},{"id":2679,"depth":135,"text":2680,"children":5735},[5736],{"id":2755,"depth":152,"text":2756},{"id":2889,"depth":135,"text":2890},{"id":3144,"depth":135,"text":3145,"children":5739},[5740,5741,5742,5743,5744,5745,5746,5747,5748,5749,5750],{"id":3175,"depth":152,"text":3176},{"id":3201,"depth":152,"text":3202},{"id":3217,"depth":152,"text":3218},{"id":3381,"depth":152,"text":3382},{"id":3502,"depth":152,"text":3503},{"id":3518,"depth":152,"text":3519},{"id":3534,"depth":152,"text":3535},{"id":3602,"depth":152,"text":3603},{"id":3657,"depth":152,"text":3658},{"id":3719,"depth":152,"text":3720},{"id":3921,"depth":152,"text":3922},{"id":4189,"depth":135,"text":4190,"children":5752},[5753,5754,5755,5756,5757],{"id":4193,"depth":152,"text":4194},{"id":4688,"depth":152,"text":4689},{"id":4847,"depth":152,"text":4848},{"id":4897,"depth":152,"text":4898},{"id":4949,"depth":152,"text":4950},{"id":5130,"depth":135,"text":5131},{"id":5397,"depth":135,"text":5398,"children":5760},[5761,5762,5763],{"id":5408,"depth":152,"text":5409},{"id":5459,"depth":152,"text":5460},{"id":5508,"depth":152,"text":5509},{"id":5593,"depth":135,"text":5594},[2390,5766],"postgresql","Handy PostgreSQL snippets: lowercase table and column names, close all connections, reset permissions, and queries to diagnose performance and index usage.",{"slug":54,"isHowTo":218},"2023-11-05T07:09:00.000Z",{"title":52,"description":5767},[2390],"lIhu8RsGMkHLjzY1JpxgFg-mN7FnVImcpYZG_rwgmfo",{"id":5774,"title":61,"body":5775,"categories":8819,"description":8820,"extension":624,"meta":8821,"navigation":218,"ogImage":627,"path":62,"publish_at":8822,"seo":8823,"stem":63,"tags":8824,"__hash__":8827},"library/library/proxmox/proxmox-encrypted-vms-with-zfs.md",{"type":96,"value":5776,"toc":8795},[5777,5784,5789,5803,5805,5807,5810,5813,5824,5827,5829,5833,5836,5839,5843,5848,5854,5862,5947,5954,5980,6056,6058,6062,6073,6122,6127,6176,6185,6262,6270,6284,6371,6376,6390,6392,6396,6409,6422,6430,6529,6534,6571,6576,6590,6592,6596,6629,6635,6641,6652,6658,6660,6664,6675,6799,6813,6819,6831,6950,6952,6956,6979,6982,7056,7059,7126,7128,7132,7139,7153,7158,7170,7188,7191,7236,7239,7307,7322,7335,7338,7404,7406,7410,7413,7416,7419,7433,7436,7440,7448,7484,7489,7507,7515,7557,7564,7619,7632,7701,7705,7708,7715,7761,7787,7789,7793,7800,7812,7819,7895,7907,7922,7924,7928,7935,7947,7953,8039,8043,8075,8079,8092,8094,8098,8114,8118,8178,8182,8248,8250,8254,8257,8260,8274,8277,8280,8294,8297,8305,8350,8357,8408,8414,8422,8510,8514,8527,8529,8533,8547,8550,8592,8595,8662,8664,8693,8695,8762,8766,8769,8772,8789,8792],[104,5778,5779],{},[641,5780],{"alt":5781,"src":5782,"style":5783},"ZFS Encrypted Virtual Machines","/images/articles/proxmox-encrypted-vms/Proxmox-ZFS-Encryption.png","display: block; margin: 0 auto; max-width: 400px; width: 100%;",[104,5785,5786],{},[1233,5787,5788],{},"!!! IMPORTANT !!!",[948,5790,5791,5794,5797,5800],{},[951,5792,5793],{},"This assumes a base ZFS setup already exists or you have done that",[951,5795,5796],{},"An existing ZFS dataset CANNOT be encrypted",[951,5798,5799],{},"We would need to create a dataset next to existing ZFS dataset then move over VMs",[951,5801,5802],{},"Before moving, it may say it has low space. It will dynamically re-assign as things move between the datasets, updating free space and usage as long as the pool as a whole fits it.",[1843,5804],{},[99,5806,881],{"id":880},[104,5808,5809],{},"Protecting virtual machines at rest is becoming a mandatory requirement for businesses running sensitive workloads. Proxmox VE makes this easier by supporting native ZFS encryption, allowing you to secure VM disks without relying on full-disk encryption at the host level. When implemented correctly, ZFS encryption ensures that even if the underlying storage is compromised, the data inside your VMs remains protected.",[104,5811,5812],{},"In this guide, we break down the three most common and practical methods for unlocking ZFS-encrypted datasets on Proxmox:",[948,5814,5815,5818,5821],{},[951,5816,5817],{},"Keyfile Unlock",[951,5819,5820],{},"Passphrase Unlock",[951,5822,5823],{},"Remote Key Unlock",[104,5825,5826],{},"Whether you’re running a home lab, managing a client’s infrastructure, or deploying Proxmox as part of a managed hosting offering, enabling ZFS encryption is one of the easiest ways to add strong, modern data protection to your virtualization stack. In the following sections, we’ll walk through each unlocking method step-by-step and outline best practices for operational security, automation, and disaster recovery.",[1843,5828],{},[99,5830,5832],{"id":5831},"zfs-encryption-using-keyfile","ZFS encryption (using keyfile)",[104,5834,5835],{},"Using a keyfile is the easiest and most convenient method for enabling ZFS encryption on Proxmox. With this approach, the system automatically unlocks your encrypted datasets at boot without requiring human input—ideal for datacenters, remote environments, or MSP deployments where uptime and automation matter.",[104,5837,5838],{},"However, keyfile security is critical. The encryption key must be stored outside the encrypted dataset, otherwise the system won’t be able to load it during startup. For best security practice, always store the keyfile on a separate disk or dedicated boot device. This prevents an attacker from simply grabbing a single drive and immediately decrypting your VM storage.",[1200,5840,5842],{"id":5841},"step-1-check-zfs-storage-of-system","Step 1: Check ZFS storage of system",[1949,5844,5845],{},[951,5846,5847],{},"Open Proxmox dashboard, select SA-PVE4 then click on \"Shell\" button",[104,5849,5850],{},[641,5851],{"alt":5852,"src":5853},"Open the Proxmox shell","/images/articles/proxmox-encrypted-vms/proxmox-shell-button.png",[1949,5855,5856],{"start":135},[951,5857,5858,5859],{},"Display information about all ZFS storage pools on system\nShow total storage stats for ",[115,5860,5861],{},"zfs1",[108,5863,5865],{"className":2759,"code":5864,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zpool list\nNAME   SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT\nzfs1  1.73T   133G  1.60T        -         -    42%     7%  1.00x    ONLINE  -\n",[115,5866,5867,5878,5913],{"__ignoreMap":113},[118,5868,5869,5872,5875],{"class":120,"line":121},[118,5870,5871],{"class":128},"root@sa-pve4:~#",[118,5873,5874],{"class":148}," zpool",[118,5876,5877],{"class":148}," list\n",[118,5879,5880,5883,5886,5889,5892,5895,5898,5901,5904,5907,5910],{"class":120,"line":135},[118,5881,5882],{"class":128},"NAME",[118,5884,5885],{"class":148},"   SIZE",[118,5887,5888],{"class":148},"  ALLOC",[118,5890,5891],{"class":148},"   FREE",[118,5893,5894],{"class":148},"  CKPOINT",[118,5896,5897],{"class":148},"  EXPANDSZ",[118,5899,5900],{"class":148},"   FRAG",[118,5902,5903],{"class":148},"    CAP",[118,5905,5906],{"class":148},"  DEDUP",[118,5908,5909],{"class":148},"    HEALTH",[118,5911,5912],{"class":148},"  ALTROOT\n",[118,5914,5915,5917,5920,5923,5926,5929,5932,5935,5938,5941,5944],{"class":120,"line":152},[118,5916,5861],{"class":128},[118,5918,5919],{"class":148},"  1.73T",[118,5921,5922],{"class":148},"   133G",[118,5924,5925],{"class":148},"  1.60T",[118,5927,5928],{"class":148},"        -",[118,5930,5931],{"class":148},"         -",[118,5933,5934],{"class":148},"    42%",[118,5936,5937],{"class":148},"     7%",[118,5939,5940],{"class":148},"  1.00x",[118,5942,5943],{"class":148},"    ONLINE",[118,5945,5946],{"class":148},"  -\n",[1949,5948,5949],{"start":152},[951,5950,5951,5952],{},"Show how each dataset uses space inside ",[115,5953,5861],{},[948,5955,5956,5965],{},[951,5957,5958,5959],{},"Pool\n",[948,5960,5961],{},[951,5962,5963],{},[115,5964,5861],{},[951,5966,5967,5968],{},"Datasets (volumes)\n",[948,5969,5970,5975],{},[951,5971,5972],{},[115,5973,5974],{},"zfs1/vm-605-disk-0",[951,5976,5977],{},[115,5978,5979],{},"zfs1/vm-699-disk-0",[108,5981,5983],{"className":2759,"code":5982,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs list\nNAME                 USED  AVAIL     REFER  MOUNTPOINT\nzfs1                 176G  1.51T       96K  /zfs1\nzfs1/vm-605-disk-0   103G  1.52T     87.8G  -\nzfs1/vm-699-disk-0  72.2G  1.54T     44.2G  -\n",[115,5984,5985,5994,6010,6026,6041],{"__ignoreMap":113},[118,5986,5987,5989,5992],{"class":120,"line":121},[118,5988,5871],{"class":128},[118,5990,5991],{"class":148}," zfs",[118,5993,5877],{"class":148},[118,5995,5996,5998,6001,6004,6007],{"class":120,"line":135},[118,5997,5882],{"class":128},[118,5999,6000],{"class":148},"                 USED",[118,6002,6003],{"class":148},"  AVAIL",[118,6005,6006],{"class":148},"     REFER",[118,6008,6009],{"class":148},"  MOUNTPOINT\n",[118,6011,6012,6014,6017,6020,6023],{"class":120,"line":152},[118,6013,5861],{"class":128},[118,6015,6016],{"class":148},"                 176G",[118,6018,6019],{"class":148},"  1.51T",[118,6021,6022],{"class":148},"       96K",[118,6024,6025],{"class":148},"  /zfs1\n",[118,6027,6028,6030,6033,6036,6039],{"class":120,"line":201},[118,6029,5974],{"class":128},[118,6031,6032],{"class":148},"   103G",[118,6034,6035],{"class":148},"  1.52T",[118,6037,6038],{"class":148},"     87.8G",[118,6040,5946],{"class":148},[118,6042,6043,6045,6048,6051,6054],{"class":120,"line":209},[118,6044,5979],{"class":128},[118,6046,6047],{"class":148},"  72.2G",[118,6049,6050],{"class":148},"  1.54T",[118,6052,6053],{"class":148},"     44.2G",[118,6055,5946],{"class":148},[1353,6057],{},[1200,6059,6061],{"id":6060},"step-2-create-encrypted-zfs-dataset","Step 2: Create encrypted ZFS dataset",[1949,6063,6064,6070],{},[951,6065,6066,6067],{},"Open shell of ",[115,6068,6069],{},"sa-pve4",[951,6071,6072],{},"Create key",[108,6074,6076],{"className":2759,"code":6075,"language":2761,"meta":113,"style":113},"dd if=/dev/urandom of=/root/zfskey.bin bs=32 count=1\nchmod 600 /root/zfskey.bin\nchown root:root /root/zfskey.bin\n",[115,6077,6078,6101,6112],{"__ignoreMap":113},[118,6079,6080,6083,6086,6089,6092,6095,6098],{"class":120,"line":121},[118,6081,6082],{"class":128},"dd",[118,6084,6085],{"class":148}," if=/dev/urandom",[118,6087,6088],{"class":148}," of=/root/zfskey.bin",[118,6090,6091],{"class":148}," bs=",[118,6093,6094],{"class":189},"32",[118,6096,6097],{"class":148}," count=",[118,6099,6100],{"class":189},"1\n",[118,6102,6103,6106,6109],{"class":120,"line":135},[118,6104,6105],{"class":128},"chmod",[118,6107,6108],{"class":189}," 600",[118,6110,6111],{"class":148}," /root/zfskey.bin\n",[118,6113,6114,6117,6120],{"class":120,"line":152},[118,6115,6116],{"class":128},"chown",[118,6118,6119],{"class":148}," root:root",[118,6121,6111],{"class":148},[1949,6123,6124],{"start":152},[951,6125,6126],{},"Create encrypted ZFS dataset",[108,6128,6130],{"className":2759,"code":6129,"language":2761,"meta":113,"style":113},"zfs create \\\\\n  -o encryption=aes-256-gcm \\\\\n  -o keyformat=raw \\\\\n  -o keylocation=file:///root/zfskey.bin \\\\\n  zfs1/encrypted\n",[115,6131,6132,6143,6153,6162,6171],{"__ignoreMap":113},[118,6133,6134,6137,6140],{"class":120,"line":121},[118,6135,6136],{"class":128},"zfs",[118,6138,6139],{"class":148}," create",[118,6141,6142],{"class":189}," \\\\\n",[118,6144,6145,6148,6151],{"class":120,"line":135},[118,6146,6147],{"class":189},"  -o",[118,6149,6150],{"class":148}," encryption=aes-256-gcm",[118,6152,6142],{"class":189},[118,6154,6155,6157,6160],{"class":120,"line":152},[118,6156,6147],{"class":189},[118,6158,6159],{"class":148}," keyformat=raw",[118,6161,6142],{"class":189},[118,6163,6164,6166,6169],{"class":120,"line":201},[118,6165,6147],{"class":189},[118,6167,6168],{"class":148}," keylocation=file:///root/zfskey.bin",[118,6170,6142],{"class":189},[118,6172,6173],{"class":120,"line":209},[118,6174,6175],{"class":148},"  zfs1/encrypted\n",[1949,6177,6178],{"start":201},[951,6179,6180,6181,6184],{},"Confirm ",[115,6182,6183],{},"/zfs1/encrypted"," encrypted ZFS dataset is created",[108,6186,6188],{"className":2759,"code":6187,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs list\nNAME                 USED  AVAIL     REFER  MOUNTPOINT\nzfs1                 176G  1.51T       96K  /zfs1\nzfs1/encrypted       192K  1.51T      192K  /zfs1/encrypted\nzfs1/vm-605-disk-0   103G  1.52T     87.8G  -\nzfs1/vm-699-disk-0  72.2G  1.54T     44.2G  -\n",[115,6189,6190,6198,6210,6222,6238,6250],{"__ignoreMap":113},[118,6191,6192,6194,6196],{"class":120,"line":121},[118,6193,5871],{"class":128},[118,6195,5991],{"class":148},[118,6197,5877],{"class":148},[118,6199,6200,6202,6204,6206,6208],{"class":120,"line":135},[118,6201,5882],{"class":128},[118,6203,6000],{"class":148},[118,6205,6003],{"class":148},[118,6207,6006],{"class":148},[118,6209,6009],{"class":148},[118,6211,6212,6214,6216,6218,6220],{"class":120,"line":152},[118,6213,5861],{"class":128},[118,6215,6016],{"class":148},[118,6217,6019],{"class":148},[118,6219,6022],{"class":148},[118,6221,6025],{"class":148},[118,6223,6224,6227,6230,6232,6235],{"class":120,"line":201},[118,6225,6226],{"class":128},"zfs1/encrypted",[118,6228,6229],{"class":148},"       192K",[118,6231,6019],{"class":148},[118,6233,6234],{"class":148},"      192K",[118,6236,6237],{"class":148},"  /zfs1/encrypted\n",[118,6239,6240,6242,6244,6246,6248],{"class":120,"line":209},[118,6241,5974],{"class":128},[118,6243,6032],{"class":148},[118,6245,6035],{"class":148},[118,6247,6038],{"class":148},[118,6249,5946],{"class":148},[118,6251,6252,6254,6256,6258,6260],{"class":120,"line":215},[118,6253,5979],{"class":128},[118,6255,6047],{"class":148},[118,6257,6050],{"class":148},[118,6259,6053],{"class":148},[118,6261,5946],{"class":148},[1949,6263,6264],{"start":209},[951,6265,6266,6267,6269],{},"Check encryption configuration of ",[115,6268,6226],{}," encrypted ZFS dataset",[104,6271,6272,6273,6276,6277,6280,6281,6283],{},"*** If the ",[115,6274,6275],{},"keystatus"," is ",[115,6278,6279],{},"available",", it means that the ",[115,6282,6226],{}," encrypted ZFS dataset is UNLOCKED ***",[108,6285,6287],{"className":2759,"code":6286,"language":2761,"meta":113,"style":113},"zfs get encryption,keylocation,keyformat,keystatus zfs1/encrypted\n\nNAME            PROPERTY     VALUE                    SOURCE\nzfs1/encrypted  encryption   aes-256-gcm              -\nzfs1/encrypted  keylocation  file:///root/zfskey.bin  local\nzfs1/encrypted  keyformat    raw                      -\nzfs1/encrypted  keystatus    available                -\n",[115,6288,6289,6302,6306,6319,6332,6345,6358],{"__ignoreMap":113},[118,6290,6291,6293,6296,6299],{"class":120,"line":121},[118,6292,6136],{"class":128},[118,6294,6295],{"class":148}," get",[118,6297,6298],{"class":148}," encryption,keylocation,keyformat,keystatus",[118,6300,6301],{"class":148}," zfs1/encrypted\n",[118,6303,6304],{"class":120,"line":135},[118,6305,219],{"emptyLinePlaceholder":218},[118,6307,6308,6310,6313,6316],{"class":120,"line":152},[118,6309,5882],{"class":128},[118,6311,6312],{"class":148},"            PROPERTY",[118,6314,6315],{"class":148},"     VALUE",[118,6317,6318],{"class":148},"                    SOURCE\n",[118,6320,6321,6323,6326,6329],{"class":120,"line":201},[118,6322,6226],{"class":128},[118,6324,6325],{"class":148},"  encryption",[118,6327,6328],{"class":148},"   aes-256-gcm",[118,6330,6331],{"class":148},"              -\n",[118,6333,6334,6336,6339,6342],{"class":120,"line":209},[118,6335,6226],{"class":128},[118,6337,6338],{"class":148},"  keylocation",[118,6340,6341],{"class":148},"  file:///root/zfskey.bin",[118,6343,6344],{"class":148},"  local\n",[118,6346,6347,6349,6352,6355],{"class":120,"line":215},[118,6348,6226],{"class":128},[118,6350,6351],{"class":148},"  keyformat",[118,6353,6354],{"class":148},"    raw",[118,6356,6357],{"class":148},"                      -\n",[118,6359,6360,6362,6365,6368],{"class":120,"line":222},[118,6361,6226],{"class":128},[118,6363,6364],{"class":148},"  keystatus",[118,6366,6367],{"class":148},"    available",[118,6369,6370],{"class":148},"                -\n",[1949,6372,6373],{"start":215},[951,6374,6375],{},"Mount encrypted ZFS dataset",[108,6377,6379],{"className":2759,"code":6378,"language":2761,"meta":113,"style":113},"zfs mount zfs1/encrypted\n",[115,6380,6381],{"__ignoreMap":113},[118,6382,6383,6385,6388],{"class":120,"line":121},[118,6384,6136],{"class":128},[118,6386,6387],{"class":148}," mount",[118,6389,6301],{"class":148},[1353,6391],{},[1200,6393,6395],{"id":6394},"step-3-auto-unlock-encrypted-zfs-dataset","Step 3: Auto-unlock encrypted ZFS dataset",[1949,6397,6398,6402],{},[951,6399,6066,6400],{},[115,6401,6069],{},[951,6403,6404,6405,6408],{},"Create ",[115,6406,6407],{},"zfs-load-key@zfs1-encrypted.service"," file",[108,6410,6412],{"className":2759,"code":6411,"language":2761,"meta":113,"style":113},"touch /etc/systemd/system/zfs-load-key@zfs1-encrypted.service\n",[115,6413,6414],{"__ignoreMap":113},[118,6415,6416,6419],{"class":120,"line":121},[118,6417,6418],{"class":128},"touch",[118,6420,6421],{"class":148}," /etc/systemd/system/zfs-load-key@zfs1-encrypted.service\n",[1949,6423,6424],{"start":152},[951,6425,6426,6427,6429],{},"In ",[115,6428,6407],{}," file, add the following",[108,6431,6433],{"className":2759,"code":6432,"language":2761,"meta":113,"style":113},"[Unit]\nDescription=Unlock ZFS dataset zfs1/encrypted\nBefore=zfs-mount.service\nAfter=zfs-import.target\n\n[Service]\nType=oneshot\nExecStart=/usr/sbin/zfs load-key zfs1/encrypted\n\n[Install]\nWantedBy=zfs-mount.service\n",[115,6434,6435,6440,6458,6468,6478,6482,6487,6496,6511,6515,6520],{"__ignoreMap":113},[118,6436,6437],{"class":120,"line":121},[118,6438,6439],{"class":124},"[Unit]\n",[118,6441,6442,6445,6447,6450,6453,6456],{"class":120,"line":135},[118,6443,6444],{"class":124},"Description",[118,6446,314],{"class":141},[118,6448,6449],{"class":148},"Unlock",[118,6451,6452],{"class":128}," ZFS",[118,6454,6455],{"class":148}," dataset",[118,6457,6301],{"class":148},[118,6459,6460,6463,6465],{"class":120,"line":152},[118,6461,6462],{"class":124},"Before",[118,6464,314],{"class":141},[118,6466,6467],{"class":148},"zfs-mount.service\n",[118,6469,6470,6473,6475],{"class":120,"line":201},[118,6471,6472],{"class":124},"After",[118,6474,314],{"class":141},[118,6476,6477],{"class":148},"zfs-import.target\n",[118,6479,6480],{"class":120,"line":209},[118,6481,219],{"emptyLinePlaceholder":218},[118,6483,6484],{"class":120,"line":215},[118,6485,6486],{"class":124},"[Service]\n",[118,6488,6489,6491,6493],{"class":120,"line":222},[118,6490,1446],{"class":124},[118,6492,314],{"class":141},[118,6494,6495],{"class":148},"oneshot\n",[118,6497,6498,6501,6503,6506,6509],{"class":120,"line":231},[118,6499,6500],{"class":124},"ExecStart",[118,6502,314],{"class":141},[118,6504,6505],{"class":148},"/usr/sbin/zfs",[118,6507,6508],{"class":128}," load-key",[118,6510,6301],{"class":148},[118,6512,6513],{"class":120,"line":239},[118,6514,219],{"emptyLinePlaceholder":218},[118,6516,6517],{"class":120,"line":247},[118,6518,6519],{"class":124},"[Install]\n",[118,6521,6522,6525,6527],{"class":120,"line":255},[118,6523,6524],{"class":124},"WantedBy",[118,6526,314],{"class":141},[118,6528,6467],{"class":148},[1949,6530,6531],{"start":201},[951,6532,6533],{},"Enable the \"auto-unlock\" service at boot",[108,6535,6537],{"className":2759,"code":6536,"language":2761,"meta":113,"style":113},"systemctl enable zfs-load-key@zfs1-encrypted.service\n\nCreated symlink /etc/systemd/system/zfs-mount.service.wants/zfs-load-key@zfs1-encrypted.service → /etc/systemd/system/zfs-load-key@zfs1-encrypted.service.\n",[115,6538,6539,6550,6554],{"__ignoreMap":113},[118,6540,6541,6544,6547],{"class":120,"line":121},[118,6542,6543],{"class":128},"systemctl",[118,6545,6546],{"class":148}," enable",[118,6548,6549],{"class":148}," zfs-load-key@zfs1-encrypted.service\n",[118,6551,6552],{"class":120,"line":135},[118,6553,219],{"emptyLinePlaceholder":218},[118,6555,6556,6559,6562,6565,6568],{"class":120,"line":152},[118,6557,6558],{"class":128},"Created",[118,6560,6561],{"class":148}," symlink",[118,6563,6564],{"class":148}," /etc/systemd/system/zfs-mount.service.wants/zfs-load-key@zfs1-encrypted.service",[118,6566,6567],{"class":148}," →",[118,6569,6570],{"class":148}," /etc/systemd/system/zfs-load-key@zfs1-encrypted.service.\n",[1949,6572,6573],{"start":209},[951,6574,6575],{},"Check \"auto-unlock\" service is enabled",[108,6577,6579],{"className":2759,"code":6578,"language":2761,"meta":113,"style":113},"systemctl is-enabled zfs-load-key@zfs1-encrypted.service\n",[115,6580,6581],{"__ignoreMap":113},[118,6582,6583,6585,6588],{"class":120,"line":121},[118,6584,6543],{"class":128},[118,6586,6587],{"class":148}," is-enabled",[118,6589,6549],{"class":148},[1353,6591],{},[1200,6593,6595],{"id":6594},"step-4-integrate-encrypted-zfs-dataset-in-proxmox","Step 4: Integrate encrypted ZFS dataset in Proxmox",[1949,6597,6598,6605],{},[951,6599,6600,6601],{},"In Proxmox dashboard, click on \"Datacenter\" -> \"Storage\" -> \"Add\" -> \"ZFS\"\n",[641,6602],{"alt":6603,"src":6604},"Add ZFS pool to Promxox","/images/articles/proxmox-encrypted-vms/proxmox-add-zfs-pool.png",[951,6606,6607,6608],{},"Input",[948,6609,6610,6616,6621,6626],{},[951,6611,6612,6613],{},"\"ID\" with ",[115,6614,6615],{},"zfs1-encrypted-pve4",[951,6617,6618,6619],{},"\"ZFS Pool\" with ",[115,6620,6226],{},[951,6622,6623,6624],{},"\"Nodes\" with ",[115,6625,6069],{},[951,6627,6628],{},"\"Thin provision\" with checked",[104,6630,6631,6632,6634],{},"*** Note that if there is no ",[115,6633,6615],{}," for \"ZFS Pool\", please login to PVE dashboard directly to this node ***",[104,6636,6637],{},[641,6638],{"alt":6639,"src":6640},"Add ZFS Pool in Datacenter storage","/images/articles/proxmox-encrypted-vms/add-zfs-pool-to-storage.png",[1949,6642,6643],{"start":152},[951,6644,6645,6646,6648,6649,6651],{},"We can see that there is ",[115,6647,6615],{}," available in ",[115,6650,6069],{}," node",[104,6653,6654],{},[641,6655],{"alt":6656,"src":6657},"View Encrypted Storage Mount in PVE","/images/articles/proxmox-encrypted-vms/view-encrypted-storage-mount.png",[1353,6659],{},[1200,6661,6663],{"id":6662},"step-5-move-vms-disk-to-encrypted-zfs-dataset","Step 5: Move VM's disk to encrypted ZFS dataset",[1949,6665,6666],{},[951,6667,6668,6669,6671,6672],{},"In shell of ",[115,6670,6069],{},", we can see ",[115,6673,6674],{},"zfs1/vm-700-disk-0",[108,6676,6678],{"className":2759,"code":6677,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs list\nNAME                  USED  AVAIL     REFER  MOUNTPOINT\nzfs1                  294G  1.39T       96K  /zfs1\nzfs1/encrypted        192K  1.39T      192K  /zfs1/encrypted\nzfs1/vm-4003-disk-0  33.0G  1.43T       56K  -\nzfs1/vm-4003-disk-1  33.0G  1.43T       56K  -\nzfs1/vm-605-disk-0    103G  1.41T     87.8G  -\nzfs1/vm-699-disk-0   72.2G  1.42T     44.2G  -\nzfs1/vm-700-disk-0   51.6G  1.41T     32.0G  -\n",[115,6679,6680,6688,6701,6715,6728,6744,6757,6771,6785],{"__ignoreMap":113},[118,6681,6682,6684,6686],{"class":120,"line":121},[118,6683,5871],{"class":128},[118,6685,5991],{"class":148},[118,6687,5877],{"class":148},[118,6689,6690,6692,6695,6697,6699],{"class":120,"line":135},[118,6691,5882],{"class":128},[118,6693,6694],{"class":148},"                  USED",[118,6696,6003],{"class":148},[118,6698,6006],{"class":148},[118,6700,6009],{"class":148},[118,6702,6703,6705,6708,6711,6713],{"class":120,"line":152},[118,6704,5861],{"class":128},[118,6706,6707],{"class":148},"                  294G",[118,6709,6710],{"class":148},"  1.39T",[118,6712,6022],{"class":148},[118,6714,6025],{"class":148},[118,6716,6717,6719,6722,6724,6726],{"class":120,"line":201},[118,6718,6226],{"class":128},[118,6720,6721],{"class":148},"        192K",[118,6723,6710],{"class":148},[118,6725,6234],{"class":148},[118,6727,6237],{"class":148},[118,6729,6730,6733,6736,6739,6742],{"class":120,"line":209},[118,6731,6732],{"class":128},"zfs1/vm-4003-disk-0",[118,6734,6735],{"class":148},"  33.0G",[118,6737,6738],{"class":148},"  1.43T",[118,6740,6741],{"class":148},"       56K",[118,6743,5946],{"class":148},[118,6745,6746,6749,6751,6753,6755],{"class":120,"line":215},[118,6747,6748],{"class":128},"zfs1/vm-4003-disk-1",[118,6750,6735],{"class":148},[118,6752,6738],{"class":148},[118,6754,6741],{"class":148},[118,6756,5946],{"class":148},[118,6758,6759,6761,6764,6767,6769],{"class":120,"line":222},[118,6760,5974],{"class":128},[118,6762,6763],{"class":148},"    103G",[118,6765,6766],{"class":148},"  1.41T",[118,6768,6038],{"class":148},[118,6770,5946],{"class":148},[118,6772,6773,6775,6778,6781,6783],{"class":120,"line":231},[118,6774,5979],{"class":128},[118,6776,6777],{"class":148},"   72.2G",[118,6779,6780],{"class":148},"  1.42T",[118,6782,6053],{"class":148},[118,6784,5946],{"class":148},[118,6786,6787,6789,6792,6794,6797],{"class":120,"line":239},[118,6788,6674],{"class":128},[118,6790,6791],{"class":148},"   51.6G",[118,6793,6766],{"class":148},[118,6795,6796],{"class":148},"     32.0G",[118,6798,5946],{"class":148},[1949,6800,6801,6808],{"start":135},[951,6802,6803,6804],{},"In PVE dashboard, select the VM that we would like to move disk to encrypted ZFS pool\n",[641,6805],{"alt":6806,"src":6807},"Move PVE Disk Storage to encrypted volume","/images/articles/proxmox-encrypted-vms/move-disk-storage.png",[951,6809,6810,6811],{},"For \"Target Storage\", select ",[115,6812,6615],{},[104,6814,6815],{},[641,6816],{"alt":6817,"src":6818},"Move PVE Disk Storage to encrypted volume confirmation","/images/articles/proxmox-encrypted-vms/move-disk-confirm-location.png",[1949,6820,6821],{"start":201},[951,6822,6668,6823,6825,6826,3152,6828],{},[115,6824,6069],{},", we can see that the VM 700 disk changes from ",[115,6827,6674],{},[115,6829,6830],{},"zfs1/encrypted/vm-700-disk-0",[108,6832,6834],{"className":2759,"code":6833,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs list\nNAME                           USED  AVAIL     REFER  MOUNTPOINT\nzfs1                           274G  1.41T       96K  /zfs1\nzfs1/encrypted                32.2G  1.41T      192K  /zfs1/encrypted\nzfs1/encrypted/vm-700-disk-0  32.2G  1.41T     32.2G  -\nzfs1/vm-4003-disk-0           33.0G  1.45T       56K  -\nzfs1/vm-4003-disk-1           33.0G  1.45T       56K  -\nzfs1/vm-605-disk-0             103G  1.43T     87.8G  -\nzfs1/vm-699-disk-0            72.2G  1.44T     44.2G  -\n",[115,6835,6836,6844,6857,6870,6883,6897,6911,6923,6936],{"__ignoreMap":113},[118,6837,6838,6840,6842],{"class":120,"line":121},[118,6839,5871],{"class":128},[118,6841,5991],{"class":148},[118,6843,5877],{"class":148},[118,6845,6846,6848,6851,6853,6855],{"class":120,"line":135},[118,6847,5882],{"class":128},[118,6849,6850],{"class":148},"                           USED",[118,6852,6003],{"class":148},[118,6854,6006],{"class":148},[118,6856,6009],{"class":148},[118,6858,6859,6861,6864,6866,6868],{"class":120,"line":152},[118,6860,5861],{"class":128},[118,6862,6863],{"class":148},"                           274G",[118,6865,6766],{"class":148},[118,6867,6022],{"class":148},[118,6869,6025],{"class":148},[118,6871,6872,6874,6877,6879,6881],{"class":120,"line":201},[118,6873,6226],{"class":128},[118,6875,6876],{"class":148},"                32.2G",[118,6878,6766],{"class":148},[118,6880,6234],{"class":148},[118,6882,6237],{"class":148},[118,6884,6885,6887,6890,6892,6895],{"class":120,"line":209},[118,6886,6830],{"class":128},[118,6888,6889],{"class":148},"  32.2G",[118,6891,6766],{"class":148},[118,6893,6894],{"class":148},"     32.2G",[118,6896,5946],{"class":148},[118,6898,6899,6901,6904,6907,6909],{"class":120,"line":215},[118,6900,6732],{"class":128},[118,6902,6903],{"class":148},"           33.0G",[118,6905,6906],{"class":148},"  1.45T",[118,6908,6741],{"class":148},[118,6910,5946],{"class":148},[118,6912,6913,6915,6917,6919,6921],{"class":120,"line":222},[118,6914,6748],{"class":128},[118,6916,6903],{"class":148},[118,6918,6906],{"class":148},[118,6920,6741],{"class":148},[118,6922,5946],{"class":148},[118,6924,6925,6927,6930,6932,6934],{"class":120,"line":231},[118,6926,5974],{"class":128},[118,6928,6929],{"class":148},"             103G",[118,6931,6738],{"class":148},[118,6933,6038],{"class":148},[118,6935,5946],{"class":148},[118,6937,6938,6940,6943,6946,6948],{"class":120,"line":239},[118,6939,5979],{"class":128},[118,6941,6942],{"class":148},"            72.2G",[118,6944,6945],{"class":148},"  1.44T",[118,6947,6053],{"class":148},[118,6949,5946],{"class":148},[1353,6951],{},[1200,6953,6955],{"id":6954},"step-6-reboot-node-for-testing-with-auto-unlock-enabled","Step 6: Reboot node for testing (with auto-unlock enabled)",[1949,6957,6958,6968,6973],{},[951,6959,6960,6961,6963,6964],{},"Reboot ",[115,6962,6069],{}," node\n",[641,6965],{"alt":6966,"src":6967},"Reboot the Proxmox node","/images/articles/proxmox-encrypted-vms/reboot-proxmox-node.png",[951,6969,6970,6971],{},"Once rebooted successfully, click on \"Shell\" button\n",[641,6972],{"alt":5852,"src":5853},[951,6974,6975,6976,6978],{},"Ensure that the ",[115,6977,6226],{}," encrypted ZFS dataset is unlocked and mounted automatically",[104,6980,6981],{},"Mounted successfully",[108,6983,6985],{"className":2759,"code":6984,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# df -h\nFilesystem              Size  Used Avail Use% Mounted on\nzfs1                    1.6T  128K  1.6T   1% /zfs1\nzfs1/encrypted          1.6T  256K  1.6T   1% /zfs1/encrypted\n",[115,6986,6987,6997,7020,7039],{"__ignoreMap":113},[118,6988,6989,6991,6994],{"class":120,"line":121},[118,6990,5871],{"class":128},[118,6992,6993],{"class":148}," df",[118,6995,6996],{"class":189}," -h\n",[118,6998,6999,7002,7005,7008,7011,7014,7017],{"class":120,"line":135},[118,7000,7001],{"class":128},"Filesystem",[118,7003,7004],{"class":148},"              Size",[118,7006,7007],{"class":148},"  Used",[118,7009,7010],{"class":148}," Avail",[118,7012,7013],{"class":148}," Use%",[118,7015,7016],{"class":148}," Mounted",[118,7018,7019],{"class":148}," on\n",[118,7021,7022,7024,7027,7030,7033,7036],{"class":120,"line":152},[118,7023,5861],{"class":128},[118,7025,7026],{"class":148},"                    1.6T",[118,7028,7029],{"class":148},"  128K",[118,7031,7032],{"class":148},"  1.6T",[118,7034,7035],{"class":148},"   1%",[118,7037,7038],{"class":148}," /zfs1\n",[118,7040,7041,7043,7046,7049,7051,7053],{"class":120,"line":201},[118,7042,6226],{"class":128},[118,7044,7045],{"class":148},"          1.6T",[118,7047,7048],{"class":148},"  256K",[118,7050,7032],{"class":148},[118,7052,7035],{"class":148},[118,7054,7055],{"class":148}," /zfs1/encrypted\n",[104,7057,7058],{},"Unlocked successfully",[108,7060,7062],{"className":2759,"code":7061,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs get encryption,keylocation,keyformat,keystatus zfs1/encrypted\nNAME            PROPERTY     VALUE                    SOURCE\nzfs1/encrypted  encryption   aes-256-gcm              -\nzfs1/encrypted  keylocation  file:///root/zfskey.bin  local\nzfs1/encrypted  keyformat    raw                      -\nzfs1/encrypted  keystatus    available                -\n",[115,7063,7064,7076,7086,7096,7106,7116],{"__ignoreMap":113},[118,7065,7066,7068,7070,7072,7074],{"class":120,"line":121},[118,7067,5871],{"class":128},[118,7069,5991],{"class":148},[118,7071,6295],{"class":148},[118,7073,6298],{"class":148},[118,7075,6301],{"class":148},[118,7077,7078,7080,7082,7084],{"class":120,"line":135},[118,7079,5882],{"class":128},[118,7081,6312],{"class":148},[118,7083,6315],{"class":148},[118,7085,6318],{"class":148},[118,7087,7088,7090,7092,7094],{"class":120,"line":152},[118,7089,6226],{"class":128},[118,7091,6325],{"class":148},[118,7093,6328],{"class":148},[118,7095,6331],{"class":148},[118,7097,7098,7100,7102,7104],{"class":120,"line":201},[118,7099,6226],{"class":128},[118,7101,6338],{"class":148},[118,7103,6341],{"class":148},[118,7105,6344],{"class":148},[118,7107,7108,7110,7112,7114],{"class":120,"line":209},[118,7109,6226],{"class":128},[118,7111,6351],{"class":148},[118,7113,6354],{"class":148},[118,7115,6357],{"class":148},[118,7117,7118,7120,7122,7124],{"class":120,"line":215},[118,7119,6226],{"class":128},[118,7121,6364],{"class":148},[118,7123,6367],{"class":148},[118,7125,6370],{"class":148},[1353,7127],{},[1200,7129,7131],{"id":7130},"step-7-reboot-node-for-testing-without-auto-unlock-enabled","Step 7: Reboot node for testing (without auto-unlock enabled)",[1949,7133,7134],{},[951,7135,6668,7136,7138],{},[115,7137,6069],{},", disable the \"auto-unlock\" service at boot",[108,7140,7142],{"className":2759,"code":7141,"language":2761,"meta":113,"style":113},"systemctl disable zfs-load-key@zfs1-encrypted.service\n",[115,7143,7144],{"__ignoreMap":113},[118,7145,7146,7148,7151],{"class":120,"line":121},[118,7147,6543],{"class":128},[118,7149,7150],{"class":148}," disable",[118,7152,6549],{"class":148},[1949,7154,7155],{"start":135},[951,7156,7157],{},"Check \"auto-unlock\" service is disabled",[108,7159,7160],{"className":2759,"code":6578,"language":2761,"meta":113,"style":113},[115,7161,7162],{"__ignoreMap":113},[118,7163,7164,7166,7168],{"class":120,"line":121},[118,7165,6543],{"class":128},[118,7167,6587],{"class":148},[118,7169,6549],{"class":148},[1949,7171,7172,7178,7182],{"start":152},[951,7173,6960,7174,6963,7176],{},[115,7175,6069],{},[641,7177],{"alt":6966,"src":6967},[951,7179,6970,7180],{},[641,7181],{"alt":5852,"src":5853},[951,7183,7184,7185,7187],{},"The ",[115,7186,6226],{}," encrypted ZFS dataset SHOULD NOT BE unlocked or mounted",[104,7189,7190],{},"Mounted unsuccessfully",[108,7192,7194],{"className":2759,"code":7193,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# df -h\nFilesystem            Size  Used Avail Use% Mounted on\nzfs1                  1.6T  128K  1.6T   1% /zfs1\n",[115,7195,7196,7204,7221],{"__ignoreMap":113},[118,7197,7198,7200,7202],{"class":120,"line":121},[118,7199,5871],{"class":128},[118,7201,6993],{"class":148},[118,7203,6996],{"class":189},[118,7205,7206,7208,7211,7213,7215,7217,7219],{"class":120,"line":135},[118,7207,7001],{"class":128},[118,7209,7210],{"class":148},"            Size",[118,7212,7007],{"class":148},[118,7214,7010],{"class":148},[118,7216,7013],{"class":148},[118,7218,7016],{"class":148},[118,7220,7019],{"class":148},[118,7222,7223,7225,7228,7230,7232,7234],{"class":120,"line":152},[118,7224,5861],{"class":128},[118,7226,7227],{"class":148},"                  1.6T",[118,7229,7029],{"class":148},[118,7231,7032],{"class":148},[118,7233,7035],{"class":148},[118,7235,7038],{"class":148},[104,7237,7238],{},"Unlocked unsuccessfully",[108,7240,7242],{"className":2759,"code":7241,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs get encryption,keylocation,keyformat,keystatus zfs1/encrypted\nNAME            PROPERTY     VALUE                    SOURCE\nzfs1/encrypted  encryption   aes-256-gcm              -\nzfs1/encrypted  keylocation  file:///root/zfskey.bin  local\nzfs1/encrypted  keyformat    raw                      -\nzfs1/encrypted  keystatus    unavailable              -\n",[115,7243,7244,7256,7266,7276,7286,7296],{"__ignoreMap":113},[118,7245,7246,7248,7250,7252,7254],{"class":120,"line":121},[118,7247,5871],{"class":128},[118,7249,5991],{"class":148},[118,7251,6295],{"class":148},[118,7253,6298],{"class":148},[118,7255,6301],{"class":148},[118,7257,7258,7260,7262,7264],{"class":120,"line":135},[118,7259,5882],{"class":128},[118,7261,6312],{"class":148},[118,7263,6315],{"class":148},[118,7265,6318],{"class":148},[118,7267,7268,7270,7272,7274],{"class":120,"line":152},[118,7269,6226],{"class":128},[118,7271,6325],{"class":148},[118,7273,6328],{"class":148},[118,7275,6331],{"class":148},[118,7277,7278,7280,7282,7284],{"class":120,"line":201},[118,7279,6226],{"class":128},[118,7281,6338],{"class":148},[118,7283,6341],{"class":148},[118,7285,6344],{"class":148},[118,7287,7288,7290,7292,7294],{"class":120,"line":209},[118,7289,6226],{"class":128},[118,7291,6351],{"class":148},[118,7293,6354],{"class":148},[118,7295,6357],{"class":148},[118,7297,7298,7300,7302,7305],{"class":120,"line":215},[118,7299,6226],{"class":128},[118,7301,6364],{"class":148},[118,7303,7304],{"class":148},"    unavailable",[118,7306,6331],{"class":148},[1949,7308,7309,7319],{"start":215},[951,7310,7311,7312,7314,7315],{},"The VM configured \"Target Storage\" with ",[115,7313,6615],{}," would not be started\n",[641,7316],{"alt":7317,"src":7318},"Error timeout: no zvol device link for vm","/images/articles/proxmox-encrypted-vms/error-no-zvol-device-link-for-vm.png",[951,7320,7321],{},"Manually unlock",[108,7323,7325],{"className":2759,"code":7324,"language":2761,"meta":113,"style":113},"zfs load-key zfs1/encrypted\n",[115,7326,7327],{"__ignoreMap":113},[118,7328,7329,7331,7333],{"class":120,"line":121},[118,7330,6136],{"class":128},[118,7332,6508],{"class":148},[118,7334,6301],{"class":148},[104,7336,7337],{},"Result",[108,7339,7340],{"className":2759,"code":7061,"language":2761,"meta":113,"style":113},[115,7341,7342,7354,7364,7374,7384,7394],{"__ignoreMap":113},[118,7343,7344,7346,7348,7350,7352],{"class":120,"line":121},[118,7345,5871],{"class":128},[118,7347,5991],{"class":148},[118,7349,6295],{"class":148},[118,7351,6298],{"class":148},[118,7353,6301],{"class":148},[118,7355,7356,7358,7360,7362],{"class":120,"line":135},[118,7357,5882],{"class":128},[118,7359,6312],{"class":148},[118,7361,6315],{"class":148},[118,7363,6318],{"class":148},[118,7365,7366,7368,7370,7372],{"class":120,"line":152},[118,7367,6226],{"class":128},[118,7369,6325],{"class":148},[118,7371,6328],{"class":148},[118,7373,6331],{"class":148},[118,7375,7376,7378,7380,7382],{"class":120,"line":201},[118,7377,6226],{"class":128},[118,7379,6338],{"class":148},[118,7381,6341],{"class":148},[118,7383,6344],{"class":148},[118,7385,7386,7388,7390,7392],{"class":120,"line":209},[118,7387,6226],{"class":128},[118,7389,6351],{"class":148},[118,7391,6354],{"class":148},[118,7393,6357],{"class":148},[118,7395,7396,7398,7400,7402],{"class":120,"line":215},[118,7397,6226],{"class":128},[118,7399,6364],{"class":148},[118,7401,6367],{"class":148},[118,7403,6370],{"class":148},[1843,7405],{},[99,7407,7409],{"id":7408},"zfs-encryption-using-remote-key","ZFS encryption (using remote key)",[104,7411,7412],{},"For environments where security and centralized control are top priorities, unlocking ZFS encryption with a remote key provides the strongest and most flexible solution. Instead of storing the key locally, the Proxmox host retrieves it securely from an external system—such as an API endpoint, HashiCorp Vault, a password manager with API access, or a dedicated key management server.",[104,7414,7415],{},"This method ensures the encrypted datasets stay locked by default until the host successfully authenticates against your key server. Even if someone steals the drives and the boot disk, they still cannot decrypt the VM storage without access to the remote key infrastructure.",[104,7417,7418],{},"A typical workflow looks like this:",[1949,7420,7421,7424,7427,7430],{},[951,7422,7423],{},"During boot, a small script (e.g. /etc/zfs/keyfetch.sh) runs before the ZFS import.",[951,7425,7426],{},"The script authenticates to your remote service (via token, certificate, VPN tunnel, or hardware-bound credential).",[951,7428,7429],{},"If the request is authorized, the server sends back the encryption key.",[951,7431,7432],{},"The key is piped directly into zfs load-key without ever touching persistent storage.",[104,7434,7435],{},"This approach is ideal for MSPs, enterprise clients, and secure hosting environments where keys must remain off-host and centrally managed. It also allows you to revoke or rotate keys without touching each Proxmox node—great for long-term operational security.",[1200,7437,7439],{"id":7438},"step-1-create-encrypted-zfs-dataset","Step 1: Create encrypted ZFS dataset",[1949,7441,7442,7446],{},[951,7443,6066,7444],{},[115,7445,6069],{},[951,7447,6072],{},[108,7449,7450],{"className":2759,"code":6075,"language":2761,"meta":113,"style":113},[115,7451,7452,7468,7476],{"__ignoreMap":113},[118,7453,7454,7456,7458,7460,7462,7464,7466],{"class":120,"line":121},[118,7455,6082],{"class":128},[118,7457,6085],{"class":148},[118,7459,6088],{"class":148},[118,7461,6091],{"class":148},[118,7463,6094],{"class":189},[118,7465,6097],{"class":148},[118,7467,6100],{"class":189},[118,7469,7470,7472,7474],{"class":120,"line":135},[118,7471,6105],{"class":128},[118,7473,6108],{"class":189},[118,7475,6111],{"class":148},[118,7477,7478,7480,7482],{"class":120,"line":152},[118,7479,6116],{"class":128},[118,7481,6119],{"class":148},[118,7483,6111],{"class":148},[1949,7485,7486],{"start":152},[951,7487,7488],{},"Encode binary key to base64",[108,7490,7492],{"className":2759,"code":7491,"language":2761,"meta":113,"style":113},"base64 /root/zfskey.bin > /root/zfskey.b64\n",[115,7493,7494],{"__ignoreMap":113},[118,7495,7496,7499,7502,7504],{"class":120,"line":121},[118,7497,7498],{"class":128},"base64",[118,7500,7501],{"class":148}," /root/zfskey.bin",[118,7503,5453],{"class":141},[118,7505,7506],{"class":148}," /root/zfskey.b64\n",[1949,7508,7509],{"start":201},[951,7510,7511,7512],{},"Create encrypted ZFS dataset with ",[115,7513,7514],{},"/root/zfskey.bin",[108,7516,7518],{"className":2759,"code":7517,"language":2761,"meta":113,"style":113},"zfs create \\\\\n  -o encryption=aes-256-gcm \\\\\n  -o keyformat=raw \\\\\n  -o keylocation=file:///root/zfskey.bin \\\\\n  zfs1/encrypted-with-remote-key\n",[115,7519,7520,7528,7536,7544,7552],{"__ignoreMap":113},[118,7521,7522,7524,7526],{"class":120,"line":121},[118,7523,6136],{"class":128},[118,7525,6139],{"class":148},[118,7527,6142],{"class":189},[118,7529,7530,7532,7534],{"class":120,"line":135},[118,7531,6147],{"class":189},[118,7533,6150],{"class":148},[118,7535,6142],{"class":189},[118,7537,7538,7540,7542],{"class":120,"line":152},[118,7539,6147],{"class":189},[118,7541,6159],{"class":148},[118,7543,6142],{"class":189},[118,7545,7546,7548,7550],{"class":120,"line":201},[118,7547,6147],{"class":189},[118,7549,6168],{"class":148},[118,7551,6142],{"class":189},[118,7553,7554],{"class":120,"line":209},[118,7555,7556],{"class":148},"  zfs1/encrypted-with-remote-key\n",[1949,7558,7559],{"start":209},[951,7560,6180,7561,6184],{},[115,7562,7563],{},"/zfs1/encrypted-with-remote-key",[108,7565,7567],{"className":2759,"code":7566,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs list\nNAME                             USED  AVAIL     REFER  MOUNTPOINT\nzfs1                            99.0G  1.58T       96K  /zfs1\nzfs1/encrypted-with-remote-key   192K  1.58T      192K  /zfs1/encrypted-with-remote-key\n",[115,7568,7569,7577,7590,7604],{"__ignoreMap":113},[118,7570,7571,7573,7575],{"class":120,"line":121},[118,7572,5871],{"class":128},[118,7574,5991],{"class":148},[118,7576,5877],{"class":148},[118,7578,7579,7581,7584,7586,7588],{"class":120,"line":135},[118,7580,5882],{"class":128},[118,7582,7583],{"class":148},"                             USED",[118,7585,6003],{"class":148},[118,7587,6006],{"class":148},[118,7589,6009],{"class":148},[118,7591,7592,7594,7597,7600,7602],{"class":120,"line":152},[118,7593,5861],{"class":128},[118,7595,7596],{"class":148},"                            99.0G",[118,7598,7599],{"class":148},"  1.58T",[118,7601,6022],{"class":148},[118,7603,6025],{"class":148},[118,7605,7606,7609,7612,7614,7616],{"class":120,"line":201},[118,7607,7608],{"class":128},"zfs1/encrypted-with-remote-key",[118,7610,7611],{"class":148},"   192K",[118,7613,7599],{"class":148},[118,7615,6234],{"class":148},[118,7617,7618],{"class":148},"  /zfs1/encrypted-with-remote-key\n",[1949,7620,7621],{"start":215},[951,7622,6266,7623,7625,7626,6276,7628,6280,7630,6283],{},[115,7624,7608],{}," encrypted ZFS dataset\n*** If the ",[115,7627,6275],{},[115,7629,6279],{},[115,7631,7608],{},[108,7633,7635],{"className":2759,"code":7634,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs get encryption,keylocation,keyformat,keystatus zfs1/encrypted-with-remote-key\nNAME                            PROPERTY     VALUE                    SOURCE\nzfs1/encrypted-with-remote-key  encryption   aes-256-gcm              -\nzfs1/encrypted-with-remote-key  keylocation  file:///root/zfskey.bin  local\nzfs1/encrypted-with-remote-key  keyformat    raw                      -\nzfs1/encrypted-with-remote-key  keystatus    available                -\n",[115,7636,7637,7650,7661,7671,7681,7691],{"__ignoreMap":113},[118,7638,7639,7641,7643,7645,7647],{"class":120,"line":121},[118,7640,5871],{"class":128},[118,7642,5991],{"class":148},[118,7644,6295],{"class":148},[118,7646,6298],{"class":148},[118,7648,7649],{"class":148}," zfs1/encrypted-with-remote-key\n",[118,7651,7652,7654,7657,7659],{"class":120,"line":135},[118,7653,5882],{"class":128},[118,7655,7656],{"class":148},"                            PROPERTY",[118,7658,6315],{"class":148},[118,7660,6318],{"class":148},[118,7662,7663,7665,7667,7669],{"class":120,"line":152},[118,7664,7608],{"class":128},[118,7666,6325],{"class":148},[118,7668,6328],{"class":148},[118,7670,6331],{"class":148},[118,7672,7673,7675,7677,7679],{"class":120,"line":201},[118,7674,7608],{"class":128},[118,7676,6338],{"class":148},[118,7678,6341],{"class":148},[118,7680,6344],{"class":148},[118,7682,7683,7685,7687,7689],{"class":120,"line":209},[118,7684,7608],{"class":128},[118,7686,6351],{"class":148},[118,7688,6354],{"class":148},[118,7690,6357],{"class":148},[118,7692,7693,7695,7697,7699],{"class":120,"line":215},[118,7694,7608],{"class":128},[118,7696,6364],{"class":148},[118,7698,6367],{"class":148},[118,7700,6370],{"class":148},[1200,7702,7704],{"id":7703},"step-2-setup-remote-key","Step 2: Setup remote key",[104,7706,7707],{},"In our example, we will use a private gist. However, there are many better ways to do this, but this is the easiest for a tutorial.",[104,7709,7710],{},[1407,7711,7712],{},[1233,7713,7714],{},"Remember, if you are encrypting using a remote key, your Proxmox node will require an internet connection before it can decrypt volumes!",[1949,7716,7717,7721,7727,7733,7740,7747,7754,7758],{},[951,7718,6066,7719],{},[115,7720,6069],{},[951,7722,7723,7724],{},"Get the content of ",[115,7725,7726],{},"/root/zfskey.b64",[951,7728,7729,7730],{},"Visit ",[891,7731,7732],{"href":7732},"https://gist.github.com/",[951,7734,7735,7736],{},"Create a gist\n",[641,7737],{"alt":7738,"src":7739},"Create a Github GIST","/images/articles/proxmox-encrypted-vms/create-github-gist.png",[951,7741,7742,7743],{},"Click on \"Raw\" button\n",[641,7744],{"alt":7745,"src":7746},"Create a RAW Github GIST","/images/articles/proxmox-encrypted-vms/github-gist-raw.png",[951,7748,7749,7750],{},"Get the URL\n",[641,7751],{"alt":7752,"src":7753},"Get GIST URL","/images/articles/proxmox-encrypted-vms/github-gist-url.png",[951,7755,6066,7756],{},[115,7757,6069],{},[951,7759,7760],{},"In shell of sa-pve4, ensure that we could get the base64 encoded value with the URL",[108,7762,7764],{"className":2759,"code":7763,"language":2761,"meta":113,"style":113},"curl -X GET \u003CGITHUB_GIST_URL>\n",[115,7765,7766],{"__ignoreMap":113},[118,7767,7768,7771,7774,7777,7779,7782,7785],{"class":120,"line":121},[118,7769,7770],{"class":128},"curl",[118,7772,7773],{"class":189}," -X",[118,7775,7776],{"class":148}," GET",[118,7778,2789],{"class":141},[118,7780,7781],{"class":148},"GITHUB_GIST_UR",[118,7783,7784],{"class":124},"L",[118,7786,414],{"class":141},[1353,7788],{},[1200,7790,7792],{"id":7791},"step-3-create-script-to-fetch-remote-key","Step 3: Create script to fetch remote key",[1949,7794,7795],{},[951,7796,6404,7797],{},[115,7798,7799],{},"unlock_with_remote_key.sh",[108,7801,7803],{"className":2759,"code":7802,"language":2761,"meta":113,"style":113},"touch /root/unlock_with_remote_key.sh\n",[115,7804,7805],{"__ignoreMap":113},[118,7806,7807,7809],{"class":120,"line":121},[118,7808,6418],{"class":128},[118,7810,7811],{"class":148}," /root/unlock_with_remote_key.sh\n",[1949,7813,7814],{"start":135},[951,7815,6426,7816,7818],{},[115,7817,7799],{},", add the following",[108,7820,7822],{"className":2759,"code":7821,"language":2761,"meta":113,"style":113},"#!/bin/bash\n\nURL=\"\u003CGITHUB_GIST_URL>\"\ncurl -s \"$URL\" | tr -d '\\\\n' | base64 --decode > /root/zfskey.bin\nzfs load-key zfs1/encrypted-with-remote-key\nrm /root/zfskey.bin\n",[115,7823,7824,7828,7832,7842,7880,7888],{"__ignoreMap":113},[118,7825,7826],{"class":120,"line":121},[118,7827,2769],{"class":2768},[118,7829,7830],{"class":120,"line":135},[118,7831,219],{"emptyLinePlaceholder":218},[118,7833,7834,7837,7839],{"class":120,"line":152},[118,7835,7836],{"class":124},"URL",[118,7838,314],{"class":141},[118,7840,7841],{"class":148},"\"\u003CGITHUB_GIST_URL>\"\n",[118,7843,7844,7846,7849,7852,7855,7857,7860,7863,7865,7868,7870,7873,7876,7878],{"class":120,"line":201},[118,7845,7770],{"class":128},[118,7847,7848],{"class":189}," -s",[118,7850,7851],{"class":148}," \"",[118,7853,7854],{"class":124},"$URL",[118,7856,2977],{"class":148},[118,7858,7859],{"class":141}," |",[118,7861,7862],{"class":128}," tr",[118,7864,5492],{"class":189},[118,7866,7867],{"class":148}," '\\\\n'",[118,7869,7859],{"class":141},[118,7871,7872],{"class":128}," base64",[118,7874,7875],{"class":189}," --decode",[118,7877,5453],{"class":141},[118,7879,6111],{"class":148},[118,7881,7882,7884,7886],{"class":120,"line":209},[118,7883,6136],{"class":128},[118,7885,6508],{"class":148},[118,7887,7649],{"class":148},[118,7889,7890,7893],{"class":120,"line":215},[118,7891,7892],{"class":128},"rm",[118,7894,6111],{"class":148},[1949,7896,7897],{"start":152},[951,7898,7899,7900,7903,7904,7906],{},"Ensure ",[115,7901,7902],{},"root"," has permission to execute the ",[115,7905,7799],{}," script",[108,7908,7910],{"className":2759,"code":7909,"language":2761,"meta":113,"style":113},"chmod u+x unlock_with_remote_key.sh\n",[115,7911,7912],{"__ignoreMap":113},[118,7913,7914,7916,7919],{"class":120,"line":121},[118,7915,6105],{"class":128},[118,7917,7918],{"class":148}," u+x",[118,7920,7921],{"class":148}," unlock_with_remote_key.sh\n",[1353,7923],{},[1200,7925,7927],{"id":7926},"step-4-auto-unlock-encrypted-zfs-dataset","Step 4: Auto-unlock encrypted ZFS dataset",[1949,7929,7930],{},[951,7931,6404,7932,6408],{},[115,7933,7934],{},"zfs-load-key@zfs1-encrypted-with-remote-key.service",[108,7936,7938],{"className":2759,"code":7937,"language":2761,"meta":113,"style":113},"touch /etc/systemd/system/zfs-load-key@zfs1-encrypted-with-remote-key.service\n",[115,7939,7940],{"__ignoreMap":113},[118,7941,7942,7944],{"class":120,"line":121},[118,7943,6418],{"class":128},[118,7945,7946],{"class":148}," /etc/systemd/system/zfs-load-key@zfs1-encrypted-with-remote-key.service\n",[1949,7948,7949],{"start":135},[951,7950,6426,7951,6429],{},[115,7952,7934],{},[108,7954,7956],{"className":2759,"code":7955,"language":2761,"meta":113,"style":113},"[Unit]\nDescription=Unlock ZFS dataset zfs1/encrypted-with-remote-key\nAfter=zfs-import.target network-online.target\nWants=network-online.target\n\n[Service]\nType=oneshot\nExecStart=/root/unlock_with_remote_key.sh\n\n[Install]\nWantedBy=zfs-mount.service\n",[115,7957,7958,7962,7976,7988,7998,8002,8006,8014,8023,8027,8031],{"__ignoreMap":113},[118,7959,7960],{"class":120,"line":121},[118,7961,6439],{"class":124},[118,7963,7964,7966,7968,7970,7972,7974],{"class":120,"line":135},[118,7965,6444],{"class":124},[118,7967,314],{"class":141},[118,7969,6449],{"class":148},[118,7971,6452],{"class":128},[118,7973,6455],{"class":148},[118,7975,7649],{"class":148},[118,7977,7978,7980,7982,7985],{"class":120,"line":152},[118,7979,6472],{"class":124},[118,7981,314],{"class":141},[118,7983,7984],{"class":148},"zfs-import.target",[118,7986,7987],{"class":128}," network-online.target\n",[118,7989,7990,7993,7995],{"class":120,"line":201},[118,7991,7992],{"class":124},"Wants",[118,7994,314],{"class":141},[118,7996,7997],{"class":148},"network-online.target\n",[118,7999,8000],{"class":120,"line":209},[118,8001,219],{"emptyLinePlaceholder":218},[118,8003,8004],{"class":120,"line":215},[118,8005,6486],{"class":124},[118,8007,8008,8010,8012],{"class":120,"line":222},[118,8009,1446],{"class":124},[118,8011,314],{"class":141},[118,8013,6495],{"class":148},[118,8015,8016,8018,8020],{"class":120,"line":231},[118,8017,6500],{"class":124},[118,8019,314],{"class":141},[118,8021,8022],{"class":148},"/root/unlock_with_remote_key.sh\n",[118,8024,8025],{"class":120,"line":239},[118,8026,219],{"emptyLinePlaceholder":218},[118,8028,8029],{"class":120,"line":247},[118,8030,6519],{"class":124},[118,8032,8033,8035,8037],{"class":120,"line":255},[118,8034,6524],{"class":124},[118,8036,314],{"class":141},[118,8038,6467],{"class":148},[1949,8040,8041],{"start":152},[951,8042,6533],{},[108,8044,8046],{"className":2759,"code":8045,"language":2761,"meta":113,"style":113},"systemctl enable zfs-load-key@zfs1-encrypted-with-remote-key.service\n\nCreated symlink /etc/systemd/system/zfs-mount.service.wants/zfs-load-key@zfs1-encrypted-with-remote-key.service → /etc/systemd/system/zfs-load-key@zfs1-encrypted-with-remote-key.service.\n",[115,8047,8048,8057,8061],{"__ignoreMap":113},[118,8049,8050,8052,8054],{"class":120,"line":121},[118,8051,6543],{"class":128},[118,8053,6546],{"class":148},[118,8055,8056],{"class":148}," zfs-load-key@zfs1-encrypted-with-remote-key.service\n",[118,8058,8059],{"class":120,"line":135},[118,8060,219],{"emptyLinePlaceholder":218},[118,8062,8063,8065,8067,8070,8072],{"class":120,"line":152},[118,8064,6558],{"class":128},[118,8066,6561],{"class":148},[118,8068,8069],{"class":148}," /etc/systemd/system/zfs-mount.service.wants/zfs-load-key@zfs1-encrypted-with-remote-key.service",[118,8071,6567],{"class":148},[118,8073,8074],{"class":148}," /etc/systemd/system/zfs-load-key@zfs1-encrypted-with-remote-key.service.\n",[1949,8076,8077],{"start":201},[951,8078,6575],{},[108,8080,8082],{"className":2759,"code":8081,"language":2761,"meta":113,"style":113},"systemctl is-enabled zfs-load-key@zfs1-encrypted-with-remote-key.service\n",[115,8083,8084],{"__ignoreMap":113},[118,8085,8086,8088,8090],{"class":120,"line":121},[118,8087,6543],{"class":128},[118,8089,6587],{"class":148},[118,8091,8056],{"class":148},[1353,8093],{},[1200,8095,8097],{"id":8096},"step-5-reboot-node-for-testing","Step 5: Reboot node for testing",[1949,8099,8100,8106,8110],{},[951,8101,6960,8102,6963,8104],{},[115,8103,6069],{},[641,8105],{"alt":6966,"src":6967},[951,8107,6970,8108],{},[641,8109],{"alt":5852,"src":5853},[951,8111,6975,8112,6978],{},[115,8113,7608],{},[948,8115,8116],{},[951,8117,6981],{},[108,8119,8121],{"className":2759,"code":8120,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# df -h\nFilesystem                      Size  Used Avail Use% Mounted on\nzfs1                            1.6T  128K  1.6T   1% /zfs1\nzfs1/encrypted-with-remote-key  1.6T  256K  1.6T   1% /zfs1/encrypted-with-remote-key\n",[115,8122,8123,8131,8148,8163],{"__ignoreMap":113},[118,8124,8125,8127,8129],{"class":120,"line":121},[118,8126,5871],{"class":128},[118,8128,6993],{"class":148},[118,8130,6996],{"class":189},[118,8132,8133,8135,8138,8140,8142,8144,8146],{"class":120,"line":135},[118,8134,7001],{"class":128},[118,8136,8137],{"class":148},"                      Size",[118,8139,7007],{"class":148},[118,8141,7010],{"class":148},[118,8143,7013],{"class":148},[118,8145,7016],{"class":148},[118,8147,7019],{"class":148},[118,8149,8150,8152,8155,8157,8159,8161],{"class":120,"line":152},[118,8151,5861],{"class":128},[118,8153,8154],{"class":148},"                            1.6T",[118,8156,7029],{"class":148},[118,8158,7032],{"class":148},[118,8160,7035],{"class":148},[118,8162,7038],{"class":148},[118,8164,8165,8167,8169,8171,8173,8175],{"class":120,"line":201},[118,8166,7608],{"class":128},[118,8168,7032],{"class":148},[118,8170,7048],{"class":148},[118,8172,7032],{"class":148},[118,8174,7035],{"class":148},[118,8176,8177],{"class":148}," /zfs1/encrypted-with-remote-key\n",[948,8179,8180],{},[951,8181,7058],{},[108,8183,8184],{"className":2759,"code":7634,"language":2761,"meta":113,"style":113},[115,8185,8186,8198,8208,8218,8228,8238],{"__ignoreMap":113},[118,8187,8188,8190,8192,8194,8196],{"class":120,"line":121},[118,8189,5871],{"class":128},[118,8191,5991],{"class":148},[118,8193,6295],{"class":148},[118,8195,6298],{"class":148},[118,8197,7649],{"class":148},[118,8199,8200,8202,8204,8206],{"class":120,"line":135},[118,8201,5882],{"class":128},[118,8203,7656],{"class":148},[118,8205,6315],{"class":148},[118,8207,6318],{"class":148},[118,8209,8210,8212,8214,8216],{"class":120,"line":152},[118,8211,7608],{"class":128},[118,8213,6325],{"class":148},[118,8215,6328],{"class":148},[118,8217,6331],{"class":148},[118,8219,8220,8222,8224,8226],{"class":120,"line":201},[118,8221,7608],{"class":128},[118,8223,6338],{"class":148},[118,8225,6341],{"class":148},[118,8227,6344],{"class":148},[118,8229,8230,8232,8234,8236],{"class":120,"line":209},[118,8231,7608],{"class":128},[118,8233,6351],{"class":148},[118,8235,6354],{"class":148},[118,8237,6357],{"class":148},[118,8239,8240,8242,8244,8246],{"class":120,"line":215},[118,8241,7608],{"class":128},[118,8243,6364],{"class":148},[118,8245,6367],{"class":148},[118,8247,6370],{"class":148},[1843,8249],{},[99,8251,8253],{"id":8252},"zfs-encryption-using-manual-passphrase","ZFS encryption (using manual passphrase)",[104,8255,8256],{},"Unlocking ZFS encryption with a manual passphrase is the simplest and most secure method from a cryptographic standpoint. Instead of storing keys locally or retrieving them from a remote system, the dataset is unlocked only when an administrator physically (or through console access) enters the passphrase during boot.",[104,8258,8259],{},"With this method, your encrypted VM storage remains fully protected until a human enters the correct passphrase. This makes it ideal for:",[948,8261,8262,8265,8268,8271],{},[951,8263,8264],{},"Standalone hosts",[951,8266,8267],{},"High-security on-premises deployments",[951,8269,8270],{},"Environments where physical or out-of-band console access is available",[951,8272,8273],{},"Situations where you want to guarantee no automatic decryption",[104,8275,8276],{},"Because no keyfiles or remote systems are involved, the security boundary is extremely tight: even if someone steals all storage devices and the boot drive, the data remains inaccessible without the passphrase.",[104,8278,8279],{},"Typical workflow:",[1949,8281,8282,8285,8288,8291],{},[951,8283,8284],{},"System boots and reaches the point where encrypted ZFS datasets need to be imported.",[951,8286,8287],{},"The system waits for user input and prompts for the passphrase.",[951,8289,8290],{},"Once entered, ZFS unlocks the dataset and the VM storage becomes available.",[951,8292,8293],{},"This method provides maximum data confidentiality, but it does require human action during every reboot—so it’s best suited for hosts where reboots are rare or where operational workflows already include console access at boot time.",[1200,8295,7439],{"id":8296},"step-1-create-encrypted-zfs-dataset-1",[1949,8298,8299,8303],{},[951,8300,6066,8301],{},[115,8302,6069],{},[951,8304,6126],{},[108,8306,8308],{"className":2759,"code":8307,"language":2761,"meta":113,"style":113},"zfs create \\\n  -o encryption=aes-256-gcm \\\n  -o keyformat=passphrase \\\n  -o keylocation=prompt \\\n  zfs1/encrypted-with-passphrase\n",[115,8309,8310,8319,8327,8336,8345],{"__ignoreMap":113},[118,8311,8312,8314,8316],{"class":120,"line":121},[118,8313,6136],{"class":128},[118,8315,6139],{"class":148},[118,8317,8318],{"class":189}," \\\n",[118,8320,8321,8323,8325],{"class":120,"line":135},[118,8322,6147],{"class":189},[118,8324,6150],{"class":148},[118,8326,8318],{"class":189},[118,8328,8329,8331,8334],{"class":120,"line":152},[118,8330,6147],{"class":189},[118,8332,8333],{"class":148}," keyformat=passphrase",[118,8335,8318],{"class":189},[118,8337,8338,8340,8343],{"class":120,"line":201},[118,8339,6147],{"class":189},[118,8341,8342],{"class":148}," keylocation=prompt",[118,8344,8318],{"class":189},[118,8346,8347],{"class":120,"line":209},[118,8348,8349],{"class":148},"  zfs1/encrypted-with-passphrase\n",[1949,8351,8352],{"start":152},[951,8353,6180,8354,6184],{},[115,8355,8356],{},"/zfs1/encrypted-with-passphrase",[108,8358,8360],{"className":2759,"code":8359,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs list\nNAME                             USED  AVAIL     REFER  MOUNTPOINT\nzfs1                            99.0G  1.58T       96K  /zfs1\nzfs1/encrypted-with-passphrase   192K  1.58T      192K  /zfs1/encrypted-with-passphrase\n",[115,8361,8362,8370,8382,8394],{"__ignoreMap":113},[118,8363,8364,8366,8368],{"class":120,"line":121},[118,8365,5871],{"class":128},[118,8367,5991],{"class":148},[118,8369,5877],{"class":148},[118,8371,8372,8374,8376,8378,8380],{"class":120,"line":135},[118,8373,5882],{"class":128},[118,8375,7583],{"class":148},[118,8377,6003],{"class":148},[118,8379,6006],{"class":148},[118,8381,6009],{"class":148},[118,8383,8384,8386,8388,8390,8392],{"class":120,"line":152},[118,8385,5861],{"class":128},[118,8387,7596],{"class":148},[118,8389,7599],{"class":148},[118,8391,6022],{"class":148},[118,8393,6025],{"class":148},[118,8395,8396,8399,8401,8403,8405],{"class":120,"line":201},[118,8397,8398],{"class":128},"zfs1/encrypted-with-passphrase",[118,8400,7611],{"class":148},[118,8402,7599],{"class":148},[118,8404,6234],{"class":148},[118,8406,8407],{"class":148},"  /zfs1/encrypted-with-passphrase\n",[1949,8409,8410],{"start":201},[951,8411,6266,8412,6269],{},[115,8413,8398],{},[104,8415,6272,8416,6276,8418,6280,8420,6283],{},[115,8417,6275],{},[115,8419,6279],{},[115,8421,8398],{},[108,8423,8425],{"className":2759,"code":8424,"language":2761,"meta":113,"style":113},"zfs get encryption,keylocation,keyformat,keystatus zfs1/encrypted-with-passphrase\n\nroot@sa-pve4:~# zfs get encryption,keylocation,keyformat,keystatus zfs1/encrypted-with-passphrase\nNAME                            PROPERTY     VALUE        SOURCE\nzfs1/encrypted-with-passphrase  encryption   aes-256-gcm  -\nzfs1/encrypted-with-passphrase  keylocation  prompt       local\nzfs1/encrypted-with-passphrase  keyformat    passphrase   -\nzfs1/encrypted-with-passphrase  keystatus    available    -\n\n",[115,8426,8427,8438,8442,8454,8465,8475,8487,8499],{"__ignoreMap":113},[118,8428,8429,8431,8433,8435],{"class":120,"line":121},[118,8430,6136],{"class":128},[118,8432,6295],{"class":148},[118,8434,6298],{"class":148},[118,8436,8437],{"class":148}," zfs1/encrypted-with-passphrase\n",[118,8439,8440],{"class":120,"line":135},[118,8441,219],{"emptyLinePlaceholder":218},[118,8443,8444,8446,8448,8450,8452],{"class":120,"line":152},[118,8445,5871],{"class":128},[118,8447,5991],{"class":148},[118,8449,6295],{"class":148},[118,8451,6298],{"class":148},[118,8453,8437],{"class":148},[118,8455,8456,8458,8460,8462],{"class":120,"line":201},[118,8457,5882],{"class":128},[118,8459,7656],{"class":148},[118,8461,6315],{"class":148},[118,8463,8464],{"class":148},"        SOURCE\n",[118,8466,8467,8469,8471,8473],{"class":120,"line":209},[118,8468,8398],{"class":128},[118,8470,6325],{"class":148},[118,8472,6328],{"class":148},[118,8474,5946],{"class":148},[118,8476,8477,8479,8481,8484],{"class":120,"line":215},[118,8478,8398],{"class":128},[118,8480,6338],{"class":148},[118,8482,8483],{"class":148},"  prompt",[118,8485,8486],{"class":148},"       local\n",[118,8488,8489,8491,8493,8496],{"class":120,"line":222},[118,8490,8398],{"class":128},[118,8492,6351],{"class":148},[118,8494,8495],{"class":148},"    passphrase",[118,8497,8498],{"class":148},"   -\n",[118,8500,8501,8503,8505,8507],{"class":120,"line":231},[118,8502,8398],{"class":128},[118,8504,6364],{"class":148},[118,8506,6367],{"class":148},[118,8508,8509],{"class":148},"    -\n",[1949,8511,8512],{"start":209},[951,8513,6375],{},[108,8515,8517],{"className":2759,"code":8516,"language":2761,"meta":113,"style":113},"zfs mount zfs1/encrypted-with-passphrase\n",[115,8518,8519],{"__ignoreMap":113},[118,8520,8521,8523,8525],{"class":120,"line":121},[118,8522,6136],{"class":128},[118,8524,6387],{"class":148},[118,8526,8437],{"class":148},[1353,8528],{},[1200,8530,8532],{"id":8531},"step-2-reboot-node-for-testing","Step 2: Reboot node for testing",[1949,8534,8535,8540,8544],{},[951,8536,8537,8538],{},"Reboot the Proxmox node\n",[641,8539],{"alt":6966,"src":6967},[951,8541,6970,8542],{},[641,8543],{"alt":5852,"src":5853},[951,8545,8546],{},"Ensure that the zfs1/encrypted-with-passphrase encrypted ZFS dataset is locked and not mounted by default",[104,8548,8549],{},"Not mounted by default",[108,8551,8552],{"className":2759,"code":7193,"language":2761,"meta":113,"style":113},[115,8553,8554,8562,8578],{"__ignoreMap":113},[118,8555,8556,8558,8560],{"class":120,"line":121},[118,8557,5871],{"class":128},[118,8559,6993],{"class":148},[118,8561,6996],{"class":189},[118,8563,8564,8566,8568,8570,8572,8574,8576],{"class":120,"line":135},[118,8565,7001],{"class":128},[118,8567,7210],{"class":148},[118,8569,7007],{"class":148},[118,8571,7010],{"class":148},[118,8573,7013],{"class":148},[118,8575,7016],{"class":148},[118,8577,7019],{"class":148},[118,8579,8580,8582,8584,8586,8588,8590],{"class":120,"line":152},[118,8581,5861],{"class":128},[118,8583,7227],{"class":148},[118,8585,7029],{"class":148},[118,8587,7032],{"class":148},[118,8589,7035],{"class":148},[118,8591,7038],{"class":148},[104,8593,8594],{},"Locked by default",[108,8596,8598],{"className":2759,"code":8597,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs get encryption,keylocation,keyformat,keystatus zfs1/encrypted-with-passphrase\nNAME                            PROPERTY     VALUE        SOURCE\nzfs1/encrypted-with-passphrase  encryption   aes-256-gcm  -\nzfs1/encrypted-with-passphrase  keylocation  prompt       local\nzfs1/encrypted-with-passphrase  keyformat    passphrase   -\nzfs1/encrypted-with-passphrase  keystatus    unavailable  -\n",[115,8599,8600,8612,8622,8632,8642,8652],{"__ignoreMap":113},[118,8601,8602,8604,8606,8608,8610],{"class":120,"line":121},[118,8603,5871],{"class":128},[118,8605,5991],{"class":148},[118,8607,6295],{"class":148},[118,8609,6298],{"class":148},[118,8611,8437],{"class":148},[118,8613,8614,8616,8618,8620],{"class":120,"line":135},[118,8615,5882],{"class":128},[118,8617,7656],{"class":148},[118,8619,6315],{"class":148},[118,8621,8464],{"class":148},[118,8623,8624,8626,8628,8630],{"class":120,"line":152},[118,8625,8398],{"class":128},[118,8627,6325],{"class":148},[118,8629,6328],{"class":148},[118,8631,5946],{"class":148},[118,8633,8634,8636,8638,8640],{"class":120,"line":201},[118,8635,8398],{"class":128},[118,8637,6338],{"class":148},[118,8639,8483],{"class":148},[118,8641,8486],{"class":148},[118,8643,8644,8646,8648,8650],{"class":120,"line":209},[118,8645,8398],{"class":128},[118,8647,6351],{"class":148},[118,8649,8495],{"class":148},[118,8651,8498],{"class":148},[118,8653,8654,8656,8658,8660],{"class":120,"line":215},[118,8655,8398],{"class":128},[118,8657,6364],{"class":148},[118,8659,7304],{"class":148},[118,8661,5946],{"class":148},[104,8663,7321],{},[108,8665,8667],{"className":2759,"code":8666,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs load-key zfs1/encrypted-with-passphrase\nEnter passphrase for 'zfs1/encrypted-with-passphrase':\n",[115,8668,8669,8679],{"__ignoreMap":113},[118,8670,8671,8673,8675,8677],{"class":120,"line":121},[118,8672,5871],{"class":128},[118,8674,5991],{"class":148},[118,8676,6508],{"class":148},[118,8678,8437],{"class":148},[118,8680,8681,8684,8687,8690],{"class":120,"line":135},[118,8682,8683],{"class":128},"Enter",[118,8685,8686],{"class":148}," passphrase",[118,8688,8689],{"class":148}," for",[118,8691,8692],{"class":148}," 'zfs1/encrypted-with-passphrase':\n",[104,8694,7337],{},[108,8696,8698],{"className":2759,"code":8697,"language":2761,"meta":113,"style":113},"root@sa-pve4:~# zfs get encryption,keylocation,keyformat,keystatus zfs1/encrypted-with-passphrase\nNAME                            PROPERTY     VALUE        SOURCE\nzfs1/encrypted-with-passphrase  encryption   aes-256-gcm  -\nzfs1/encrypted-with-passphrase  keylocation  prompt       local\nzfs1/encrypted-with-passphrase  keyformat    passphrase   -\nzfs1/encrypted-with-passphrase  keystatus    available    -\n",[115,8699,8700,8712,8722,8732,8742,8752],{"__ignoreMap":113},[118,8701,8702,8704,8706,8708,8710],{"class":120,"line":121},[118,8703,5871],{"class":128},[118,8705,5991],{"class":148},[118,8707,6295],{"class":148},[118,8709,6298],{"class":148},[118,8711,8437],{"class":148},[118,8713,8714,8716,8718,8720],{"class":120,"line":135},[118,8715,5882],{"class":128},[118,8717,7656],{"class":148},[118,8719,6315],{"class":148},[118,8721,8464],{"class":148},[118,8723,8724,8726,8728,8730],{"class":120,"line":152},[118,8725,8398],{"class":128},[118,8727,6325],{"class":148},[118,8729,6328],{"class":148},[118,8731,5946],{"class":148},[118,8733,8734,8736,8738,8740],{"class":120,"line":201},[118,8735,8398],{"class":128},[118,8737,6338],{"class":148},[118,8739,8483],{"class":148},[118,8741,8486],{"class":148},[118,8743,8744,8746,8748,8750],{"class":120,"line":209},[118,8745,8398],{"class":128},[118,8747,6351],{"class":148},[118,8749,8495],{"class":148},[118,8751,8498],{"class":148},[118,8753,8754,8756,8758,8760],{"class":120,"line":215},[118,8755,8398],{"class":128},[118,8757,6364],{"class":148},[118,8759,6367],{"class":148},[118,8761,8509],{"class":148},[99,8763,8765],{"id":8764},"need-help-with-proxmox-or-secure-virtualization","Need Help With Proxmox or Secure Virtualization?",[104,8767,8768],{},"If you want Proxmox ZFS encryption set up correctly—or you need help designing a secure, high-availability virtualisation environment—we can do it for you.",[104,8770,8771],{},"Whether it’s configuring encrypted VM storage, hardening your hypervisor, setting up automated backups, or managing your entire Proxmox infrastructure, our team can assist with:",[948,8773,8774,8777,8780,8783,8786],{},[951,8775,8776],{},"Proxmox installation, upgrades, and migrations",[951,8778,8779],{},"ZFS encrypted storage design (keyfile, passphrase, or remote key)",[951,8781,8782],{},"Firewalling, VPNs, and secure remote access",[951,8784,8785],{},"Backup and disaster recovery planning",[951,8787,8788],{},"Performance tuning and ongoing maintenance",[104,8790,8791],{},"If you’d like this implemented in your environment—or you need reliable Proxmox support—get in touch and we’ll be happy to help.",[613,8793,8794],{},"html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}",{"title":113,"searchDepth":135,"depth":135,"links":8796},[8797,8798,8807,8814,8818],{"id":880,"depth":135,"text":881},{"id":5831,"depth":135,"text":5832,"children":8799},[8800,8801,8802,8803,8804,8805,8806],{"id":5841,"depth":152,"text":5842},{"id":6060,"depth":152,"text":6061},{"id":6394,"depth":152,"text":6395},{"id":6594,"depth":152,"text":6595},{"id":6662,"depth":152,"text":6663},{"id":6954,"depth":152,"text":6955},{"id":7130,"depth":152,"text":7131},{"id":7408,"depth":135,"text":7409,"children":8808},[8809,8810,8811,8812,8813],{"id":7438,"depth":152,"text":7439},{"id":7703,"depth":152,"text":7704},{"id":7791,"depth":152,"text":7792},{"id":7926,"depth":152,"text":7927},{"id":8096,"depth":152,"text":8097},{"id":8252,"depth":135,"text":8253,"children":8815},[8816,8817],{"id":8296,"depth":152,"text":7439},{"id":8531,"depth":152,"text":8532},{"id":8764,"depth":135,"text":8765},[56],"How to encrypt Proxmox VM disks at rest with native ZFS encryption, using a keyfile with auto-unlock or a remote key, then move VMs onto the new dataset.",{"slug":63,"isHowTo":218},"2025-11-18T17:00:00.000Z",{"title":61,"description":8820},[8825,8826],"encryption","infrastructure","o0tmD7M6RnWdfbZaAjrjZtlvnZoIT6gr2C5JOHYxvgM",{"id":8829,"title":65,"body":8830,"categories":9750,"description":9751,"extension":624,"meta":9752,"navigation":218,"ogImage":627,"path":66,"publish_at":9753,"seo":9754,"stem":67,"tags":9755,"__hash__":9758},"library/library/proxmox/proxmox-monitoring-with-grafana.md",{"type":96,"value":8831,"toc":9737},[8832,8838,8845,9057,9064,9090,9094,9101,9127,9130,9139,9142,9191,9195,9202,9205,9208,9213,9220,9275,9281,9351,9354,9363,9373,9382,9386,9389,9398,9401,9421,9425,9432,9590,9593,9597,9620,9627,9630,9639,9648,9673,9682,9690,9694,9699,9702,9706,9715,9719,9734],[104,8833,8834],{},[641,8835],{"alt":8836,"src":8837,"style":645},"Sample Grafana Dashboard","/images/articles/grafana-dashboard.png",[104,8839,8840,8841,8844],{},"The following is a guide on how to add Proxmox metrics to a Grafana dashboard. This assumes you have already got a Grafana and Prometheus setup already established. If you don’t, a simple experimental environment can be created using the following ",[115,8842,8843],{},"docker-compose.yml"," .",[108,8846,8850],{"className":8847,"code":8848,"language":8849,"meta":113,"style":113},"language-yaml shiki shiki-themes github-dark","services:\n  prometheus:\n    image: prom/prometheus:latest\n    container_name: prometheus\n    ports:\n      - \"9090:9090\"\n    volumes:\n      - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro\n      - prometheus_data:/prometheus\n    restart: unless-stopped\n\n  grafana:\n    image: grafana/grafana:latest\n    container_name: grafana\n    ports:\n      - \"3000:3000\"\n    environment:\n      - GF_SECURITY_ADMIN_USER=admin\n      - GF_SECURITY_ADMIN_PASSWORD=admin\n    volumes:\n      - grafana_data:/var/lib/grafana\n    depends_on:\n      - prometheus\n    restart: unless-stopped\n\nvolumes:\n  prometheus_data:\n  grafana_data:\n  \n","yaml",[115,8851,8852,8861,8868,8879,8889,8896,8904,8911,8918,8925,8935,8939,8946,8955,8964,8970,8977,8984,8991,8998,9004,9011,9018,9024,9032,9036,9043,9050],{"__ignoreMap":113},[118,8853,8854,8858],{"class":120,"line":121},[118,8855,8857],{"class":8856},"s4JwU","services",[118,8859,8860],{"class":124},":\n",[118,8862,8863,8866],{"class":120,"line":135},[118,8864,8865],{"class":8856},"  prometheus",[118,8867,8860],{"class":124},[118,8869,8870,8873,8876],{"class":120,"line":152},[118,8871,8872],{"class":8856},"    image",[118,8874,8875],{"class":124},": ",[118,8877,8878],{"class":148},"prom/prometheus:latest\n",[118,8880,8881,8884,8886],{"class":120,"line":201},[118,8882,8883],{"class":8856},"    container_name",[118,8885,8875],{"class":124},[118,8887,8888],{"class":148},"prometheus\n",[118,8890,8891,8894],{"class":120,"line":209},[118,8892,8893],{"class":8856},"    ports",[118,8895,8860],{"class":124},[118,8897,8898,8901],{"class":120,"line":215},[118,8899,8900],{"class":124},"      - ",[118,8902,8903],{"class":148},"\"9090:9090\"\n",[118,8905,8906,8909],{"class":120,"line":222},[118,8907,8908],{"class":8856},"    volumes",[118,8910,8860],{"class":124},[118,8912,8913,8915],{"class":120,"line":231},[118,8914,8900],{"class":124},[118,8916,8917],{"class":148},"./prometheus.yml:/etc/prometheus/prometheus.yml:ro\n",[118,8919,8920,8922],{"class":120,"line":239},[118,8921,8900],{"class":124},[118,8923,8924],{"class":148},"prometheus_data:/prometheus\n",[118,8926,8927,8930,8932],{"class":120,"line":247},[118,8928,8929],{"class":8856},"    restart",[118,8931,8875],{"class":124},[118,8933,8934],{"class":148},"unless-stopped\n",[118,8936,8937],{"class":120,"line":255},[118,8938,219],{"emptyLinePlaceholder":218},[118,8940,8941,8944],{"class":120,"line":263},[118,8942,8943],{"class":8856},"  grafana",[118,8945,8860],{"class":124},[118,8947,8948,8950,8952],{"class":120,"line":271},[118,8949,8872],{"class":8856},[118,8951,8875],{"class":124},[118,8953,8954],{"class":148},"grafana/grafana:latest\n",[118,8956,8957,8959,8961],{"class":120,"line":279},[118,8958,8883],{"class":8856},[118,8960,8875],{"class":124},[118,8962,8963],{"class":148},"grafana\n",[118,8965,8966,8968],{"class":120,"line":568},[118,8967,8893],{"class":8856},[118,8969,8860],{"class":124},[118,8971,8972,8974],{"class":120,"line":579},[118,8973,8900],{"class":124},[118,8975,8976],{"class":148},"\"3000:3000\"\n",[118,8978,8979,8982],{"class":120,"line":589},[118,8980,8981],{"class":8856},"    environment",[118,8983,8860],{"class":124},[118,8985,8986,8988],{"class":120,"line":597},[118,8987,8900],{"class":124},[118,8989,8990],{"class":148},"GF_SECURITY_ADMIN_USER=admin\n",[118,8992,8993,8995],{"class":120,"line":4478},[118,8994,8900],{"class":124},[118,8996,8997],{"class":148},"GF_SECURITY_ADMIN_PASSWORD=admin\n",[118,8999,9000,9002],{"class":120,"line":4490},[118,9001,8908],{"class":8856},[118,9003,8860],{"class":124},[118,9005,9006,9008],{"class":120,"line":4502},[118,9007,8900],{"class":124},[118,9009,9010],{"class":148},"grafana_data:/var/lib/grafana\n",[118,9012,9013,9016],{"class":120,"line":4514},[118,9014,9015],{"class":8856},"    depends_on",[118,9017,8860],{"class":124},[118,9019,9020,9022],{"class":120,"line":4528},[118,9021,8900],{"class":124},[118,9023,8888],{"class":148},[118,9025,9026,9028,9030],{"class":120,"line":4540},[118,9027,8929],{"class":8856},[118,9029,8875],{"class":124},[118,9031,8934],{"class":148},[118,9033,9034],{"class":120,"line":4564},[118,9035,219],{"emptyLinePlaceholder":218},[118,9037,9038,9041],{"class":120,"line":4576},[118,9039,9040],{"class":8856},"volumes",[118,9042,8860],{"class":124},[118,9044,9045,9048],{"class":120,"line":4597},[118,9046,9047],{"class":8856},"  prometheus_data",[118,9049,8860],{"class":124},[118,9051,9052,9055],{"class":120,"line":4610},[118,9053,9054],{"class":8856},"  grafana_data",[118,9056,8860],{"class":124},[104,9058,9059,9060,9063],{},"Once you run ",[115,9061,9062],{},"docker compose up -d",", you’ll have:",[948,9065,9066,9075],{},[951,9067,9068,9071,9072],{},[1233,9069,9070],{},"Prometheus"," on ",[891,9073,9074],{"href":9074},"http://localhost:9090",[951,9076,9077,9071,9080,9083,9085,9086,9089],{},[1233,9078,9079],{},"Grafana",[891,9081,9082],{"href":9082},"http://localhost:3000",[1353,9084],{},"(login with ",[115,9087,9088],{},"admin / admin"," and connect Prometheus as a data source)",[99,9091,9093],{"id":9092},"create-user-on-the-proxmox-server","Create user on the Proxmox server",[104,9095,9096,9097,9100],{},"This user is used by the ",[115,9098,9099],{},"promox-pve-exporter"," to be able to connect to the Proxmox API and retrieve the servers metrics.",[108,9102,9106],{"className":9103,"code":9104,"language":9105,"meta":113,"style":113},"language-xml shiki shiki-themes github-dark","pveum user add prometheus@pve\n\n# Grant read-only permissions\npveum acl modify / --user prometheus@pve --role PVEAuditor\n","xml",[115,9107,9108,9113,9117,9122],{"__ignoreMap":113},[118,9109,9110],{"class":120,"line":121},[118,9111,9112],{"class":124},"pveum user add prometheus@pve\n",[118,9114,9115],{"class":120,"line":135},[118,9116,219],{"emptyLinePlaceholder":218},[118,9118,9119],{"class":120,"line":152},[118,9120,9121],{"class":124},"# Grant read-only permissions\n",[118,9123,9124],{"class":120,"line":201},[118,9125,9126],{"class":124},"pveum acl modify / --user prometheus@pve --role PVEAuditor\n",[104,9128,9129],{},"Generate an API token for the user and save it for later",[108,9131,9133],{"className":9103,"code":9132,"language":9105,"meta":113,"style":113},"pveum user token add prometheus@pve pve-exporter-token --comment \"Prometheus Exporter\"\n",[115,9134,9135],{"__ignoreMap":113},[118,9136,9137],{"class":120,"line":121},[118,9138,9132],{"class":124},[104,9140,9141],{},"It should look like the following",[108,9143,9145],{"className":9103,"code":9144,"language":9105,"meta":113,"style":113},"┌──────────────┬───────────────────────────────────────────────┐\n│ key          │ value                                         │\n╞══════════════╪═══════════════════════════════════════════════╡\n│ full-tokenid │ prometheus@pve!pve-exporter-token             │\n├──────────────┼───────────────────────────────────────────────┤\n│ info         │ {\"comment\":\"Prometheus Exporter\",\"privsep\":1} │\n├──────────────┼───────────────────────────────────────────────┤\n│ value        │xxxxx                                          │\n└──────────────┴───────────────────────────────────────────────┘\n",[115,9146,9147,9152,9157,9162,9167,9172,9177,9181,9186],{"__ignoreMap":113},[118,9148,9149],{"class":120,"line":121},[118,9150,9151],{"class":124},"┌──────────────┬───────────────────────────────────────────────┐\n",[118,9153,9154],{"class":120,"line":135},[118,9155,9156],{"class":124},"│ key          │ value                                         │\n",[118,9158,9159],{"class":120,"line":152},[118,9160,9161],{"class":124},"╞══════════════╪═══════════════════════════════════════════════╡\n",[118,9163,9164],{"class":120,"line":201},[118,9165,9166],{"class":124},"│ full-tokenid │ prometheus@pve!pve-exporter-token             │\n",[118,9168,9169],{"class":120,"line":209},[118,9170,9171],{"class":124},"├──────────────┼───────────────────────────────────────────────┤\n",[118,9173,9174],{"class":120,"line":215},[118,9175,9176],{"class":124},"│ info         │ {\"comment\":\"Prometheus Exporter\",\"privsep\":1} │\n",[118,9178,9179],{"class":120,"line":222},[118,9180,9171],{"class":124},[118,9182,9183],{"class":120,"line":231},[118,9184,9185],{"class":124},"│ value        │xxxxx                                          │\n",[118,9187,9188],{"class":120,"line":239},[118,9189,9190],{"class":124},"└──────────────┴───────────────────────────────────────────────┘\n",[99,9192,9194],{"id":9193},"exporter-node","Exporter Node",[104,9196,9197],{},[641,9198],{"alt":9199,"src":9200,"style":9201},"Proxmox PVE Exporter Diagram","/images/articles/proxmox-pve-exporter-diagram.png","display: block; margin: 0 auto",[104,9203,9204],{},"This setup runs the Proxmox Node Exporter on a separate machine in a Docker container. It can be run directly Proxmox machine itself also.",[104,9206,9207],{},"We run it on a separate node cluster that collects metrics on all our different Proxmox clusters. We find this a better and more scalable way to manage it.",[104,9209,9210],{},[891,9211,9212],{"href":9212},"https://github.com/prometheus-pve/prometheus-pve-exporter?tab=readme-ov-file#prometheus-configuration",[104,9214,9215,9216,9219],{},"Create a ",[115,9217,9218],{},"pve.yml"," to store the access details to the Proxmox cluster",[108,9221,9223],{"className":8847,"code":9222,"language":8849,"meta":113,"style":113},"default:\n  user: prometheus@pve\n  token_name: pve-exporter-token\n  token_value: \"\u003CYOUR_TOKEN_SECRET>\"\n  verify_ssl: false # true if you have a valid SSl trusted on your exporter\n",[115,9224,9225,9232,9242,9252,9262],{"__ignoreMap":113},[118,9226,9227,9230],{"class":120,"line":121},[118,9228,9229],{"class":8856},"default",[118,9231,8860],{"class":124},[118,9233,9234,9237,9239],{"class":120,"line":135},[118,9235,9236],{"class":8856},"  user",[118,9238,8875],{"class":124},[118,9240,9241],{"class":148},"prometheus@pve\n",[118,9243,9244,9247,9249],{"class":120,"line":152},[118,9245,9246],{"class":8856},"  token_name",[118,9248,8875],{"class":124},[118,9250,9251],{"class":148},"pve-exporter-token\n",[118,9253,9254,9257,9259],{"class":120,"line":201},[118,9255,9256],{"class":8856},"  token_value",[118,9258,8875],{"class":124},[118,9260,9261],{"class":148},"\"\u003CYOUR_TOKEN_SECRET>\"\n",[118,9263,9264,9267,9269,9272],{"class":120,"line":209},[118,9265,9266],{"class":8856},"  verify_ssl",[118,9268,8875],{"class":124},[118,9270,9271],{"class":189},"false",[118,9273,9274],{"class":2768}," # true if you have a valid SSl trusted on your exporter\n",[104,9276,9277,9278,9280],{},"Then use the following ",[115,9279,8843],{}," for easy setup and running of the container.",[108,9282,9284],{"className":8847,"code":9283,"language":8849,"meta":113,"style":113},"services:\n  pve-exporter:\n    image: prompve/prometheus-pve-exporter:latest\n    container_name: pve-exporter\n    ports:\n      - \"9221:9221\"\n    volumes:\n      - ./pve.yml:/etc/prometheus/pve.yml:ro\n    restart: unless-stopped\n",[115,9285,9286,9292,9299,9308,9317,9323,9330,9336,9343],{"__ignoreMap":113},[118,9287,9288,9290],{"class":120,"line":121},[118,9289,8857],{"class":8856},[118,9291,8860],{"class":124},[118,9293,9294,9297],{"class":120,"line":135},[118,9295,9296],{"class":8856},"  pve-exporter",[118,9298,8860],{"class":124},[118,9300,9301,9303,9305],{"class":120,"line":152},[118,9302,8872],{"class":8856},[118,9304,8875],{"class":124},[118,9306,9307],{"class":148},"prompve/prometheus-pve-exporter:latest\n",[118,9309,9310,9312,9314],{"class":120,"line":201},[118,9311,8883],{"class":8856},[118,9313,8875],{"class":124},[118,9315,9316],{"class":148},"pve-exporter\n",[118,9318,9319,9321],{"class":120,"line":209},[118,9320,8893],{"class":8856},[118,9322,8860],{"class":124},[118,9324,9325,9327],{"class":120,"line":215},[118,9326,8900],{"class":124},[118,9328,9329],{"class":148},"\"9221:9221\"\n",[118,9331,9332,9334],{"class":120,"line":222},[118,9333,8908],{"class":8856},[118,9335,8860],{"class":124},[118,9337,9338,9340],{"class":120,"line":231},[118,9339,8900],{"class":124},[118,9341,9342],{"class":148},"./pve.yml:/etc/prometheus/pve.yml:ro\n",[118,9344,9345,9347,9349],{"class":120,"line":239},[118,9346,8929],{"class":8856},[118,9348,8875],{"class":124},[118,9350,8934],{"class":148},[104,9352,9353],{},"To run it, execute the following",[108,9355,9357],{"className":8847,"code":9356,"language":8849,"meta":113,"style":113},"docker compose up -d\n",[115,9358,9359],{"__ignoreMap":113},[118,9360,9361],{"class":120,"line":121},[118,9362,9356],{"class":148},[104,9364,9365,9366,9372],{},"You can verify the exporter is running by doing the following on the exporter node, or replacing ",[891,9367,9369],{"href":9368},"http://localhost",[115,9370,9371],{},"localhost"," with the exporter node’s IP address.",[108,9374,9376],{"className":8847,"code":9375,"language":8849,"meta":113,"style":113},"curl http://localhost:9221/metrics | head\n",[115,9377,9378],{"__ignoreMap":113},[118,9379,9380],{"class":120,"line":121},[118,9381,9375],{"class":148},[1200,9383,9385],{"id":9384},"confirm-access-to-the-proxmox-node","Confirm access to the Proxmox node",[104,9387,9388],{},"The exporter retrieves the metrics from the Proxmox API. So prometheus calls it, it needs to have the target set. The following curl command can show this is working.",[108,9390,9392],{"className":8847,"code":9391,"language":8849,"meta":113,"style":113},"curl http://\u003Cexporter node IP>:9221/pve?target=\u003Cpve node IP>\n",[115,9393,9394],{"__ignoreMap":113},[118,9395,9396],{"class":120,"line":121},[118,9397,9391],{"class":148},[104,9399,9400],{},"If you get access forbidden, 403, this may fix it by assigning the ACL to the token. Run this on the Proxmox server.",[108,9402,9404],{"className":8847,"code":9403,"language":8849,"meta":113,"style":113},"pveum acl modify / \\\n  --token 'prometheus@pve!pve-exporter-token' \\\n  --role PVEAuditor\n",[115,9405,9406,9411,9416],{"__ignoreMap":113},[118,9407,9408],{"class":120,"line":121},[118,9409,9410],{"class":148},"pveum acl modify / \\\n",[118,9412,9413],{"class":120,"line":135},[118,9414,9415],{"class":148},"  --token 'prometheus@pve!pve-exporter-token' \\\n",[118,9417,9418],{"class":120,"line":152},[118,9419,9420],{"class":148},"  --role PVEAuditor\n",[99,9422,9424],{"id":9423},"connecting-to-prometheus","Connecting to Prometheus",[104,9426,9427,9428,9431],{},"In your ",[115,9429,9430],{},"prometheus.yml"," add the following scrape job. Replace the Proxmox Node IP with the IP address of your Proxmox machine, and the Exporter Node IP with the external IP of your Proxmox Node Exporter.",[108,9433,9435],{"className":8847,"code":9434,"language":8849,"meta":113,"style":113},"- job_name: 'proxmox'\n    params:\n      target: ['\u003CProxmox NODE IP>']\n    scrape_interval: 5s\n    metrics_path: /pve\n    static_configs:\n      - targets:\n        - \u003CProxmox NODE IP>\n    relabel_configs:\n      - source_labels: [__address__]\n        target_label: __param_target\n      - source_labels: [__param_target]\n        target_label: instance\n      - target_label: __address__\n        replacement: \u003CExporter Node IP>:9221\n",[115,9436,9437,9450,9457,9471,9481,9491,9498,9507,9515,9522,9536,9546,9559,9568,9580],{"__ignoreMap":113},[118,9438,9439,9442,9445,9447],{"class":120,"line":121},[118,9440,9441],{"class":124},"- ",[118,9443,9444],{"class":8856},"job_name",[118,9446,8875],{"class":124},[118,9448,9449],{"class":148},"'proxmox'\n",[118,9451,9452,9455],{"class":120,"line":135},[118,9453,9454],{"class":8856},"    params",[118,9456,8860],{"class":124},[118,9458,9459,9462,9465,9468],{"class":120,"line":152},[118,9460,9461],{"class":8856},"      target",[118,9463,9464],{"class":124},": [",[118,9466,9467],{"class":148},"'\u003CProxmox NODE IP>'",[118,9469,9470],{"class":124},"]\n",[118,9472,9473,9476,9478],{"class":120,"line":201},[118,9474,9475],{"class":8856},"    scrape_interval",[118,9477,8875],{"class":124},[118,9479,9480],{"class":148},"5s\n",[118,9482,9483,9486,9488],{"class":120,"line":209},[118,9484,9485],{"class":8856},"    metrics_path",[118,9487,8875],{"class":124},[118,9489,9490],{"class":148},"/pve\n",[118,9492,9493,9496],{"class":120,"line":215},[118,9494,9495],{"class":8856},"    static_configs",[118,9497,8860],{"class":124},[118,9499,9500,9502,9505],{"class":120,"line":222},[118,9501,8900],{"class":124},[118,9503,9504],{"class":8856},"targets",[118,9506,8860],{"class":124},[118,9508,9509,9512],{"class":120,"line":231},[118,9510,9511],{"class":124},"        - ",[118,9513,9514],{"class":148},"\u003CProxmox NODE IP>\n",[118,9516,9517,9520],{"class":120,"line":239},[118,9518,9519],{"class":8856},"    relabel_configs",[118,9521,8860],{"class":124},[118,9523,9524,9526,9529,9531,9534],{"class":120,"line":247},[118,9525,8900],{"class":124},[118,9527,9528],{"class":8856},"source_labels",[118,9530,9464],{"class":124},[118,9532,9533],{"class":148},"__address__",[118,9535,9470],{"class":124},[118,9537,9538,9541,9543],{"class":120,"line":255},[118,9539,9540],{"class":8856},"        target_label",[118,9542,8875],{"class":124},[118,9544,9545],{"class":148},"__param_target\n",[118,9547,9548,9550,9552,9554,9557],{"class":120,"line":263},[118,9549,8900],{"class":124},[118,9551,9528],{"class":8856},[118,9553,9464],{"class":124},[118,9555,9556],{"class":148},"__param_target",[118,9558,9470],{"class":124},[118,9560,9561,9563,9565],{"class":120,"line":271},[118,9562,9540],{"class":8856},[118,9564,8875],{"class":124},[118,9566,9567],{"class":148},"instance\n",[118,9569,9570,9572,9575,9577],{"class":120,"line":279},[118,9571,8900],{"class":124},[118,9573,9574],{"class":8856},"target_label",[118,9576,8875],{"class":124},[118,9578,9579],{"class":148},"__address__\n",[118,9581,9582,9585,9587],{"class":120,"line":568},[118,9583,9584],{"class":8856},"        replacement",[118,9586,8875],{"class":124},[118,9588,9589],{"class":148},"\u003CExporter Node IP>:9221\n",[104,9591,9592],{},"Then restart Prometheus.",[1200,9594,9596],{"id":9595},"breakdown-of-the-scrape-job","Breakdown of the scrape job",[108,9598,9600],{"className":8847,"code":9599,"language":8849,"meta":113,"style":113},"params:\n  target: ['\u003CProxmox NODE IP>']\n",[115,9601,9602,9609],{"__ignoreMap":113},[118,9603,9604,9607],{"class":120,"line":121},[118,9605,9606],{"class":8856},"params",[118,9608,8860],{"class":124},[118,9610,9611,9614,9616,9618],{"class":120,"line":135},[118,9612,9613],{"class":8856},"  target",[118,9615,9464],{"class":124},[118,9617,9467],{"class":148},[118,9619,9470],{"class":124},[104,9621,9622,9623,9626],{},"The above adds ",[115,9624,9625],{},"?target=\u003CProxmox NODE IP>"," to the exporter URL.",[104,9628,9629],{},"So when Prometheus calls the exporter it becomes",[108,9631,9633],{"className":8847,"code":9632,"language":8849,"meta":113,"style":113},"http://\u003CExporter IP>:9221/pve?target=\u003CProxmox NODE IP>\n",[115,9634,9635],{"__ignoreMap":113},[118,9636,9637],{"class":120,"line":121},[118,9638,9632],{"class":148},[104,9640,9641,9642,9645,9646],{},"Then we have the ",[115,9643,9644],{},"static_configs"," → ",[115,9647,9504],{},[108,9649,9651],{"className":8847,"code":9650,"language":8849,"meta":113,"style":113},"    static_configs:\n      - targets:\n        - \u003CProxmox NODE IP>\n",[115,9652,9653,9659,9667],{"__ignoreMap":113},[118,9654,9655,9657],{"class":120,"line":121},[118,9656,9495],{"class":8856},[118,9658,8860],{"class":124},[118,9660,9661,9663,9665],{"class":120,"line":135},[118,9662,8900],{"class":124},[118,9664,9504],{"class":8856},[118,9666,8860],{"class":124},[118,9668,9669,9671],{"class":120,"line":152},[118,9670,9511],{"class":124},[118,9672,9514],{"class":148},[104,9674,9675,9676,9678,9679,452],{},"This is what Prometheus uses as its internal list of “real” targets. They show up as the ",[115,9677,9533],{}," label, which we then change using the ",[115,9680,9681],{},"relabel_configs",[104,9683,7184,9684,9687,9688,452],{},[115,9685,9686],{},"replacement: \u003CExporter Node IP>"," tells Prometheus to scrape the Proxmox Node Exporter, not the Proxmox machine. Otherwise it would normally scrape the address in the ",[115,9689,9504],{},[99,9691,9693],{"id":9692},"dashboard","Dashboard",[104,9695,9696],{},[891,9697,9698],{"href":9698},"https://grafana.com/grafana/dashboards/10347-proxmox-via-prometheus/",[104,9700,9701],{},"The above will collect metrics for all nodes across the cluster. You can use the cluster above and choose the Prometheus data source, so it starts collecting those metrics.",[1200,9703,9705],{"id":9704},"make-the-total-cpus-the-whole-cluster","Make the total CPU’s the whole cluster",[108,9707,9709],{"className":8847,"code":9708,"language":8849,"meta":113,"style":113},"sum(pve_cpu_usage_limit and on(id) pve_node_info)\n",[115,9710,9711],{"__ignoreMap":113},[118,9712,9713],{"class":120,"line":121},[118,9714,9708],{"class":148},[1200,9716,9718],{"id":9717},"make-the-total-ram-the-whole-cluster","Make the total RAM the whole cluster",[108,9720,9722],{"className":8847,"code":9721,"language":8849,"meta":113,"style":113},"sum(pve_memory_usage_bytes{instance=\"$instance\"} and on(id) pve_node_info)\nsum(pve_memory_size_bytes{instance=\"$instance\"} and on(id) pve_node_info)\n",[115,9723,9724,9729],{"__ignoreMap":113},[118,9725,9726],{"class":120,"line":121},[118,9727,9728],{"class":148},"sum(pve_memory_usage_bytes{instance=\"$instance\"} and on(id) pve_node_info)\n",[118,9730,9731],{"class":120,"line":135},[118,9732,9733],{"class":148},"sum(pve_memory_size_bytes{instance=\"$instance\"} and on(id) pve_node_info)\n",[613,9735,9736],{},"html pre.shiki code .s4JwU, html code.shiki .s4JwU{--shiki-default:#85E89D}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}",{"title":113,"searchDepth":135,"depth":135,"links":9738},[9739,9740,9743,9746],{"id":9092,"depth":135,"text":9093},{"id":9193,"depth":135,"text":9194,"children":9741},[9742],{"id":9384,"depth":152,"text":9385},{"id":9423,"depth":135,"text":9424,"children":9744},[9745],{"id":9595,"depth":152,"text":9596},{"id":9692,"depth":135,"text":9693,"children":9747},[9748,9749],{"id":9704,"depth":152,"text":9705},{"id":9717,"depth":152,"text":9718},[56],"Monitor your Proxmox cluster with Grafana and Prometheus: create an API user, run the Proxmox PVE exporter, add a scrape job and build a cluster dashboard.",{"slug":67,"isHowTo":218},"2025-11-10T18:00:00.000Z",{"title":65,"description":9751},[9756,9757],"monitoring","observability","_4tNXsu-d767bueLW8haSk5oEoCpkKIFQVcidT40zWQ",{"id":9760,"title":74,"body":9761,"categories":9915,"description":9916,"extension":624,"meta":9917,"navigation":218,"ogImage":627,"path":75,"publish_at":628,"seo":9919,"stem":76,"tags":9920,"__hash__":9921},"library/library/windows/Windows-Subsystem-for-Linux.md",{"type":96,"value":9762,"toc":9911},[9763,9767,9769,9772,9776,9824,9828,9832,9835,9842,9846,9852,9862,9905,9908],[99,9764,9766],{"id":9765},"how-to-compact-an-overgrown-disk","How to compact an overgrown disk",[1538,9768,881],{"id":880},[104,9770,9771],{},"Overtime a WSL2 partition may grow and not be reclaimed. The following will fix that.",[1538,9773,9775],{"id":9774},"process","Process",[108,9777,9779],{"className":2759,"code":9778,"language":2761,"meta":113,"style":113},"wsl --list\nwsl --terminate Debian\ndiskpart\nselect vdisk file=\"C:\\Users\\joseph\\AppData\\Local\\Packages\\Debian.16571368D6CFF_kd1vv0z0vy70w\\LocalState\\ext4.vhdx\"\ncompact vdisk\n",[115,9780,9781,9789,9799,9804,9816],{"__ignoreMap":113},[118,9782,9783,9786],{"class":120,"line":121},[118,9784,9785],{"class":128},"wsl",[118,9787,9788],{"class":189}," --list\n",[118,9790,9791,9793,9796],{"class":120,"line":135},[118,9792,9785],{"class":128},[118,9794,9795],{"class":189}," --terminate",[118,9797,9798],{"class":148}," Debian\n",[118,9800,9801],{"class":120,"line":152},[118,9802,9803],{"class":128},"diskpart\n",[118,9805,9806,9808,9811,9813],{"class":120,"line":201},[118,9807,3186],{"class":141},[118,9809,9810],{"class":124}," vdisk file",[118,9812,314],{"class":141},[118,9814,9815],{"class":148},"\"C:\\Users\\joseph\\AppData\\Local\\Packages\\Debian.16571368D6CFF_kd1vv0z0vy70w\\LocalState\\ext4.vhdx\"\n",[118,9817,9818,9821],{"class":120,"line":209},[118,9819,9820],{"class":128},"compact",[118,9822,9823],{"class":148}," vdisk\n",[99,9825,9827],{"id":9826},"wsl2-and-ssh-keys-between-sessions","WSL2 and SSH Keys between sessions",[1538,9829,9831],{"id":9830},"the-problem","The Problem",[104,9833,9834],{},"ssh-agent is a thing we normally take for granted when using SSH on linux. We add the key, then it’s there until we restart.",[104,9836,9837,9838,9841],{},"When switching to WSL2 we quickly find that isn’t the case. We might first try ",[115,9839,9840],{},"eval $(ssh-agent -s)"," but that is lost every time we open a new window or tmux session. Another option is to stop using encrypted SSH keys. For those of us who prefer to keep our keys encrypted, there is a better way. We can use the keychain package to persist our SSH keys between windows and sessions.",[1538,9843,9845],{"id":9844},"the-keychain-package","The keychain package",[104,9847,9848,9849],{},"Install ",[115,9850,9851],{},"keychain",[104,9853,9854,9855,349,9858,9861],{},"sudo apt-get install keychain\nEdit your ",[115,9856,9857],{},"~/.bashrc",[115,9859,9860],{},"~/.zshrc"," or your choice of shell, and add the following to the bottom of your file.",[108,9863,9865],{"className":2759,"code":9864,"language":2761,"meta":113,"style":113},"# Store SSH key between sessions\n/usr/bin/keychain -q --nogui $HOME/.ssh/id_rsa\nsource $HOME/.keychain/$HOST-sh\n",[115,9866,9867,9872,9889],{"__ignoreMap":113},[118,9868,9869],{"class":120,"line":121},[118,9870,9871],{"class":2768},"# Store SSH key between sessions\n",[118,9873,9874,9877,9880,9883,9886],{"class":120,"line":135},[118,9875,9876],{"class":128},"/usr/bin/keychain",[118,9878,9879],{"class":189}," -q",[118,9881,9882],{"class":189}," --nogui",[118,9884,9885],{"class":124}," $HOME",[118,9887,9888],{"class":148},"/.ssh/id_rsa\n",[118,9890,9891,9894,9896,9899,9902],{"class":120,"line":152},[118,9892,9893],{"class":189},"source",[118,9895,9885],{"class":124},[118,9897,9898],{"class":148},"/.keychain/",[118,9900,9901],{"class":124},"$HOST",[118,9903,9904],{"class":148},"-sh\n",[104,9906,9907],{},"This will prompt you for the key on startup if it doesn’t already exist. Adjust to suit your keys.",[613,9909,9910],{},"html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}",{"title":113,"searchDepth":135,"depth":135,"links":9912},[9913,9914],{"id":9765,"depth":135,"text":9766},{"id":9826,"depth":135,"text":9827},[69],"Handy Windows Subsystem for Linux tips we use daily: compacting an overgrown WSL2 disk and keeping SSH keys loaded between sessions with keychain.",{"slug":9918,"isHowTo":218,"image":626},"library/windows/windows-subsystem-for-linux",{"title":74,"description":9916},[9785],"dWvpv9HXw5dj9lqNbyiujbqQCp3LYy_-9PHMrM65rQ0",{"id":9923,"title":78,"body":9924,"categories":10474,"description":10476,"extension":624,"meta":10477,"navigation":218,"ogImage":627,"path":79,"publish_at":628,"seo":10478,"stem":80,"tags":10479,"__hash__":10482},"library/library/windows/handy-powershell-scripts.md",{"type":96,"value":9925,"toc":10468},[9926,9930,9933,10073,10077,10081,10084,10349,10353,10411,10415,10418,10465],[99,9927,9929],{"id":9928},"a-simple-script-to-send-emails-through-a-remote-smtp-server","A simple script to send emails through a remote SMTP server",[104,9931,9932],{},"Used to test an outgoing mail server and send a test message… or just send any email.",[108,9934,9938],{"className":9935,"code":9936,"language":9937,"meta":113,"style":113},"language-powershell shiki shiki-themes github-dark","$EmailTo = \"\"\n$EmailFrom = \"\"\n$Subject = \"Test\"\n$Body = \"Test Body\"\n$SMTPServer = \"\"\n$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)\n$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)\n$SMTPClient.EnableSsl = $true\n$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(\"[user]\", \"[password]\");\n$SMTPClient.Send($SMTPMessage)\n","powershell",[115,9939,9940,9950,9959,9969,9979,9988,10017,10036,10046,10068],{"__ignoreMap":113},[118,9941,9942,9945,9947],{"class":120,"line":121},[118,9943,9944],{"class":124},"$EmailTo ",[118,9946,314],{"class":141},[118,9948,9949],{"class":148}," \"\"\n",[118,9951,9952,9955,9957],{"class":120,"line":135},[118,9953,9954],{"class":124},"$EmailFrom ",[118,9956,314],{"class":141},[118,9958,9949],{"class":148},[118,9960,9961,9964,9966],{"class":120,"line":152},[118,9962,9963],{"class":124},"$Subject ",[118,9965,314],{"class":141},[118,9967,9968],{"class":148}," \"Test\"\n",[118,9970,9971,9974,9976],{"class":120,"line":201},[118,9972,9973],{"class":124},"$Body ",[118,9975,314],{"class":141},[118,9977,9978],{"class":148}," \"Test Body\"\n",[118,9980,9981,9984,9986],{"class":120,"line":209},[118,9982,9983],{"class":124},"$SMTPServer ",[118,9985,314],{"class":141},[118,9987,9949],{"class":148},[118,9989,9990,9993,9995,9998,10001,10004,10007,10009,10012,10014],{"class":120,"line":215},[118,9991,9992],{"class":124},"$SMTPMessage ",[118,9994,314],{"class":141},[118,9996,9997],{"class":189}," New-Object",[118,9999,10000],{"class":124}," System.Net.Mail.MailMessage($EmailFrom",[118,10002,10003],{"class":141},",",[118,10005,10006],{"class":124},"$EmailTo",[118,10008,10003],{"class":141},[118,10010,10011],{"class":124},"$Subject",[118,10013,10003],{"class":141},[118,10015,10016],{"class":124},"$Body)\n",[118,10018,10019,10022,10024,10026,10029,10031,10034],{"class":120,"line":222},[118,10020,10021],{"class":124},"$SMTPClient ",[118,10023,314],{"class":141},[118,10025,9997],{"class":189},[118,10027,10028],{"class":124}," Net.Mail.SmtpClient($SmtpServer",[118,10030,10003],{"class":141},[118,10032,10033],{"class":189}," 587",[118,10035,2515],{"class":124},[118,10037,10038,10041,10043],{"class":120,"line":231},[118,10039,10040],{"class":124},"$SMTPClient.EnableSsl ",[118,10042,314],{"class":141},[118,10044,10045],{"class":189}," $true\n",[118,10047,10048,10051,10053,10055,10058,10061,10063,10066],{"class":120,"line":239},[118,10049,10050],{"class":124},"$SMTPClient.Credentials ",[118,10052,314],{"class":141},[118,10054,9997],{"class":189},[118,10056,10057],{"class":124}," System.Net.NetworkCredential(",[118,10059,10060],{"class":148},"\"[user]\"",[118,10062,10003],{"class":141},[118,10064,10065],{"class":148}," \"[password]\"",[118,10067,444],{"class":124},[118,10069,10070],{"class":120,"line":247},[118,10071,10072],{"class":124},"$SMTPClient.Send($SMTPMessage)\n",[99,10074,10076],{"id":10075},"create-a-scheduled-task-from-powershell","Create a scheduled task from Powershell",[1200,10078,10080],{"id":10079},"create-a-recurring-task","Create a recurring task",[104,10082,10083],{},"This will run every day at 5am. The $taskExists conditional is so that it can be overwritten if it already existed with the new settings.",[108,10085,10087],{"className":9935,"code":10086,"language":9937,"meta":113,"style":113},"$userName = \"${env:computername}\\Administrator\"\n$taskName = \"RefreshSQLData\"\n$taskExists = Get-ScheduledTask | Where-Object {$_.TaskName -like $taskName }\n\necho $userName\n\nif($taskExists) {\n  Unregister-ScheduledTask -TaskName $taskName -Confirm:$False\n}\n\n$action = New-ScheduledTaskAction -Execute \"n:\\eaccountsRestApi\\eMigrateToSql64.exe\"\n$trigger = New-ScheduledTaskTrigger -Daily -At 5am\n$settings = New-ScheduledTaskSettingsSet -Hidden -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -RunOnlyIfNetworkAvailable\n$principal = New-ScheduledTaskPrincipal -UserId ((Get-CimInstance –ClassName Win32_ComputerSystem | Select-Object -expand Name) + \"\\Administrator\")\n$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings -Principal $principal\nRegister-ScheduledTask $taskName -InputObject $task\n",[115,10088,10089,10110,10120,10150,10154,10159,10163,10171,10189,10193,10197,10215,10235,10268,10306,10336],{"__ignoreMap":113},[118,10090,10091,10094,10096,10098,10101,10104,10107],{"class":120,"line":121},[118,10092,10093],{"class":124},"$userName ",[118,10095,314],{"class":141},[118,10097,7851],{"class":148},[118,10099,10100],{"class":124},"${",[118,10102,10103],{"class":189},"env:",[118,10105,10106],{"class":124},"computername}",[118,10108,10109],{"class":148},"\\Administrator\"\n",[118,10111,10112,10115,10117],{"class":120,"line":135},[118,10113,10114],{"class":124},"$taskName ",[118,10116,314],{"class":141},[118,10118,10119],{"class":148}," \"RefreshSQLData\"\n",[118,10121,10122,10125,10127,10130,10132,10135,10138,10141,10144,10147],{"class":120,"line":152},[118,10123,10124],{"class":124},"$taskExists ",[118,10126,314],{"class":141},[118,10128,10129],{"class":189}," Get-ScheduledTask",[118,10131,7859],{"class":141},[118,10133,10134],{"class":189}," Where-Object",[118,10136,10137],{"class":124}," {",[118,10139,10140],{"class":189},"$_",[118,10142,10143],{"class":124},".TaskName ",[118,10145,10146],{"class":141},"-like",[118,10148,10149],{"class":124}," $taskName }\n",[118,10151,10152],{"class":120,"line":201},[118,10153,219],{"emptyLinePlaceholder":218},[118,10155,10156],{"class":120,"line":209},[118,10157,10158],{"class":124},"echo $userName\n",[118,10160,10161],{"class":120,"line":215},[118,10162,219],{"emptyLinePlaceholder":218},[118,10164,10165,10168],{"class":120,"line":222},[118,10166,10167],{"class":141},"if",[118,10169,10170],{"class":124},"($taskExists) {\n",[118,10172,10173,10176,10178,10181,10183,10186],{"class":120,"line":231},[118,10174,10175],{"class":189},"  Unregister-ScheduledTask",[118,10177,2062],{"class":141},[118,10179,10180],{"class":124},"TaskName $taskName ",[118,10182,142],{"class":141},[118,10184,10185],{"class":124},"Confirm:",[118,10187,10188],{"class":189},"$False\n",[118,10190,10191],{"class":120,"line":239},[118,10192,212],{"class":124},[118,10194,10195],{"class":120,"line":247},[118,10196,219],{"emptyLinePlaceholder":218},[118,10198,10199,10202,10204,10207,10209,10212],{"class":120,"line":255},[118,10200,10201],{"class":124},"$action ",[118,10203,314],{"class":141},[118,10205,10206],{"class":189}," New-ScheduledTaskAction",[118,10208,2062],{"class":141},[118,10210,10211],{"class":124},"Execute ",[118,10213,10214],{"class":148},"\"n:\\eaccountsRestApi\\eMigrateToSql64.exe\"\n",[118,10216,10217,10220,10222,10225,10227,10230,10232],{"class":120,"line":263},[118,10218,10219],{"class":124},"$trigger ",[118,10221,314],{"class":141},[118,10223,10224],{"class":189}," New-ScheduledTaskTrigger",[118,10226,2062],{"class":141},[118,10228,10229],{"class":124},"Daily ",[118,10231,142],{"class":141},[118,10233,10234],{"class":124},"At 5am\n",[118,10236,10237,10240,10242,10245,10248,10250,10253,10255,10258,10260,10263,10265],{"class":120,"line":271},[118,10238,10239],{"class":124},"$settings ",[118,10241,314],{"class":141},[118,10243,10244],{"class":189}," New-ScheduledTaskSettingsSet",[118,10246,10247],{"class":141}," -Hidden",[118,10249,2062],{"class":141},[118,10251,10252],{"class":124},"AllowStartIfOnBatteries ",[118,10254,142],{"class":141},[118,10256,10257],{"class":124},"DontStopIfGoingOnBatteries ",[118,10259,142],{"class":141},[118,10261,10262],{"class":124},"StartWhenAvailable ",[118,10264,142],{"class":141},[118,10266,10267],{"class":124},"RunOnlyIfNetworkAvailable\n",[118,10269,10270,10273,10275,10278,10280,10283,10286,10289,10291,10294,10296,10299,10301,10304],{"class":120,"line":279},[118,10271,10272],{"class":124},"$principal ",[118,10274,314],{"class":141},[118,10276,10277],{"class":189}," New-ScheduledTaskPrincipal",[118,10279,2062],{"class":141},[118,10281,10282],{"class":124},"UserId ((",[118,10284,10285],{"class":189},"Get-CimInstance",[118,10287,10288],{"class":124}," –ClassName Win32_ComputerSystem ",[118,10290,178],{"class":141},[118,10292,10293],{"class":189}," Select-Object",[118,10295,2062],{"class":141},[118,10297,10298],{"class":124},"expand Name) ",[118,10300,3632],{"class":141},[118,10302,10303],{"class":148}," \"\\Administrator\"",[118,10305,2515],{"class":124},[118,10307,10308,10311,10313,10316,10318,10321,10323,10326,10328,10331,10333],{"class":120,"line":568},[118,10309,10310],{"class":124},"$task ",[118,10312,314],{"class":141},[118,10314,10315],{"class":189}," New-ScheduledTask",[118,10317,2062],{"class":141},[118,10319,10320],{"class":124},"Action $action ",[118,10322,142],{"class":141},[118,10324,10325],{"class":124},"Trigger $trigger ",[118,10327,142],{"class":141},[118,10329,10330],{"class":124},"Settings $settings ",[118,10332,142],{"class":141},[118,10334,10335],{"class":124},"Principal $principal\n",[118,10337,10338,10341,10344,10346],{"class":120,"line":579},[118,10339,10340],{"class":189},"Register-ScheduledTask",[118,10342,10343],{"class":124}," $taskName ",[118,10345,142],{"class":141},[118,10347,10348],{"class":124},"InputObject $task\n",[1538,10350,10352],{"id":10351},"run-it-for-one-day-at-5am-every-30-minutes","Run it for one day at 5am every 30 minutes",[108,10354,10356],{"className":9935,"code":10355,"language":9937,"meta":113,"style":113},"$trigger = New-ScheduledTaskTrigger -Once -At 5am -RepetitionDuration  (New-TimeSpan -Days 1)  -RepetitionInterval  (New-TimeSpan -Minutes 30)\n",[115,10357,10358],{"__ignoreMap":113},[118,10359,10360,10362,10364,10366,10368,10371,10373,10376,10378,10381,10384,10386,10389,10391,10394,10396,10399,10401,10403,10406,10409],{"class":120,"line":121},[118,10361,10219],{"class":124},[118,10363,314],{"class":141},[118,10365,10224],{"class":189},[118,10367,2062],{"class":141},[118,10369,10370],{"class":124},"Once ",[118,10372,142],{"class":141},[118,10374,10375],{"class":124},"At 5am ",[118,10377,142],{"class":141},[118,10379,10380],{"class":124},"RepetitionDuration  (",[118,10382,10383],{"class":189},"New-TimeSpan",[118,10385,2062],{"class":141},[118,10387,10388],{"class":124},"Days ",[118,10390,603],{"class":189},[118,10392,10393],{"class":124},")  ",[118,10395,142],{"class":141},[118,10397,10398],{"class":124},"RepetitionInterval  (",[118,10400,10383],{"class":189},[118,10402,2062],{"class":141},[118,10404,10405],{"class":124},"Minutes ",[118,10407,10408],{"class":189},"30",[118,10410,2515],{"class":124},[1538,10412,10414],{"id":10413},"register-it-as-a-userpassword","Register it as a user/password",[104,10416,10417],{},"Depending on the privilege of the user running the script, password may not be needed.",[108,10419,10421],{"className":9935,"code":10420,"language":9937,"meta":113,"style":113},"$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings\nRegister-ScheduledTask $taskName -InputObject $task -User $username -Password $password\n",[115,10422,10423,10444],{"__ignoreMap":113},[118,10424,10425,10427,10429,10431,10433,10435,10437,10439,10441],{"class":120,"line":121},[118,10426,10310],{"class":124},[118,10428,314],{"class":141},[118,10430,10315],{"class":189},[118,10432,2062],{"class":141},[118,10434,10320],{"class":124},[118,10436,142],{"class":141},[118,10438,10325],{"class":124},[118,10440,142],{"class":141},[118,10442,10443],{"class":124},"Settings $settings\n",[118,10445,10446,10448,10450,10452,10455,10457,10460,10462],{"class":120,"line":135},[118,10447,10340],{"class":189},[118,10449,10343],{"class":124},[118,10451,142],{"class":141},[118,10453,10454],{"class":124},"InputObject $task ",[118,10456,142],{"class":141},[118,10458,10459],{"class":124},"User $username ",[118,10461,142],{"class":141},[118,10463,10464],{"class":124},"Password $password\n",[613,10466,10467],{},"html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":113,"searchDepth":135,"depth":135,"links":10469},[10470,10471],{"id":9928,"depth":135,"text":9929},{"id":10075,"depth":135,"text":10076,"children":10472},[10473],{"id":10079,"depth":152,"text":10080},[10475],"Powershell","Powershell is the swiss army knife of Windows Administration. Here is a collection of scripts we thought you might also find handy.",{"slug":80,"isHowTo":218,"image":626},{"title":78,"description":10476},[10480,10481],"scripting","windows admin","2n2Of2XG3sSy_i0BnAf0FbeHBjPxhY7xYQQhniPiI4c",{"id":10484,"title":87,"body":10485,"categories":10952,"description":10953,"extension":624,"meta":10954,"navigation":218,"ogImage":627,"path":88,"publish_at":10955,"seo":10956,"stem":89,"tags":10957,"__hash__":10959},"library/library/wordpress/how-to-install-wordpress-in-xampp-with-vhost.md",{"type":96,"value":10486,"toc":10942},[10487,10490,10494,10505,10511,10517,10521,10527,10531,10538,10544,10551,10557,10560,10566,10569,10573,10583,10600,10612,10618,10622,10628,10639,10645,10659,10665,10672,10678,10684,10694,10700,10707,10713,10718,10725,10735,10741,10744,10750,10756,10764,10773,10780,10784,10789,10795,10801,10807,10813,10819,10825,10828,10838,10845,10851,10860,10866,10872,10878,10884,10887,10893,10896,10902,10906,10919,10929,10933,10936,10939],[104,10488,10489],{},"One excellent method for setting up a WordPress environment on your computer is to install WordPress locally using XAMPP.\nWith this configuration, themes, plugins, and customizations can be tested without impacting a live website.\nHere's a detailed how-to for getting started:",[99,10491,10493],{"id":10492},"step-1-download-and-install-xampp","Step 1: Download and install XAMPP",[104,10495,10496,10499,10500,10504],{},[1233,10497,10498],{},"1. Download XAMPP:","\nGet XAMPP from ",[891,10501,10503],{":target":10502,"href":10503},"_blank","https://www.apachefriends.org",", the official website. Select the version that works best with your operating system (Linux, macOS, or Windows).",[104,10506,10507,10510],{},[1233,10508,10509],{},"2. Install XAMPP:","\nRun the downloaded file and adhere to the on-screen directions to install XAMPP. Choose the components that are required to run WordPress, such as Apache and MySQL.",[104,10512,10513,10516],{},[1233,10514,10515],{},"3. Launch XAMPP:","\nafter installation. You can manage your Apache and MySQL services using the XAMPP management interface.",[99,10518,10520],{"id":10519},"step-2-start-apache-and-mysql-servers","Step 2: Start Apache and MySQL Servers",[104,10522,10523,10524,10526],{},"In the XAMPP Control Panel, click Start next to Apache and MySQL to start the servers.\nConfirm the servers are running. You should see green indicators next to each if they’re active.\nTo check if XAMPP is working, open a browser and go to ",[891,10525,9368],{":target":10502,"href":9368},". You should see the XAMPP dashboard.",[99,10528,10530],{"id":10529},"step-3-create-a-database-for-wordpress","Step 3: Create a Database for WordPress",[104,10532,10533,10534,10537],{},"In your browser, go to ",[891,10535,10536],{":target":10502,"href":10536},"http://localhost/phpmyadmin",", which will open phpMyAdmin, a database management tool.\nor you can simply click the admin button on XAMPP",[104,10539,10540],{},[641,10541],{"alt":10542,"src":10543},"createdb1","/images/articles/createdb1.png",[104,10545,10546,10547,10550],{},"Then click ",[1233,10548,10549],{},"databases"," at the top:",[104,10552,10553],{},[641,10554],{"alt":10555,"src":10556},"createdb2","/images/articles/createdb2.png",[104,10558,10559],{},"After giving your database a name, click Create. Whatever you choose for your name, simply keep it in mind since you'll need it for the following step:",[104,10561,10562],{},[641,10563],{"alt":10564,"src":10565},"createdb3","/images/articles/createdb3.png",[104,10567,10568],{},"Remember this database name, as you’ll need it during WordPress setup.",[99,10570,10572],{"id":10571},"step-4-download-and-install-wordpress","Step 4: Download and install WordPress",[104,10574,10575,10578,10579,10582],{},[1233,10576,10577],{},"1. Download WordPress:","\nGo to the official WordPress website at ",[891,10580,10581],{":target":10502,"href":10581},"https://wordpress.org/download/"," and download the latest version.",[104,10584,10585,10588,10589,10591,10592,10596,10597],{},[1233,10586,10587],{},"2. Extract Files:","\nExtract the WordPress ZIP file and copy the extracted ",[1233,10590,631],{}," folder and paste it into the htdocs folder of your XAMPP installation directory. For Example,\nif you installed XAMPP on ",[1407,10593,10595],{":style":10594},"background-color: #ececec;","C:\\xampp",", paste it in ",[1407,10598,10599],{":style":10594},"C:\\xampp\\htdocs",[104,10601,10602,10605,10606,10608,10609,452],{},[1233,10603,10604],{},"3. Renaming Folder:","\nRename the ",[1233,10607,631],{}," folder to your liking but for this example we will rename it to ",[1233,10610,10611],{},"myblog",[104,10613,10614],{},[641,10615],{"alt":10616,"src":10617},"renamewordpress","/images/articles/renamewordpress.png",[99,10619,10621],{"id":10620},"step-5-setting-up-vhost","Step 5: Setting up vhost",[104,10623,10624,10627],{},[1233,10625,10626],{},"1. Edit your local hosting","\nOpen a notepad, run it as administrator",[104,10629,10630,10631,10634,10635,10638],{},"click on ",[1407,10632,10633],{},"file"," at the top left corner, and click on the ",[1407,10636,10637],{},"open"," on the dropdown selection",[104,10640,10641],{},[641,10642],{"alt":10643,"src":10644},"vhost1","/images/articles/vhost2.png",[104,10646,10647,10648,10651,10652,10655,10656],{},"Navigate to ",[1407,10649,10650],{":style":10594},"C:\\Windows\\System32\\drivers\\etc"," and select the ",[1407,10653,10654],{},"hosts"," file and open, if the file does not show click on the dropdown of file extensions and select ",[1407,10657,10658],{},"all files",[104,10660,10661],{},[641,10662],{"alt":10663,"src":10664},"vhost2","/images/articles/vhost1.png",[104,10666,10667,10668,10671],{},"Add a new line of text at the bottom of the hosts file ",[1407,10669,10670],{},"127.0.0.1"," is the default localhost and we'll use the same and host it on a different test domain and save it",[104,10673,10674],{},[641,10675],{"alt":10676,"src":10677},"vhost3","/images/articles/vhost3.png",[104,10679,10680,10681],{},"for this example, we used ",[1407,10682,10683],{":style":10594},"myblog.test",[104,10685,10686,10689,10690,10693],{},[1233,10687,10688],{},"2. Enable XAMPP vhost","\nTo enable the vhost for XAMPP, go to your XAMPP app and click on Apache config button click on the dropdown ",[1407,10691,10692],{},"Apache(httpd.conf)"," and it will open a notepad",[104,10695,10696],{},[641,10697],{"alt":10698,"src":10699},"vhost4","/images/articles/vhost4.png",[104,10701,10702,10703,10706],{},"search for the line ",[1407,10704,10705],{":style":10594},"conf/extra/httpd-vhosts.conf"," and check if the line has been commented out. If it is then uncomment the line to enable it and save.",[104,10708,10709],{},[641,10710],{"alt":10711,"src":10712},"vhost5","/images/articles/vhost5.png",[104,10714,10715],{},[1233,10716,10717],{},"3. Edit XAMPP vhost file",[104,10719,10720,10721,10634,10723,10638],{},"Open a new notepad, click on the ",[1407,10722,10633],{},[1407,10724,10637],{},[104,10726,10647,10727,10651,10730,10655,10733],{},[1407,10728,10729],{":style":10594},"C:\\xampp\\apache\\conf\\extra",[1407,10731,10732],{},"httpd-vhosts.conf",[1407,10734,10658],{},[104,10736,10737],{},[641,10738],{"alt":10739,"src":10740},"vhost6","/images/articles/vhost6.png",[104,10742,10743],{},"At the bottom of the file add the following code",[108,10745,10748],{"className":10746,"code":10747,"language":903,"meta":113},[901],"\u003CVirtualHost *:80>\n    DocumentRoot \"C:/xampp/htdocs/myblog\"\n    ServerName myblog.test\n\u003C/VirtualHost>\n",[115,10749,10747],{"__ignoreMap":113},[104,10751,10752],{},[641,10753],{"alt":10754,"src":10755},"vhost7","/images/articles/vhost7.png",[104,10757,7184,10758,10761,10762,452],{},[1233,10759,10760],{},"DocumentRoot"," is the root of your WordPress extracted folder and renamed to ",[1233,10763,10611],{},[104,10765,7184,10766,10769,10770,10772],{},[1233,10767,10768],{},"ServerName"," is the domain added from the ",[1407,10771,10654],{}," file we edited on Step 5-1.",[104,10774,10775,10776,10779],{},"Once all of these are done, you can now ",[1233,10777,10778],{},"restart"," your xampp apache and test your domain",[99,10781,10783],{"id":10782},"step-6-install-wordpress-locally-using-the-on-screen-installer","Step 6: Install WordPress locally using the on-screen installer",[104,10785,10786,10787],{},"Open your browser and type in the URL ",[1233,10788,10683],{},[104,10790,10791],{},[641,10792],{"alt":10793,"src":10794},"wordpress1","/images/articles/wordpress1.png",[104,10796,10797,10798,10800],{},"and it will open the ",[1233,10799,622],{}," on-screen installer",[104,10802,10803],{},[641,10804],{"alt":10805,"src":10806},"wordpress2","/images/articles/wordpress2.png",[104,10808,10630,10809,10812],{},[1233,10810,10811],{},"Continue"," and a new screen will show informing you that the next page will be a setup of your database.",[104,10814,10546,10815,10818],{},[1233,10816,10817],{},"Let's go!"," button",[104,10820,10821],{},[641,10822],{"alt":10823,"src":10824},"wordpress3","/images/articles/wordpress3.png",[104,10826,10827],{},"This screen will be the database setup. Enter the name of your database created on Step 3.",[104,10829,10830,10831,10834,10835,10837],{},"The default ",[1407,10832,10833],{},"username"," for XAMPP is ",[1233,10836,7902],{}," and you can create your own database user as well.",[104,10839,10840,10841,10844],{},"We have not set up the ",[1407,10842,10843],{},"password"," for XAMPP so we'll leave it a blank",[104,10846,10847],{},[641,10848],{"alt":10849,"src":10850},"wordpress4","/images/articles/wordpress4.png",[104,10852,10853,10854,10856,10857,452],{},"Since we are using the same local IP from hosts ",[1233,10855,10670],{}," we can leave it as localhost and you can change your TablePrefix on your preferences but I will leave it as is and click ",[1233,10858,10859],{},"Submit",[104,10861,10862,10863,10818],{},"After that, you need to click on the ",[1233,10864,10865],{},"Run the installation",[104,10867,10868],{},[641,10869],{"alt":10870,"src":10871},"wordpress5","/images/articles/wordpress5.png",[104,10873,10874,10875,10818],{},"Setup your wordpress site information and click on ",[1233,10876,10877],{},"Install WordPress",[104,10879,10880],{},[641,10881],{"alt":10882,"src":10883},"wordpress6","/images/articles/wordpress6.png",[104,10885,10886],{},"Once the installation is successful, you can now login to your dashboard and enjoy customizing your fresh and new site.",[104,10888,10889],{},[641,10890],{"alt":10891,"src":10892},"wordpress7","/images/articles/wordpress7.png",[104,10894,10895],{},"go to your homepage and check out your locally installed website",[104,10897,10898],{},[641,10899],{"alt":10900,"src":10901},"wordpress8","/images/articles/wordpress8.png",[99,10903,10905],{"id":10904},"troubleshooting-tips","Troubleshooting Tips",[104,10907,10908,10911,10912,10915,10916],{},[1233,10909,10910],{},"Port Conflicts:"," If Apache fails to start, it might be due to a port conflict. Change Apache’s port by going to the XAMPP Control Panel > Config > Apache (httpd.conf) and change ",[1407,10913,10914],{":style":10594},"Listen 80"," to another port like ",[1407,10917,10918],{":style":10594},"8080",[104,10920,10921,10924,10925,10928],{},[1233,10922,10923],{},"Forgotten Database Details:"," If WordPress can’t connect to the database, double-check the database name, username, and password in ",[1407,10926,10927],{":style":10594},"wp-config.php"," located in the WordPress folder",[99,10930,10932],{"id":10931},"wrapping-up","Wrapping Up",[104,10934,10935],{},"Congratulations! You’ve successfully installed WordPress locally using XAMPP. You can now experiment with WordPress themes, plugins, and customizations safely on your local machine.",[104,10937,10938],{},"Once you are able to learn on how to install WordPress locally using XAMPP vhost, it is a very easy cycle and you can setup new testing sites whenever you wanted.",[104,10940,10941],{},"As a developer, I use XAMPP and WordPress on almost a hundred sites to review and test a number of themes and plugins.",{"title":113,"searchDepth":135,"depth":135,"links":10943},[10944,10945,10946,10947,10948,10949,10950,10951],{"id":10492,"depth":135,"text":10493},{"id":10519,"depth":135,"text":10520},{"id":10529,"depth":135,"text":10530},{"id":10571,"depth":135,"text":10572},{"id":10620,"depth":135,"text":10621},{"id":10782,"depth":135,"text":10783},{"id":10904,"depth":135,"text":10905},{"id":10931,"depth":135,"text":10932},[622],"Step-by-step guide to installing WordPress locally on Windows with XAMPP and a vhost, so you can test themes and plugins without touching your live site.",{"slug":89,"isHowTo":218},"2024-11-11T04:45:00.000Z",{"title":87,"description":10953},[631,10958,2041],"xampp","w428LVdnDK5mMMovXdGkRdIN1RvPWN_MJ1Qk0io0nNA",{"id":94,"title":3,"body":10961,"categories":11338,"description":623,"extension":624,"meta":11339,"navigation":218,"ogImage":627,"path":91,"publish_at":628,"seo":11340,"stem":92,"tags":11341,"__hash__":632},{"type":96,"value":10962,"toc":11333},[10963,10965,10967,11085,11087,11089,11091,11111,11113,11115,11331],[99,10964,102],{"id":101},[104,10966,106],{},[108,10968,10969],{"className":110,"code":111,"language":112,"meta":113,"style":113},[115,10970,10971,10979,10989,11023,11029,11033,11037,11043,11049,11055,11061,11067,11073,11079],{"__ignoreMap":113},[118,10972,10973,10975,10977],{"class":120,"line":121},[118,10974,125],{"class":124},[118,10976,129],{"class":128},[118,10978,132],{"class":124},[118,10980,10981,10983,10985,10987],{"class":120,"line":135},[118,10982,138],{"class":124},[118,10984,142],{"class":141},[118,10986,145],{"class":124},[118,10988,149],{"class":148},[118,10990,10991,10993,10995,10997,10999,11001,11003,11005,11007,11009,11011,11013,11015,11017,11019,11021],{"class":120,"line":152},[118,10992,155],{"class":124},[118,10994,142],{"class":141},[118,10996,160],{"class":124},[118,10998,163],{"class":148},[118,11000,166],{"class":141},[118,11002,169],{"class":124},[118,11004,172],{"class":141},[118,11006,175],{"class":124},[118,11008,178],{"class":141},[118,11010,181],{"class":124},[118,11012,142],{"class":141},[118,11014,186],{"class":124},[118,11016,190],{"class":189},[118,11018,193],{"class":124},[118,11020,142],{"class":141},[118,11022,198],{"class":124},[118,11024,11025,11027],{"class":120,"line":201},[118,11026,138],{"class":124},[118,11028,206],{"class":148},[118,11030,11031],{"class":120,"line":209},[118,11032,212],{"class":124},[118,11034,11035],{"class":120,"line":215},[118,11036,219],{"emptyLinePlaceholder":218},[118,11038,11039,11041],{"class":120,"line":222},[118,11040,225],{"class":124},[118,11042,228],{"class":148},[118,11044,11045,11047],{"class":120,"line":231},[118,11046,225],{"class":124},[118,11048,236],{"class":148},[118,11050,11051,11053],{"class":120,"line":239},[118,11052,225],{"class":124},[118,11054,244],{"class":148},[118,11056,11057,11059],{"class":120,"line":247},[118,11058,225],{"class":124},[118,11060,252],{"class":148},[118,11062,11063,11065],{"class":120,"line":255},[118,11064,225],{"class":124},[118,11066,260],{"class":148},[118,11068,11069,11071],{"class":120,"line":263},[118,11070,225],{"class":124},[118,11072,268],{"class":148},[118,11074,11075,11077],{"class":120,"line":271},[118,11076,225],{"class":124},[118,11078,276],{"class":148},[118,11080,11081,11083],{"class":120,"line":279},[118,11082,225],{"class":124},[118,11084,284],{"class":148},[99,11086,288],{"id":287},[104,11088,291],{},[104,11090,294],{},[108,11092,11093],{"className":297,"code":298,"language":299,"meta":113,"style":113},[115,11094,11095],{"__ignoreMap":113},[118,11096,11097,11099,11101,11103,11105,11107,11109],{"class":120,"line":121},[118,11098,306],{"class":141},[118,11100,299],{"class":189},[118,11102,311],{"class":124},[118,11104,314],{"class":141},[118,11106,317],{"class":189},[118,11108,320],{"class":124},[118,11110,323],{"class":141},[99,11112,327],{"id":326},[104,11114,330],{},[108,11116,11117],{"className":297,"code":333,"language":299,"meta":113,"style":113},[115,11118,11119,11133,11149,11153,11167,11171,11179,11187,11201,11215,11225,11247,11285,11293,11297,11305,11313,11319],{"__ignoreMap":113},[118,11120,11121,11123,11125,11127,11129,11131],{"class":120,"line":121},[118,11122,340],{"class":128},[118,11124,343],{"class":124},[118,11126,346],{"class":148},[118,11128,349],{"class":124},[118,11130,352],{"class":141},[118,11132,355],{"class":124},[118,11134,11135,11137,11139,11141,11143,11145,11147],{"class":120,"line":135},[118,11136,360],{"class":141},[118,11138,363],{"class":189},[118,11140,343],{"class":124},[118,11142,368],{"class":148},[118,11144,349],{"class":124},[118,11146,373],{"class":148},[118,11148,376],{"class":124},[118,11150,11151],{"class":120,"line":152},[118,11152,381],{"class":124},[118,11154,11155,11157,11159,11161,11163,11165],{"class":120,"line":201},[118,11156,386],{"class":128},[118,11158,343],{"class":124},[118,11160,391],{"class":148},[118,11162,349],{"class":124},[118,11164,352],{"class":141},[118,11166,398],{"class":124},[118,11168,11169],{"class":120,"line":209},[118,11170,403],{"class":141},[118,11172,11173,11175,11177],{"class":120,"line":215},[118,11174,408],{"class":141},[118,11176,411],{"class":189},[118,11178,414],{"class":141},[118,11180,11181,11183,11185],{"class":120,"line":222},[118,11182,419],{"class":124},[118,11184,352],{"class":141},[118,11186,424],{"class":124},[118,11188,11189,11191,11193,11195,11197,11199],{"class":120,"line":231},[118,11190,429],{"class":141},[118,11192,432],{"class":189},[118,11194,435],{"class":141},[118,11196,438],{"class":124},[118,11198,441],{"class":148},[118,11200,444],{"class":124},[118,11202,11203,11205,11207,11209,11211,11213],{"class":120,"line":239},[118,11204,449],{"class":189},[118,11206,452],{"class":141},[118,11208,455],{"class":128},[118,11210,458],{"class":124},[118,11212,352],{"class":141},[118,11214,463],{"class":124},[118,11216,11217,11219,11221,11223],{"class":120,"line":247},[118,11218,468],{"class":189},[118,11220,452],{"class":141},[118,11222,473],{"class":128},[118,11224,476],{"class":124},[118,11226,11227,11229,11231,11233,11235,11237,11239,11241,11243,11245],{"class":120,"line":255},[118,11228,481],{"class":189},[118,11230,452],{"class":141},[118,11232,486],{"class":189},[118,11234,489],{"class":141},[118,11236,492],{"class":189},[118,11238,452],{"class":141},[118,11240,486],{"class":189},[118,11242,452],{"class":141},[118,11244,501],{"class":128},[118,11246,476],{"class":124},[118,11248,11249,11251,11253,11255,11257,11259,11261,11263,11265,11267,11269,11271,11273,11275,11277,11279,11281,11283],{"class":120,"line":263},[118,11250,508],{"class":124},[118,11252,511],{"class":189},[118,11254,452],{"class":141},[118,11256,516],{"class":189},[118,11258,519],{"class":124},[118,11260,452],{"class":141},[118,11262,524],{"class":141},[118,11264,458],{"class":124},[118,11266,529],{"class":148},[118,11268,519],{"class":124},[118,11270,452],{"class":141},[118,11272,536],{"class":128},[118,11274,458],{"class":124},[118,11276,541],{"class":148},[118,11278,519],{"class":124},[118,11280,452],{"class":141},[118,11282,455],{"class":128},[118,11284,476],{"class":124},[118,11286,11287,11289,11291],{"class":120,"line":271},[118,11288,554],{"class":141},[118,11290,557],{"class":189},[118,11292,560],{"class":124},[118,11294,11295],{"class":120,"line":279},[118,11296,565],{"class":124},[118,11298,11299,11301,11303],{"class":120,"line":568},[118,11300,571],{"class":124},[118,11302,574],{"class":189},[118,11304,444],{"class":124},[118,11306,11307,11309,11311],{"class":120,"line":579},[118,11308,582],{"class":141},[118,11310,411],{"class":189},[118,11312,414],{"class":141},[118,11314,11315,11317],{"class":120,"line":589},[118,11316,306],{"class":141},[118,11318,594],{"class":189},[118,11320,11321,11323,11325,11327,11329],{"class":120,"line":597},[118,11322,600],{"class":124},[118,11324,603],{"class":189},[118,11326,349],{"class":124},[118,11328,608],{"class":189},[118,11330,611],{"class":124},[613,11332,615],{},{"title":113,"searchDepth":135,"depth":135,"links":11334},[11335,11336,11337],{"id":101,"depth":135,"text":102},{"id":287,"depth":135,"text":288},{"id":326,"depth":135,"text":327},[622],{"slug":92,"isHowTo":218,"image":626},{"title":3,"description":623},[631],1790234433482]