Giter Club home page Giter Club logo

helios4-nix's Introduction

Initial setup

This is written for this repo at tag build-sd

This sets up a machine with two disks using btrfs. This will clear anything already on the disks!

Setting up the disks:

# New partition tables on sda and sdb
sgdisk --clear --new 0:0:0 /dev/sda
sgdisk --clear --new 0:0:0 /dev/sdb

# Set up btrfs
mkfs.btrfs -m raid1 -d raid1 /dev/sda1 /dev/sdb1

# Create a subvolume called nixos
mount /dev/sda1 /mnt/
btrfs subvolume create /mnt/nixos
umount /mnt/

# Mount this subvolume and create volumes for some other directories
mount -t btrfs -o subvol=nixos /dev/sda1 /mnt
btrfs subvolume create /mnt/var
btrfs subvolume create /mnt/home
btrfs subvolume create /mnt/tmp
btrfs subvolume create /mnt/boot

Installing NixOS:

# Set up your desired machine configuration
vim /mnt/etc/nixos/configuration.nix

# Initialize nixpkgs repo in /mnt/etc now

# Install!
NIX_PATH=nixpkgs=/mnt/etc/nixpkgs/ nixos-install

Oops, we forgot to make a boot partition

# Set devid to the device id of /dev/sda1 (find with: btrfs filesystem show /mnt)
devid=...

# Shrink the disk by 500MB, can be any number larger than how much we'll shrink
# the partition by later
mount /dev/sda1 /mnt
btrfs filesystem resize $devid:-500m /mnt
umount /dev/sda1

# Delete the partition and make it again, 400MB smaller
sgdisk --delete 1 /dev/sda
sgdisk --new 0:0:-400M /dev/sda

# Create a boot partition
sgdisk --largest-new 0 /dev/sda
# This is the bootable attribute
sgdisk --attributes 2:set:2 /dev/sda

# Don't forget to resize the btrfs partition to fill the space
btrfs filesystem resize $devid:max /mnt

Booting to the new system

U-Boot's preference is to boot from the SD card, so to prevent this (hence getting it to boot from the HDD) we should move extlinux.conf on the SD card's boot partition.

mount /dev/mmcblk0p1 /mnt
mv /mnt/extlinux/extlinux.conf /mnt/extlinux/not-extlinux.conf/
umount /mnt

helios4-nix's People

Contributors

expipiplus1 avatar

Watchers

James Cloos avatar  avatar Arthur avatar  avatar

Forkers

fmagin arthurl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.