Git for Ubuntu

Running a recent Git for Ubuntu can sometimes be problematic. The Git version in the offical Ubuntu archives lags behind the maintainers, stable, version. To solve this install the Maintainers team version.


In a corporate envrionment the case of an unverified key can rise a problem. Cause is that

apt-key adv --recv-keys ;

may not work behind some firewalls. to solve this issue, follow these steps:

  • Open in a Browser
  • and search for the offending key. Don’t forget to mark the string as hex by prepending 0x.
  • Get key from Ubuntu keyserver
  • Insert into a file
  • apt-key add <file>
  • apt-get update

For details see

HA Proxy as a reverse ssh proxy

If you want to hide a ssh service to the public use a reverse ssh proxy. Just as Apache can act as a reverse http / https proxy, so can HA Proxy act as a reverse ssh proxy.

Why just don’t use port forwarding? Well, suppose you have a service like GitLab or Stash to serve your upstream Git repository and you want to access your reverse proxy host and your service host by ssh on port 22? Then HAProxy is in my opinion the easiest option to forward the SSL service port to a backend server.

Bear in mind to upgrade your firewall on the proxy host.

Here is a sample configuration file.

# this config needs haproxy-1.1.28 or haproxy-1.2.1 # Customized to use a ssh proxy

log local0
#log local1 notice
#log loghost local0 info
maxconn 4096
user haproxy
group haproxy

log global
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000

frontend sshd
bind *: <port>

default_backend ssh
timeout client 1h

backend ssh
mode tcp
server <server-ip:check port


Shrink logic volume

In this post I will point out the steps to shrink logic volumes.

The order of shrinking is just the reverse of expanding:

  • un-mount the file system
  • check file system integrity
  • shrink file system
  • shrink logic volume.

The steps in detail

1. First un-mount the file system to make sure no one has access anymore. For some file systems you must switch to single user mode for this. Then check the file system integrity.

# /yyy is the mount point
sudo umount /yyy
# This is the logical volume. vg-xxx is the volume group
# and yyy is the symbolic name of the lv.
sudo e2fsck -f /dev/mapper/vg-xxx/yyy

2. Shrink the file system to some point

sudo resize2fs /dev/mapper/vg-xxx/yyy 2000M

Here it goes down to 2G, but above the physical size of existing files. This command works for both ext2 and ext3.

3. Shrink the logic volume

sudo lvresize -L -1G /dev/mapper/vg-xxx/yyy

Here the logic volume is shrunk by 1G. Don’t shrink beyond your file system size, the consequences are disatrous. Do the math.

4. Expand the file system to fit the shrunk logic volume

sudo resize2fs -p /dev/mapper/vg-xxx/yyy

5. Remount the file system.

Expand logic volume

Logical volumes are easy to extend. The basic steps are like this: check free space –> expand logic volume –> expand file system. You can do it even with file system mounted.

Although I recommend to make a backup first and switch to single user mode  if it is a server.

Here’s the recipe:

1. Check the mounted file system with

df -h

2. Check the available logic volumes

sudo lvdisplay

3. Check how much free space available in this volume group for the growth

sudo vgdisplay

4. Now resize the logic volume up to some point (of course within the free space limit)

sudo lvresize -L +1GB /dev/mapper/vg-xxx/yyy

5. Check the new size of the logic volume

sudo lvdisplay

6. Expand the existing file system to the size of logic volume

sudo resize2fs -p /dev/mapper/vg-xxx/yyy

This command works for both ext2 and ext3 file systems.

Volume layout

Here’s my personal preference for an allround Linux box. The following volume layout is a baseline. If the machine is a server reduce /home and add much more to /var where normally you data lives. For a development box increase /home for all your projects.

I use the lvm2 package, so these commands use the most common options.

First harddrive:

With fdisk /dev/sda

  1. /dev/sda1 -> /boot ext3, 256MB
  2. /dev/sda2 -> pvcreate /dev/sda2  -> vgcreate vg0 /dev/sda

With lvm2 tools

  1. pvcreate /dev/sda2
  2. vgcreate vg0 /dev/sda
  3. lvcreate -L 2G – n root vg0 -> ext3 mount on /
  4. lvcreate -L <depending on memory and disksize> -n swap vg0 -> use as swaparea
  5. lvcreate -L 2G -n usr vg0 -> ext3 mount on /usr
  6. lvcreate -L 512M -n tmp -vg0 > ext3, mount on /tmp
  7. lvcreate -L <512M – 2G> -n home vg0 -> ext3, mount on /home
  8. lvcreate -L 256M -n opt vg0 -> ext3, mount on /opt
  9. lvcreate -L 512M -n usrlocal vg0 -> ext3, mount on /usrlocal
  10. lvcreate -L <1G – nG> -n var vg0 -> ext3, mount on /var

Additional harddisks

/dev/sd[b..z] -> extend pv and use where the bulk data is, normally var

Linux File System

This is just a short example how I use the Linux file system. A full discussion with lot’s of links you will find on Wikipedia. The home of the Linux File System Hierarchy is here.
The layout below is the (almost) default of Debian and Ubuntu distributions.



Just for personal settings, annotations  and workspaces.


Classic place to put everything short living. Probably best to (automatically) clean it out regularly.


Static and dynamic websites


Database data-files, if big put on its own logical volume.


Any other non-web, non-db data or archive files.


Other distributions use slightly different file system layouts and the data-files are maybe in different folders, but as mentioned earlier this is my personal approach.