Inizio  >  Docs  >  Linux  >  How to  >  Virtualization  
VirtualizationVirtualization

Index

Ubuntu 18.04

 

When Cloning Hosts:

 

to change Hostname

hostnamectl set-hostname u1804-nixcraft

then change the /etc/hosts file:

sudo nano /etc/hosts

 

then change this flag  <code class="language-ini">preserve_hostname: true</code>

<code class="language-console-bash">sudo nano /etc/cloud/cloud.cfg</code>
 

 

 

to regenearate SSH keys:

/bin/rm -v /etc/ssh/ssh_host_*

then

dpkg-reconfigure openssh-server

 

change network config:

 /etc/netplan/50-cloud-init.yaml

 

Ubuntu 18.04 default lvm layout comes with only a 4 GB root partition. Here we will extend it to occupy the full free space in the volume group:

sudo lvextend -l 100%FREE --resizefs /dev/ubuntu-vg/ubuntu-lv

To top

https://stackoverflow.com/questions/19872591/how-to-use-vagrant-in-a-proxy-environment

 

If your proxy requires authentication it is better to set the environment variable rather than storing your password in the Vagrantfile. Also your Vagrantfile can be used by others easily who are not behind a proxy.

For Mac/Linux (in Bash)

<code>export http_proxy="http://user:password@host:port" export https_proxy="http://user:password@host:port" vagrant plugin install vagrant-proxyconf </code>

then

<code>export VAGRANT_HTTP_PROXY=${http_proxy} export VAGRANT_NO_PROXY="127.0.0.1" vagrant up </code>

For Windows use set instead of export.

<code>set http_proxy=http://user:password@host:port set https_proxy=%http_proxy% vagrant plugin install vagrant-proxyconf </code>

then

<code>set VAGRANT_HTTP_PROXY="%http_proxy%" set VAGRANT_NO_PROXY="127.0.0.1" vagrant up </code>

To top

Type the following command:

virsh autostart vmName

 

To top

setup Ubuntu 18.04.1

https://www.linuxtechi.com/install-configure-kvm-ubuntu-18-04-server/

https://websiteforstudents.com/setup-linux-kvm-kernel-virtualization-module-on-ubuntu-18-04-lts-server/

https://www.ostechnix.com/setup-headless-virtualization-server-using-kvm-ubuntu/

sudo apt update
sudo apt dist-upgrade
sudo apt autoremove -y
sudo reboot
sudo apt install qemu-kvm libvirt-bin bridge-utils cpu-checker
systemctl enable libvirtd
systemctl start libvirtd
virsh list --all

 

Network Configuration with Bridges:

https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan

https://netplan.io/reference#examples


networkctl status -a
vim /etc/netplan/50-cloud-init.yaml

network:
    ethernets:
        eno1:
            dhcp4: false
        eno2:
            dhcp4: false
        enp10s0:
            addresses: []
            dhcp4: true
        enp8s0:
            addresses: []
            dhcp4: true
            optional: true
    bridges:
        br0:
            interfaces:
            - eno1
            addresses:
            - 192.168.0.38/23
            dhcp4: false
            gateway4: 192.168.0.1
            nameservers:
                addresses:
                - 192.168.0.4
                - 192.168.0.5
                search:
                - nikoz.org
            
        br1:
            interfaces:
            - eno2
            dhcp4: true

    version: 2

netplan --debug try

 

Net Time setup:

https://linuxconfig.org/how-to-sync-time-on-ubuntu-18-04-bionic-beaver-linux


cd /etc/
vim systemd/timesyncd.conf
add:

NTP=192.168.0.5
FallbackNTP=192.168.0.4

timedatectl set-ntp false
timedatectl set-ntp true

for Virt-manager:

sudo apt-add-repository multiverse && sudo apt-get update

apt install virt-manager

 

 

