User:Zulu Foxtrott/GentooOnARM/EasyInstall/CreatingFilesystems
Default Btrfs filesystem layout
In case a filesystem other than Btrfs will be used, this section can be skipped. In that case it is recommended to proceed with designing a partition scheme.
Btrfs is a modern copy-on-write (CoW) filesystem for Linux aimed at implementing advanced features while focusing on fault tolerance, repair, and easy administration. With Btrfs it's possible to use subvolumes to replicate the functionality - organizing and managing data - of what on older systems used to be implemented by an advanced partitioning scheme. Btrfs subvolumes are not block level devices, they are POSIX file namespaces. They can be created at any location in the filesystem and will act like any other directory on the system with the exception that subvolumes can be mounted and unmounted.
Throughout the remainder of the handbook, the following structure for the Btrfs filesystem on /dev/mmcblk0p4 will be used as a simple example layout:
Subvolume name | Parent volume | Future mountpoint | Description |
---|---|---|---|
not to be mounted by default | Toplevel volume | ||
rootvol | Toplevel volume | / | Subvolume to accomodate the root filesystem (rootfs) |
homevol | Toplevel volume | /home | Subvolume for the Users' home directories |
swapvol | Toplevel volume | /var/swap | Subvolume to host the swapfile |
TODO remove this section
For instance, to have TODO: what about those nowiki-tags (inherited from upstream handbook)?
To have the main partition () in btrfs as used in the example partition structure, the following command would be used:
root #
mkfs.btrfs
Alternatively, in case the main partition has been encrypted as outlined in the optional section above, use instead:
root #
mkfs.btrfs /dev/mapper/main_crypt
Now create the filesystems on the newly created partitions.
Creating Btrfs subvolumes
TODO: text
root #
mount /mnt
Alternatively, in case the main partition has been encrypted as outlined in the optional section above, use instead:
root #
mount /dev/mapper/main_crypt /mnt
TODO: text
root #
btrfs subvolume create /mnt/rootvol
root #
btrfs subvolume create /mnt/swapvol
root #
btrfs subvolume create /mnt/homevol
root #
umount
Mounting the subvolumes
Now that the partitions are initialized, are housing a filesystem, and subvolumes have been created, don't forget to create the necessary mount directories for every subvolume. Once this is done it is time to mount the subvolumes. Use the mount command followed by the command line parameter -o
to indicate that options are going to be passed to the command. The subvolume that is to be mounted can now be specified with the subvol=
option. As an example we mount the primary hierarchy root, the subvolume accommodating the rootfs:
root #
mount -o subvol=rootvol /mnt/gentoo
Alternatively, in case the main partition has been encrypted as outlined in the optional section above, use instead:
root #
mount -o subvol=rootvol /dev/mapper/main_crypt /mnt/gentoo
If /tmp/ needs to reside on a separate partition or subvolume, be sure to change its permissions after mounting:
root #
chmod 1777 /mnt/gentoo/tmp
Setting up the swapfile
As another example, in case it hasn't been done yet, create the mount directory for the subvolume that's going to host the swapfile:
root #
mkdir /mnt/gentoo/var/swap
Mount the respective subvolume:
root #
mount -o subvol=swapvol /mnt/gentoo/var/swap
Create an empty file that will serve as the swap space:
root #
touch /mnt/gentoo/var/swap/swapfile
Adjust the permissions:
root #
chmod 600 /var/swap/swapfile
Disable copy-on-write (COW) for the swapfile:
root #
chattr +C /var/swap/swapfile
As COW is disabled, it's necessary to define the size of the swapfile:
root #
fallocate /var/swap/swapfile -l4g
mkswap is the command that is used to initialize swapfiles (and swap partitions):
root #
mkswap /var/swap/swapfile
Create the swapfile with the commands mentioned above.
Alternative: no btrfs
TODO
Mounting the boot partition
The boot partition () needs to be mounted, too:
root #
mount /mnt/gentoo/boot
Later in the instructions the proc filesystem (a virtual interface with the kernel) as well as other kernel pseudo-filesystems will be mounted. But first we [[Handbook:Zulu Foxtrott/Installation/Stage|install the Gentoo installation files]].
Next
[[User:Zulu_Foxtrott/GentooOnARM/EasyInstall/Stage|Installing the Gentoo installation files]]