summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/guix.texi63
1 files changed, 56 insertions, 7 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index f5efd34024e..a9930d01e6b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -153,6 +153,7 @@ Copyright @copyright{} 2026 Nguyễn Gia Phong@*
153Copyright @copyright{} 2026 Yarl Baudig@* 153Copyright @copyright{} 2026 Yarl Baudig@*
154Copyright @copyright{} 2026 Joan Vilardaga Castro@* 154Copyright @copyright{} 2026 Joan Vilardaga Castro@*
155Copyright @copyright{} 2026 Nemin@* 155Copyright @copyright{} 2026 Nemin@*
156Copyright @copyright{} 2026 Fredrik Salomonsson@*
156 157
157Permission is granted to copy, distribute and/or modify this document 158Permission is granted to copy, distribute and/or modify this document
158under the terms of the GNU Free Documentation License, Version 1.3 or 159under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -2717,7 +2718,7 @@ bootloaders.
2717 2718
2718Once you are done partitioning the target hard disk drive, you have to 2719Once you are done partitioning the target hard disk drive, you have to
2719create a file system on the relevant partition(s)@footnote{Currently 2720create a file system on the relevant partition(s)@footnote{Currently
2720Guix System can mount only ext4, btrfs, JFS, F2FS, and XFS file systems 2721Guix System can mount only ext4, Btrfs, JFS, F2FS, and XFS file systems
2721at boot time. In particular, code that reads file system UUIDs and 2722at boot time. In particular, code that reads file system UUIDs and
2722labels works only for these file system types. The code for bcachefs is 2723labels works only for these file system types. The code for bcachefs is
2723in place, but support for loading out-of-tree kernel modules in the 2724in place, but support for loading out-of-tree kernel modules in the
@@ -2784,12 +2785,18 @@ mkswap /dev/sda3
2784swapon /dev/sda3 2785swapon /dev/sda3
2785@end example 2786@end example
2786 2787
2787Alternatively, you may use a swap file. For example, assuming that in 2788Alternatively, you may use a swap file, whose size can be trivially
2788the new system you want to use the file @file{/swapfile} as a swap file, 2789modified at a later date. Creating a swap file will look a bit
2789you would run@footnote{This example will work for many types of file 2790different depending on what sort of file system your new system is
2790systems (e.g., ext4). However, for copy-on-write file systems (e.g., 2791using. We therefore have two examples on how to create a swap file, the
2791btrfs), the required steps may be different. For details, see the 2792first will work for many types of file systems (e.g., ext4) but not
2792manual pages for @command{mkswap} and @command{swapon}.}: 2793Btrfs@footnote{For other copy-on-write file systems, the required steps
2794may also be different. For details, see the manual pages for
2795@command{mkswap} and @command{swapon}.}. The second example is
2796specifically for Btrfs.
2797
2798For the common case, assuming that in the new system you want to use the
2799file @file{/swapfile} as a swap file, you would run:
2793 2800
2794@example 2801@example
2795# This is 10 GiB of swap space. Adjust "count" to change the size. 2802# This is 10 GiB of swap space. Adjust "count" to change the size.
@@ -2800,6 +2807,35 @@ mkswap /mnt/swapfile
2800swapon /mnt/swapfile 2807swapon /mnt/swapfile
2801@end example 2808@end example
2802 2809
2810When you use Btrfs the steps for creating a swap file are slightly
2811different and it comes with a few caveats. I.e. it must be on a single
2812device, the filesystem must only have @code{single} as the data profile
2813and the subvolume that contains the active swap file or files cannot be
2814snapshotted. It is therefore best to put the swap file in a separate
2815subvolume to allow to snapshot the rest of the filesystem. This example
2816assumes the label for the Btrfs file system is @code{btrfs-pool} and the
2817subvolume for the root is @code{rootfs}.
2818
2819@example
2820# Temporarily unmount btrfs-pool
2821umount /mnt
2822# Mount the top level subvolume
2823mount LABEL=btrfs-pool -o subvolid=5 /mnt
2824# Create the subvolume (swap) that will hold the swap file
2825cd /mnt && btrfs subvolume create swap && cd -
2826# Remount the target file system
2827unmount /mnt
2828mount LABEL=btrfs-pool -o subvol=rootfs /mnt
2829# Create the directory where it should mount the swap subvolume
2830mkdir /mnt/swap
2831# Mount the swap subvolume
2832mount LABEL=btrfs-pool -o subvol=swap /mnt/swap
2833# Create a 10 GiB of swap space. It accepts k/m/g/e/p as suffix
2834btrfs filesystem mkswapfile --size 10G /mnt/swap/swapfile
2835# Activate the swap file
2836swapon /mnt/swap/swapfile
2837@end example
2838
2803Note that if you have encrypted the root partition and created a swap 2839Note that if you have encrypted the root partition and created a swap
2804file in its file system as described above, then the encryption also 2840file in its file system as described above, then the encryption also
2805protects the swap file, just like any other file in that file system. 2841protects the swap file, just like any other file in that file system.
@@ -2865,6 +2901,10 @@ Be sure that your file system labels match the value of their respective
2865your @code{file-system} configuration uses the @code{file-system-label} 2901your @code{file-system} configuration uses the @code{file-system-label}
2866procedure in its @code{device} field. 2902procedure in its @code{device} field.
2867 2903
2904If you are using Btrfs and your swap file is in a subvolume make sure to
2905list the root partition as its dependency in its @code{file-system}
2906entry to make sure everything is mounted in the right order.
2907
2868@item 2908@item
2869If there are encrypted or RAID partitions, make sure to add a 2909If there are encrypted or RAID partitions, make sure to add a
2870@code{mapped-devices} field to describe them (@pxref{Mapped Devices}). 2910@code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
@@ -19813,6 +19853,15 @@ $ sudo filefrag -e /swapfile | grep '^ *0:' | cut -d: -f3 | cut -d. -f1
19813 92514304 19853 92514304
19814@end smallexample 19854@end smallexample
19815 19855
19856Note that if the swap file is on a Btrfs file system use @command{btrfs
19857inspect-internal map-swapfile -r} instead of @command{filefrag} to get
19858the offset as the latter will not give the right offset.
19859
19860@smallexample
19861$ sudo btrfs inspect-internal map-swapfile -r /swapfile
19862 163845376
19863@end smallexample
19864
19816@node User Accounts 19865@node User Accounts
19817@section User Accounts 19866@section User Accounts
19818 19867