Desktop network with bridge:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

  ethernets:
        enp1s0:
            dhcp4: false

  bridges:
    br0:
        dhcp4: yes
        interfaces:
            - enp1s0


To top

modprobe nbd max_part=16 qemu-nbd -c /dev/nbd0 image.qcow2 partprobe /dev/nbd0 mount /dev/nbd0p1 /mnt/image
 
fdisk /dev/nbd0  Command (m for help): p  Disk /dev/nbd0: 4294 MB, 4294967296 bytes  255 heads, 63 sectors/track, 522 cylinders, total 8388608 sectors  Units = sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  Disk identifier: 0x000183ca       Device  Boot     Start        End      Blocks   Id  System  /dev/nbd0p1   *        2048      499711      248832   83  Linux  /dev/nbd0p2          501758     8386559     3942401    5  Extended  /dev/nbd0p5          501760     8386559     3942400   8e  Linux LVM
umount /mnt/image qemu-nbd -d /dev/nbd0
killall qemu-nbd
 
 

VMware Converter: GrubInstaller failed – /vmware-updateGrub.sh: 38: grub: not found

http://mattiasgeniar.be/2011/12/29/ubuntu-9-10-with-vmware-convertor-grubinstaller-failed-vmware-updategrub-sh-38-grub-not-found/

I encountered the following when trying to do a VMware Conversion of an Ubuntu 9.10 system. It failed at the last 99% with the following error.

 

How to fix your Grub after a VMware Convertor

Here are the steps I took to fix this and boot the system again.

