Archive for the “Unix general” Category

Everything that has to do with Unix and Linux systems

I am working for the last few days to finish the first release of a OpenVZ installer.

This OpenVZ installer will be for the start a script write in Bash which will download, check and install from A to Z a OpenVZ server including downloading a few templates.

The script will be released under a GPLv3 license so it will be free.

Project name: OVZinstall

General functions:

- Check if OS is supported and select installation type for the installed OS

- Import repositories

- Check if OpenVZ is already installed

- Check the CPU type and memory available and download/install appropriate kernel

- Set values in sysctl.conf

- Install vzctl, vzquota etc. packages

- Download a few templates

The script will save a log file under /var/log/openvz-install.log so if there will be any issues during the install we will know why.

The first release will be available only for x86 systems, will try later to add 64bit also.

The idea is that the script is supposed to save some time if you have to install plain OpenVZ servers.

Currently it was tested on Debian 4 and Centos 5 OSs and seems to be doing the job just fine.

During the following week i am planing to test it on Centos 4.7 and Fedora Core OSs also .

A small issue at the moment is that i can’t test it against a system with over 4Gb of RAM and/or running a Quad core CPU as i don’t have this hardware just laying around. Would be helpful if someone has access to this hardware and wants to test it and provide me with the output.

Any input is appreciated.

Comments No Comments »

Building akernel is not as hard as many may think it is actually pretty easy and stright forward of course if you know what you are doing, but after doing this a few times(even if you don’t get it right from the first time) you will see that everything looks easy.

In order to be able to build a new kernel you may need some extra packages like make, kernel-headers(if rebuilding) or C++ so if you get any errors that a package is needed or not installed just install it even by using apt-get(debian) or yum(redhat based) or by simply downloading and installing the package(harder way) .

If you want to build a new kernel(like build the latest kernel) you will need the new kernel source and this can be downloaded from kernel.org as the latest patches(if any or needed).

Lets say that we want to have the latest stable kernel(at this time 2.6.27.4) installed on the server:

1. Download the kernel to the server:

cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.4.tar.gz

2. Unpack the archive and create a symlink:

tar -zxvf linux-2.6.27.4.tar.gz
cd linux-2.6.27.4
ln -s /usr/src/linux-2.6.27.4 /usr/src/linux

3. You may need to apply some patches:

Download the patch(es) from http://www.kernel.org/pub/linux/kernel/v2.6/ :

cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/patch-2.6.27.4.bz2

Apply the patch:

cd /usr/src/linux
bzip2 -dc /usr/src/patch-2.6.27.4.bz2 | patch -p1 --dry-run
bzip2 -dc /usr/src/patch-2.6.27.4.bz2 | patch -p1

First command will test the patch against the kernel files, don’t worry if you get a message saying that the patch is already existing as that just means that this is already applied and you did not need to do this step so just jump over the patching step.

4. Configure the new kernel and make modifications:

To make everything more simple we will use the already existing and working configuration of the kernel we are currently running and make modifications on it if needed, like adding extra hardware support or modules(for example adding Tarpit support).

cd /usr/src/linux
make clean && make mrproper
cp /boot/config-`uname -r` ./.config
make menuconfig

Running make menuconfig will open a new window where you will be able to see all available modules and make modifications if needed.
A good idea is to add another name to the kernel like “custom” and also remember to save the config at the end.

5. Build the new kernel:

5.1 If you want to build the kernel and also install it on the server follow this path:

make bzImage
make modules && make modules_install
make install
vi /boot/grub/grub.conf
default=1 -> default=0

5.2 If you just want to create an rpm and to install it later:

make rpm

5.2.1 You now have to install the kernel:

cd /usr/src/redhat/RPMS/i386/
rpm -ivh --nodeps kernel-2.6.27.4custom.i386.rpm
mkinitrd /boot/initrd-2.6.27.4-custom.img 2.6.27.4-custom
vi /boot/grub/grub.conf
default=1 -> default=0

6. Reboot

If you want to make sure that your server will boot up even if the kernel crashes try and do the following instead of editing grub.conf (last 2 commands on 5.1 and 5.2.1):

grub
savedefault --default=0 --once
quit

Now reboot the server shutdown -r now and make sure everything is fine.
To check which kernel was booted run uname -r on the server.

If everything was done right you should have the latest available kernel installed on the server.

Comments No Comments »

A few days ago i was writing about how to create a VPS on the free OpenVZ platform which is almost identical to Virtuozzo.

Here is a list of commands “good to know” for everyone who starts using OpenVZ, this will work even if you have HyperVM installed:

[root@test /]#vzctl start 101 // start the VPS 101

[root@test /]#vzctl stop 101 // stop 101 VPS

[root@test /]#vzctl restart 101 // restart 101 VPS

[root@test /]#vzctl enter 101 // enter into 101 VPS

[root@101 /]#exit // log out from 101 VPS

[root@test /]#vzlist // display the list of active VPS’s

[root@test /]#vzlist -a // display the list of all VPS’s

[root@test /]#vzctl destroy 101 // destroy the VPS (good idea to stop it first)

[root@test /]#vzcalc -v 101 // show resources usage on VPS

[root@test /]#vzctl exec 101 df -m // execute commands against the VPS(in this case ‘df -m’)

[root@test /]#vzyum 101 -y update // run yum update on VPS

[root@test /]#vzyum 101 -y install package // install package using yum on VPS

[root@test /]#vzrpm 101 -Uvh package // install package using rpm on VPS

Most of the commands are used from inside the Node to run commands against a VPS(@test is the node server).
If you run commands directly on the VPS then you do not need this commands, yo will use the Linux/Unix distribution specific commands like on any other server.

Comments 1 Comment »