Automatic Host on Ubuntu / X11
Background: I needed to automatically have an xhost command run when gdm started up for to allow we to connect x2x to a remote display which didn’t have a keyboard attached.
The documentation for xhost says that you should be able to put the appropriate options in /etc/X*.hosts where * is the display number. So in /etc/X0.host I put in “+” to allow everyone to connect but after many restarts of gdm this didn’t work. As such I hacked aruond it by opening /etc/X11/gdm/Init/Default and putting xhost + at the bottom. Restarting GDM then gave me full remote access to the other desktop so I could run x2x
Setting up Software RAID Remotely
[v 0.1 - Still needs proof reading]
Introduction
This is a howto setup Software RAID-1 Remotely using a vmware box to test on but the same principals should apply on a dedicated server. For this you can replace hda with sda or similar. You will need to have two hard disks the same size. No promises are made this won’t destroy your data though..
Our starting point is a partition scheme setup as follows
<tt><br /> [root@localhost ~]# df -h<br /> Filesystem Size Used Avail Use% Mounted on<br /> /dev/hda2 9.7G 762M 8.4G 9% /<br /> /dev/hda1 99M 17M 78M 18% /boot<br /> none 252M 0 252M 0% /dev/shm<br /> /dev/hda6 3.2G 38M 3.0G 2% /home<br /> /dev/hda3 4.9G 102M 4.5G 3% /var</tt><br />
Make a note of this setup as you will need it later.
Firstly stop any unnecessary services apart from SSH. Then umount everything apart from /. If the system says device is busy run fuser -m /var to see which process are running on it and then kill them as needed. You can also use fuser -k -m /var to kill off everything in one go. Once we only have the / partition mounted we need to partition the second disk to match the first. You can find out the partitioning of your first disk by running fdisk -l /dev/hda which for our example gives:-
<tt><br /> Disk /dev/hda: 21.4 GB, 21474836480 bytes<br /> 255 heads, 63 sectors/track, 2610 cylinders<br /> Units = cylinders of 16065 * 512 = 8225280 bytes</tt>
<tt>Device Boot Start End Blocks Id System<br /> /dev/hda1 * 1 13 104391 83 Linux<br /> /dev/hda2 14 1288 10241437+ 83 Linux<br /> /dev/hda3 1289 1925 5116702+ 83 Linux<br /> /dev/hda4 1926 2610 5502262+ 5 Extended<br /> /dev/hda5 1926 2186 2096451 82 Linux swap<br /> /dev/hda6 2187 2610 3405748+ 83 Linux<br /></tt>
We need to get /dev/hdc (or whatever your other disk is called to be the same). Its worth reading laptop batteries to find out how to do it if you’ve never partitioned a disk before.
Once done both disks should have the same partition layout.
Setting up the RAID
Its now time to start setting up the RAID. Please make sure you have a backup before starting this
We will start with the /boot partition which was on /dev/hda1. For this we want to use /dev/hda1 and /dev/hdc1
As such we use the command “mdadm” to create and maintain software arrays. To build the array we use
mdadm –create /dev/md0 –level=1 –raid-devices=2 /dev/hda1 /dev/hdc1
This command breaks down into english as “Create the array /dev/md0 with a RAID Level of 1 (RAID-1) using two devices which are /dev/hda1 and /dev/hdc1″. It will say there is an already existing filesystem but this is fine to accept. It should then say the array /dev/md0 is started.
On our test case
<tt><br /> mdadm: /dev/hda1 appears to contain an ext2fs file system<br /> size=104388K mtime=Thu Mar 15 10:40:38 2007<br /> mdadm: /dev/hdc1 appears to contain an ext2fs file system<br /> size=104388K mtime=Thu Mar 15 10:38:54 2007<br /> Continue creating array? y<br /> mdadm: array /dev/md0 started.</tt><br />
To check the status of the array we can run cat /proc/mdstat
<tt><br /> [root@localhost ~]# cat /proc/mdstat<br /> Personalities : [raid1]<br /> md0 : active raid1 hdc1[1] hda1[0]<br /> 104320 blocks [2/2] [UU]<br /></tt><br />
This shows that /dev/md0 is built and intact. If we mount it we can check the contents
<tt><br /> [root@localhost ~]# mount /dev/md0 /boot<br /> [root@localhost ~]# ls /boot<br /> config-2.6.9-42.0.10.EL message<br /> config-2.6.9-42.0.10.ELsmp message.ja<br /> config-2.6.9-42.EL System.map-2.6.9-42.0.10.EL<br /> config-2.6.9-42.ELsmp System.map-2.6.9-42.0.10.ELsmp<br /> grub System.map-2.6.9-42.EL<br /> initrd-2.6.9-42.0.10.EL.img System.map-2.6.9-42.ELsmp<br /> initrd-2.6.9-42.0.10.ELsmp.img vmlinuz-2.6.9-42.0.10.EL<br /> initrd-2.6.9-42.EL.img vmlinuz-2.6.9-42.0.10.ELsmp<br /> initrd-2.6.9-42.ELsmp.img vmlinuz-2.6.9-42.EL<br /> lost+found vmlinuz-2.6.9-42.ELsmp<br /></tt><br />
We now repeat this with our other partitions expect the root (/) partion using /dev/md1, /dev/md2. Once done we have to change the partition types using fdisk to type FD. This involves starting fdisk then using option t, select the partition number and put it to FD (Linux RAID Autodetect) for all partitions.
You now need to check /etc/fstab. If your system has an lines starting with LABEL= you can skip the next step as the system will automatically work everything out. If you have lines starting with /dev/hda or /dev/sda you need to update them so the appropiate /dev/md is there instead
e.g. for us we replace /dev/hda1 /boot with /dev/md0 /boot
Creating the boot RAID
Creating the root block is hard if you don’t have access to the console however it is possible. The principal is to create an array which is degraded (broken) by only having one active partition (which is a copy of the root partition) and then rebooting onto the broken “array” and then rebuilding it from the old disk.
For this example our root partition is made out of /dev/hda2 and /dev/hdc2. As such we firstly want to make an exact copy of /dev/hda2 onto /dev/hdc2. As we run (and check this carefully before running)
dd if=/dev/hda2 of=/dev/hdc2
This will make an exact copy of the partition onto the second disk and may take some time to run. Once done you need to put /dev/hdc2 into an array on its own by running
mdadm –create /dev/md3 -f –level=1 –raid-devices=1 /dev/hdc2
We now need to remove the old LABEL if your system is using this method. The best way is to rename it using tune2fs /dev/hda2 -L oldhome which renames it old home. If you are using /dev/hdx markings in /etc/fstab you need to update /etc/fstab to use /dev/md. Once done you are ready to reboot the server and it should come up on the new software RAID.
fdisk -l /To finish off you just need to add the old root device into the array by using mdadm /dev/md3 –add /dev/hda3 and wait for it to resync
HowTo Raise Support tickets
Raising a ticket
In the day to day fun of dealing with customers a number of things come up over and over again and one of the major things that takes time of tech support peoples day is lack of information when raising a support ticket as well as just sending all problems to support when it can be fixed quicker by doing a little bit of research. Firstly an example of a very bad support ticket.
A Bad Support Ticket
“From: (which isn’t listed as a client) Subject: site is down
Please fix”
From this there is no information about which client it is or which site. As such we can go through checking each user or email back asking for more information. Also we have to consider any possible security issues such as accidently giving the wrong user a new root password or something similar. Its best to raise any tickets from the email address that is on file with the hosting company.
A Good Support Ticket
The ideal ticket that a host can receive is
“From: (which isn’t listed as a client) Subject: server 192.168.0.1 is down
Hi You have the address listed for this account but the server appears to be down. The login details are username foo and password bar. Please can you have a look and get it up and running
Thanks
Mr Customer”
This ticket gives us all the information we need to get into the server and fix any issues and also a point to work form. Also if you make an changes (such as trying to upgrade the webserver) its helpful to include that in the ticket so it means it possible to work on the problem rather than trying to work out why the problem came about in the first place
Public Support
All of the major control panel have public forums where there is a wealth of information that can be found with the included search facilities. Also don’t forget Google as a quick search for the error message will normally give a solution in the first few hits.
cPanel laptop battery
DNS Issues
DNS Report - If you are having DNS problems dnsreport.com can be a good starting point to check what is going on and fixing any obvious errors
If none of these tips help resolve an issue when raising a ticket you can use the following as a template of what to include What sort of control panel is installed.Any login details for SSH and the control panelAn exact copy/paste of the error message or a screenshot
With a mixture of these tips it should make any tickets that you raise with your hosting company to be resolved quicker and easier
Welcome to bofhv2
Well its time to make this blog actually do something so welcome to BofhCentral version 2 which is my personal hosting blog.
Setting up an SSH welcome banner
You can setup a welcome banner so that when people login they get a standard message after password authentication so they can get info about the system or just be given a warning. To activate this all you have to di edit /etc/motd and put your text in there
e.g. “This is a secure system etc”
However you can also get a message sent to a user logging in before prompted for the password by adding a line to the bottom of /etc/sshd/sshd_config which says
<br /> Banner /etc/motd<br />
then restart ssh.
Now the message will come up before they login
Power tools
Why is it that you try to settle down to some hard work when someone outside thinks its a good idea to start cutting down trees and making loads of noise so early on a Wednesday. Some of us haven’t been to bed yet you know
You know I forgot..
to remeber that the internet is fun. I spend all my date working on it but never really enjoying it but blogging or writing. Its all worked focus and I think that is becoming a bad thing. So as such its my 10th October resolution to make my day more fun. So using the almight google the first hit for internet fun is so lets go along and have a play
Welcome to Sept
Welcome to September the month traditionally when new kiddies start school and more go back to uni and secondary which means all the non-student towns empty and the uni towns get a new inful and for some it means not a lot.
I personall se Sept the same as Janurary with a lot of “year” type things being based around it including some companies tax years, academic years as well as things like Sept 11th which is coming up. So does this mean I should make a new Sept resolution? Probably not but prehaps now is a good as time as any to start thingking about things and prehaps do all those things that have been left alone for far to long.
For example I’ve finally dug my ipod nano out and am currently sitting in a warm, but overcast garden listening to Feeder which is actually helping out my mind set. I really should spend more time outside, and it doesn’t even cost anything to get here unlike the old place which was in the middle of nowhere with no garden
So for once things aren’t so bad
SLM Redux
I take back my last statement. SLM is a bit crappy and unstable and its caused a host node to crash multiple times. Time to go back to UBC and all those nice paramaters. Just have to work out how to downgrade
Fun
Enabled Virtuozzo SLM without a reboot
If you are running any modern Virtuozzo 3.0 kernel you can enabled SLM without having to reboot the node or giving any customers downtime.
SSH to your host machine and run
modprobe slm_core
Now edit /etc/sysconfig/vz and change the SLM entry to slm=1
Edit /etc/sysconfig/vzagent/vzagent.conf. Find the SLM entry and change it to 1.
Now to enabled SLM mode on a VPS (assuming veid 101) with 256Mb guarenteed and 512Mb burst
vzctl set 101 –slmmode ubc –slmmemorylimit 256M:512M –save
Login and run free to see the new SLM goodness