Knowledgebase

Install Arch Linux With Btrfs Snapshotting Print

  • 0

Preface

Arch Linux is a general-purpose distribution well-known for its cutting-edge technology and flexible configuration. With Btrfs snapshots, we can take the advantage of its fast-pace while being confident of the system's stability. Let's start.

Prerequisites

  • A newly-created Rcs instance.
  • Some free time and patience.

Preparations

You can choose the Arch Linux ISO from the ISO library when creating the instance. If not, you can load that in the machine's settings. As the time of writing the newest (2017.01.01) ISO is available in the library. If that ISO is outdated, I recommend downloading it again.

After the machine starts, click View Console and boot the system up. We need to set up a root password for the environment so that we can access it from our working computer:

passwd
systemctl start sshd

Close the VNC window and connect to the machine via ssh:

ssh root@<your host ip here>

Install tmux so that we can keep our session across unstable connections:

pacman -Sy tmux

If the connection accidentally closes during the installation, simply ssh back to the machine and run:

tmux attach

Installation

First things first, let's partition the disk.

lsblk
mkfs.btrfs -m single -L arch /dev/vda
mount -o compress=lzo /dev/vda /mnt

Next comes the tricky part: creating subvolumes.

cd /mnt
btrfs su cr @
btrfs su cr @boot
btrfs su cr @home
btrfs su cr @log
btrfs su cr @pkg
btrfs su cr @srv
btrfs su cr @tmp

Then, mount the subvolumes.

cd /
umount /mnt
mount -o compress=lzo,subvol=@ /dev/vda /mnt
cd /mnt
mkdir -p {boot,home,srv,var/{log,cache/pacman/pkg,tmp}}
mount -o compress=lzo,subvol=@boot /dev/vda boot
mount -o compress=lzo,subvol=@home /dev/vda home
mount -o compress=lzo,subvol=@log /dev/vda var/log
mount -o compress=lzo,subvol=@pkg /dev/vda var/cache/pacman/pkg
mount -o compress=lzo,subvol=@srv /dev/vda srv
mount -o compress=lzo,subvol=@tmp /dev/vda var/tmp

Install the base system.

pacstrap -i /mnt base base-devel snapper vim

Configure the system.

genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt
ln -s /usr/share/zoneinfo/Region/City /etc/localtime # Replace Region/City with your value
hwclock --systohc
vim /etc/locale.gen # Uncomment en_US.UTF-8 UTF-8 line
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
pacman -S networkmanager 
echo "your-hostname" > /etc/hostname # Replace your-hostname with your value
vim /etc/hosts # Configure 127.0.0.1 and ::1 lines accordingly
systemctl enable NetworkManager.service

Enable sshd for future remote logins.

vim /etc/ssh/sshd_config # Set PermitRootLogin yes
systemctl enable sshd.service

Note that the best practice is putting your public key into the ~/.ssh/authorized_keys file instead of enabling password login for root.

Configure the initramfs so that it satisfies our need for btrfs.

vim /etc/mkinitcpio.conf

Locate MODULES="..." and add btrfs into the list. Re-generate the initramfs:

mkinitcpio -p linux

Set the root password.

passwd

Install and configure the bootloader.

pacman -S grub
grub-install /dev/vda
grub-mkconfig -o /boot/grub/grub.cfg

Reboot and remove the ISO in your machine control panel.

exit
reboot

Connect to the server again (perhaps after a short while; wait until the boot completes). Note that the server fingerprint has changed, so you may need to alter your known_hosts file:

vim ~/.ssh/known_hosts
ssh root@<your host ip here>

Let's configure snapper, which automates the snapshotting procedure.

snapper -c root create-config /

Edit the config and alter TIMELINE_LIMIT_{HOURLY,DAILY,WEEKLY,MONTHLY,YEARLY} according to your needs.

vim /etc/snapper/configs/root

Enable the systemd timers.

systemctl enable snapper-timeline.timer
systemctl start snapper-timeline.timer
systemctl enable snapper-cleanup.timer
systemctl start snapper-cleanup.timer

Job's done!

The configuration of the system is now finished. For more detailed information about how to use snapper, consult the wiki page or snapper(8) for more information. Enjoy your new Arch Linux with btrfs auto-snapshotting system!

