Commit graph

401 commits

Author SHA1 Message Date
Ludovic Courtès
61d9c4458e
image: Error out when passed an unsupported partition type.
* gnu/build/image.scm (make-partition-image): Use 'raise' instead of
'format' when TYPE is not supported.
(convert-disk-image): Remove unneeded 'begin'.
2020-11-05 16:13:50 +01:00
Mathieu Othacehe
a38d861e57
system: reconfigure: Use the disk-installer if provided.
Fixes: <https://issues.guix.gnu.org/44101>.

* gnu/build/bootloader.scm (write-file-on-device): Pass 'no-fail flag instead
of 'no-create. Use a latin-1 transcoder.
* guix/scripts/system/reconfigure.scm (install-bootloader-program): Add a
"disk-installer" argument and use it as a fallback.
(install-bootloader): Adapt accordingly.
* gnu/tests/reconfigure.scm (run-install-bootloader-test): Ditto.
2020-11-03 07:59:59 +01:00
Ludovic Courtès
11e19555e5
file-systems: Allow swap space lookup by UUID/label.
* gnu/build/file-systems.scm (%linux-swap-magic, %page-size): New
variables.
(linux-swap-superblock?, read-linux-swap-superblock)
(linux-swap-superblock-uuid, linux-swap-superblock-volume-name): New
procedures.
(%partition-label-readers, %partition-uuid-readers): Add them.
2020-10-30 01:14:20 +01:00
Ludovic Courtès
57a7aa1ae3
hurd-boot: Set /hurd/magic on /dev/fd.
* gnu/build/hurd-boot.scm (set-hurd-device-translators)[devices]: Add
"/dev/fd".
2020-10-14 15:22:55 +02:00
Ludovic Courtès
44e65a7588
hurd-boot: Create /servers/crash.
* gnu/build/hurd-boot.scm (set-hurd-device-translators): Create
/servers/crash.
2020-10-08 12:26:56 +02:00
Mathieu Othacehe
b97b423e3f
bootloader: Fix u-boot installation.
This is a follow-up of f19cf27c2b. The
bootloader installation must be done on the final disk-image, hence using
"disk-image-installer" instead of "installer" callback.

* gnu/bootloader/u-boot.scm: Turn all installer callbacks into
disk-image-installer callbacks.
* gnu/build/bootloader.scm (write-file-on-device): Open the output file with
'no-truncate and 'no-create options.
* gnu/system/image.scm (with-imported-modules*): Add (gnu build bootloader)
module.
2020-10-05 11:10:35 +02:00
Jelle Licht
e748183538
linux-container: Reset jailed root permissions.
* gnu/build/linux-container.scm (mount-file-systems): Add 'chmod' call.
* tests/containers.scm
("call-with-container, mnt namespace, root permissions"): New test.
2020-10-01 12:51:13 +02:00
Ludovic Courtès
d5366500ec
secret-service: Add proper logging procedure and log to syslog.
* gnu/build/secret-service.scm (log): New macro.
(secret-service-send-secrets, secret-service-receive-secrets): Use it
instead of raw 'format' calls.
2020-09-29 21:56:27 +02:00
Ludovic Courtès
59261a22f9
services: secret-service: Add initial client/server handshake.
This allows the client running on the host to know when it's actually
connect to the server running in the guest.  Failing that, the client
would connect right away to QEMU and send secrets even though the server
is not running yet in the guest, which is unreliable.

* gnu/build/secret-service.scm (secret-service-send-secrets): Add
 #:handshake-timeout.  Read from SOCK an initial message from the
