Blurt

When your NixOS store outgrows you...

I’m running around on TOA2017 and I just did something stupid. It all started with me being in the process of installing all of the tooling necessary to deal with the Estonian digital bureaucracy from my NixOS :snowflake: machine…

After noticing that I could build chrome with WideVine support, which I needed anyways for Netflix :unamused: I managed to trigger the most rigorous build on my nix setup to date. DAMN.

Apparently, WideVine support on Nix requires a lot of shit to be pulled and compiled from scratch. So much so that a 40 gig partition with about 20 percent of free space will not suffice to pull you through the experience.

So what happens when NixOS runs on a box without any storage left on the / partition? It chokes :angry:. Getting past the display manager has been one of my failings over the past hours. Good thing that I always walk with a bootable NixOS stick for exactly these occassions.

Fortunately enough, I had anticipated the potential need to do something rather rigorous to my machine, which prompted me to keep the user directory safely on a seperate partition allowing me to change my OS without risking my files :wink:.

Let’s run through the circus :snowflake:

The instructions on the NixOS page are pretty straightforward when it comes to partitioning. I will not provide any real help here since gparted makes creating, removing and modifying partitions a breeze.

nix-shell -p gparted
gparted
In case you are out of luck in enlarging the existing partition due to lack of a consecutive partition, you could consider stitching two partitions together in LVM and using them as a larger logical volume, but that is beyond the scope of this little note-to-self.

It’s my LVM and LUKS setup that required a bit more thought. I had formerly created a volume group with two logical volumes – a 40 gig btrfs volume and a 10 gig swap volume. With both volumes mounted into the system I had to

  • reconfigure Nix to boot without the swap volume
  • reboot to system such that the swap volume is not utilised
  • remove the swap volume
  • resize the root volume to fill the entire drive
  • resize the btrfs partition to utilize the full size of the volume

TL;DR

So Tech Open Air has been pretty cool so far, I’ve

  • played around with tools for building chatbots (wasn’t really impressive, anyways I learned something there)
  • witnessed a classical mini concert mixed with a perfume experience that was quite meditative,
  • learned about another innovation in mobility that rises from inventive minds in Karlsruhe
  • got some inside scoop and lessons from a bunch of cool people including
    • Gadi from NewDealDesign (one of the bright minds behind Fitbit),
    • Ryan from Floodgate Fund (one of the bright minds behind Beats by Dre),
    • a couple of professors working on some cool interactive work-out setups backed by the Max-Planck Institute and
    • a plethora of AI-heads working on a number of different problems.

Meanwhile I’m dealing with my little machine fuck-up :rage:

Basically /etc/nixos/hardware-configuration.nix contains a listing of the disk configuration that is currently in effect. Since I had another swap partition taking up the space that I needed to expand my logical volume to accomodate my growing needs, I I needed to remove the line referencing the device that bears the uuid to the LVM mapping for my swap drive in order to avoid mounting it at boot :wink:.

In my case realpath /dev/disk/by-uuid/UUID_OF_SWAP_B pointed to /dev/dm-N which is the path for a mapped device so out it went.

swapDevices = [
  { device = "/dev/disk/by-uuid/UUID_OF SWAP_A"; }
  # { device = "/dev/disk/by-uuid/UUID_OF_SWAP_B"; }
];

After a reboot, I was able to remove the swap partition with

sudo lvremove /dev/vg/swap

and subsequently extend the logical volume using

sudo lvextend -l 100%FREE /dev/vg/root

That is all :wink: and all done within a few minutes.

After that I proceeded to nixos-rebuild test. The google-chrome package with WideVine is still building. A full day of occassionally plugging in to build has not been enough :hourglass_flowing_sand:.

It’s about time to leave the premises. Something with a raft is next :rowboat: :metal:.

So I’ll sudo systemctl hibernate and continue this busy work later… Well busy-work for the machine… I basically just read papers, chat with cool people including my Startupbus family and of course… chill :grin:

The day after the build [failed](https://github.com/NixOS/nixpkgs/issues/26299). :shit:

Debugging :frown:

The [Nix manual](https://nixos.org/nixos/manual/index.html#sec-nix-gc) mentions the use of the `nix-store --optimise` command which, also in my case cleaned up 20 gigs of 50 so yeah... do yourself a favor. :wink:

Learnings

  • install your home directory to a seperate partition… you’ll be glad you did someday
  • do encrypt your :shit: (just because…)
  • use LVM… It’s convenient to be able to stitch LV’s together if you ever run out of space :wink:
  • read up on how to clean your Nix store