Re: Guix System on a GCE VM -- Success

2020-04-08 Thread elaexuotee
elaexuotee--- via "Development of GNU Guix and the GNU System distribution." 
 wrote:
> > This all looks pretty nifty! Just to be clear, under which license did
> > you make this script available?
> 
> Ouch. That was a major oversight. Thanks for bringing this up!
> I went ahead and put it under the BSD-3-CLAUSE. Attached is the same source
> with a copyright notice and license header.


It looks like I messed up the attachment. Trying again.

#!/usr/bin/env sh
set -o errexit -o noclobber -o nounset

# Copyright (c) 2020 elaexuo...@wilsonb.com. All rights reserved.
#
# Licensed under 
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
#this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
#this list of conditions and the following disclaimer in the documentation
#and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors
#may be used to endorse or promote products derived from this software
#without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.


## GCE Custom Image
#
# This script intends to be "executable documention" for the process of setting
# up a Google Compute Engine (GCE) virtual machine from a custom image.


usage() {
cat <<-USAGE
Usage: $(basename "${0}") [options]  [ [..]]

This script aids in setting up Google Compute Engine with an instance
running a custom image.

Execute commands in order provided at the command line. The procedure
for a fresh setup follows the order listed below in Status Commands.

Setup Commands:
  mkconf  Configure files on raw image partition
  mkraw   Convert image to raw format
  mksize  Grow image to integer multiple of GBs
  mktar   Archive raw image
  mkgsb   Create GS bucket

  togsa   Upload archive to GS bucket
  togci   Create GCE image from GS archive
  togvm   Create GCE instance from GCE image

Status Commands:
  ckconf  Check contents of qcow2 image
  ckraw   Check integrity of raw image
  cksize  Check size of raw image
  cktar   Check contents of tar archive
  ckgsb   Check existence of GS bucket
  ckgsa   Check existence of tar archive in GS bucket
  ckgci   Check existence of GCE image
  ckgvm   Check status of GCE instance

  ttysro  View GCE instance's serial output
  ttysrw  Connect to instance serial port

Removal Commands:
  rmgvm   Remove GCE instance
  rmgci   Remove GCE image
  rmgsa   Remove archive from GS bucket
  rmgsb   Remove GS bucket

Metainfo Commands:
  helpShow this help message
  varsPrint value of configuration variables

Options:
  -f  Family name for GCE image
  -v Version string of GCE image
  -nName of GCE image

  -NName of GCE instance
  -s  Subnet name of GCE instance
  -mMachine type of GCE instance

  -B URI of GS bucket
  -A URI of GS tar file

  -p  Partition of image on which / resides
  -S  Serial port of GCE instance

  -bCommon path base for files and names
  -gPath on image of grub.cfg
  -iLocal path of source image file
  -rLocal path of raw image file
  -aLocal path of tar file

  -h  Show this help message
USAGE
}

fail() {
msg=${1}; errno=${2-1}

>&2 printf 'Error: %s\n' "${msg}"
>&2 usage
exit "${errno}"
}


Re: Guix System on a GCE VM -- Success

2020-04-08 Thread Development of GNU Guix and the GNU System distribution.
> This all looks pretty nifty! Just to be clear, under which license did
> you make this script available?

Ouch. That was a major oversight. Thanks for bringing this up!
I went ahead and put it under the BSD-3-CLAUSE. Attached is the same source
with a copyright notice and license header.



signature.asc
Description: PGP signature


Re: Guix System on a GCE VM -- Success

2020-04-08 Thread Jonathan Brielmaier
On 08.04.20 05:16, elaexuo...@wilsonb.com wrote:
> The boot problem fix boils down to this:
>
> (initrd-modules (cons "virtio_scsi" %base-initrd-modules))
>
> Referencing Google's documentation on operating system requirements [2], we 
> see
> that their VMs run with Virtio-SCSI controllers; however, it just so happens
> that the corresponding kernel module, virtio_scsi, is not included in the
> initrd by default. Would it make sense to change this default?

This had to been done on Hetzner Cloud as well. I wonder if its not
fixed already on master. Need to check that...



Re: Guix System on a GCE VM -- Success

2020-04-08 Thread Jelle Licht
Hey there,

elaexuo...@wilsonb.com writes:

> To simplify the process I created a script capable of setting up a GCE 
> instance
> from a local qcow2 image, which I am also attaching. The script is intentially
> not a simple turnkey solution, since you should be somewhat familiar with the
> GCE infrastructure before using it. However, feel free to ask questions if
> anything is unclear.

