ラベル Debian の投稿を表示しています。 すべての投稿を表示
ラベル Debian の投稿を表示しています。 すべての投稿を表示

USBストレージから起動するテキストベースLinuxイメージ

標記のひとつにDebian Liveイメージがある。

配布サイト


上記のサイトには各種Linuxディストリビューションのイメージがある。特に好みがなければ、以下のようなstandard版を使う。
  • debian-live-12.5.0-amd64-standard.iso

USBストレージへの書き込み

以下の例では、青色の/dev/sdxがUSBストレージのデバイス。/proc/partitionsやdmsgの出力などから実際に接続しているデバイスを特定してそれに変更する
dd if=debian-live-12.5.0-amd64-standard.iso of=/dev/sdx bs=1M
上記のbs=1Mは、ブロックサイズを1MiBにするオプション。昔、特定の環境でブロックサイズを一定サイズ以上に設定しないと極端に遅いことがあったので習慣として付与している。最近のほとんどのLinux環境では、なくても問題ないと思われる。

おまけ:QEMUの実行例

#!/bin/sh

QEMU=qemu-system-x86_64
IMAGE=debian-live-12.5.0-amd64-standard.iso
MEMORY=2048

${QEMU} \
-cpu host \
-enable-kvm \
-m ${MEMORY} \
-device nec-usb-xhci,id=xhci \
-drive id=DRIVE_ID,format=raw,file=${IMAGE},if=none \
-device usb-storage,bus=xhci.0,drive=DRIVE_ID
上記スクリプトを実行する次のような画面が表示される。
上の画面でLive system (amd64)を選択する(ENTERキーを押す)と、次のようにコンソール画面が表示される。

参考

QEMUでドライブを追加するオプション例

Ubuntu上で新しいバージョンのDebianのLXCコンテナを作る方法

例えば、Ubuntu 20.04上でDebian12のLXCコンテナを作成すると、'signed by unknown key'(知らない鍵で署名されている)と表示されエラーとなる。
# lxc-create -t debian -n deb12 -- -r bookworm
debootstrap is /usr/sbin/debootstrap
Checking cache download in /var/cache/lxc/debian/rootfs-bookworm-amd64 ...
gpg: key 7638D0442B90D010: 4 signatures not checked due to missing keys
gpg: key 7638D0442B90D010: "Debian Archive Automatic Signing Key (8/jessie) " not changed
gpg: Total number processed: 1
gpg:              unchanged: 1
Downloading debian minimal ...
I: Retrieving InRelease
I: Checking Release signature
E: Release signed by unknown key (key id F8D2585B8783D481)
   The specified keyring /var/cache/lxc/debian/archive-key.gpg may be incorrect or out of date.
   You can find the latest Debian release key at https://ftp-master.debian.org/keys.html
Failed to download the rootfs, aborting.
Failed to download 'debian base'
failed to install debian
lxc-create: deb12: lxccontainer.c: create_run_template: 1627 Failed to create container from template
lxc-create: deb12: tools/lxc_create.c: main: 317 Failed to create container deb12
次のように鍵をダウンロードして、ホストOSに登録してから、再度lxc-createを実行すればよい。
wget https://ftp-master.debian.org/keys/archive-key-12.asc -O - --quiet \
| gpg --import --no-default-keyring --keyring=/usr/share/keyrings/debian-archive-keyring.gpg
青字の部分は使用するDebianのバージョンに適宜変更する。鍵の一覧は以下のサイトにある。 https://ftp-master.debian.org/keys.html

Debian 11(サーバ)でのネットワーク設定例(ブリッジあり)

設定例

以下は/etc/network/interfacesの内容。ここでは、ブリッジbr0に物理NICenp6s0を含む。
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug enp6s0
iface enp6s0 inet manual

auto br0
iface br0 inet static
  bridge_ports enp6s0
  address 192.168.10.10
  netmask 255.255.255.0
  gateway 192.168.10.1
  dns-nameservers 192.168.10.1
  bridge_stp off
  bridge_maxwait 0

注記

上記の設定には'bridge-utils'パッケージが必要です。

ブリッジを使う利点

物理NICをブリッジに含めておくと、下図のようにLXCコンテナやQEMUのインスタンスをホストマシンが所属するネットワークに容易に接続できる。macvlanやmacvtapだと、ホストOSと仮想マシンが通信できない課題があるが、この方法ならそれを解決できる。

Debian 11 (server)でのDNSの設定

/etc/network/interfacesに以下のようにdns-nameservers行を記載
auto enp6s0
iface enp6s0 inet static
  bridge_ports enp6s0
  address 192.168.1.100
  netmask 255.255.255.0
  gateway 192.168.1.1
  dns-nameservers 192.168.1.254
参考: https://wiki.debian.org/NetworkConfiguration