카테고리

asm (27) bootloader_x86_grub (1) C (92) compile (11) config (76) CPP (13) CSS (1) debugging (7) gimp (1) Go (1) html (1) Java (1) JavaScript (1) kernel (19) LibreOffice (3) Linux system progamming (21) MFC (1) opencv (4) OpenGL (1) PHP (1) Python (4) qemu (29) shell (3) socket (7) troubleshooting (2) ubuntu18.04 (2) windows (1)

2018/12/31

데비안 기반에서 파생된 운영체제 이미지 제작

데비안 기반에서 파생된 운영체제 이미지 제작
주로 사용되는 방식은 debootstrap 사용한다.

사용자 정의 이미지 제작, 추가 패키지 설치, 스크립트 실행, 파일 추가 등등.

debos 유틸은 qemu 지원하는 모든 아키텍처에 대한 이미지를 생성 할 수 있다.
sudo apt-get install debos

debootstrap 이미지
필요한 패키지를 설치.
사용자 생성
기본 호스트 이름 설정
사용자 만드는 스크립트 작성.
sudoers에 사용자 추가
최종 이미지 tarball 만들기

dobos 사용 스크립트
https://github.com/ana/debos-example

shell> vi simple.yaml
{{- $architecture := or .architecture "arm64" -}}
{{- $suite := or .suite "stretch" -}}
{{ $image := or .image (printf "debian-%s-%s.tgz" $suite $architecture) }}

architecture: {{ $architecture }}

actions:
  - action: debootstrap
    suite: {{ $suite }}
    components:
      - main
    mirror: http://deb.debian.org/debian
    variant: minbase

  - action: apt
    recommends: false
    packages:
      - adduser
      - sudo

  - action: run
    description: Set hostname
    chroot: true
    command: echo debian-{{ $suite }}-{{ $architecture }} > /etc/hostname

  - action: run
    chroot: true
    script: scripts/setup-user.sh

  - action: overlay
    description: Add sudo configuration
    source: overlays/sudo

  - action: pack
    file: {{ $image }}
    compression: gz

설정 파일 실행.
$ debos simple.yaml
최종 결과: debian-stretch-arm64.tar.gz

$ debos -t suite:"buster" -t architecture:"amd64" simple.yaml
최종 결과: debian-buster-amd64.tar.gz

매개변수 몇 가지 맞춤 설정
armhf
arm64:
python-libsoc

- action: apt
  recommends: false
  packages:
    - adduser
    - sudo
{{- if eq $architecture "armhf" "arm64" }}
    - python-libsoc
{{- end }}

파티션 분할 이미지 생성
- action: image-partition
  imagename: {{ $ext4 }}
  imagesize: 1GB
  partitiontype: msdos
  mountpoints:
    - mountpoint: /
      partition: root
  partitions:
    - name: root
      fs: ext4
      start: 0%
      end: 100%
      flags: [ boot ]

- action: filesystem-deploy
  description: Deploying filesystem onto image

사용할 파일시스템 정의
{{ $ext4 := or .image (printf "debian-%s-%s.ext4" $suite $architecture) }}

압축 파일 생성, debos 옵션에 추가 파일에 대한 이미지 작성 추가
$ debos -t type:"full" full.yaml

최종 full 파일
{{- $architecture := or .architecture "arm64" -}}
{{- $suite := or .suite "stretch" -}}
{{ $type := or .type "min" }}
{{ $image := or .image (printf "debian-%s-%s.tgz" $suite $architecture) }}
{{ $ext4 := or .image (printf "debian-%s-%s.ext4" $suite $architecture) }}

architecture: {{ $architecture }}

actions:
  - action: debootstrap
    suite: {{ $suite }}
    components:
      - main
    mirror: http://deb.debian.org/debian
    variant: minbase

  - action: apt
    recommends: false
    packages:
      - adduser
      - sudo
{{- if eq $architecture "armhf" "arm64" }}
      - python-libsoc
{{- end }}

  - action: run
    description: Set hostname
    chroot: true
    command: echo debian-{{ $suite }}-{{ $architecture }} > /etc/hostname

  - action: run
    chroot: true
    script: scripts/setup-user.sh

  - action: overlay
    description: Add sudo configuration
    source: overlays/sudo

  - action: pack
    file: {{ $image }}
    compression: gz

{{ if eq $type "full" }}
  - action: image-partition
    imagename: {{ $ext4 }}
    imagesize: 1GB
    partitiontype: msdos
    mountpoints:
      - mountpoint: /
        partition: root
    partitions:
      - name: root
        fs: ext4
        start: 0%
        end: 100%
        flags: [ boot ]

  - action: filesystem-deploy
    description: Deploying filesystem onto image
{{end}}

프로젝트 사이트 : https://github.com/go-debos/debos-recipes

댓글 없음:

댓글 쓰기