Resize root partition on UEFI/GPT machines

It assumes you want to resize root partition (/) on a virtual machine and the partition you want to resize is the last one that has data. Swap would be ok if it’s last.

Example (disk already resized from 5GB to 20GB):

Disk /dev/sda: 41943040 sectors, 20.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 7DCC138E-820C-42FA-AFB4-3E9A89946AFB
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 10485726
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          194559   94.0 MiB    EF00
   2          194560         6639615   3.1 GiB     8300  root
   3         6639616        10483711   1.8 GiB     8200  swap
  1. resize the disk
  2. reboot?
  3. swapoff -a
  4. gdisk /dev/sda
  5. make all new sectors usable
    • go to expert mode with command ‘x’
    • use command ‘e’ to relocate backup data structures to the end of the disk
    • go back to menu (‘m’)
  6. delete partitions sda3 and sda2
  7. re-create partition sda2, type 8300
    • it should start from the same sector to preserve the data
    • leave some space at the end for the swap
  8. re-create sda3, type 8200
  9. optional: rename the partitions with the old (or new) names
  10. write parition table to disk
  11. mkswap /dev/sda3
  12. edit /ets/fstab and update UUID of the swap partition, it probably changed
  13. reboot
  14. resize2fs /dev/sda2

Clean URLs with Apache httpd

a la Caddy

Caddy server let’s you easily define implicit extensions for your server URLs. Check ext directive in it’s documentation.

Get the same result in apache httpd using rewrite rules

Configuration snippet
RewriteEngine On
# Auto ext, clean URLs
# -----
# .html
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !.*\.html$
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
# .php
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !.*\.php$
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

The story: If (1) the URI does not already end with the extension and (2) if it is not a folder with the same name and (3) if the file with the added extension actually exists, then it adds the extension

Later edit:  If the folder exists the rewriting is not done and therefore the index.html or index.php in the folder is served. If you want the file plus the added extention to have precedence over folder, comment out out the 2nd condition.

flag L|last stop processing rules after match. If you have other rules you need applied, remove it!

flag NC|nocase case-insensitive matching

Use the config snippet per VirtualHost. Or add it to your server global rewrite rules. Usually it’s the /etc/apache2/mods-enabled/rewrite.conf file. Don’t forget about RewriteOptions Inherit in your VirtualHost if you use the global configuration.

— tried and works with Apache 2.4