Próximo: image-type Reference, Anterior: image
Reference, Acima: Criando imagens do sistema [Conteúdo][Índice]
Let’s say you would like to create an MBR image with three distinct partitions:
%simple-os
operating-system.
You would then write the following image definition in a my-image.scm
file for instance.
(use-modules (gnu) (gnu image) (gnu tests) (gnu system image) (guix gexp)) (define MiB (expt 2 20)) (image (format 'disk-image) (operating-system %simple-os) (partitions (list (partition (size (* 40 MiB)) (offset (* 1024 1024)) (label "GNU-ESP") (file-system "vfat") (flags '(esp)) (initializer (gexp initialize-efi-partition))) (partition (size (* 50 MiB)) (label "DATA") (file-system "ext4") (initializer #~(lambda* (root . rest) (mkdir root) (call-with-output-file (string-append root "/data") (lambda (port) (format port "my-data")))))) (partition (size 'guess) (label root-label) (file-system "ext4") (flags '(boot)) (initializer (gexp initialize-root-partition))))))
Note que a primeira e a terceira partições usam procedimentos de
inicializadores genéricos, initialize-efi-partition e
initialize-root-partition, respectivamente. O initialize-efi-partition
instala um carregador EFI GRUB que está carregando o carregador de
inicialização GRUB localizado na partição raiz. O initialize-root-partition
instancia um sistema completo conforme definido pelo sistema operacional
%simple-os
.
Agora você pode executar:
guix system image my-image.scm
para instanciar a definição image
. Isso produz uma imagem de disco
que tem a estrutura esperada:
$ parted $(guix system image my-image.scm) print … Model: (file) Disk /gnu/store/yhylv1bp5b2ypb97pd3bbhz6jk5nbhxw-disk-image: 1714MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 43.0MB 41.9MB primary fat16 esp 2 43.0MB 95.4MB 52.4MB primary ext4 3 95.4MB 1714MB 1619MB primary ext4 boot
The size of the boot
partition has been inferred to 1619MB
so
that it is large enough to host the %simple-os
operating-system.
You can also use existing image
record definitions and inherit from
them to simplify the image
definition. The (gnu system image)
module provides the following image
definition variables.
An MBR disk-image composed of a single ROOT partition. The ROOT partition starts at a 1 MiB offset so that the bootloader can install itself in the post-MBR gap.
An MBR disk-image composed of two partitions: a 64 bits ESP partition and a
ROOT boot partition. The ESP partition starts at a 1 MiB offset so
that a BIOS compatible bootloader can install itself in the post-MBR gap.
The image can be used by x86_64
and i686
machines supporting
only legacy BIOS booting. The ESP partition ensures that it can also be
used by newer machines relying on UEFI booting, hence the hybrid
denomination.
A GPT disk-image composed of two partitions: a 64 bits ESP partition and a
ROOT boot partition. This image can be used on most x86_64
and
i686
machines, supporting BIOS or UEFI booting.
Same as efi-disk-image
but with a 32 bits EFI partition.
An ISO-9660 image composed of a single bootable partition. This image can
also be used on most x86_64
and i686
machines.
Uma imagem do Docker que pode ser usada para gerar um contêiner do Docker.
Using the efi-disk-image
we can simplify our previous image
declaration this way:
(use-modules (gnu) (gnu image) (gnu tests) (gnu system image) (guix gexp) (ice-9 match)) (define MiB (expt 2 20)) (define data (partition (size (* 50 MiB)) (label "DATA") (file-system "ext4") (initializer #~(lambda* (root . rest) (mkdir root) (call-with-output-file (string-append root "/data") (lambda (port) (format port "my-data"))))))) (image (inherit efi-disk-image) (operating-system %simple-os) (partitions (match (image-partitions efi-disk-image) ((esp root) (list esp data root)))))
This will give the exact same image
instantiation but the
image
declaration is simpler.
Próximo: image-type Reference, Anterior: image
Reference, Acima: Criando imagens do sistema [Conteúdo][Índice]