server.  Return #f on error.
(secret-service-receive-secrets): Send 'secret-service-server' message
to the client.  Close SOCK upon timeout.
* gnu/services/virtualization.scm (hurd-vm-shepherd-service): 'start'
method returns #f when 'secret-service-send-secrets' returns #f.
2020-09-29 21:56:27 +02:00
Ludovic Courtès
f9090015c5
secret-service: Fix file port leak in 'secret-service-send-secrets'.
* gnu/build/secret-service.scm (secret-service-send-secrets): Use
'call-with-input-file' instead of 'open-input-file'.
2020-09-29 21:56:27 +02:00
Ludovic Courtès
4d047853da
secret-service: Add a timeout when waiting for a client.
* gnu/build/secret-service.scm (secret-service-receive-secrets)
[wait-for-client]: Call 'select' with a 60s timeout before 'accept'.
Return #f upon timeout.
[read-secrets]: Return FILES on success.
Adjust caller of 'wait-for-client' to handle #f.
2020-09-29 21:56:27 +02:00
Ludovic Courtès
118b6dbb46
secret-service: Clarify the origin of messages.
* gnu/build/secret-service.scm (secret-service-send-secrets)
(secret-service-receive-secrets): Prefix messages by "secret service".
2020-09-29 21:56:26 +02:00
Mathieu Othacehe
f441e3e8b5
image: Add support for compressed-qcow2 format.
* gnu/build/image.scm (convert-disk-image): New procedure.
(genimage): Remove target argument.
* gnu/system/image.scm (system-disk-image): Add support for 'compressed-qcow2
image format. Call "convert-disk-image" to apply image conversions on the
final image. Add "qemu-minimal" to the build inputs.
(system-image): Also add support for 'compressed-qcow2.
2020-09-29 11:42:52 +02:00
Mathieu Othacehe
6453915cf7
build: shepherd: Check for container support.
Fixes: <https://issues.guix.gnu.org/43533>.

* gnu/build/shepherd.scm (fork+exec-command/container): Check if containers
are supported before joining PID namespaces.
2020-09-21 10:22:12 +02:00
Mathieu Othacehe
b3a83f1ece
build: linux-container: Fix run-container.
This is a follow-up of 5316dfc0f1. Some users of
run-container may expect that the container is jailed, even if there are no
mounts. This is the case for some Guix tests.

* gnu/build/linux-container.scm (run-container): Do not jail the container
when the requested root is "/".
2020-09-10 09:38:52 +02:00
Stefan
1c3b709edb
linux-boot: Handle nfs-root device strings.
* gnu/build/linux-boot.scm (device-string->file-system-device): Support
nfs-root "device" strings.
* gnu/build/file-systems.scm (canonicalize-device-spec): Support nfs-root
"device" strings.
* gnu/machine/ssh.scm (machine-check-file-system-availability): Avoid
checking of NFS file systems.
* gnu/system.scm (read-boot-parameters, device-sexp->device): Support
nfs-root "device" strings.

Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
2020-09-07 11:00:48 +02:00
Mathieu Othacehe
8ce6f4dc28
installer: Run the installation inside a container.
When the store overlay is mounted, other processes such as kmscon, udev
and guix-daemon may open files from the store, preventing the
underlying install support from being umounted. See:
https://lists.gnu.org/archive/html/guix-devel/2018-12/msg00161.html.

To avoid this situation, mount the store overlay inside a container,
and run the installation from within that container.

* gnu/build/shepherd.scm (fork+exec-command/container): New procedure.
* gnu/services/base.scm (guix-shepherd-service): Support an optional PID
argument passed to the "start" method. If that argument is passed, ensure that
guix-daemon enters the given PID MNT namespace by using
fork+exec-command/container procedure.
* gnu/installer/final.scm (umount-cow-store): Remove it,
(install-system): run the installation from within a container.
* gnu/installer/newt/final.scm (run-install-shell): Remove the display hack.
2020-09-02 17:05:23 +02:00
Mathieu Othacehe
5316dfc0f1
linux-container: Do not jail the container unconditionally.
We may want to run a container inside the MNT namespace, without jailing the
container. If RUN-CONTAINER is passed a null MOUNTS list, do not jail the
container.

* gnu/build/linux-container.scm (run-container): Do not call
MOUNT-FILE-SYSTEMS if MOUNTS list is empty.
2020-09-02 17:05:23 +02:00
Mathieu Othacehe
22827396ba
install: Factorize cow-store procedure.
Move the cow-store procedure from the service declaration in (gnu system
install) to (gnu build install), so that it can be called from within a
different context than Shepherd.

