I've just started playing around with vserver and am finding the documentation regarding this project lacking. As such, the way I'm doing this below may not be optimal.

I've just started playing around with vserver and am finding the documentation regarding this project lacking. As such, the way I'm doing this below may not be optimal.

−

That being said, I'm thinking that the next step to make this more efficient would be to write the proper scripts to integrate pacman into util-vserver as has been done for apt, rpm, etc... The actual files may be found in ''/usr/lib/util-vserver''

+

That being said, I'm thinking that the next step to make this more efficient would be to write the proper scripts to integrate pacman into util-vserver as has been done for apt, rpm, etc... The actual files may be found in ''/usr/lib/util-vserver''.

=Preparing the Host=

=Preparing the Host=

Revision as of 14:42, 20 November 2009

This article is a stub.

Notes:please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Arch VServer#)

Introduction

This article aims to provide all necessary information regarding the creation of a vserver host as well as vserver guests running ArchLinux. Tis will enable you to setup virtual servers that provide different services as if they were on different machines, with a very little overhead. You can get more information about virtual servers here.

Current status / Next steps

I've just started playing around with vserver and am finding the documentation regarding this project lacking. As such, the way I'm doing this below may not be optimal.

That being said, I'm thinking that the next step to make this more efficient would be to write the proper scripts to integrate pacman into util-vserver as has been done for apt, rpm, etc... The actual files may be found in /usr/lib/util-vserver.

Preparing the Host

To prepare the vserver host environment, you will need to install both a vserver patched kernel and the vserver utilities which are located in AUR. In the following steps, the instructions are provided using yaourt to fetch them automatically. This has the aded benefit of pulling down the required dependencies ( dietlibc and beecrypt ) automagically :

Paths of Interest

/etc/vservers/.defaults : configuration skeleton used when building new guests

/etc/vservers/.defaults/vdirbase : symlink to the folder containing vserver guests. This defaults to /vservers.

/etc/vservers/<guest name> : guest specific configurations

Preparing the Guests

Vserver will launch guests from subfolders of /etc/vservers/.defaults/vdirbase. As such, creating a new guest system is as simple as installing the required packages in a folder of the host. Furthermore, there's nothing stopping you ( and quite a few things encouraging you ) to mount filesystems to the subfolders of vdirbase and installing your guest in there.

If you plan on doing this often, I highly recommend that you write yourself a little batch script since most of these steps can be automated quite easily.

Preparing the guest installation media

Optional: Base variables to follow along with the steps

GuestName= # Name of the guest
GuestRoot=/etc/vservers/.defaults/vdirbase/$GuestName
GuestPackages= # Listing of packages to install via pacman
GuestDisk= # Installation target device
GuestNetDevice= # ex.: eth0, dummy0, etc...
GuestIP= # I think you get it
GuestContext= # Unique identifier for the guest, I go with the last part of the IP

Optional: Preparing the guest disk

Create a LVM Physical Volume, a Volume Group and a Logical Volume ( wiki:LVM )

Prepare the guest's filesystem

Prepare guest filesystem for the pacman db

mkdir -p /newarch/var/lib/pacman

Install the base system

NOTE : To save some time, it's probably a good idea to create a text file containing all the packages to install and call it via "pacman -Sy `cat $GuestPackages` -r $GuestRoot" instead of the following :

pacman -Sy base -r $GuestRoot

Optional: If you want to chroot into the newly created guest so as to install new packages, it might be a good idea to mount a few filesystems required by some packages.

Bind /dev, /proc, /sys to the corresponding directories in $GuestRoot

Modify guest configuration files to enable a smoother boot process

Modify /etc/inittab by deleting all lines that create the consoles ( agetty )

Viewing output from vserver $GuestName start / stop

SSH will not start

I noticed that /dev/null did not always get created properly in my first experimentations. Therefore I did a quick :

cp -a /dev/null $GuestRoot/dev

cp -a /dev/zero $GuestRoot/dev

Furthermore, if you're not using the dummy network driver and are attaching to the host's network interface, you'll want to configure the ListenAddress statement of /etc/ssh/sshd_config so that it binds only to the guest's IP address as opposed to 127.0.0.1.

Tips & Trick

Network via dummy adapters

Here, you're either using the dummy module to create virtual network adapters or created interface aliases via /usr/sbin/ip or /usr/sbin/ifconfig. I went for the former and configured the host as such :