FIX A PC

How To Install BTRFS On Ubuntu Server, A Comprehensive Installation Tutorial.

Step 1: Prepare a Ubuntu Server USB, and boot to the Ubuntu image.
https://releases.ubuntu.com/
https://releases.ubuntu.com/21.04/ubuntu-21.04-live-server-amd64.iso


Step 2: Drop into the shell, configure installation for SSH access and login via SSH from another system

(drop into the shell by pressing F2, use Nano to make changes to SSH config.)
nano /etc/ssh/sshd_config           
(restarts SSH service to apply configured changes)
systemctl restart sshd 
(SSH to Ubuntu Server USB using your IP)
ssh root@youriphere

Step 3. Create partition table, create partitions and set up the BTRFS filesystem

(EDIT THE BELOW COMMANDS FOR YOUR DRIVE LAYOUT AND USE THEM AS A COPY AND PASTE GUIDE LINE IF NEEDED)
#!/bin/bash
#btrfs create volumes


#create legacy partition for 2 disk raid 1 drives
parted -a optimal /dev/sda "mklabel msdos"
parted -a optimal /dev/sdc "mklabel msdos"

#create boot
 partition for 2 disk raid 1 drives
parted -a optimal /dev/sda mkpart primary 2 1000
parted -a optimal /dev/sdc mkpart primary 2 1000

#create swap filesystem for 2 disk raid 1 drives
parted -a optimal /dev/sda mkpart primary 1000 10000
parted -a optimal /dev/sdc mkpart primary 1000 10000

#create root partition for 2 disk raid 1 drives
parted -a optimal /dev/sda "mkpart primary 10000 -1"
parted -a optimal /dev/sdc "mkpart primary 10000 -1"

#create swap filesystem for 2 disk raid 1 drives
mkswap /dev/sda2
mkswap /dev/sdc2

#swap on enable swap filesystem for 2 disk raid 1 drives
swapon /dev/sda2
swapon /dev/sdc2

#make btrfs filesystem for boot partition on 2 disk raid 1 drives
mkfs.btrfs -m raid1 -d raid1 /dev/sda1 /dev/sdc1 -f

#make btrfs filesystem for root partition on 2 disk raid 1 drives
mkfs.btrfs -m raid1 -d raid1 /dev/sda3 /dev/sdc3 -f

#make partitionless btrfs filesystem for datastore
 (10x 2tb on raid10)
mkfs.btrfs -m raid10 -d raid10 /dev/sdi /dev/sdl /dev/sdj /dev/sdh /dev/sdd /dev/sdb /dev/sdk /dev/sdf /dev/sde /dev/sdg -f

#set boot to on state for 2 disk raid1
parted -a optimal /dev/sda set 1 boot on
parted -a optimal /dev/sdc set 1 boot on

Step 4. Create a mount directory, mount root BTRFS filesystem and copy ROFS files

mkdir /mnt/osdrive               (Creates mount directory for mounting BTRFS filesystem)
mount /dev/sda3 /mnt/osdrive     (Mounts primary BTRFS filesystem)
cd /rofs && cp -a * /mnt/osdrive (Copies all the base Ubuntu Server OS files to the root of the BTRFS filesystem)

Step 5. Mount proc, sys, dev and chroot

mount --type proc /proc /mnt/osdrive/proc           (Mounts the Linux running process folder)
mount --rbind /sys /mnt/osdrive/sys                 (Mounts the system folder)
mount --rbind /dev /mnt/osdrive/dev                 (Mounts the devices folder)
mount --make-rslave /mnt/osdrive/sys                (Mounts the system folder)
mount --make-rslave /mnt/osdrive/dev                (Mounts the devices folder)
chroot /mnt/osdrive /bin/bash                       (Changes the root directory to /mnt/osdrive)
source /etc/profile
mount /dev/sda1 /boot

Step 6. Setup DNS, run apt update, apt upgrade and make trueroot directories

echo -e "nameserver 8.8.8.8"   >  /etc/resolv.conf   (writes DNS your ip to your DNS settings file)
apt update                                           (updates package repository list)          
apt upgrade                                          (updates packages installed on system)
mkdir /mnt/trueroot           (Create the subvol 0 mount directory for the root filesystem)
mkdir /mnt/datastore                 (Create a standard mount directory for your datastore)
mkdir /mnt/datastoretruetoort (Create the subvol 0 mount directory for the datastore drives)

Step 7. Prepare the Fstab mount file.

blkid   >  /etc/fstab                              (Prints all the UUIDs to the fstab file)
Clean up the UUIDs you forwarded to your Fstab file to represent the following mount layout. Keep in mind we have 2 BTRFS filesystems in this Fstab entry. 1 BTRFS filesystem is for 2 512GB drives, the other BTRFS filesystem is for primary storage pool called datastore. This storage pool is comprised of 10 2TB drives.

Step 8. Install Grub application and install grub to the starting sectors of the drive.

apt install grub2      (Installs grub2 application)
grub-install /dev/sda  (Installs grub to the starting sectors of the drive and creates a entry in the boot partition)

Step 9. Install kernel, modules, firmware, generate initramfs, generate grub config and reboot.

apt install linux-image-generic             (Installs kernel and a range of malicious but needed OS packages)
reboot                        (Reboots to your Ubuntu Server OS, should end up with a blinking cursor screen)