* gnu/build/install.scm (mount-cow-store, unmount-cow-store): New procedures.
* gnu/system/install.scm (make-cow-store): Remove it,
(cow-store-service-type): adapt it accordingly.
2020-09-02 17:05:22 +02:00
Jan (janneke) Nieuwenhuizen
ec32d4f291
services: Add secret-service-type.
This adds a "secret-service" that can be added to a Childhurd VM to receive
out-of-band secrets (keys) sent from the host.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>

* gnu/services/virtualization.scm (secret-service-activation): New procedure.
(secret-service-type): New variable.
* gnu/build/secret-service.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
2020-09-01 16:06:38 +02:00
Mathieu Othacehe
755f365b02
linux-libre: Support module compression.
This commit adds support for GZIP compression for linux-libre kernel
modules. The initrd modules are kept uncompressed as the initrd is already
compressed as a whole.

The linux-libre kernel also supports XZ compression, but as Guix does not have
any available bindings for now, and the compression time is far more
significant, GZIP seems to be a better option.

* gnu/build/linux-modules.scm (modinfo-section-contents): Use
'call-with-gzip-input-port' to read from a module file using '.gz' extension,
(strip-extension): new procedure,
(dot-ko): adapt to support compression,
(ensure-dot-ko): ditto,
(file-name->module-name): ditto,
(find-module-file): ditto,
(load-linux-module*): ditto,
(module-name->file-name/guess): ditto,
(module-name-lookup): ditto,
(write-module-name-database): ditto,
(write-module-alias-database): ditto,
(write-module-device-database): ditto.
* gnu/installer.scm (installer-program): Add "guile-zlib" to the extensions.
* gnu/machine/ssh.scm (machine-check-initrd-modules): Ditto.
* gnu/services.scm (activation-script): Ditto.
* gnu/services/base.scm (default-serial-port): Ditto,
(agetty-shepherd-service): ditto,
(udev-service-type): ditto.
* gnu/system/image.scm (gcrypt-sqlite3&co): Ditto.
* gnu/system/linux-initrd.scm (flat-linux-module-directory): Add "guile-zlib"
to the extensions and make sure that the initrd only contains
uncompressed module files.
* gnu/system/shadow.scm (account-shepherd-service): Add "guile-zlib" to the
extensions.
* guix/profiles.scm (linux-module-database): Ditto.
2020-08-25 11:53:20 +02:00
Mathieu Othacehe
7c27bd115b
file-system: Add mount-may-fail? option.
* gnu/system/file-systems.scm (<file-system>): Add a mount-may-fail? field.
(file-system->spec): adapt accordingly,
(spec->file-system): ditto.
* gnu/build/file-systems.scm (mount-file-system): If 'system-error is raised
and mount-may-fail? is true, ignore it. Otherwise, re-raise the exception.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
2020-07-31 13:43:20 +02:00
Mathieu Othacehe
675e56221e
file-systems: Add NTFS support.
* gnu/system/uuid.scm (%ntfs-endianness): New macro,
(ntfs-uuid->string): new procedure,
(%ntfs-endianness): new variable,
(string->ntfs-uuid): new exported procedure,
(%uuid-parsers): add NTFS support,
(%uuid-printers): add NTFS support.
* gnu/build/file-systems.scm (%ntfs-endianness): New macro,
(ntfs-superblock?, read-ntfs-superblock, ntfs-superblock-uuid,
check-ntfs-file-system): new procedure,
(%partition-uuid-readers): add NTFS support,
(check-file-system): add NTFS support.
2020-07-26 18:35:10 +02:00
Jan (janneke) Nieuwenhuizen
4b9eecd322
image: Do not set journal_model=WAL for the Hurd.
This fixes <https://bugs.gnu.org/42151>.