First, boot your system with the Ubuntu 9.10 Server ISO image (the desktop version won't work). Make sure your boot order in the Virtual Machine's BIOS is changed to boot from CDROM first.

 

Now, you should be prompted with several install options from the Server ISO. Choose the "Rescue a broken system".

You'll be prompted with a few questions, such as location, language, keyboard layout and network config. Make sure you enter it all. You will need an internet connection to proceed, so check if your network connections are OK.

After you've booted, you'll be prompted to choose a partition to mount as your root filesystem. In my case, that was /dev/sdb1. On the /dev/sda1 was my /boot mount and the /dev/sda2 contained the swap partition. So I choose /dev/sdb1 as root file system.

 

After the prompt, choose the option to get a shell on that partition.

~# fdisk -l /dev/sda1: boot /dev/sda2: swap /dev/sdb1: root

With fdisk -l I verified my partition layout. Next, mount the /boot partition.

~# mkdir /boot ~# mount /dev/sda1 /boot

And run the grub2 install & configure.

~# apt-get install grub2 ~# upgrade-from-grub-legacy

You'll be prompted where to install the grub bootloader next. If you're unsure, check both partitions.

Next up: unmount your Server ISO and reboot the system, it should boot just fine now.

 

 

 

Converting Xen Linux VMs to VMWare ESXi

http://blog.michael.kuron-germany.de/2011/10/how-to-converting-xen-linux-vms-to-vmware-esxi/

1. In VMWare Fusion or Workstation, do a basic install of Debian Squeeze onto a flat-file (not split into 2GB segments and preallocated) VMDK that is slightly larger than your virtual Xen disk with a separate VMDK for swap.
2. Downgrade it to Grub 1 using apt-get install grub-legacy, grub-install /dev/sda, update-grub (as Grub 2 is not compatible with /boot/grub/menu.lst files as generated by xen-create-image).
3. Shut down and make a copy of the VMDK.
4. Boot the VM back up and re-install Grub2 using apt-get install grub.
5. Edit /boot/grub/grub.cfg and replace root=UUID=xxxxxxxxxx in the linux lines with root=/dev/sda1
6. Shut down the VM and attach the VMDK you copied in step 3 as an additional disk (this will be the target disk for our conversion).
7. Boot it up and make sure that you’re getting a Grub2 screen (i.e. it is not booting from the copied VMDK).
8. Using mount, check that your root disk is sda1 (which usually should be the first disk, not the copied disk). Using ls /dev/sd*, make sure it sees the target disk as sdc.
9. dd if=/path/to/xen/vm/disk.img of=/dev/sdc1 bs=1048576
10. mount /dev/sdc1 /mnt; cd /mnt
11. nano etc/fstab: replace swap disk /dev/xvda1 with /dev/sdb1 and root disk /dev/xvda2 with /dev/sda1
12. nano etc/inittab: replace hvc0 with tty1
13. nano boot/grub/menu.lst: replace /dev/xvda2 with /dev/sda1
14. umount /mnt
15. Attach the new virtual disk to a VM and boot a rescue system. There, drop to a shell on /dev/sda1 and apt-get update, apt-get install grub
16. Reboot
17. Done!

 

Convert XEN Vm to Vmware (redhat5 /centos5)

on the source:

 

yum install kernel-2.6.18-194.el5 (kernel version found with yum search kernel) 

check Grub configuration:

/boot/grub/grub.conf

must boot from the new kernel (without xen) should be like this:

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title CentOS (2.6.18-194.el5)

root (hd0,0)
kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00 
initrd /initrd-2.6.18-194.el5.img

title CentOS (2.6.18-53.el5xen)

root (hd0,0)
kernel /vmlinuz-2.6.18-53.el5xen ro root=/dev/VolGroup00/LogVol00 console=xvc0
initrd /initrd-2.6.18-53.el5xen.img 

 

after that make the conversion (with Vmware converter or with qemu(?))

start the new Vm machine with the Centos(Redhat) setup DVD and chose: Linux rescue
follow the wizard:
- disable network;
- mount drives in /mnt/sysimage

on the shell:

chroot /mnt/sysimage

Modify /etc/modprobe.conf to add the proper SCSI and network card modul

alias eth0 xennet
alias scsi_hostadapter xenblk

will be replaced by

alias scsi_hostadapter mptbase
alias scsi_hostadapter1 mptspi
alias scsi_hostadapter2 ata_piix

Modify /etc/inittab by removing the # in front of the getty and puting a comment in front of the line containg the xen console:

1:2345:respawn:/sbin/mingetty --noclear tty1  
2:2345:respawn:/sbin/mingetty
3:2345:respawn:/sbin/mingetty
4:2345:respawn:/sbin/mingetty
5:2345:respawn:/sbin/mingetty
6:2345:respawn:/sbin/mingetty

finally:

mkinitrd -v -f /boot/initrd-2.6.18-194.el5.img 2.6.18-194.el5

exit

reboot

 

http://www.howtoforge.com/how-to-convert-a-xen-virtual-machine-to-vmware

Xen -> VMware VM Migration Steps (Kernel Step)

The kernel on the VM to be migrated must support fully virtualized operation. The kernels used for para-virtulized machines using RHEL/Fedora/CentOS as a guest do not support fully virtualized operation by default. The best way to deal with this is to also install a standard kernel in the machine, port the machine and finally remove the Xen kernel.

1. Since this is a highly risky procedure, FIRST CREATE A BACK-UP OF YOUR VIRTUAL MACHINE!!!

2. Download a kernel with the same version number and architecture as the Xen kernel, except it should be the a generic one. Use the distribution CD/DVD or any other repository to get it.

3. Use RPM tools to install the kernel.

4. Modify /etc/modprobe.conf to add the proper SCSI and network card modules:

alias eth0 xennet  alias scsi_hostadapter xenblk 

will be replaced by

alias eth0 pcnet32 alias  scsi_hostadapter mptbase  alias scsi_hostadapter1 mptspi  alias scsi_hostadapter2 ata_piix 

Modify /etc/inittab by removing the # in front of the getty and puting a comment in front of the line containg the xen console:

1:2345:respawn:/sbin/mingetty --noclear tty1  2:2345:respawn:/sbin/mingetty  3:2345:respawn:/sbin/mingetty  4:2345:respawn:/sbin/mingetty  5:2345:respawn:/sbin/mingetty  6:2345:respawn:/sbin/mingetty

This is a one way action. Once modified the kernel modules, you won'tbe able to properly start the machine, and you will receive a Kernel panic error message.

Xen - > VMware VM Migration Steps (Disk Step)

To convert a XEN machine in a .vmdk format to be used with VMware, a tool called qemu will be used. QEMU is a generic and open source machine emulator and virtualizer. It is also a fast processor emulator using dynamic translation to achieve good emulation speed.

1. Download qemu from DAG repository. Use the EL5 package for any Fedora/RHEL5/CentOS5 that you use.

dag.wieers.com/rpm/packages/qemu/

2. Convert the XEN machine to VMware:

qemu-img convert <source_xen_machine> -O vmdk <destination_vmware.vmdk>  <dest_vmware.vmdk>

3. At this point, we have a valid VMware Server 1.xx disk image. This can be powered on onto any VMware Server. We need to do it anyway in order to build a .VMX file that will be later used. This stage also confirms whether the newly machine runs properly. </dest_vmware.vmdk>

3.1 Create a new virtual machine. Do not create a new HDD, but use the previously created vmdk.

3.2 Power it on in order to validate that it is usable and to allow the machine to reconfigure itself.

4. Move the VMware Server virtual machine to a Windows workstation running VMwareConverter.

5. Using VMware Converter, convert the VMware Server virtual machine to VMware ESXi.

Xen -> VMware VM Migration Steps (ESX Step)

1. Configure the virtual machine to boot first from CD-ROM drive.

2. Modify the machine's HDD SCSI controller type from BUS Logic to LSI Logic.

Edit Virtual Machine Settings > SCSI Controller 0 > Change type > LSI Logic.

3. Boot using Knoppix or the distribution's first CD.

4. Mount the VM's disk and chroot to it.

5. Get the disk architecture using fdisk -l, and modify /etc/fstab accordingly.

6. Create a new initrd image. You also must know the version of the running kernel. For example, if you are running kernel 2.6.18-1234, then the initrd command would look like this:

# mkinitrd -v -f /boot/initrd-2.6.18-1234.img 2.6.18-1234

7. Edit /boot/grub/menu.lst to boot from this initrd.

8. Keep your fingers crossed and reboot the machine.

Don't forget to re-configure your network card.

External references:

communities.vmware.com/docs/DOC-8300

Configure two network bridge

CentOS 5.5

http://idolinux.blogspot.com/2008/08/xen-add-network-bridge-for-eth1.html

su -

vim /etc/xen/xend-config.sxp

#(network-script network-bridge)
(network-script twoNetBridge)

vim twoNetBridge
#!/bin/sh
/etc/xen/scripts/network-bridge "$@" vifnum=0 bridge=xenbr0 netdev=eth0
/etc/xen/scripts/network-bridge "$@" vifnum=1 bridge=xenbr1 netdev=eth1

 

service xend restart

 

Ubuntu 8.04

sudo vim /etc/xen/xend-config.sxp

#(network-script network-bridge)
(network-script twoNetBridge)

sudo vim /etc/xen/scripts/twoNetBridge

#!/bin/sh
/etc/xen/scripts/network-bridge "$@" netdev=eth0
/etc/xen/scripts/network-bridge "$@" netdev=eth1

service xend restart

To top

Xen

http://www.wlug.org.nz/XenPciPassthrough

Xen has a feature which lets you pass a PCI device through to an unpriviledged domain. Only the unpriviledged domain has access to this specific PCI device – the priviledged domain binds to the PCI device with a dummy drive that stops the dom0 from accessing it as well.

This could be used for passing a SCSI controller or NIC through to one domain, eg. for a file server or FireWall domU.

What you'll need

You'll have to compile in the right PCI backend driver for Xen.

    CONFIG_XEN_PCIDEV_FRONTEND=y (for DomU kernels)
CONFIG_XEN_PCIDEV_BACKEND=y (for Dom0 kernels)

You'll also need the PCI ID of the device in question, in the <tt>xx:xx:x</tt> notation displayed by lspci(8). Note that the formatting is important – don't drop or add leading 0's!

In some cases it is required to set the <tt>pciback.permissive</tt> option – this is for drivers which need to write to registers on the PCI device itself. Apparently some NICs will fail to operate without this, and from what I've read it doesn't hurt to have it enabled regardless.

Kernel options

In <tt>grub.conf</tt>, add something like the following to your <tt>module</tt> line corresponding to the dom0 kernel.

pciback.permissive pciback.hide=(03:00.0)

This assumes the device we are passing through has a PCI ID of <tt>03:00.0</tt>.

Xen config file

In your Xen config file for the domain, add a line that looks like the following, again assuming a PCI ID of <tt>03:00.0</tt>:

pci = ['03:00.0']

Note that if this is a network interface, it will come up in addition to any you specify with your <tt>vif</tt> config option.


http://lordnaeo.blogspot.com/2008/05/xen-pci-usb-e-domu.html

Avete allestito un server Xen con tante belle macchine virtuali?
Avete configurato un domU solo per Samba che funge anche da server di stampa?

Ok, allora vi sarete chiesti come fare a condividere la vostra stampante locale collegata fisicamente alla dom0.

Di default infatti Xen (che non virtualizza, ma paravirtualizza) non passa alcun device reale alle macchine virtuali, ma bastano 2 semplici modifiche ed ecco che la vostra domU sara' come fisicamente collegata ai vostri dispositivi, siano essi stampanti USB o altro.

Per prima cosa, ed e' quella piu' difficile, bisogna individuare su quale bus e' installato il dispositivo da passare alla domU. Comandi come lspci hwinfo o lsusb vi saranno senz'altro di aiuto.

Ad esempio, ho una stampante collegata tramite USB:

root@dom0:~# lsusb
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 002: ID 03f0:8704 Hewlett-Packard
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 003: ID 1241:1603 Belkin
Bus 001 Device 001: ID 0000:0000


Ok, la mia HP e' collegata al bus 002:

root@dom0:~# lspci |grep USB
00:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.3 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 82)


