From 40665d78d10bc207ba4a8df311455161167da80c Mon Sep 17 00:00:00 2001 From: Felipe Martin Date: Sun, 29 Nov 2020 21:26:42 +0100 Subject: [PATCH] Drafts for future posts --- .../contents.lr | 4 +- .../contents.lr | 155 ++++++++++++++++++ .../contents.lr | 62 +++++++ 3 files changed, 219 insertions(+), 2 deletions(-) rename content/blog/{2020-12-09-self-hosting-my-home-part-1 => 00-self-hosting-my-home-part-1}/contents.lr (87%) create mode 100644 content/blog/01-archlinux-install-from-zero-to-hero/contents.lr create mode 100644 content/blog/02-running-alpine-on-raspi-3-from-usb/contents.lr diff --git a/content/blog/2020-12-09-self-hosting-my-home-part-1/contents.lr b/content/blog/00-self-hosting-my-home-part-1/contents.lr similarity index 87% rename from content/blog/2020-12-09-self-hosting-my-home-part-1/contents.lr rename to content/blog/00-self-hosting-my-home-part-1/contents.lr index 5c9cdc8..0604ab7 100644 --- a/content/blog/2020-12-09-self-hosting-my-home-part-1/contents.lr +++ b/content/blog/00-self-hosting-my-home-part-1/contents.lr @@ -1,8 +1,8 @@ title: Self hosting my home (part 1) --- -_template: blog/post.html +_template: blog-post.html --- -pub_date: 2020-12-09 +pub_date: 2021-12-31 --- body: diff --git a/content/blog/01-archlinux-install-from-zero-to-hero/contents.lr b/content/blog/01-archlinux-install-from-zero-to-hero/contents.lr new file mode 100644 index 0000000..117077b --- /dev/null +++ b/content/blog/01-archlinux-install-from-zero-to-hero/contents.lr @@ -0,0 +1,155 @@ +title: Arch Linux on my Dell XPS +--- +pub_date: 2021-12-31 +--- +body: + +## Create install media +## Install +- Follow the wiki + +``` sh +# Connect to the internet, the moment we do relector will update the mirrorlist +iwctl station wlan0 connect + +# Set up date and time +timedatectl set-ntp true +timedatectl set-timezone Europe/Madrid + +# Prepare the disk, the setup I used: +# Disk #0: 512MB, Boot partition, UEFI type +# Disk #1: 16384MB, SWAP, swap type +# Disk #2: Rest of the disk, btrfs type +# fdisk ... + +# Prepare the filesystems and the luks encryption +mkfs.vfat -F32 /dev/nmve0n1p0 +mkswap /dev/nmve0n1p1 +cryptsetup luksFormat /dev/nvme0n1p2 # Password here +cryptsetup open /dev/nvme0n1p2 luks +mkfs.btrfs -L btrfs /dev/mapper/luks + +# Prepare the btrfs partition +mkdir /mnt/luks +mount -t btrfs /dev/mapper/luks /mnt/luks +btrfs subvolume create root +btrfs subvolume create home +btrfs subvolume create snapshots + +# Mount everything under /mnt +mkdir /mnt/{home,boot} +mount -o subvol=root,compress=lzo /dev/mapper/luks /mnt +mount -o subvol=home,compress=lzo /dev/mapper/luks /mnt/home +mount /dev/nvme0n1p0 /mnt/boot + +# Run pacstrap with several base packages: +pacstrap /mnt \ +base \ +linux-lts linux-firmware \ +intel-ucode \ +terminus-font \ # Fonts in vconsole +man-db man-pages \ # Man pages +iwd sudo vim # Utilities + +# Generate the /etc/fstab file +genfstab -L /mnt >> /mnt/etc/fstab + +# Check everything is correct, use noatime and discard flags to +# make flash drive last longer +vim /mnt/etc/fstab + +# Enter into the system +arch-chroot /mnt + +# Setup timedate +timedatectl set-timezone Europe/Madrid + +# Sync the RTC from the system time (useful if dual booting) +hwclock --systohc + +# Set the en_US.UTF-8 locale (uncomment) +vim /etc/locale.gen +locale-gen + +# Setup default locale +echo 'LANG=en_US.UTF-8' > /etc/locale.conf + +# Setup keymap and font +echo 'KEYMAP=us\nFONT=ter-232n' > /etc/vconsole.conf + +# Setup the computer hostname +echo 'deru' > /etc/hostname + +# Setup the hosts file +echo '127.0.0.1 localhost\n::1 localhost\n127.0.1.1 deru.localdomain deru' > /etc/hosts + +# Set root password +passwd + +# Setup init hooks to use systemd +vim /etc/mkinitcpio.conf +# Remove udev and add systemd, sd-vconsole and sd-encrypt + +# Regenerate initrd +mkinitcpio -p linux-lts + +# Setup systemd-boot +bootctl --path=/boot install + +# Create the bootloader entry for Arch +LUKS_UUID=$(cryptsetup luksUUID /dev/nvme0n1p2) +cat >/etc/loader/entries/arch.conf < /boot/loader/loader.conf + +# System ready! +exit +reboot + +# Login as root + +# Setup IWD to use it's own DHCP +cat >/etc/iwd/main.con < +echo 'AutoConnect=true' >> /var/lib/iwd/.pks + +# Start and enable iwd and systemd-resolved services +systemctl enable --now iwd +systemctl enable --now systemd-resolved + +# Setup hibernate +# Get the swap disk UUID (double check this is the correct disk) +sudo blkid | grep swap | sed -rn 's/^.*UUID=\"([a-z0-9\-]+)\".*$/\1/p' + +# Add the resume boot parameter +vim /boot/loader/entries/arch.conf +# Under options: +# resume=UUID= +# Systemd should check automatically for the swap partition on GPT tables [1] + +# Setup suspend-then-hibernate +vim /etc/systemd/login.conf +# Find HandleLidSwitch and set `suspend-then-hibernate`. +vim /etc/systemd/sleep.conf +# Find HibernateDelaySec and set to 5min +# All these will be into effect in next boot +``` + +- [ ] IDLE toggle +- [ ] Docked toggle +- [ ] VConsole auto lock diff --git a/content/blog/02-running-alpine-on-raspi-3-from-usb/contents.lr b/content/blog/02-running-alpine-on-raspi-3-from-usb/contents.lr new file mode 100644 index 0000000..7ef8b19 --- /dev/null +++ b/content/blog/02-running-alpine-on-raspi-3-from-usb/contents.lr @@ -0,0 +1,62 @@ +title: Running Alpine Linux from USB on the Raspberry Pi 3 +--- +pub_date: 2021-12-31 +--- +body: + +``` sh +# Tested on Raspberry Pi 3 +# Create a Raspberry pi OS SD card +sudo apt update +sudo apt upgrade +sudo rpi-update +echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt +reboot + +# At this point the boot flag is enabled +# Prepare the USB + +# Install Alpine to USB Drive +# Format USB +# Create two partitions: +# - boot fat16 +# - root ext4 +tar xzvf ~/Downloads/alpine-rpi-3.12.1-armhf.tar.gz + +# boot/usercfg.txt: +enable_uart=1 # Not sure I need this +gpu_mem=32 # The minimal memory for the bootloader + +setup-alpine +apk update +apk add cfdisk e2fsprogs +mkfs.ext4 /dev/sda2 + +# Setup proper TZ +apk add tzdata +cp /usr/share/zoneinfo/Europe/Madrid /etc/localtime +echo "Europe/Madrid" > /etc/timezone +apk del tzdata + +mount /dev/sda2 /mnt +setup-disk -m sys /mnt +mount -o remount,rw /media/sda1 + +rm -f /media/sda1/boot/* +cd /mnt +rm boot/boot # Remove symlink + +mv boot/* /media/sda1/boot/ +rm -rf boot +mkdir media/sda1 + +ln -s media/sda1/boot boot + +# /mnt/etc/fstab +# Remove cdrom +# Add: +/dev/sda1 /media/sda1 vfat default 0 0 + +# Edit boot cmdline to boot from the ext partition +# /mnt +```