User:MalakymR/Drafts/Gentoo on OVH VPS

From Gentoo Wiki
Jump to:navigation Jump to:search
Warning, this page is a work in progress by MalakymR (talk | contribs). Treat its contents with caution.
This is just a dump of steps - you probably don't want to rely on this unless you're trying to troubleshoot your own install
  • OVH uses KVM/OpenStack
  • Does not allow you to mount ISO files to boot from
  • Normally provides only a small list of distributions to choose from
  • Provides a rescue environment based on debian which gentoo stage3 can be installed from
  • lowest vps package provides a Static IP, Reverse DNS, 10GB storage and 2GB RAM
  • 2GB RAM may be too low for some packages but is suitable for most cmake compiles where it would struggle with 1GB
  • Monitoring (SSH, HTTP etc) doesn't work as OVH will assume the initial images system is installed - you will need to turn SLA Monitoring off to avoid warning emails (will do some checking up on this to see if we can make it work)

Some Title Here

A lot of these notes can be handed over to the handbook for reference


leave this as a quick guide where decisions are made for you to get you running as quick as possible

OVH's web KVM view wont allow you to connect through a reboot and rebooting is slow, specially into the rescue environment
  • When choosing an operating system for your VPS with OVH pick any, this will be ignored.
  • Under control panel select "Rescue mode" - this will take 5 minutes.
  • You will receive an email with your root u/p
  • you can either use the KVM view in the OVH control panel or SSH directly (I recommend SSHin directly)
  • (for ssh) once in I recommend using "screen" just incase you are disconnected you can resume with screen -r
  • rescue environment mounts your VPS's HDD as /mnt/vdb1 etc
  • vdb is our disk (will be vda after reboot) - current vda is the rescue environments dev

Prepare Disks

root #umount /mnt/vdb*
root #echo -e "o\nn\np\n1\n\n+32M\nn\np\n2\n\n+1024M\nn\np\n3\n\n\nt\n2\n82\na\n1\nw" PIPEHERE fdisk /dev/vdb
root #mkfs.ext2 /dev/vdb1
root #mkfs.ext4 /dev/vdb3
root #mkswap /dev/vdb2
root #swapon /dev/vdb2

Install Stage3

root #mkdir /mnt/gentoo
root #mount /dev/vdb3 /mnt/gentoo
root #cd /mnt/gentoo
root #tar xvjpf stage3-*.tar.bz2 --xattrs --numeric-owner
root #rm -f stage3-*.tar.bz2

Initial Configuration (mirror, make, repo)

root #/mnt/gentoo/etc/portage/make.conf
root #cat /mnt/gentoo/etc/portage/make.conf
root #mkdir /mnt/gentoo/etc/portage/repos.conf
root #cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

chroot into new environment

root #cp -L /etc/resolv.conf /mnt/gentoo/etc/
root #mount -t proc /proc /mnt/gentoo/proc
root #mount --rbind /sys /mnt/gentoo/sys
root #mount --rbind /dev /mnt/gentoo/dev
root #chroot /mnt/gentoo /bin/bash
root #source /etc/profile

Initial Sync/Update system

root #mkdir /boot
root #mount /dev/vdb1 /boot #fstab isnt created yet so we need to mount this manually
root #emerge-webrsync
root #emerge --sync #optional
root #emerge --update --deep --changed-use @world #--ask #optional

Regional settings

root #echo "Europe/London" > /etc/timezone
root #emerge --config sys-libs/timezone-data
root #echo 'en_GB ISO-8859-1' >> /etc/locale.gen
root #echo 'en_GB.UTF-8 UTF-8' >> /etc/locale.gen
root #locale-gen
root #env-update
root #source /etc/profile

Emerge first utilities

  • pciutils for knowing your hardware (not needed here at
root #emerge pciutils app-misc/screen #--ask #optional but screen would allow us to reconnect to the chroot but we cannot do 2 screens in a row for some reason at this point (to follow up)

Compile Kernel

root #emerge sys-kernel/gentoo-sources #--ask
root #cd /usr/src/linux
root #make menuconfig
root #list changes from .config here (mostly VIRTIO stuff - added temporary list below)
root #mount /dev/vdb1 /boot #not modified fstab yet so manually mount (most this step up)
root #make
root #make modules_install
root #make install
FILE .config

Update fstab

  • This should stay as vda even though we are currently mounted under vdb
root #move this up so we can remove manual mount command
root #echo '/dev/vda1 /boot ext2 defaults,noatime 0 2' >> /etc/fstab
root #echo '/dev/vda2 none swap sw 0 0' >> /etc/fstab
root #echo '/dev/vda3 / ext4 noatime 0 1' >> /etc/fstab
FILE /etc/fstab
# <fs>      <mountpoint> <type>  <opts>               <dump/pass>
/dev/vda1   /boot        ext2    defaults,noatime     0 2
/dev/vda2   none         swap    sw                   0 0
/dev/vda3   /            ext4    noatime              0 1

Configure Networking

root #cd /etc/init.d/
root #ln -s net.lo net.eth0
root #rc-update add net.eth0 default
root #sed -i s/localhost/\ vps\ localhost/g /etc/hosts

Additional Tools

root #emerge syslog-ng cronie #--ask
root #rc-update add syslog-ng default
root #rc-update add cronie default
root #rc-update add sshd default
root #sed -i s/#PermitRootLogin\ prohibit-password/PermitRootLogin\ yes/g /etc/ssh/sshd_config

Optional Tools

  • Check without dhcpcd
root #emerge e2fsprogs xfsprogs dosfstools #--ask #optional
root #emerge dhcpcd #--ask #to allow system to pull from ovh which supplies your static address

Install/Configure Grub

root #emerge --verbose sys-boot/grub:2 #--ask
root #grub-mkconfig -o /boot/grub/grub.cfg
root #this step produces a wrong config and needs vdb replacing with vda #add sed for this

Set PW/Rebooting

root #passwd #to script
root #exit
root #cd
root #umount -l /mnt/gentoo/dev{/shm,/pts,} #needs updating
root #umount -R /mnt/gentoo
root #reboot

at this step we need to go back to OVH control panel and reboot the VPS - this will leave rescue mode

(Is an important box suitable as an instruction?)

at this step we need to go back to OVH control panel and reboot the VPS - this will leave rescue mode

Other Utilities

Virtual machines are not reliable timewise

root #emerge --ask bash-completion ntp #optional #ntp pulls from dhcpcp on bytemark - what about OVH?
root #/etc/init.d/ntp-client start
root #rc-update add ntp-client default

Clean up? rm stage3 (its marked above as it was part of a previous script

root ##eselect news purge all
root ##dist files? src? etc

  • add steps to return to chroot from rescue environment if something goes wrong