In tutto ci sono 4 bus, quindi il bus 002 dovrebbe corrispondere con il device pci 00:10.1, ora inizia la configurazione vera e propria, modficate il votro file /boot/grub/menu.lst aggiungendo quanto vedete in grassetto qui sotto:

module /vmlinuz-2.6.24-16-xen root=/dev/mapper/xenbuntu-root ro console=tty0 pciback.hide=(00:10.1)


Ora l'ultimo step, modificare il vostro file di configurazione della macchina virtuale /etc/xen/domu.cfg aggiundo la riga

pci=['00,10,1']


Facciamo partire la macchina virtuale e controlliamo con lsusb:

root@dom0:~# lsusb
Bus 001 Device 002: ID 03f0:8704 Hewlett-Packard
Bus 001 Device 001: ID 0000:0000


La nostra stampante e' stata correttamente rilevata

To top

creazione macchina

mkdir hylafax
cd hylafax/
mv /root/58.59.tgz .

dd if=/dev/zero of=hylafax.img bs=1k seek=4048k count=1
dd if=/dev/zero of=hylafax.swp bs=1k seek=1048k count=1

mkfs.ext3 hylafax.img
mkswap hylafax.swp
mount -o loop hylafax.img /mnt/
cd /mnt/
tar xfpvz /root/Desktop/hylafax/58.59.tgz

