# - bof - #

#!/bin/bash



<<'comment'
# -  - #
# - File name - #
Btrfs-FileSystemConfiguration.sh

cd ~/; rm -rf ~/ArchBase1_Ermanno_Btrfs.sh; vim ~/ArchBase1_Ermanno_Btrfs.sh;
copy & paste this content
chmod +x ~/ArchBase1_Ermanno_Btrfs.sh; ~/./ArchBase1_Ermanno_Btrfs.sh;

cd ~/.ssh;
ssh-keygen -t rsa;

# -  - #
# - Fixing ssh error - #
ssh-keygen -R "you server hostname or ip"
ssh-keygen -R 10.0.0.1
ssh-keygen -R 192.168.1.1;
comment




#:1
# -  - #
# - Initial configuration - #
timedatectl set-ntp true;
timedatectl set-timezone America/New_York;

# -  - #
# - BTRFS Requirements - #
<<'comment'
 vda                                                                                              
 ├─vda1 vfat     FAT32            EFI BOOT    0548-C74E                                           
 ├─vda2 swap     1                Swap        c7335240-6db1-4a89-89ce-428b77ce5c0b                
 ├─vda3 btrfs                     Arch        a4011d58-cede-4059-afa0-00aaf0891d55                
 └─vda4 btrfs                     Data        2f14e979-a386-44ab-93fb-78ac932fd8a0
comment


#:1.1
# -  - #
# - Mount partitions & Create subvolumes - #
swapon /dev/vda2;
mount /dev/vda3 /mnt;

# -  - #
# - Create subvolumes - #
btrfs subvolume create /mnt/@;
btrfs subvolume create /mnt/@home;
btrfs subvolume create /mnt/@var;
btrfs subvolume create /mnt/@.snapshots;
umount /mnt;

# -  - #
# - Mount subvolumes - #
mount -o noatime,compress=lzo,space_cache=v2,subvol=@ /dev/vda3 /mnt;
mkdir -p /mnt/{boot,home,var,.snapshots};
mount -o noatime,compress=lzo,space_cache=v2,subvol=@home /dev/vda3 /mnt/home;
mount -o noatime,compress=lzo,space_cache=v2,subvol=@var /dev/vda3 /mnt/var;
mount -o noatime,compress=lzo,space_cache=v2,subvol=@.snapshots /dev/vda3 /mnt/.snapshots;

# - commit: Periodic interval (second) data is synchronized to permanent storage - #
#mount -o noatime,commit=120,compress=lzo,space_cache=v2,subvol=@ /dev/vda3 /mnt;

# -  - #
# - Create Data subvolume - #
mkdir -p /mnt/Data;
mount /dev/vda4 /mnt/Data;
btrfs subvolume create /mnt/Data/@Data;
umount /mnt/Data;

# -  - #
# - Mount Data subvolume - #
mount -o noatime,compress=lzo,space_cache=v2,subvol=@Data /dev/vda4 /mnt/Data;

# -  - #
# - Efi mount (Arch alone install) - #
mount /dev/vda1 /mnt/boot;

echo " ";
read -t 5 -p "Partitions processed.";
echo "5 Seconds pause...";


#:1.3
# -  - #
# - Install linux base - #
pacstrap /mnt base base-devel btrfs-progs dhcpcd dialog gedit git grub grub-btrfs linux linux-headers \
              linux-firmware mesa nano net-tools netctl networkmanager network-manager-applet openssh \
              samba snapper sudo sshfs tilix vim wpa_supplicant;



#:1.4
# -  - #
# - Generate fstab file - #
genfstab -U /mnt >> /mnt/etc/fstab;



#:1.5
# -  - #
# - Get into the new ArchLinux (login as root) - #
arch-chroot /mnt;



# - eof - #
