<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>lvm &amp;mdash; LinuxPizza</title>
    <link>https://blogs.linux.pizza/tag:lvm</link>
    <description>Personal notes and occasional posts - 100% human, 0% AI generated</description>
    <pubDate>Sat, 24 Oct 2026 06:14:18 +0000</pubDate>
    <item>
      <title>Random stuff cheat-sheet</title>
      <link>https://blogs.linux.pizza/random-stuff-cheat-sheet</link>
      <description>&lt;![CDATA[LVM stuff&#xA;&#xA;WARNING: PV /dev/sda2 in VG vg0 is using an old PV header, modify the VG to update.&#xA;Update the metadata with the vgck command - where the &#34;vg0&#34; is your own pool.&#xA;vgck --updatemetadata vg0&#xA;curl stuff&#xA;Curl a specific IP with a another host-header&#xA;curl -H &#34;Host: subdomain.example.com&#34; http://172.243.6.400/&#xA;git stuff&#xA;tell git.exe to use the built-in CA-store in Windows&#xA;git config --global http.sslBackend schannel&#xA;random stuff&#xA;See which process is using a file&#xA;fuser file&#xA;Import RootCert into Java-keystore example&#xA;sudo /usr/lib/java/jdk8u292-b10-jre/bin/keytool -import -alias some-rootcert -keystore /usr/lib/java/jdk8u292-b10-jre/lib/security/cacerts -file /usr/share/ca-certificates/extra/someRoot.crt`&#xA;&#xA;Apache2 configs example&#xA;Enable AD-authentication for web-resources&#xA;Location /&#xA;   AuthName &#34;AD authentication&#34;&#xA;   AuthBasicProvider ldap&#xA;   AuthType Basic&#xA;   AuthLDAPGroupAttribute member&#xA;   AuthLDAPGroupAttributeIsDN On&#xA;   AuthLDAPURL ldap://IP:389/OU=Users,OU=pizza,DC=linux,DC=pizza? &#xA;   sAMAccountName?sub?(objectClass=)&#xA;   AuthLDAPBindDN cn=tomcat7,ou=ServiceAccounts,ou=Users,OU=pizza,dc=linux,dc=pizza&#xA;  AuthLDAPBindPassword &#34;exec:/bin/cat /etc/apache2/ldap-password.conf&#34;&#xA;  Require ldap-group &#xA;  CN=somegroup,OU=Groups,OU=pizza,DC=linux,DC=pizza&#xA;  ProxyPass &#34;http://localhost:5601/&#34;&#xA;  ProxyPassReverse &#34;http://localhost:5601/&#34;&#xA;&#xA;/Location&#xA;&#xA;Insert Matomo tracking script in Apache using modsubstitute&#xA;AddOutputFilterByType SUBSTITUTE text/html&#xA;Substitute &#34;s-/head-script type=\&#34;text/javascript\&#34;var paq = paq || [];paq.push([&#39;trackPageView&#39;]);paq.push([&#39;enableLinkTracking&#39;]);(function() {var u=\&#34;https://matomo.example.com/\&#34;;paq.push([&#39;setTrackerUrl&#39;, u+&#39;matomo.php&#39;]);paq.push([&#39;setSiteId&#39;, &#39;1&#39;]);var d=document, g=d.createElement(&#39;script&#39;), s=d.getElementsByTagName(&#39;script&#39;)[0];g.type=&#39;text/javascript&#39;; g.async=true; g.defer=true; g.src=u+&#39;matomo.js&#39;; s.parentNode.insertBefore(g,s);})();/script/head-n&#34;&#xA;Load balance backend-servers&#xA;Proxy balancer://k3singress&#xA;&#x9;BalancerMember http://x.x.x.1:80&#xA;&#x9;BalancerMember http://x.x.x.2:80&#xA;&#x9;BalancerMember http://x.x.x.3:80&#xA;&#x9;BalancerMember http://x.x.x.4:80&#xA;&#x9;ProxySet lbmethod=bytraffic&#xA;&#x9;ProxySet connectiontimeout=5 timeout=30&#xA;&#x9;SetEnv force-proxy-request-1.0 1&#xA;&#x9;SetEnv proxy-nokeepalive 1&#xA;/Proxy&#xA;       ProxyPass &#34;/&#34; &#34;balancer://k3singress/&#34;&#xA;       ProxyPassReverse &#34;/&#34; &#34;balancer://k3singress/&#34;&#xA;       ProxyVia Full&#xA;       ProxyRequests On&#xA;       ProxyPreserveHost On&#xA;Basic Apache-config for PHP-FPM&#xA;VirtualHost :80&#xA;  ServerName www.example.com&#xA;  DocumentRoot /srv/www.example.com/htdocs&#xA;  Directory /srv/www.example.com/htdocs&#xA;    AllowOverride All&#xA;    Require all granted&#xA;    DirectoryIndex index.html index.htm index.php&#xA;    FilesMatch &#34;\.php$&#34;&#xA;      SetHandler proxy:unix:/run/php/www.example.com.sock|fcgi://localhost&#xA;    /FilesMatch&#xA;  /Directory&#xA;  SetEnvIf x-forwarded-proto https HTTPS=on&#xA;/VirtualHost&#xA;Basic PHP-fpm pool&#xA;[www.example.com]&#xA;user = USER&#xA;group = GROUP&#xA;&#xA;listen = /var/run/php/$pool.sock&#xA;&#xA;listen.owner = www-data&#xA;listen.group = www-data&#xA;&#xA;pm = ondemand&#xA;pm.processidletimeout = 10&#xA;pm.maxchildren = 1&#xA;&#xA;chdir = /&#xA;&#xA;phpadminvalue[sendmailpath] = /usr/sbin/sendmail -t -i -f no-reply@ftp.selea.se&#xA;phpadminvalue[mail.log] = /srv/ftp.selea.se/log/mail.log&#xA;phpadminvalue[openbasedir] = /srv/ftp.selea.se:/tmp&#xA;phpadminvalue[memorylimit] = 64M&#xA;phpadminvalue[uploadmaxfilesize] = 64M&#xA;phpadminvalue[postmaxsize] = 64M&#xA;phpadminvalue[maxexecutiontime] = 180&#xA;phpadminvalue[maxinputvars] = 1000&#xA;&#xA;phpadminvalue[disablefunctions] = passthru,exec,shellexec,system,procopen,popen,curlexec,curlmultiexec,parseinifile,showsource,mail&#xA;Netplan - use device MAC instead of /etc/machine-id for DHCP&#xA;network:&#xA;  ethernets:&#xA;    eth0:&#xA;      dhcp4: true&#xA;      dhcp-identifier: mac&#xA;  version: 2&#xA;HPs apt repo for various utilities for proliant machines &#xA;deb http://downloads.linux.hpe.com/SDR/repo/mcp buster/current non-free&#xA;psql stuff&#xA;CREATE DATABASE yourdbname;&#xA;CREATE USER youruser WITH ENCRYPTED PASSWORD &#39;yourpass&#39;;&#xA;GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;&#xA;&#xA;Get entity for AD/SMB based user so you can put it in getent passwd USERNAME&#xA;Nicely shutdown NetApp cluster&#xA;system node autosupport invoke -node  -type all -message &#34;MAINT=48h Power Maintenance&#34;&#xA;system node halt -node  -skip-lif-migration-before-shutdown true -ignore-quorum-warnings true -inhibit-takeover true&#xA;Allow a process to listen on ports 0-1000 in systemd.service file&#xA;[Service]&#xA;AmbientCapabilities=CAPNETBINDSERVICE&#xA;&#xA;#linux #kubernetes #netplan #php-fpm #apache #LVM&#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<h4 id="lvm-stuff" id="lvm-stuff">LVM stuff</h4>

<pre><code>WARNING: PV /dev/sda2 in VG vg0 is using an old PV header, modify the VG to update.
</code></pre>

<p>Update the metadata with the vgck command – where the “vg0” is your own pool.</p>

<pre><code>vgck --updatemetadata vg0
</code></pre>

<h4 id="curl-stuff" id="curl-stuff">curl stuff</h4>

<p>Curl a specific IP with a another host-header</p>

<pre><code>curl -H &#34;Host: subdomain.example.com&#34; http://172.243.6.400/
</code></pre>

<h4 id="git-stuff" id="git-stuff">git stuff</h4>

<p>tell git.exe to use the built-in CA-store in Windows</p>

<pre><code>git config --global http.sslBackend schannel
</code></pre>

<h4 id="random-stuff" id="random-stuff">random stuff</h4>

<p>See which process is using a file</p>

<pre><code>fuser file
</code></pre>

<h4 id="import-rootcert-into-java-keystore-example" id="import-rootcert-into-java-keystore-example">Import RootCert into Java-keystore example</h4>

<pre><code>sudo /usr/lib/java/jdk8u292-b10-jre/bin/keytool -import -alias some-rootcert -keystore /usr/lib/java/jdk8u292-b10-jre/lib/security/cacerts -file /usr/share/ca-certificates/extra/someRoot.crt`
</code></pre>

<h2 id="apache2-configs-example" id="apache2-configs-example">Apache2 configs example</h2>

<h4 id="enable-ad-authentication-for-web-resources" id="enable-ad-authentication-for-web-resources">Enable AD-authentication for web-resources</h4>

<pre><code>&lt;Location /&gt;
   AuthName &#34;AD authentication&#34;
   AuthBasicProvider ldap
   AuthType Basic
   AuthLDAPGroupAttribute member
   AuthLDAPGroupAttributeIsDN On
   AuthLDAPURL ldap://IP:389/OU=Users,OU=pizza,DC=linux,DC=pizza? 
   sAMAccountName?sub?(objectClass=*)
   AuthLDAPBindDN cn=tomcat7,ou=ServiceAccounts,ou=Users,OU=pizza,dc=linux,dc=pizza
  AuthLDAPBindPassword &#34;exec:/bin/cat /etc/apache2/ldap-password.conf&#34;
  Require ldap-group 
  CN=some_group,OU=Groups,OU=pizza,DC=linux,DC=pizza
  ProxyPass &#34;http://localhost:5601/&#34;
  ProxyPassReverse &#34;http://localhost:5601/&#34;

&lt;/Location&gt;

</code></pre>

<h4 id="insert-matomo-tracking-script-in-apache-using-mod-substitute" id="insert-matomo-tracking-script-in-apache-using-mod-substitute">Insert Matomo tracking script in Apache using mod_substitute</h4>

<pre><code>AddOutputFilterByType SUBSTITUTE text/html
Substitute &#34;s-&lt;/head&gt;-&lt;script type=\&#34;text/javascript\&#34;&gt;var _paq = _paq || [];_paq.push([&#39;trackPageView&#39;]);_paq.push([&#39;enableLinkTracking&#39;]);(function() {var u=\&#34;https://matomo.example.com/\&#34;;_paq.push([&#39;setTrackerUrl&#39;, u+&#39;matomo.php&#39;]);_paq.push([&#39;setSiteId&#39;, &#39;1&#39;]);var d=document, g=d.createElement(&#39;script&#39;), s=d.getElementsByTagName(&#39;script&#39;)[0];g.type=&#39;text/javascript&#39;; g.async=true; g.defer=true; g.src=u+&#39;matomo.js&#39;; s.parentNode.insertBefore(g,s);})();&lt;/script&gt;&lt;/head&gt;-n&#34;
</code></pre>

<h4 id="load-balance-backend-servers" id="load-balance-backend-servers">Load balance backend-servers</h4>

<pre><code>&lt;Proxy balancer://k3singress&gt;
	BalancerMember http://x.x.x.1:80
	BalancerMember http://x.x.x.2:80
	BalancerMember http://x.x.x.3:80
	BalancerMember http://x.x.x.4:80
	ProxySet lbmethod=bytraffic
	ProxySet connectiontimeout=5 timeout=30
	SetEnv force-proxy-request-1.0 1
	SetEnv proxy-nokeepalive 1
&lt;/Proxy&gt;
       ProxyPass &#34;/&#34; &#34;balancer://k3singress/&#34;
       ProxyPassReverse &#34;/&#34; &#34;balancer://k3singress/&#34;
       ProxyVia Full
       ProxyRequests On
       ProxyPreserveHost On
</code></pre>

<h4 id="basic-apache-config-for-php-fpm" id="basic-apache-config-for-php-fpm">Basic Apache-config for PHP-FPM</h4>

<pre><code>&lt;VirtualHost *:80&gt;
  ServerName www.example.com
  DocumentRoot /srv/www.example.com/htdocs
  &lt;Directory /srv/www.example.com/htdocs&gt;
    AllowOverride All
    Require all granted
    DirectoryIndex index.html index.htm index.php
    &lt;FilesMatch &#34;\.php$&#34;&gt;
      SetHandler proxy:unix:/run/php/www.example.com.sock|fcgi://localhost
    &lt;/FilesMatch&gt;
  &lt;/Directory&gt;
  SetEnvIf x-forwarded-proto https HTTPS=on
&lt;/VirtualHost&gt;
</code></pre>

<h4 id="basic-php-fpm-pool" id="basic-php-fpm-pool">Basic PHP-fpm pool</h4>

<pre><code>[www.example.com]
user = USER
group = GROUP

listen = /var/run/php/$pool.sock

listen.owner = www-data
listen.group = www-data

pm = ondemand
pm.process_idle_timeout = 10
pm.max_children = 1

chdir = /

php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f no-reply@ftp.selea.se
php_admin_value[mail.log] = /srv/ftp.selea.se/log/mail.log
php_admin_value[open_basedir] = /srv/ftp.selea.se:/tmp
php_admin_value[memory_limit] = 64M
php_admin_value[upload_max_filesize] = 64M
php_admin_value[post_max_size] = 64M
php_admin_value[max_execution_time] = 180
php_admin_value[max_input_vars] = 1000

php_admin_value[disable_functions] = passthru,exec,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source,mail
</code></pre>

<h3 id="netplan-use-device-mac-instead-of-etc-machine-id-for-dhcp" id="netplan-use-device-mac-instead-of-etc-machine-id-for-dhcp">Netplan – use device MAC instead of /etc/machine-id for DHCP</h3>

<pre><code>network:
  ethernets:
    eth0:
      dhcp4: true
      dhcp-identifier: mac
  version: 2
</code></pre>

<h4 id="hps-apt-repo-for-various-utilities-for-proliant-machines" id="hps-apt-repo-for-various-utilities-for-proliant-machines">HPs apt repo for various utilities for proliant machines</h4>

<pre><code>deb http://downloads.linux.hpe.com/SDR/repo/mcp buster/current non-free
</code></pre>

<h4 id="psql-stuff" id="psql-stuff">psql stuff</h4>

<pre><code>CREATE DATABASE yourdbname;
CREATE USER youruser WITH ENCRYPTED PASSWORD &#39;yourpass&#39;;
GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;
</code></pre>

<p>Get entity for AD/SMB based user so you can put it in <code>/etc/passwd</code>:</p>

<pre><code>getent passwd USERNAME
</code></pre>

<p>Nicely shutdown NetApp cluster</p>

<pre><code>system node autosupport invoke -node * -type all -message &#34;MAINT=48h Power Maintenance&#34;
system node halt -node * -skip-lif-migration-before-shutdown true -ignore-quorum-warnings true -inhibit-takeover true
</code></pre>

<p>Allow a process to listen on ports 0-1000 in systemd.service file</p>

<pre><code>[Service]
AmbientCapabilities=CAP_NET_BIND_SERVICE
</code></pre>

<p><a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a> <a href="https://blogs.linux.pizza/tag:kubernetes" class="hashtag"><span>#</span><span class="p-category">kubernetes</span></a> <a href="https://blogs.linux.pizza/tag:netplan" class="hashtag"><span>#</span><span class="p-category">netplan</span></a> <a href="https://blogs.linux.pizza/tag:php" class="hashtag"><span>#</span><span class="p-category">php</span></a>-fpm <a href="https://blogs.linux.pizza/tag:apache" class="hashtag"><span>#</span><span class="p-category">apache</span></a> <a href="https://blogs.linux.pizza/tag:LVM" class="hashtag"><span>#</span><span class="p-category">LVM</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/random-stuff-cheat-sheet</guid>
      <pubDate>Fri, 30 Jun 2023 07:53:42 +0000</pubDate>
    </item>
    <item>
      <title> Expanding the drive on a live Linux system</title>
      <link>https://blogs.linux.pizza/expanding-the-drive-on-a-live-linux-system</link>
      <description>&lt;![CDATA[This assumes that you are running your Linuxsystem as a virtual server on VMWare, KVM, XEN or AHV. &#xA;Be sure to take a backup first! &#xA;&#xA;It is quite common - for me atleast - that a busy databaseserver is going to use more and more space. And in most cases it is not always that attractive to have to restart the server and resize it with a LiveCD such as gparted live.&#xA;&#xA;Luckily, there is possible to expand the partitions while your machine is running. I will try to guide you with this step to step guide on how you can successfully proceed with it:&#xA;&#xA;If you are using LVM, read until 12, and skip 13.&#xA;&#xA;First of all, add the storage in you hypervisor.&#xA;Next, you want to tell the kernel that to rescan the bulk device:&#xA;fdisk are now able to &#34;see&#34; the expanded disk, in this case Now, we need to do the actual expansion of the partinion, so we need to &#34;delete&#34; the partion and add it again via fdisk - dont worry, we are not going to write the changes to disk while the partinion is deleted:&#xA;Just to make sure, check the partinion by selecting Delete the partition by pressing Press Press Press Press 10. And lastly, doublecheck the changes by pressing 11. !The following actions will write the changes to disk!&#xA;Now, in order to make is real, press 12. Now, run 13. Now, we just need to expand the filesystem itself in order to actually use the newly added space:&#xA;&#xA;Verify with &#xA;Steps for if you are using LVM&#xA;I assume that you have done step 1-12 in the previous section.&#xA;&#xA;13. First, expand your physical volume: 14. Then, we will proceed with expanding the Logical volume, replace &#34;X1&#34; with the Logical Volume you want to extend:&#xA;15. After that is done, we have to expand the filesystem, again - replace &#34;X1&#34; with the Logical Volume you want to extend&#xA;&#xA;Verify with &#xA;You should be able to see the new size now.&#xA;&#xA;#linux #lvm #disk&#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<h4 id="this-assumes-that-you-are-running-your-linuxsystem-as-a-virtual-server-on-vmware-kvm-xen-or-ahv" id="this-assumes-that-you-are-running-your-linuxsystem-as-a-virtual-server-on-vmware-kvm-xen-or-ahv">This assumes that you are running your Linuxsystem as a virtual server on VMWare, KVM, XEN or AHV.</h4>

<h4 id="be-sure-to-take-a-backup-first" id="be-sure-to-take-a-backup-first">Be sure to take a backup first!</h4>

<p>It is quite common – for me atleast – that a busy databaseserver is going to use more and more space. And in most cases it is not always that attractive to have to restart the server and resize it with a LiveCD such as gparted live.</p>

<p>Luckily, there is possible to expand the partitions while your machine is running. I will try to guide you with this step to step guide on how you can successfully proceed with it:</p>

<h2 id="if-you-are-using-lvm-read-until-12-and-skip-13" id="if-you-are-using-lvm-read-until-12-and-skip-13">If you are using LVM, read until 12, and skip 13.</h2>
<ol><li>First of all, add the storage in you hypervisor.</li>
<li>Next, you want to tell the kernel that to rescan the bulk device:
<code>echo 1 &gt; /sys/class/block/sda/device/rescan</code>
fdisk are now able to “see” the expanded disk, in this case <code>/dev/sda</code></li>
<li>Now, we need to do the actual expansion of the partinion, so we need to “delete” the partion and add it again via fdisk – dont worry, we are not going to write the changes to disk while the partinion is deleted:
<code>fdisk /dev/sda</code></li>
<li>Just to make sure, check the partinion by selecting <code>p</code>, if the disk looks like it should, you may continue</li>
<li>Delete the partition by pressing <code>d</code></li>
<li>Press <code>n</code> to create a new partinion</li>
<li>Press <code>p</code> to chose “Primary Partition”</li>
<li>Press <code>1</code> to chose the partition number 1</li>
<li>Press <code>ENTER</code>twice</li>
<li>And lastly, doublecheck the changes by pressing <code>p</code>, note the difference from the first time you did it. You should see that the partition has been expanded.</li>
<li><strong>!The following actions will write the changes to disk!</strong>
Now, in order to make is real, press <code>w</code> in order to write the changes to disk, you will see a warning about that the partition table has been changed. Do not worry, it is expected.</li>
<li>Now, run <code>partprobe</code> (you have to install <code>parted</code> for this to work). If you are using an older kernel, you maybe would need to reboot if the <code>partprobe</code> task did not work.</li>
<li>Now, we just need to expand the filesystem itself in order to actually use the newly added space:
<code>resize2fs -p /dev/sda1</code></li></ol>

<p>Verify with <code>df -h</code> or <code>lsblk</code></p>

<h2 id="steps-for-if-you-are-using-lvm" id="steps-for-if-you-are-using-lvm">Steps for if you are using LVM</h2>

<h4 id="i-assume-that-you-have-done-step-1-12-in-the-previous-section" id="i-assume-that-you-have-done-step-1-12-in-the-previous-section">I assume that you have done step 1-12 in the previous section.</h4>
<ol><li>First, expand your physical volume: <code>pvresize /dev/sda1</code></li>
<li>Then, we will proceed with expanding the Logical volume, replace “X1” with the Logical Volume you want to extend:
<code>lvextend --extents +100%FREE /dev/vg0/X1</code></li>
<li>After that is done, we have to expand the filesystem, again – replace “X1” with the Logical Volume you want to extend
<code>resize2fs /dev/vg0/X1</code></li></ol>

<p>Verify with <code>df -h</code> or <code>lsblk</code></p>

<p>You should be able to see the new size now.</p>

<p><a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a> <a href="https://blogs.linux.pizza/tag:lvm" class="hashtag"><span>#</span><span class="p-category">lvm</span></a> <a href="https://blogs.linux.pizza/tag:disk" class="hashtag"><span>#</span><span class="p-category">disk</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/expanding-the-drive-on-a-live-linux-system</guid>
      <pubDate>Sat, 28 Sep 2019 20:59:47 +0000</pubDate>
    </item>
  </channel>
</rss>