cd /mnt/
mkdir proc
mkdir sysfs
mkdir mnt
mkdir tmp
chmod +rwxt tmp/
chmod ugo+rwx tmp/
vim etc/fstab
reset
vim etc/sysconfig/network-scripts/ifcfg-eth0.bak
etc/sysconfig/network-scripts/ifcfg-eth0.bak etc/sysconfig/network-scripts/ifcfg-eth0
rm etc/sysconfig/network-scripts/ifcfg-eth1
rm etc/sysconfig/network-scripts/ifcfg-eth0.bak
vim etc/sysconfig/network-scripts/ifcfg-eth0
cp -av /lib/modules/2.6.16.46-0.12-xen/ /mnt/lib/modules/

/etc/xen/vm/hylafax.cfg

###############################################

kernel = "/boot/vmlinuz-2.6.16.46-0.12-xen"
ramdisk = "/boot/initrd-2.6.16.46-0.12-xen"
memory = 1024
name = "hylafax"
vif=[ 'mac=00:16:3e:4f:bd:c8,bridge=xenbr0', ]
#vcpus=2
#disk = ['tap:aio:dev/loop10,sda1,w', 'tap:aio:dev/loop10,sda2,w', ]
disk = ['file:/root/Desktop/hylafax/hylafax.img,sda1,w','file:/root/Desktop/hylafax/hylafax.swp,sda2,w',]
root = "/dev/sda1 ro"
extra = ' xencons=tty ROOT=/dev/sda1 single'
#apic=0
#acpi=0
pci=['00,1d,3']
on_crash="destroy"
on_poweroff="destroy"
on_reboot="restart"
localtime=0
#serial="pty"
###############################################

 xm create /etc/xen/vm/hylafax -c