* gnu/system/images/hurd.scm (hurd-initialize-root-partition): Use #:wal-mode #f
in call to ...
* gnu/build/image.scm (initialize-root-partition): ... this, add #:wal-mode?
parameter, pass it to ...
(register-closure): ... this, add #:wal-mode? parameter, pass it to ...
* guix/store/database.scm (with-database): ... this, add #:wal-mode?
parameter, pass it to ...
(call-with-database): ... this, add #:wal-mode? parameter; when
set to #f, do not set journal_model=WAL.
2020-07-11 16:34:01 +02:00
Jan (janneke) Nieuwenhuizen
65d95e5d85
hurd-boot: Mount /proc, add /etc/mtab.
* gnu/build/hurd-boot.scm (set-hurd-device-translators): Mount /proc.  Add
symlink to /etc/mtab into /proc/mounts.
2020-06-27 13:01:40 +02:00
Jan (janneke) Nieuwenhuizen
db08a0d203
hurd-boot: Remove duplicate calls to 'scope'.
* gnu/build/hurd-boot.scm (set-hurd-device-translators): Remove duplicate
calls to 'scope'.
2020-06-27 12:59:40 +02:00
Mathieu Othacehe
7f75a7ec08
system: image: Remove "image-root" when building raw disk-images.
The "image-root" derivation output is used as a temporary directory that is
passed to mke2fs and mkdosfs later on. By merging the creation of this
directory and the production of partition images, we can get rid of the
derivation.

As mke2fs and mkdosfs are not able to override file permissions, call those
commands with fakeroot. This way, all the image files will be owned by root,
even if image generation is done in an unprivilegded context.

