* How to boot GuixSD in LXD
@ 2016-12-17 22:49 David Braun
2016-12-18 19:27 ` David Craven
0 siblings, 1 reply; 5+ messages in thread
From: David Braun @ 2016-12-17 22:49 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 1720 bytes --]
Hi,
I just discovered GuixSD; it's very exciting! I want to boot it as a
virtual machine in LXD (https://www.ubuntu.com/cloud/lxd).
So far I've created a LXD image by using the GuixSD installer to create a
bare bones file system. Here's my etc/config.scm:
;; This is an operating system configuration template
;; for a "bare bones" setup, with no X11 display server.
(use-modules (gnu))
(use-service-modules networking ssh)
(use-package-modules admin)
(operating-system
(host-name "GuixSD")
(timezone "Etc/UTC")
(locale "en_US.UTF-8")
;; Assuming /dev/sdX is the target hard disk, and "my-root" is
;; the label of the target root file system.
(bootloader (grub-configuration (device "/dev/sda")))
(file-systems (cons (file-system
(device "my-root")
(title 'label)
(mount-point "/")
(type "ext4"))
%base-file-systems))
;; Add services to the baseline: a DHCP client and
;; an SSH server.
(services (cons* (dhcp-client-service)
(lsh-service #:port-number 2222)
%base-services)))
and my LXD metadata.yaml:
architecture: x86_64
creation_date: 1481846400
properties:
description: GuixSD 0.11.0 bare bones x86_64
os: GuixSD
release: 0.11.0
Now when I attempt to launch the image, LXD fails when it tries to start
/sbin/init and can't find it. I understand that GuixSD uses Shepherd
instead of init. What's the best way for me to configure the image so that
LXD can start it? Perhaps I should create a symlink at /sbin/init that
points to shepherd but I'm not sure if I should take the initrd into
account as well.
Thanks,
David
[-- Attachment #2: Type: text/html, Size: 5800 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to boot GuixSD in LXD
2016-12-17 22:49 How to boot GuixSD in LXD David Braun
@ 2016-12-18 19:27 ` David Craven
2016-12-19 14:24 ` Ludovic Courtès
2016-12-22 22:36 ` David Braun
0 siblings, 2 replies; 5+ messages in thread
From: David Craven @ 2016-12-18 19:27 UTC (permalink / raw)
To: David Braun; +Cc: guix-devel
Hi David,
I'm not familiar with LXD, so it might be helpful if you could share
more details of how you created the LXD image.
> Now when I attempt to launch the image, LXD fails when it tries to start
> /sbin/init and can't find it. I understand that GuixSD uses Shepherd
> instead of init. What's the best way for me to configure the image so that
> LXD can start it? Perhaps I should create a symlink at /sbin/init that
> points to shepherd
That sounds like it could work. I believe what you are looking for is
the boot script contained in a system derivation. If you used guix
system init to create the LXD image, you can find it by running $(guix
system build etc/config.scm)/boot.
> but I'm not sure if I should take the initrd into account as well.
LXD looks like it's based on containers, so the initrd shouldn't be
needed. The initrd's main task is to load the root file system and
then load the boot script that is passed through the --load argument
to the initrd from grub. So you should be able to skip the kernel
loading and the initrd and jump right into the boot script that starts
shepherd.
Part of grub.cfg:
menuentry "GNU with Linux-Libre 4.8.12 (beta)" {
search --label --set gnu-disk-image
linux /gnu/store/90nmdrl491nyhsy7ar1zczvz5wgqlymh-linux-libre-4.8.12/bzImage
--root=gnu-disk-image
--system=/gnu/store/qd2zplli61dnjawzfanagh5sikwlbz9m-system
--load=/gnu/store/qd2zplli61dnjawzfanagh5sikwlbz9m-system/boot
console=ttyS0
initrd /gnu/store/70shm14ywkydvp5f5lbzhl4wshkamwz4-base-initrd/initrd
}
The boot script:
(eval-when (expand load eval) (set! %load-path (cons
"/gnu/store/gi2zry48hdsr87yvasc3nv7niixab8lw-module-import"
%load-path)) (set! %load-compiled-path (cons
"/gnu/store/dz6yx4q81zb3pxvysblfd68lgwrya9a2-module-import-compiled"
%load-compiled-path)))(begin (begin (use-modules (guix build utils))
(letrec-syntax ((fail-safe (syntax-rules () ((_ exp rest ...) (begin
(catch (quote system-error) (lambda () exp) (const #f)) (fail-safe
rest ...))) ((_) #t)))) (fail-safe (delete-file-recursively "/tmp")
(delete-file-recursively "/var/run") (mkdir "/tmp") (chmod "/tmp"
1023) (mkdir "/var/run") (chmod "/var/run" 493)))) (primitive-load
"/gnu/store/xs63km6mqdkxdbwqkvbk2ryccaq80971-activate") (begin
(false-if-exception (delete-file "/run/booted-system")) (symlink
(readlink "/run/current-system") "/run/booted-system") (let loop ((fd
3)) (when (< fd 1024) (false-if-exception (close-fdes fd)) (loop (+ 1
fd)))) (execl (string-append
"/gnu/store/qfax650mynyx9x8wm8lq8w7fp82kkfc6-shepherd-0.3.2"
"/bin/shepherd") "shepherd" "--config"
"/gnu/store/i5cqh5kx4mmz616aqp9g8qkcq9v7fszg-shepherd.conf")))
HTH
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to boot GuixSD in LXD
2016-12-18 19:27 ` David Craven
@ 2016-12-19 14:24 ` Ludovic Courtès
2016-12-22 22:37 ` David Braun
2016-12-22 22:36 ` David Braun
1 sibling, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2016-12-19 14:24 UTC (permalink / raw)
To: David Craven; +Cc: guix-devel
David Craven <david@craven.ch> skribis:
> The boot script:
> (eval-when (expand load eval) (set! %load-path (cons
> "/gnu/store/gi2zry48hdsr87yvasc3nv7niixab8lw-module-import"
> %load-path)) (set! %load-compiled-path (cons
> "/gnu/store/dz6yx4q81zb3pxvysblfd68lgwrya9a2-module-import-compiled"
> %load-compiled-path)))(begin (begin (use-modules (guix build utils))
> (letrec-syntax ((fail-safe (syntax-rules () ((_ exp rest ...) (begin
> (catch (quote system-error) (lambda () exp) (const #f)) (fail-safe
> rest ...))) ((_) #t)))) (fail-safe (delete-file-recursively "/tmp")
> (delete-file-recursively "/var/run") (mkdir "/tmp") (chmod "/tmp"
> 1023) (mkdir "/var/run") (chmod "/var/run" 493)))) (primitive-load
> "/gnu/store/xs63km6mqdkxdbwqkvbk2ryccaq80971-activate") (begin
> (false-if-exception (delete-file "/run/booted-system")) (symlink
> (readlink "/run/current-system") "/run/booted-system") (let loop ((fd
> 3)) (when (< fd 1024) (false-if-exception (close-fdes fd)) (loop (+ 1
> fd)))) (execl (string-append
> "/gnu/store/qfax650mynyx9x8wm8lq8w7fp82kkfc6-shepherd-0.3.2"
> "/bin/shepherd") "shepherd" "--config"
> "/gnu/store/i5cqh5kx4mmz616aqp9g8qkcq9v7fszg-shepherd.conf")))
Scary, no? :-)
To understand where this code comes from, you can look at the output of
‘guix system extension-graph’, specifically arrows that flow in the
“boot” service. This “boot” service corresponds to:
http://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services.scm#n232
… and the main contribution to this boot script is:
http://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/shepherd.scm#n67
HTH!
Ludo’.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to boot GuixSD in LXD
2016-12-19 14:24 ` Ludovic Courtès
@ 2016-12-22 22:37 ` David Braun
0 siblings, 0 replies; 5+ messages in thread
From: David Braun @ 2016-12-22 22:37 UTC (permalink / raw)
To: ludo-at-gnu.org |Guix-box|; +Cc: guix-devel
[-- Attachment #1: Type: text/plain, Size: 174 bytes --]
On Mon, Dec 19, 2016 at 9:24 AM, ludo-at-gnu.org |Guix-box| <
2wkutzekpt@sneakemail.com> wrote:
>
> Scary, no? :-)
>
Haha, yes!
> HTH!
>
Thank you, it did!
Best,
David
[-- Attachment #2: Type: text/html, Size: 721 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to boot GuixSD in LXD
2016-12-18 19:27 ` David Craven
2016-12-19 14:24 ` Ludovic Courtès
@ 2016-12-22 22:36 ` David Braun
1 sibling, 0 replies; 5+ messages in thread
From: David Braun @ 2016-12-22 22:36 UTC (permalink / raw)
To: David Craven david-at-craven.ch |Guix-box|; +Cc: guix-devel
[-- Attachment #1: Type: text/plain, Size: 469 bytes --]
On Sun, Dec 18, 2016 at 2:27 PM, David Craven david-at-craven.ch |Guix-box|
<7br2j1e1rt@sneakemail.com> wrote:
> That sounds like it could work. I believe what you are looking for is
> the boot script contained in a system derivation. If you used guix
> system init to create the LXD image, you can find it by running $(guix
> system build etc/config.scm)/boot.
>
Thank you for the tips; they were helpful. I moved on from LXD to Docker
and I got it working.
David
[-- Attachment #2: Type: text/html, Size: 875 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-12-22 22:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-17 22:49 How to boot GuixSD in LXD David Braun
2016-12-18 19:27 ` David Craven
2016-12-19 14:24 ` Ludovic Courtès
2016-12-22 22:37 ` David Braun
2016-12-22 22:36 ` David Braun
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).