This all looks pretty nifty! Just to be clear, under which license did
you make this script available?

Thanks!
- Jelle



Guix System on a GCE VM -- Success

2020-04-07 Thread elaexuotee
Attached is a minimal system configuration I have used to successfully
create a virtual machine instance on Google's Compute Engine (GCE).

The stock QEMU image [1] fails to boot under GCE, and since there is some past
interest [0], I figure it may be helpful to share the salient issues and how I
deal with them in the config.scm.

The boot problem fix boils down to this:

(initrd-modules (cons "virtio_scsi" %base-initrd-modules))

Referencing Google's documentation on operating system requirements [2], we see
that their VMs run with Virtio-SCSI controllers; however, it just so happens
that the corresponding kernel module, virtio_scsi, is not included in the
initrd by default. Would it make sense to change this default?

That should be enough to get a working GCE instance running, provided you
follow Google's requirements for importing custom images [3]. It's not
challenging, but it takes time to familiarize oneself with GCE and the
associated toolchain.

To simplify the process I created a script capable of setting up a GCE instance
from a local qcow2 image, which I am also attaching. The script is intentially
not a simple turnkey solution, since you should be somewhat familiar with the
GCE infrastructure before using it. However, feel free to ask questions if
anything is unclear.

Returning back to config.scm, the only other non-obvious pieces deal with the
bootloader setup. On GCE at boot time, our only choice of interface is a serial
console, so the following set that up in case it becomes necessary:


  (bootloader (bootloader-configuration
...
(serial-speed 115200)
(terminal-outputs '(serial))
(terminal-inputs '(serial

  (kernel-arguments '("console=ttyS0,115200"))

We set the baud rate to 115200 instead of the default 9600, for two reasons.
One it is essential that grub.cfg get populated with the following:

serial [options]
terminal_output serial
terminal_input serial

and for some reason, bootloader-configuration seems to elide these lines
without serial-speed set to something other than 9600. Secondly, baud 115200
ends up providing a better shell experience anyway.

Finally, the attached config.scm sets a bootloader timeout of 0:

  (bootloader (bootloader-configuration
...
(timeout 0)))

Since the vm is completely headless during normal bootup, anything else just
slows down boot times.


Finally, GCE allows community supported images [4]. If there is enough
interest, it might make sense to invest the few cents per month to maintain a
Guix System one. Thoughts?

Hopefully, the above is clear. I am happy to answer any questions.


[0]:https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01815.html
[1]:https://ftp.gnu.org/gnu/guix/guix-system-vm-image-1.0.1.x86_64-linux.xz
[2]:https://cloud.google.com/compute/docs/images/building-custom-os
[3]:https://cloud.google.com/compute/docs/import/import-existing-image
[4]:https://cloud.google.com/compute/docs/images#community_supported_images

(use-modules (gnu))
(use-service-modules networking ssh)

(operating-system
  (host-name "guixsd")
  (timezone "Europe/Berlin")
  (locale "en_US.utf8")

  (bootloader (bootloader-configuration
(bootloader grub-bootloader)
(target "/dev/sda")
(theme (grub-theme))
(timeout 0)
(serial-speed 115200)
(terminal-outputs '(serial))
(terminal-inputs '(serial

  (kernel-arguments '("console=ttyS0,115200"))
  (initrd-modules (cons "virtio_scsi" %base-initrd-modules))

  (file-systems (cons (file-system
(device (uuid "b6a32092-b004-43ba-bab7-e4c8d5480026"))
(mount-point "/")
(type "ext4"))
  %base-file-systems))

  (users (cons (user-account
 (name "guest")
 (group "users")
 (supplementary-groups '("wheel")))
   %base-user-accounts))

  (services (append (list (service dhcp-client-service-type)
  (service openssh-service-type))
%base-services)))
#!/usr/bin/env sh
set -o errexit -o noclobber -o nounset

## GCE Custom Image
#
# This script intends to be "executable documention" for the process of setting
# up a Google Compute Engine (GCE) virtual machine from a custom image.


usage() {
cat <<-USAGE
Usage: $(basename "${0}") [options]  [ [..]]

This script aids in setting up Google Compute Engine with an instance
running a custom image.

Execute commands in order provided at the command line. The procedure
for a fresh setup follows the order listed below in Status Commands.

Setup Commands:
  mkconf  Configure files on raw image partition
  mkraw   Convert image to raw format