* gnu/system/image.scm (system-disk-image): Merge "image-root" and
"iso9660-image" derivations so that we spare an extra derivation. Also add
"fakeroot" and its runtime dependencies to the inputs.
* gnu/build/image.scm (make-ext-image, make-vfat-image): Make sure that mke2fs
and mkdosfs are respectively called by fakeroot.
2020-06-22 17:49:19 +02:00
Jan (janneke) Nieuwenhuizen
f25e8f76fe
hurd-boot: Use 'setxattr' instead of invoking settrans.
Note: Using `getxattr' on the Hurd instead of running showtrans does not
work (yet?).

* gnu/build/hurd-boot.scm (setup-translator): Use 'setxattr' instead of
invoking settrans.
* gnu/system.scm (hurd-multiboot-modules): Add --x-xattr-translator-records to
enable xattr-embedding of translators.
2020-06-19 10:40:53 +02:00
Jan (janneke) Nieuwenhuizen
951847ee37
hurd-boot: Create individual translators instead of running MAKEDEV.
* gnu/build/hurd-boot.scm (make-hurd-device-nodes): Do not create
dev/{null,zero,full,random,urandom} mount points.
(passive-translator-xattr?, passive-translator-installed?, translated?,
set-translator, set-hurd-device-translators): New procedures.
(false-if-EEXIST): New macro.
(boot-hurd-system): Use them instead of running MAKEDEV.
2020-06-19 10:38:26 +02:00
Ludovic Courtès
97a46055ca
database: 'register-items' takes an open database.
* guix/store/database.scm (store-database-directory)
(store-database-file): New procedures.
(call-with-database): Add call to 'mkdir-p'.
(register-items): Add 'db' parameter and remove #:state-directory and #:schema.
(register-path): Use 'store-database-file' and 'with-database', and
parameterize SQL-SCHEMA.
* gnu/build/image.scm (register-closure): Likewise.
* gnu/build/vm.scm (register-closure): Likewise.
* guix/scripts/pack.scm (store-database)[build]: Likewise.
2020-06-18 14:48:17 +02:00
Ludovic Courtès
8a02e45d93
shepherd: 'read-pid-file/container' terminates the whole process group.
This mirrors a change made in the Shepherd 0.8.0.  Previously, upon
startup failure, we could have left processes behind.

* gnu/build/shepherd.scm (read-pid-file/container): Kill (- PID) instead
of PID.
2020-06-12 00:04:42 +02:00
Ludovic Courtès
b6b95685d0
shepherd: Unblock signals in the child process.
Fixes <https://bugs.gnu.org/41791>.
Reported by Tobias Geerinckx-Rice <me@tobias.gr>.

This change mirrors changes made in the Shepherd 0.8.1, where signals
are blocked in the shepherd process in support of 'signalfd'.  The
regression was introduced with the switch to 0.8.1 in
3f9c62d1a8: child processes would not
receive SIGTERM upon 'herd stop SERVICE'.

* gnu/build/shepherd.scm <top level>: Autoload (shepherd system).
(make-forkexec-constructor/container): Call call to 'sigaction' and
'unblock-signals'.
2020-06-12 00:04:42 +02:00
Royce Strange
ea80cdbcea
activation: Fix function call for system activation
* gnu/build/activation.scm (boot-time-system):
Evaluate the linux-command-line thunk for linux systems to boot

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-06-09 10:43:54 +02:00
Mathieu Othacehe
8423c2d309
build: image: Do not call make-essential-device-nodes by default.
Calling "mknod" without root permissions fails. Plus those device nodes do not
appear to be needed to boot.

* gnu/build/image.scm (initialize-root-partition): Do not use
make-essential-device-nodes as default make-device-nodes procedure.
2020-06-09 10:32:19 +02:00
Jan (janneke) Nieuwenhuizen
68d8c09465
gnu: services: Add %hurd-startup-service.
This decouples startup of the Hurd from the "hurd" package, moving the RC
script into SYSTEM.

* gnu/packages/hurd.scm (hurd)[inputs]: Remove hurd-rc-script.
[arguments]: Do not substitute it.  Update "runsystem.sh" to parse kernel
arguments and exec into --system=SYSTEM/rc.
(hurd-rc-script): Move to...
* gnu/services.scm (%hurd-rc-file): ...this new variable.
(hurd-rc-entry): New procedure.
(%hurd-startup-service): Use it in new variable.
* gnu/system.scm (hurd-default-essential-services): Use it.
2020-06-08 14:26:14 +02:00
Jan (janneke) Nieuwenhuizen
b37c544196
hurd-boot: Further cleanup of "rc".
* gnu/packages/hurd.scm (hurd-rc-script): Move implementation to ...
* gnu/build/hurd-boot.scm (boot-hurd-system): ...here, new file.
* gnu/build/linux-boot.scm (make-hurd-device-nodes): Move there likewise.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
2020-06-08 14:26:14 +02:00
Jan (janneke) Nieuwenhuizen
c3fd2df705
system: Support activation service for the Hurd.
* gnu/build/activation.scm (boot-time-system): Use "command-line" for the
Hurd.
* gnu/system.scm (hurd-default-essential-services): Add %boot-service and
%activation-service.
2020-06-08 14:12:20 +02:00
Mathieu Othacehe
c77b92859f
image: Add Hurd support.
* gnu/system/image.scm (hurd-disk-image): New exported variable,
(root-offset, root-label): new variables,
(esp-partition, root-partition): adapt accordingly,
(find-image): add Hurd support.
2020-06-08 13:51:18 +02:00
Jan (janneke) Nieuwenhuizen
6cea61f2fa
linux-boot: Update 'make-hurd-device-nodes'.
* gnu/build/linux-boot.scm (make-hurd-device-nodes): Avoid de-duplication of
device mount points; also create mount points for /servers/.
2020-06-08 13:51:18 +02:00
Ludovic Courtès
b347723445
vm: 'expression->derivation-in-linux-vm' always returns a native build.
* gnu/system/vm.scm (expression->derivation-in-linux-vm): Remove #:target.
[builder]: Use #+.  Don't pass #:target-arm32? and #:target-aarch64? to
'load-in-linux-vm'.
Pass #:target #f to 'gexp->derivation'.
(qemu-image): Adjust accordingly.
* gnu/build/vm.scm (load-in-linux-vm): Remove #:target-aarch64?
and #:target-arm32?.  Define them as local variables.
2020-06-06 23:28:49 +02:00
Mathieu Othacehe
72d1562a4d
build: image: Fix initialize-efi-partition docstring.
* gnu/build/image.scm (initialize-efi-partition): Turn BOOTLOADER-PACKAGE into
GRUB-EFI.
2020-05-29 12:20:15 +02:00
Mathieu Othacehe
05f37c16a3
image: Use grub-efi to install the EFI bootloader.
* gnu/build/image.scm (initialize-efi-partition): Rename bootloader-package
argument to grub-efi.
* gnu/system/image.scm (system-disk-image): Adapt accordingly to pass
grub-efi package.
2020-05-29 08:43:20 +02:00
Mathieu Othacehe
9c1adb2400
image: Add bootloader installation support.
* gnu/build/image.scm (initialize-root-partition): Add bootloader-package and
bootloader-installer arguments. Run the bootloader-installer if defined.
* gnu/system/image.scm (system-disk-image): Adapt the partition initializer
call accordingly.
2020-05-29 08:40:03 +02:00
Mathieu Othacehe
bd3716f6fe
image: Add partition file-system options support.
* gnu/image.scm (<partition>)[file-system-options]: New field,
(partition-file-system-options): new exported procedure.
* gnu/system/image.scm (partition->gexp): Adapt accordingly.
* gnu/build/image.scm (sexp->partition): Also adapt accordingly,
(make-ext-image): and pass file-system options to mke2fs.
2020-05-26 17:16:42 +02:00
Mathieu Othacehe
16f9124d1f
build: image: Add support for EXT2 and EXT3 file-systems.
* gnu/build/image.scm (make-ext4-image): Rename to ...
(make-ext-image): ... it, and pass the file-system type to mke2fs,
(make-partition-image): Adapt to call "make-ext-image" if the partition
file-system is prefixed by "ext".
2020-05-26 09:57:10 +02:00
Maxim Cournoyer
281d80d8e5
linux-boot: Refactor boot-system.
The --root option can now be omitted, and inferred from the root file system
declaration instead.

* gnu/build/file-systems.scm (canonicalize-device-spec): Extend to support NFS
directly, and...
* gnu/build/linux-boot.scm (boot-system): ...remove NFS special casing from
here.  Remove nested definitions for root-fs-type, root-fs-flags and
root-fs-options, and bind those inside the let* instead.  Make "--root" take
precedence over the device field string representation of the root file
system.
* doc/guix.texi (Initial RAM Disk): Document that "--root" can be left
unspecified.
2020-05-20 08:30:34 -04:00
Marius Bakke
87a40d7203
Merge branch 'master' into core-updates 2020-05-05 20:43:21 +02:00
Mathieu Othacehe
77f5296236
vm: Remove obsolete procedures.
* gnu/build/vm.scm (install-efi, make-iso9660-image): Remove those procedures
that are now implemented in (gnu build image) module,
(initialize-hard-disk): remove efi support.
* gnu/system/vm.scm (iso9660-image): Remove it,
(qemu-image): adapt it to remove ISO9660 support.
2020-05-05 16:13:55 +02:00
Mathieu Othacehe
f19cf27c2b
image: Add a new API.
Raw disk-images and ISO9660 images are created in a Qemu virtual machine. This
is quite fragile, very slow, and almost unusable without KVM.

For all these reasons, add support for host image generation. This implies the
use new image generation mechanisms.

- Raw disk images: images of partitions are created using tools such as mke2fs
  and mkdosfs depending on the partition file-system type. The partition
  images are then assembled into a final image using genimage.

- ISO9660 images: the ISO root directory is populated within the store. GNU
  xorriso is then called on that directory, in the exact same way as this is
  done in (gnu build vm) module.

Those mechanisms are built upon the new (gnu image) module.

* gnu/image.scm: New file.
* gnu/system/image.scm: New file.
* gnu/build/image: New file.
* gnu/local.mk: Add them.
* gnu/system/vm.scm (system-disk-image): Rename to system-disk-image-in-vm.
* gnu/ci.scm (qemu-jobs): Adapt to new API.
* gnu/tests/install.scm (run-install): Ditto.
* guix/scripts/system.scm (system-derivation-for-action): Ditto.
2020-05-05 16:13:53 +02:00
Mathieu Othacehe
f8fd115717
build: bootloader: Add install-efi procedure.
* gnu/build/bootloader.scm (install-efi): New procedure copied from (gnu build vm).
(install-efi-loader): New exported procedure, wrapping install-efi.
* gnu/build/vm.scm (initialize-hard-disk): Adapt to use install-efi-loader.
2020-05-05 16:08:33 +02:00