OVH Rescue Install

OVH' installer does not offer btrfs with btrfs raid, only with mdadm and limited options. so DiY!

stop raid

mdadm --stop /dev/md*

partiton:

gdisk /dev/sda
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048            4095   1024.0 KiB  EF02  BIOS boot partition
   2            4096         1052671   512.0 MiB   FD00  Linux RAID
   3         1052672         3149823   1024.0 MiB  FD00  Linux RAID
   4         3149824        34607103   15.0 GiB    8300  Linux filesystem
   5        34607104       937703054   430.6 GiB   8300  Linux filesystem

copy to other disc

sgdisk -R=/dev/sdb /dev/sda

NEW UUIDS!

sgdisk --randomize-guids /dev/sdb

..tell the kernel:

partprobe /dev/sda* /dev/sdb*

mdadm raid1 for /boot - ignore metadata warning - grub2 is fine

mdadm --create /dev/md0 --level 1 --raid-devices=2 /dev/sda2 /dev/sdb2

mdadm raid2 for /swap

mdadm --create /dev/md1 --level 1 --raid-devices=2 /dev/sda3 /dev/sdb3 

cat /proc/mdstat

create swap

mkswap -L swap /dev/md1
swapon /dev/md1

boot fs

mkfs.ext2 -L bootfs /dev/md0

create btrfs raid fs root / home:

mkfs.btrfs -L rootfs -draid1 -mraid1 /dev/sda4 /dev/sdb4
mkfs.btrfs -L homefs -draid1 -mraid1 /dev/sda5 /dev/sdb5

mount the new partition

mkdir /debian/
mount /dev/sda4 /debian

check, that mkfs did the right thing: single chunks must not be used, “System, RAID1” is required to boot

btrfs fi df /debian/

if you find “System, single:…” convert to raid1, because single copies of data and metadata are not required in raid1-mode

btrfs bal start -v -f -sconvert=raid1 /debian/

check again:

btrfs fi df /debian/

remove all other single chunks:

btrfs bal start -v -f -dconvert=raid1 -mconvert=raid1 /debian/

do the same for homefs

mount /dev/sda5 /debian/home
btrfs fi df /debian/home
btrfs bal start -v -f -sconvert=raid1 /debian/home
btrfs bal start -v -f -dconvert=raid1 -mconvert=raid1 /debian/home

debootstrap

debootstrap --arch amd64 jessie /debian/ http://ftp.debian.org/debian/

mount chroot dirs && chroot into

cd /debian/ && mkdir boot dev proc sys
for i in dev proc sys ; do mount --bind /$i /debian/$i ; done

mount /dev/md0 /debian/boot
chroot /debian /bin/bash --login
nano /etc/apt/sources.list

deb http://ftp.debian.org/debian jessie main contrib non-free
deb-src http://ftp.fr.debian.org/debian/ jessie main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free

jessie-updates, previously known as 'volatile'

deb http://ftp.fr.debian.org/debian/ jessie-updates main contrib non-free
deb-src http://ftp.fr.debian.org/debian/ jessie-updates main contrib non-free

debian backports

deb http://ftp.debian.org/debian jessie-backports main
apt-get update && apt-get -y upgrade
nano /etc/fstab

/dev/sda4       /       btrfs   noatime,ssd,user_subvol_rm_allowed      0 0
/dev/sda5       /home   btrfs   noatime,ssd,user_subvol_rm_allowed      0 0
/dev/md0        /boot   ext2    noatime         0 1
/dev/md1        swap    swap    pri=3           0 0
tmpfs   /tmp    tmpfs   defaults        0 0
tmpfs   /var/tmp        tmpfs   defaults        0 0
# proc ... cgroup is automatic by init scripts

mtab:

ln -sf ../proc/mounts /etc/mtab

setup mdadm.conf:

  mdadm --detail --scan >> /etc/mdadm/mdadm.conf

install btrfs-tools: very important for initramfs generation, so the btrfs and scripts will be in initramfs if you miss this, you get: btrfs: error (device sda4) failed to read the system array: -5 btrfs: open_ctree failed

apt-get install btrfs-tools

kernel install (unsigned steht nur für non-secureboot)

apt-get -t jessie-backports install linux-image-4.7.0-0.bpo.1-amd64-unsigned

make /boot/grub/device.map or grub fails

grub-mkdevicemap
apt install openssh-server grub2 mdadm mc tmux

generate bootmenu, ..:

update-grub

& initramfs:

ln -s ../bin/fsck.btrfs /sbin/fsck.btrfs
ln -s ../bin/btrfs /sbin/btrfs
update-initramfs -kall -u

set passwd and keys!!

passwd 
ssh-keygen -t ed25519
mcedit /root/.ssh/authorized_keys

mcedit /etc/ssh/sshd_config 

reboot!

/sbin/reboot

good luck! :)

optional checks:

test if grub install something to sdb1 bios boot parti, to ensure boot works if sda1 failed

cat /dev/zero >/dev/sdb1
cat /dev/sdb1 | sha256sum
grub-install /dev/sdb
cat /dev/sdb1 | sha256sum

simulate disc failure - overwrite MBR on sda with 0000.. to check, if sdb boots:

dd bs=512 count=1 if=/dev/zero of=/dev/sda
reboot

to restore mbr, run:

dd bs=512 count=1 if=/dev/sdb of=/dev/sda

Howto:

 
Back to top
linux/debian_install/ovh_rescue_install.txt · Last modified: 2016/10/06 20:19 by tkilla