To top

UBUNTU 8.04 HowTo

Based on:
http://www.howtoforge.com/high-performance-xen-on-ubuntu-8.04-amd64

and

http://www.howtoforge.com/perfect-server-ubuntu8.04-lts

 

Install OS (host) and SSH server

aptitude update
aptitude safe-upgrade
aptitude install openssh-server

Install Xen Kernel and utils

aptitude install xen-utils-3.2 ubuntu-xen-server
reboot

Checks

uname -a
Linux itb-s0030 2.6.24-26-xen #1 SMP Tue Dec 1 19:54:57 UTC 2009 x86_64 GNU/Linux
xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  1879     4     r-----    720.6

Create VM WebServer

sudo -s
mkdir -p /opt/xen/vm
cd /opt/xen/vm

Create VM disks
dd if=/dev/zero of=webServerRoot.img bs=1k seek=8048k count=1
1+0 records in
1+0 records out
1024 bytes (1,0 kB) copied, 0,000115246 s, 8,9 MB/s

dd if=/dev/zero of=webServerSwap.img bs=1k seek=2048k count=1
1+0 records in
1+0 records out
1024 bytes (1,0 kB) copied, 0,00010514 s, 9,7 MB/s

dd if=/dev/zero of=webServerOpt.img bs=1k seek=8048k count=1
1+0 records in
1+0 records out
1024 bytes (1,0 kB) copied, 0,000115246 s, 8,9 MB/s


ls -al
total 10104
drwxr-xr-x 2 root root        128 2009-12-11 16:50 .
drwxr-xr-x 3 root root         72 2009-12-11 16:49 ..
-rw-r--r-- 1 root root 8438940672 2009-12-11 16:49 webServerRoot.img
-rw-r--r-- 1 root root 2147484672 2009-12-11 16:50 webServerSwap.img

Create filesystems on Images

mkfs.ext3 webServerRoot.img

mke2fs 1.40.8 (13-Mar-2008)
webServerRoot.img is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
516096 inodes, 2060288 blocks
103014 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2109734912
63 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:

    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

mkfs.ext3 webServerOpt.img
mkswap webServerSwap.img

Setting up swapspace version 1, size = 2147479 kB
no label, UUID=59fd6b42-207f-40d1-baaf-4df3a21eaaa8

mount root image
mount -o loop webServerRoot.img /mnt/

