All Posts

Apache HTTPD configuration to allow easy upgrading of OS

 mkdir /mnt/media/www/conf ln -s /mnt/media/www/conf /etc/httpd/conf.d/local /etc/httpd/conf.d/local.conf include conf.d/local/*.conf semanage fcontext -a -t httpd_sys_content_t "/mnt/media/www(/.*)?" semanage fcontext -a -t httpd_config_t "/mnt/media/www/conf(/.*)?" restorecon -Rv /mnt/media/www /mnt/media/www/conf/vhost_default.conf <VirtualHost _default_:*> ServerAdmin webmaster@localhost DocumentRoot /mnt/media/www/vhosts/default/html/ ErrorLog logs/default-error_log TransferLog logs/default-access_log <Directory "/mnt/media/www/vhosts"> AllowOverride None # Allow open access: Require all granted </Directory> <Directory "/mnt/media/www/vhosts/default/html"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost>

Howto setup a isolated installation network with dnsmasq pxeboot and on Fedora 15

Simple pxeboot environment on a Fedora 15 system. This is useful if machines you are trying to build are on a network that cannot see the internet. My particular case is a home server which I want to setup from a place that doesn’t have cabling. I will move it into the cupboard that does have cabling when done but for the time being it is more convenient to set it up on the desk in my bedroom. Unfortunately my bedroom doesn’t have network cabling so I need to create a few things for this to work. Since I am going to use my laptop as the installation server I will refer it as the ’laptop’ and the machine I am going to install onto as the ‘server’

KVM Serial console and VNC console

Configuration for libvirt to get serial and graphics working at the same time: virt-install \ --name centos6_golden \ --ram 2048 \ --arch x86_64 \ --vcpus 4 \ --disk path=/var/lib/libvirt/images/centos6_golden.disk,format=qcow2,sparse=true,size=24,bus=virtio \ --location http://repos.example.com/repos/centos/6.4/os/x86_64/ \ --hvm \ --accelerate \ --nographics \ --os-type linux \ --os-variant virtio26 \ --extra-args 'acpi=force noipv6 console=tty0 console=ttyS0,115200 ks=http://repos.example.com/kickstarts/el6.ks ksdevice=52:54:00:A8:7A:0A ip=192.168.122.10 gateway=192.168.122.1 netmask=255.255.255.0 dns=192.168.122.1 ' \ --network bridge:br250 \ --mac 52:54:00:A8:7A:0A Serial console in GRUB: serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1 terminal --timeout=15 serial console Change the kernel command line to attach ttys in the right spots. Remove rhgb and quiet and add the following to the kernel command line:

Easy OpenSSH VPN using tunneling

This is a simple VPN for those times when you want the ease of use of a VPN but only have a ssh server available. Both servers need to have ssh configured to allow tunnels. You need to change the configs for ssh under /etc/ssh Remote server sshd_config: PermitTunnel yes Local server ssh_config: Tunnel yes Remote server Setting up the tunnels requires you to use root when sshing. Since I don’t open my servers up to remote root logins I work around it by first creating a reverse tunnel from the remote server back to my home machine. You will need to forward your external ssh port on your broadband router to the ssh on your local machine. Then create the reverse tunnel like this.

webdiff

This is just a simple script for doing a diff of two web pages. #!/bin/bash TMP1=$(mktemp) TMP2=$(mktemp) wget -q $1 -O $TMP1 wget -q $2 -O $TMP2 diff $TMP1 $TMP2 rm -f $TMP1 $TMP2

Installing stock CentOS kernel on an OVH or Kimsufi server

I recently signed up for a small dedicated server at Kimsufi.co.uk for the grand price of £14 a month which I think is pretty good price for what you get. Brand Intel Model Celeron / Atom Frequency 1.20+ GHz Architecture 64 bits NIC FastEthernet Memory 2 GB Hard disk 1 TB FTP Backup 100 GB Bandwidth Heaps more than I need :-) The machine itself is nothing special but they do have remote management and you can install a variety of Linux and Windows operating systems. I am quite happy with their service and management tools but I wasn't happy with the fact that they run their own custom kernels on them. The kernel that they install is a 'grsec' hardened 3.2 kernel but this caused a variety of issues when doing 'yum update', mainly dependency issues. I Googled around and found a few different solutions on remotely installing CentOS which were all basically variations on the way I describe in a previous post using [grub to re-install](http://www.thegoldfish.org/2009/12/reinstall-centos-using-grub/). Whatever I tried with this including [using VNC](http://forum.ovh.co.uk/showthread.php?t=4991) and attempting a fully automated install with a tested kickstart file it would become unresponsive when rebooting into the OS the first time. Instead of all these methods I should have been thinking inside the box instead of outside it :-(

Set txqueuelen on virtual vnetX devices with libvirt

The txqueuelen is a value in the kernel on network interfaces that sets the transmit queue length. This value can be tuned for different work loads. In the case of modern networking the defaults can sometimes be changed to get better line speeds over ethernet. Most people will do this using a rc.local command to set it on the physical ethX devices like this. vim /etc/rc.local Add the following /sbin/ip link set eth0 txqueuelen 2500 This is a perfectly reasonable way of doing it but what happens when network interfaces appear after boot and the name is unknown before hand? This is exactly what happens with Libvirt vnetX interfaces. Ideally we would be able to get Libvirt to tune these interfaces when it creates them, but that level of control is yet to be implemented BZ#809172. Libvirt >= 0.8.0 has some hooks which enable you to run commands at specific times in the lifecycle of a guest which may be good for this but on RHEL 5 Libvirt is version 0.6.0 so I needed a different solution.

Reverting to a previous snapshot using Linux LVM

Reverting to a previous snapshot has been possible for over a year!!!!! How did I miss that ?? This has for a long time been one of my only real criticisms of LVM and I just discovered that it was quietly committed into the kernel back in 2.6.33 The command used to do the revert is contained within lvconvert. From the lvconvert man page: --merge Merges a snapshot into its origin volume. To check if your ker‐ nel supports this feature, look for 'snapshot-merge' in the out‐ put of 'dmsetup targets'. If both the origin and snapshot vol‐ ume are not open the merge will start immediately. Otherwise, the merge will start the first time either the origin or snap‐ shot are activated and both are closed. Merging a snapshot into an origin that cannot be closed, for example a root filesystem, is deferred until the next time the origin volume is activated. When merging starts, the resulting logical volume will have the origin's name, minor number and UUID. While the merge is in progress, reads or writes to the origin appear as they were directed to the snapshot being merged. When the merge finishes, the merged snapshot is removed. Multiple snapshots may be spec‐ ified on the commandline or a @tag may be used to specify multi‐ ple snapshots be merged to their respective origin. A quick check using the command ‘dmsetup targets’ shows that it is definitely in my kernel so I thought I would give it a quick run through and test it a lot. I created a testing logical volume and then put some data on it, took a snapshot, changed the data and then reverted to the snapshot. Here is what I did.

Turn off the Caps-Lock key

I HATE THE CAPS_LOCK KEY!!!! I don’t like it when people send me messages with full caps and I don’t like accidentally pressing it and then sending messages to other people who then think I am yelling at them. It also wastes too much keyboard space and is in an easy place to accidentally hit. Time to get rid of it. The following method is for Fedora 15 but will probably work on other Gnome 3 systems.

Linux network bond without restarting the network

This is quite handy to know if you need to create a new network bond on a live system without disrupting traffic. First of all create your bond configs in the normal way so that in the event of a reboot it will come back up working. See the Redhat documentation for how to do it in RHEL6. Now because we cannot just restart the networking to bring that up we need to construct it by hand. Let’s say our 2 interfaces we wish to bond are eth3 and eth4 and the bond we are going to create is bond1