📜 ⬆️ ⬇️

We put Gentoo x64 + xen on 3Tb disks in Hetzner

What it is for: Suppose you need to organize a couple of three independent remote desktops. Do not rent the same for each rdp, a separate server, you can rent one and make them there at least 16 pieces.

Having rented a couple of EX4 class servers at hetzner.de, I faced a problem, the server has two 3Tb disks and that's it. There is a known problem that disks with an MBR partition table can address only 2.2 TB. There were two options, either to configure the MBR and give up 800gov of disk space, or make a GPT table and try to boot from it, which is not trivial, but in fact is simple.
Plus a small howto how to put Xen.

Step by step
After renting the server, you are sent an un, login and password to the new server, going through ssh, we get into the rescue system, based on some kind of Debian, but this is not a hindrance to us.
It was decided to merge two disks sda and sdb into raid1 array, and make LVM on top of it, so as not to risk, it was decided to put the boot into a separate partition, an additional partition for efi was also needed.
We will break the program
gdisk /dev/sda 

Create the first partition it will boot
 Command:n Partition Number: 1 ↵ First sector: ↵ Last sector: +100M ↵ Hex Code: ↵ 

Create a second section this will be efi
 Command: n ↵ Partition Number: 2 ↵ First sector: ↵ Last sector: +32M ↵ Hex Code: EF02 ↵ 

I want to note that it is very important for him to indicate the type of section.
Create a third section under LVM
 Command: n ↵ Partition Number: 3 ↵ First sector: ↵ Last sector: ↵ Hex Code: ↵ 

Write data to disk with the w command and exit.
Do the same for the sdb disk.
Create ride arrays.
Array for boot:
 mdadm –C /dev/md0 –-level=1 -–raid-devices=2 -–metadata=0.9 /dev/sd[ab]1 

Array for LVM:
 mdadm –C /dev/md1 –-level=1 –-raid-devices=2 /dev/sd[ab]3 

Make sure they start syncing successfully:
 cat /proc/mdstat 

Create an LVM group:
 pvcreate /dev/md1 vgcreate ld1 /dev/md1 vhchange –ay 

Create lvm sections:
 lvcreate –L2G –n swap ld1 lvcreate –L8G –n root ld1 

Format the sections:
 mkswap /dev/ld1/swap mkreiserfs /dev/md0 mkreiserfs /dev/ld1/root 

Create a folder and add the new root to it:
 mkdir /mnt/gentoo mount /dev/ld1/root /mnt/gentoo 

Next on the Gentoo.org manual, we put Gentoo from stage3, I will not focus, just list the commands.
 cd /mnt/gentoo wget http://de-mirror.org/gentoo/releases/amd64/current-stage3/stage3-amd64-20111006.tar.bz2 tar –xvjpf stage3-amd64-20111006.tar.bz2 mount /dev/md0 boot mount –o bind /dev/ dev mount –t proc proc proc cp /etc/resolv.conf etc/ scp   make.conf etc/make.conf 

It looks like this for me:
 CFLAGS="-O2 -pipe" CXXFLAGS="${CFLAGS}" CHOST="x86_64-pc-linux-gnu" MAKEOPTS="-j9" LINGUAS="ru" ACCEPT_KEYWORDS="~amd64" USE="-ipv6 mmx sse sse2 hvm qemu pygrub xen static-libs agent efiemu" 

We continue:
 chroot /mnt/gentoo env-update && source /etc/profile emerge -–sync echo “=sys-fs/lvm2-2.02.88” >> /etc/portage/package.mask emerge gentoo-sources screen vim vixie-cron metalog reiserfsprogs mdadm lvm2 gentoolkit genkernel dhcp mdadm -–detail -–scan >> /etc/mdadm.conf ln –s /etc/init.d/net.lo /etc/init.d/net.eth0 

We configure and build the kernel with support for raid and lvm, I collect via genkernel.
Rule fstab:
 /dev/md0 /boot reiserfs noatime 1 2 /dev/ld1/root / reiserfs noatime 0 1 /dev/ld1/swap none swap sw 0 0 

We set the root password via passwd.
We put in the loading service:
 rc-update add net.eth0 default rc-update add sshd default rc-update add metalog default rc-update add vixie-cron default 

Now the most interesting is to configure grub or rather its version 2.
 echo "sys-boot/grub:2" >> /etc/portage/package.accept_keywords echo "sys-boot/grub:2" >> /etc/portage/package.unmask emerge -av sys-boot/grub:2 

It is necessary to prescribe rough disks:
 grub2-install /dev/sda grub2-install /dev/sdb 

And set it up, I did this:
 grub2-mkconfig -o test.cfg 

At the exit, he created test.cfg for me.
I changed the line
 linux /kernel-genkernel-x86_64-3.0.6-gentoo root=/dev/mapper/ld1-root ro 

on
 linux /kernel-genkernel-x86_64-3.0.6-gentoo root=/dev/ram0 real_root=/dev/ld1/root dolvm domdadm init=/linuxrc 

and copied this file to boot:
 cp test.cfg /boot/grub2/grub.cfg 

Everything can be overloaded.
')
Install and configure the xen itself
 emerge xen xen-tools –av 

Configure the network:
 cat /etc/conf.d/net bridge_br0="eth0" rc_need_br0="net.eth0" config_eth0=("null") config_br0=( "xxxx/27" "192.168.194.1/24"     ) routes_br0=("default gw yyyy") 

Add the bridge to the autoload:
 ln –s /etc/init.d/net.lo /etc/init.d/net.br0 rc-update add net.br0 default 

Commenting out the line in /etc/xen/xend-config.sxp
 (network-script network-bridge) 

Add to the Xen autoload:
 rc-update add xenstored default 

Add a line to fstab:
 none /proc/xen xenfs defaults 0 0 

Reconfigure the kernel to enable para-virtualization support:
 Processor type and features ---> [*] Paravirtualized guest support ---> [*] Xen guest support -*- Enable paravirtualization code [*] Paravirtualization layer for spinlocks 

Plus, go to Device Drivers --->
And turn on all backends:
 <*> Block-device backend driver <*> Xen backend network device 

Plus in Xen driver support --->
Turn on all checkboxes, i.e. compile into the kernel.
Rebuild the kernel via genkernel and fix grub.cfg
 multiboot /xen.gz module /kernel-genkernel-x86_64-3.0.6-gentoo root=/dev/ram0 real_root=/dev/ld1/root dolvm domdadm init=/linuxrc module /initramfs-genkernel-x86_64-3.0.6-gentoo 


We are overloaded and can create virtual machines.
Configuration example:
 cat /etc/xen/dp-rdp kernel = "/usr/lib/xen/boot/hvmloader" builder='hvm' vcpus=2 memory = 3400 shadow_memory = 8 name = "dp-rdp" vif = [ 'type=ioemu, bridge=br0, mac=00:16:3e:03:00:c5' ] disk = [ 'phy:/dev/ld1/dprdp,hda,w' , 'phy:/dev/ld1/dprdp_back,xvdb,w' , 'file:/root/Windows.x64.6in1.DVD-XiSO.iso,hdc:cdrom,r' ] device_model = '/usr/lib64/xen/bin/qemu-dm' boot="c" acpic=0 sdl=0 vnc=1 vncdisplay=1 vnclisten="0.0.0.0" vncpasswd='  ' stdvga=0 usb=0 


Virtualka starts with the command:
 xl create /etc/xen/dp-rdp 


PS If there are problems with configuring the kernel, write to comments, I'll post the finished .config somewhere.

Source: https://habr.com/ru/post/131196/


All Articles