Next: , Up: 手动安装   [Contents][Index]

3.6.1 Keyboard Layout, Networking, and Partitioning

Before you can install the system, you may want to adjust the keyboard layout, set up networking, and partition your target hard disk. This section will guide you through this. 键盘布局

安装镜像使用的是美国的 qwerty 键盘布局,如果想更改,可以使用 loadkeys 命令。 例如,用以下命令选择 Dvorak 键盘布局:

loadkeys dvorak

See the files under /run/current-system/profile/share/keymaps for a list of available keyboard layouts. Run man loadkeys for more information. Networking


ifconfig -a

… 或者,使用 GNU/Linux 特有的 ip 命令:

ip address

Wired interfaces have a name starting with ‘e’; for example, the interface corresponding to the first on-board Ethernet controller is called ‘eno1’. Wireless interfaces have a name starting with ‘w’, like ‘w1p2s0’.


To configure a wired network run the following command, substituting interface with the name of the wired interface you want to use.

ifconfig interface up

… 或者,使用 GNU/Linux 特有的 ip 命令:

ip link set interface up

To configure wireless networking, you can create a configuration file for the wpa_supplicant configuration tool (its location is not important) using one of the available text editors such as nano:

nano wpa_supplicant.conf

As an example, the following stanza can go to this file and will work for many wireless networks, provided you give the actual SSID and passphrase for the network you are connecting to:

  psk="the network's secret passphrase"

Start the wireless service and run it in the background with the following command (substitute interface with the name of the network interface you want to use):

wpa_supplicant -c wpa_supplicant.conf -i interface -B

Run man wpa_supplicant for more information.

At this point, you need to acquire an IP address. On a network where IP addresses are automatically assigned via DHCP, you can run:

dhclient -v interface

Try to ping a server to see if networking is up and running:

ping -c 3

Setting up network access is almost always a requirement because the image does not contain all the software and tools that may be needed.

If you need HTTP and HTTPS access to go through a proxy, run the following command:

herd set-http-proxy guix-daemon URL

where URL is the proxy URL, for example

If you want to, you can continue the installation remotely by starting an SSH server:

herd start ssh-daemon

Make sure to either set a password with passwd, or configure OpenSSH public key authentication before logging in. 磁盘分区

Unless this has already been done, the next step is to partition, and then format the target partition(s).

The installation image includes several partitioning tools, including Parted (see Overview in GNU Parted User Manual), fdisk, and cfdisk. Run it and set up your disk with the partition layout you want:


If your disk uses the GUID Partition Table (GPT) format and you plan to install BIOS-based GRUB (which is the default), make sure a BIOS Boot Partition is available (see BIOS installation in GNU GRUB manual).

If you instead wish to use EFI-based GRUB, a FAT32 EFI System Partition (ESP) is required. This partition can be mounted at /boot/efi for instance and must have the esp flag set. E.g., for parted:

parted /dev/sda set 1 esp on

注: Unsure whether to use EFI- or BIOS-based GRUB? If the directory /sys/firmware/efi exists in the installation image, then you should probably perform an EFI installation, using grub-efi-bootloader. Otherwise you should use the BIOS-based GRUB, known as grub-bootloader. See 引导设置, for more info on bootloaders.

Once you are done partitioning the target hard disk drive, you have to create a file system on the relevant partition(s)10. For the ESP, if you have one and assuming it is /dev/sda1, run:

mkfs.fat -F32 /dev/sda1

For the root file system, ext4 is the most widely used format. Other file systems, such as Btrfs, support compression, which is reported to nicely complement file deduplication that the daemon performs independently of the file system (see deduplication).

Preferably, assign file systems a label so that you can easily and reliably refer to them in file-system declarations (see 文件系统). This is typically done using the -L option of mkfs.ext4 and related commands. So, assuming the target root partition lives at /dev/sda2, a file system with the label my-root can be created with:

mkfs.ext4 -L my-root /dev/sda2

If you are instead planning to encrypt the root partition, you can use the Cryptsetup/LUKS utilities to do that (see man cryptsetup for more information).

Warning: Note that GRUB can unlock LUKS2 devices since version 2.06, but only supports the PBKDF2 key derivation function, which is not the default for cryptsetup luksFormat. You can check which key derivation function is being used by a device by running cryptsetup luksDump device, and looking for the PBKDF field of your keyslots.

Assuming you want to store the root partition on /dev/sda2, the command sequence to format it as a LUKS2 partition would be along these lines:

cryptsetup luksFormat --type luks2 --pbkdf pbkdf2 /dev/sda2
cryptsetup open /dev/sda2 my-partition
mkfs.ext4 -L my-root /dev/mapper/my-partition

Once that is done, mount the target file system under /mnt with a command like (again, assuming my-root is the label of the root file system):

mount LABEL=my-root /mnt

Also mount any other file systems you would like to use on the target system relative to this path. If you have opted for /boot/efi as an EFI mount point for example, mount it at /mnt/boot/efi now so it is found by guix system init afterwards.

Finally, if you plan to use one or more swap partitions (see Swap Space), make sure to initialize them with mkswap. Assuming you have one swap partition on /dev/sda3, you would run:

mkswap /dev/sda3
swapon /dev/sda3

Alternatively, you may use a swap file. For example, assuming that in the new system you want to use the file /swapfile as a swap file, you would run11:

# This is 10 GiB of swap space.  Adjust "count" to change the size.
dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
# For security, make the file readable and writable only by root.
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
swapon /mnt/swapfile

Note that if you have encrypted the root partition and created a swap file in its file system as described above, then the encryption also protects the swap file, just like any other file in that file system.



Currently Guix System only supports ext4, btrfs, JFS, F2FS, and XFS file systems. In particular, code that reads file system UUIDs and labels only works for these file system types.


This example will work for many types of file systems (e.g., ext4). However, for copy-on-write file systems (e.g., btrfs), the required steps may be different. For details, see the manual pages for mkswap and swapon.

Next: , Up: 手动安装   [Contents][Index]