<commit_before>Btrfs on Whole Drive
====================

Installing Btrfs on the whole drive simplifies setup of a new system.  In this
setup, Btrfs occupies the entire storage device, including the partition table,
and Btrfs subvolumes can be used to simulate partitions.  There are some
limitations to this, however.

* You cannot use whole disk encryption (to my knowledge).
* You cannot create swap space since Btrfs doesn't support swap files and there
  is no room to create a swap partition.
* You cannot use UEFI to boot.

Setup
-----

The following are commands I used to set Btrfs up on the whole drive:

    mkfs.btrfs -L nixos /dev/sda
    mount -o discard,compress=lzo /dev/sda /mnt
    nixos-generate-config --root /mnt

    nano /etc/nixos/hardware-configuration.nix

When editing `/etc/nixos/hardware-configuration.nix` I include the following...

    fileSystems."/" = {
      device = "/dev/disk/by-label/nixos";
      fsType = "btrfs";
      options = [ "discard" "compress=lzo" ];
    };

Then I continue with my configuration and run the NixOS install command.

    nano /etc/nixos/configuration.nix
    nixos-install

Before I restart, I apply compression to the installed files like so:

    btrfs filesystem defragment -r -v clzo /mnt

Compression isn't enabled during installation (a suggestion found on ArchWiki),
but will be enabled after reboot.

See Also
--------

* [Btrfs article on ArchWiki](https://wiki.archlinux.org/index.php/Btrfs)<commit_msg>Update btrfs_whole_drive.md with latest pattern<commit_after>Btrfs on Whole Drive
====================

Installing Btrfs on the whole drive simplifies setup of a new system.  In this
setup, Btrfs occupies the entire storage device, including the partition table,
and Btrfs subvolumes can be used to simulate partitions.  There are some
limitations to this, however.

* You cannot use whole disk encryption (to my knowledge).
* You cannot create swap space since Btrfs doesn't support swap files and there
  is no room to create a swap partition.
* You cannot use UEFI to boot.

Setup
-----

The following are commands I used to set Btrfs up on the whole drive:

    mkfs.btrfs -L nixos /dev/sda
    mount -o discard,compress=lzo /dev/sda /mnt
    nixos-generate-config --root /mnt

    nano /mnt/etc/nixos/hardware-configuration.nix

When editing `hardware-configuration.nix` I include the following...

    fileSystems."/" = {
      device = "/dev/disk/by-label/nixos";
      fsType = "btrfs";
      options = [ "discard" "compress=lzo" ];
    };

Next I replace the default `configuration.nix` with my own bootstrap
configuration.

    curl -o /mnt/etc/nixos/configuration.nix \
    https://raw.githubusercontent.com/KibaFox/nixos/master/bootstrap.nix

Install...

    nixos-install

Notes
-----

ArchWiki suggests not to enable compression during installation, but does not
explain why.  I haven't had an issue installing NixOS with compression on during
installation.

If you decide to have compression off during installation, then before you
restart you can apply compression to the installed files like so:

    btrfs filesystem defragment -r -v clzo /mnt

See Also
--------

* [Btrfs article on ArchWiki](https://wiki.archlinux.org/index.php/Btrfs)
{'fraction_non_alphanumeric': 0.09456118665018541, 'fraction_numerical': 0.0, 'mean_word_length': 3.4160982264665756, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6925524', 'n_tokens_mistral': 977, 'n_tokens_neox': 943, 'n_words': 394}