0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

suseのbootstrap

Posted at

suseのbootstrapの方法がネットで探しても英語でさえあまり情報が無いので、
ここに書く。

dnfとzypperでやる方法があり、
できればzypperの方がsuseとの相性がよくてトラブルが無いだろう。

zypperはdebianやubuntu, archlinuxでインストールする事ができる。

rhel系はfedoraのレポジトリにあるzypperを使うか、dnfを使おう。

仮想環境へのディレクトリにインストール

chroot先やsystemd-nspawnするディレクトリにインストールしよう。
ここではsystemd-nspawnで書いていくので、chrootの人は置き換えて
理解してください。

dnfでやる場合

下のようにyumのレポジトリを追加する。
gpgcheck=0とするのは、
gpgkeyがopensuseの場合はバージョンごとに名前が
違うので、それに合わせて書くことができないからである。
15.4などバージョンを決め打つなら、gpgcheckをしても良い。

/etc/yum.repos.d/opensuse-leap.repo
[opensuse-leap]
name=OpenSUSE Leap $releasever
baseurl=https://download.opensuse.org/distribution/leap/$releasever/repo/oss/
gpgcheck=0
ARCH=amd64
version=15.4
# repoにyum.repoに設定したレポジトリ名(例[opensuse-leap])を使う。
dnf install --installroot=/var/lib/machines/opensuse --repo=opensuse-leap --releasever=$version rpm-repos-openSUSE-Leap systemd systemd-network bash zypper util-linux

zypperでやる場合

まずホストOS側でzypperに使いたいOSのレポジトリを追加しよう。
今回はOpensuse の15.4を使いたいので下のようになる。

zypper ar -f -c http://download.opensuse.org/distribution/leap/15.4/repo/oss opensuse-leap-15.4
zypper --installroot /var/lib/machines/opensuse/ in rpm-repos-openSUSE-Leap systemd systemd-network bash zypper util-linux

仮想環境の起動

chrootやsystemd-nspawnを使って起動させよう。

仮想環境に入った後の処理

ネットワークの設定

systemd-nspawnを使っている場合はsystemdが動くので下のように設定しておく。

sudo systemctl start systemd-networkd
sudo systemctl enable systemd-networkd
sudo systemctl start systemd-resolved
sudo systemctl enable systemd-resolved

レポジトリの追加

仮想環境に入ったら下のようにレポジトリを追加しておく。

zypper ar -f -c 'http://download.opensuse.org/distribution/leap/$releasever/repo/oss' repo-oss
zypper ar -f -c 'http://download.opensuse.org/distribution/leap/$releasever/repo/non-oss' repo-non-oss
zypper ar -f -c 'http://download.opensuse.org/update/leap/$releasever/oss' repo-oss-update
zypper ar -f -c 'http://download.opensuse.org/update/leap/$releasever/non-oss' repo-non-oss-update

localeの設定

最小限のインストールだとロケールが入っていないのでログイン時にエラーが出るため、
仮想環境に入ったら設定しておく。

zypper in -y glibc-i18ndata glibc-locale
localectl set-locale LANG=en_US.UTF-8
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?