Preface Arch Linux is a general-purpose distribution well-known for its cutting-edge technology and flexible configuration. With Btrfs snapshots, we can take the advantage of its fast-pace while being confident of the system's stability. Let's start. Prerequisites A newly-created Rcs instance. Some free time and patience. Preparations You can choose the Arch Linux ISO from the ISO library when creating the instance. If not, you can load that in the machine's settings. As the time of writing the newest (2017.01.01) ISO is available in the library. If that ISO is outdated, I recommend downloading it again. After the machine starts, click View Console and boot the system up. We need to set up a root password for the environment so that we can access it from our working computer: passwd systemctl start sshd Close the VNC window and connect to the machine via ssh: ssh root@ Install tmux so that we can keep our session across unstable connections: pacman -Sy tmux If the connection accidentally closes during the installation, simply ssh back to the machine and run: tmux attach Installation First things first, let's partition the disk. lsblk mkfs.btrfs -m single -L arch /dev/vda mount -o compress=lzo /dev/vda /mnt Next comes the tricky part: creating subvolumes. cd /mnt btrfs su cr @ btrfs su cr @boot btrfs su cr @home btrfs su cr @log btrfs su cr @pkg btrfs su cr @srv btrfs su cr @tmp Then, mount the subvolumes. cd / umount /mnt mount -o compress=lzo,subvol=@ /dev/vda /mnt cd /mnt mkdir -p {boot,home,srv,var/{log,cache/pacman/pkg,tmp}} mount -o compress=lzo,subvol=@boot /dev/vda boot mount -o compress=lzo,subvol=@home /dev/vda home mount -o compress=lzo,subvol=@log /dev/vda var/log mount -o compress=lzo,subvol=@pkg /dev/vda var/cache/pacman/pkg mount -o compress=lzo,subvol=@srv /dev/vda srv mount -o compress=lzo,subvol=@tmp /dev/vda var/tmp Install the base system. pacstrap -i /mnt base base-devel snapper vim Configure the system. genfstab -U /mnt >> /mnt/etc/fstab arch-chroot /mnt ln -s /usr/share/zoneinfo/Region/City /etc/localtime # Replace Region/City with your value hwclock --systohc vim /etc/locale.gen # Uncomment en_US.UTF-8 UTF-8 line locale-gen echo "LANG=en_US.UTF-8" > /etc/locale.conf pacman -S networkmanager echo "your-hostname" > /etc/hostname # Replace your-hostname with your value vim /etc/hosts # Configure 127.0.0.1 and ::1 lines accordingly systemctl enable NetworkManager.service Enable sshd for future remote logins. vim /etc/ssh/sshd_config # Set PermitRootLogin yes systemctl enable sshd.service Note that the best practice is putting your public key into the ~/.ssh/authorized_keys file instead of enabling password login for root. Configure the initramfs so that it satisfies our need for btrfs. vim /etc/mkinitcpio.conf Locate MODULES="..." and add btrfs into the list. Re-generate the initramfs: mkinitcpio -p linux Set the root password. passwd Install and configure the bootloader. pacman -S grub grub-install /dev/vda grub-mkconfig -o /boot/grub/grub.cfg Reboot and remove the ISO in your machine control panel. exit reboot Connect to the server again (perhaps after a short while; wait until the boot completes). Note that the server fingerprint has changed, so you may need to alter your known_hosts file: vim ~/.ssh/known_hosts ssh root@ Let's configure snapper, which automates the snapshotting procedure. snapper -c root create-config / Edit the config and alter TIMELINE_LIMIT_{HOURLY,DAILY,WEEKLY,MONTHLY,YEARLY} according to your needs. vim /etc/snapper/configs/root Enable the systemd timers. systemctl enable snapper-timeline.timer systemctl start snapper-timeline.timer systemctl enable snapper-cleanup.timer systemctl start snapper-cleanup.timer Job's done! The configuration of the system is now finished. For more detailed information about how to use snapper, consult the wiki page or snapper(8) for more information. Enjoy your new Arch Linux with btrfs auto-snapshotting system!

Was this answer helpful?
Back

Powered by WHMCompleteSolution