if beyound a proxy
export http_proxy=http://10.18.3.39:8080/

Install ubuntu 8.04 with debootstrap

debootstrap --arch amd64 hardy /mnt http://it.archive.ubuntu.com/ubuntu

Mount service directory (dev proc)
mount --bind /dev /mnt/dev
mount proc /mnt/proc -t proc

Copy network configuration/apt configuration files
cp /etc/resolv.conf /mnt/etc/resolv.conf
cp /etc/network/interfaces /mnt/etc/network/

cp /etc/apt/sources.list /mnt/etc/apt/sources.list

cp /etc/apt/apt.conf /mnt/etc/apt/

Create and populate modules dir for guest
mkdir -p /mnt/lib/modules/2.6.24-26-xen/
cp -R /lib/modules/2.6.24-26-xen/* /mnt/lib/modules/2.6.24-26-xen/

or

mkdir /mnt/lib/modules/`uname -r`
cp -R /lib/modules/`uname -r`/* /mnt/lib/modules/`uname -r`/

Enter in chroot on guest
chroot /mnt /bin/bash

update repository index and system

apt-get update
apt-get upgrade

Starting Up from debbootstrap it's necessary to setup language packs:

sudo apt-get install --reinstall openssh-server bash-completion language-pack-en language-pack-it vim ssh nfs-common mc

Create User (sudoer) and group:
useradd -m nikoz
passwd nikoz
groupadd admin
usermod -a -G admin,adm nikoz

check /etc/passwd that shell for nikoz is BASH and not SH

Modify fstab:
vim /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/hda1               /               ext3    defaults        1       2
proc            /proc           proc    defaults        0       0
/dev/hdb1       none            swap    sw              0       0
/dev/hdc1       /opt/           ext3    defaults    1    2

10.18.3.44:/var/others  /media/nfs_44       nfs             auto,defaults,nolock        0 0
10.18.3.2:/opt  /media/nfs_32       nfs             auto,defaults,nolock        0 0

Modify /etc/network/interfaces and change the IP address of the guest OS

iface eth0 inet static
    address 10.18.3.22 <---

Exit chroot:
exit

Copy sudoers file:
cp /etc/sudoers /mnt/etc/

umount  /mnt/dev /mnt/proc /mnt

Create Vm configuration file:
mkdir /etc/xen/vm
vim /etc/xen/vm/webserver.cfg

kernel      = '/boot/vmlinuz-2.6.24-26-xen'
ramdisk     = '/boot/initrd.img-2.6.24-26-xen'
memory      = '512'

#
#  Disk device(s).
#
root        = '/dev/hda1 ro'
disk        = ['tap:aio:/opt/xen/vm/webServerRoot.img,hda1,w',
        'tap:aio:/opt/xen/vm/webServerSwap.img,hdb1,w',
        'tap:aio:/opt/xen/vm/webServerOpt.img,hdc1,w',]
#disk        = ['phy:/dev/sda2,hda1,w',]
#
#  Hostname
#
name        = 'domu1'
#
#  Networking
#
vif         = [ 'mac=00:16:EF:FE:00:11' ]
#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'
vcpus        = '2'
extra = 'xencons=tty1'

Start the Vm:
xm create /etc/xen/vm/webserver.cfg -c

Start Vm at boot time:

ln -sf /etc/xen/vm/webserver.cfg /etc/xen/vm/auto

Setup Web Server:

Change hostname:
vim /etc/hostname
itb-s00322

vim /etc/hosts

127.0.0.1       localhost.localdomain   localhost
10.18.3.22       ITB-S00322   
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

for a centralized nfs server apt archive

cd /var/cache/apt/

mv archives/ archives.local

ln -sf /media/nfs_32/archives/server/8.04/64/ archives

 

Install all Packages:
sudo apt-get install mysql-server mysql-client libmysqlclient15-dev apache2 apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl