目的
mmdebstrapを使用しDebian/Ubuntuの日本語版Live DVDを作る。
- debootstrap.sh に取り込み済み
Debian上のdebootstrap.sh ヘルプ画面(GPG key指定有り)
master@sv-server:~/mkcd$ ./debootstrap.sh -k ./keyring/
usage: sudo ./debootstrap.sh -a architecture -s suite [ -k directory ]
-h,--help : This message.
-l,--log : Output log to text file.
-a,--arch : See arch below.
-s,--suite : See suite below.
-k,--key : GPG key file directory.
arch : suite : distribution
amd64,i386 : oldoldstable : Debian 9.xx(stretch)
amd64,i386 : oldstable : Debian 10.xx(buster)
amd64,i386 : stable : Debian 11.xx(bullseye)
amd64,i386 : testing : Debian 12.xx(bookworm)
amd64,i386 : bionic : Ubuntu 18.04(Bionic Beaver):LTS
amd64 : focal : Ubuntu 20.04(Focal Fossa):LTS
amd64 : impish : Ubuntu 21.10(Impish Indri)
amd64 : jammy : Ubuntu 22.04(Jammy Jellyfish):LTS
amd64 : kinetic : Ubuntu 22.10(Kinetic Kudu)
開発環境
dist_remaster.shで作成したDVDイメージでインストールしinstall.shで環境設定した。
OS情報
OS情報
master@sv-ubuntu:~/work$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
ファイルシステム構成
ファイルシステム構成
master@sv-ubuntu:~/work$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 195M 3.2M 192M 2% /run
/dev/mapper/vgubuntu-root 117G 9.8G 101G 9% /
tmpfs 972M 0 972M 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
vmhgfs-fuse 764G 661G 103G 87% /mnt/hgfs
/dev/sda1 511M 5.3M 506M 2% /boot/efi
tmpfs 195M 88K 195M 1% /run/user/127
tmpfs 195M 80K 195M 1% /run/user/1000
ディレクトリー/ファイル構成
ディレクトリー/ファイル構成
.
| inst-net.sh
| 0000-user.conf
| 9999-user.conf
| 9999-user-setting
| splash.png
| linux_signing_key.pub
|
|-- _work
|-- cdimg
|-- fsimg
|-- media
+-- keyring
debian-archive-bullseye-automatic.gpg
debian-archive-bullseye-security-automatic.gpg
debian-archive-bullseye-stable.gpg
debian-archive-buster-automatic.gpg
debian-archive-buster-security-automatic.gpg
debian-archive-buster-stable.gpg
debian-archive-keyring.gpg
debian-archive-removed-keys.gpg
debian-archive-stretch-automatic.gpg
debian-archive-stretch-security-automatic.gpg
debian-archive-stretch-stable.gpg
ubuntu-archive-keyring.gpg
ubuntu-archive-removed-keys.gpg
ubuntu-cloudimage-keyring.gpg
ubuntu-cloudimage-removed-keys.gpg
ubuntu-keyring-2012-cdimage.gpg
ubuntu-keyring-2018-archive.gpg
ubuntu-master-keyring.gpg
必要パッケージ
必要パッケージ
master@sv-ubuntu:~$ dpkg --no-pager -l mmdebstrap squashfs-tools xorriso curl
要望=(U)不明/(I)インストール/(R)削除/(P)完全削除/(H)保持
| 状態=(N)無/(I)インストール済/(C)設定/(U)展開/(F)設定失敗/(H)半インストール/(W)トリガ待ち/(T)トリガ保留
|/ エラー?=(空欄)無/(R)要再インストール (状態,エラーの大文字=異常)
||/ 名前 バージョン アーキテクチ 説明
+++-==============-=================-============-=======================================================
ii curl 7.81.0-1ubuntu1.2 amd64 command line tool for transferring data with URL syntax
ii mmdebstrap 0.8.4-1 all create a Debian chroot
ii squashfs-tools 1:4.5-3build1 amd64 Tool to create and append to squashfs filesystems
ii xorriso 1.5.4-2 amd64 command line ISO-9660 and Rock Ridge manipulation tool
準備
インストール作業
インストール作業
sudo apt-get -y install mmdebstrap squashfs-tools xorriso
# 上記パッケージ以外の不足分は各自の環境に合わせて導入
設定ファイル(リンク先を参照の事)
-
inst-net.sh :ユーザー設定
-
0000-user.conf:暫定対応
-
9999-user.conf:変更パラメーター関係
-
9999-user-setting:Live版用ユーザー設定
mmdebstrap用パラメーター設定
共通設定
共通設定
TARGET_VARIANT="debootstrap"
TARGET_PACKAGE=" \
open-infrastructure-system-boot \
open-infrastructure-system-build \
open-infrastructure-system-config \
open-infrastructure-system-images \
isolinux syslinux \
build-essential curl vim \
open-vm-tools open-vm-tools-desktop \
clamav \
bind9 \
openssh-server \
samba smbclient cifs-utils \
isc-dhcp-server \
minidlna \
task-laptop \
task-japanese \
fonts-noto \
ibus-mozc mozc-utils-gui \
libreoffice-l10n-ja libreoffice-help-ja \
"
GPG keyを使用する場合は次のパラメータを設定する。
Ubuntu上でDebain環境をmmdebstrapで作る例(変数は下記パラメータを使用)
TARGET_KEYRING="./keyring/"
KEYRING="--keyring=${TARGET_KEYRING}"
Debian
debian stable amd64
TARGET_SUITE="stable"
TARGET_ARCH="amd64"
TARGET_COMPONENTS="main non-free contrib"
TARGET_MIRROR="http://deb.debian.org/debian/"
TARGET_PACKAGE+=" \
linux-headers-${TARGET_ARCH//i386/686} \
linux-image-${TARGET_ARCH//i386/686} \
task-lxde-desktop \
task-japanese-desktop \
task-japanese-gnome-desktop \
thunderbird-l10n-ja \
"
Ubuntu
ubuntu kinetic amd64
TARGET_SUITE="kinetic"
TARGET_ARCH="amd64"
TARGET_COMPONENTS="main multiverse restricted universe"
TARGET_MIRROR="http://archive.ubuntu.com/ubuntu/"
TARGET_PACKAGE+=" \
linux-headers-generic \
linux-image-generic \
ubuntu-desktop ubuntu-server \
language-pack-ja \
language-pack-gnome-ja \
thunderbird-locale-ja \
"
作成作業(Ubuntu上でDebian Live DVDを作る)
作業ディレクトリ
作業ディレクトリ
DIR_TOP="."
rm -rf "${DIR_TOP}/media" "${DIR_TOP}/cdimg" "${DIR_TOP}/fsimg" "${DIR_TOP}/_work"
mkdir -p "${DIR_TOP}/media" "${DIR_TOP}/cdimg" "${DIR_TOP}/fsimg" "${DIR_TOP}/_work"
共通の必須ファイル
共通の必須ファイル
sudo wget "https://raw.githubusercontent.com/office-itou/Linux/master/live/shell/inst-net.sh"
sudo wget "https://raw.githubusercontent.com/office-itou/Linux/master/live/shell/0000-user.conf"
sudo wget "https://raw.githubusercontent.com/office-itou/Linux/master/live/shell/9999-user.conf"
sudo wget "https://raw.githubusercontent.com/office-itou/Linux/master/live/shell/9999-user-setting"
sudo wget "https://dl-ssl.google.com/linux/linux_signing_key.pub"
sudo chmod +x inst-net.sh 0000-user.conf 9999-user.conf 9999-user-setting
# 9999-user.conf を自分の環境に合わせて編集する事
sudo vi "${DIR_TOP}/9999-user.conf"
debian-installerの取得:Debian
debianの場合
wget "https://cdimage.debian.org/debian/dists/${TARGET_SUITE}/main/installer-${TARGET_ARCH}/current/images/cdrom/debian-cd_info.tar.gz"
sudo tar -xzf "${DIR_TOP}/debian-cd_info.tar.gz" -C "${DIR_TOP}/_work/"
debian-installerの取得:Ubuntu
ubuntuの場合
wget "https://cdimage.debian.org/debian/dists/stable/main/installer-${TARGET_ARCH}/current/images/cdrom/debian-cd_info.tar.gz"
wget "http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/current/legacy-images/netboot/ubuntu-installer/amd64/boot-screens/splash.png"
sudo tar -xzf "${DIR_TOP}/debian-cd_info.tar.gz" -C "${DIR_TOP}/_work/"
sudo cp -p "${DIR_TOP}/splash.png" "${DIR_TOP}/_work/"
sudo chown root.root "${DIR_TOP}/_work/splash.png"
GPG keyのダウンロードと解凍
GPG keyを使用するとDebianでUbuntuの、UbuntuでDebianのイメージが作れる。
GPG keyのダウンロードと解凍(Ubuntu上にて)
sudo rm -rf ./work/ ./keyring/
sudo mkdir -p ./work ./keyring
apt-get download debian-archive-keyring ubuntu-keyring
sudo dpkg -x ./debian-archive-keyring_2021.1.1ubuntu2_all.deb ./work/
sudo dpkg -x ./ubuntu-keyring_2021.03.26_all.deb ./work/
sudo find ./work/ -type f -name "*.gpg" -print -exec cp -p {} ./keyring/ \;
2022/6/1現在、Debian上ではツールの制限でUbuntuイメージの展開ができない。
エラーメッセージの一部
dpkg-deb: error: archive '/home/master/work/fsimg//var/cache/apt/archives//apt-utils_2.5.0_amd64.deb' uses unknown compression for member 'control.tar.zst', giving up
mmdebstrap
mmdebstrap
sudo rm -rf "${DIR_TOP}"/fsimg/*
sudo mkdir -p "${DIR_TOP}/fsimg"
# -------------------------------------------------------------------------
# 32bit版を作成する場合はlinux_signing_key.pubの行を削除する事
HOOK_CMD=" \
cp -p "${DIR_TOP}/linux_signing_key.pub" "${DIR_TOP}/fsimg/tmp/";
cp -p \"${DIR_TOP}/inst-net.sh\" \"${DIR_TOP}/fsimg/\"; \
chroot \"${DIR_TOP}/fsimg/\" /bin/bash /inst-net.sh; \
"
# -------------------------------------------------------------------------
sudo mmdebstrap \
--components="${TARGET_COMPONENTS}" \
--variant=${TARGET_VARIANT} \
--mode=sudo \
--aptopt='Apt::Install-Recommends "true"' \
--include="${TARGET_PACKAGE} " \
--architectures=${TARGET_ARCH} \
--customize-hook="${HOOK_CMD}" \
${KEYRING:-} \
${TARGET_SUITE} \
"${DIR_TOP}/fsimg/" \
${TARGET_MIRROR}
# -------------------------------------------------------------------------
sudo find "${DIR_TOP}/fsimg/var/log/" -type f -name \* -exec cp -f /dev/null {} \;
sudo rm -rf "${DIR_TOP}/fsimg/inst-net.sh" \
"${DIR_TOP}/fsimg/root/.bash_history" \
"${DIR_TOP}/fsimg/root/.viminfo" \
"${DIR_TOP}"/fsimg/tmp/* \
"${DIR_TOP}/fsimg/var/cache/apt/*.bin" \
"${DIR_TOP}/fsimg/var/cache/apt/archives/*.deb"
DVDイメージの作成
DVDイメージの展開準備
DVDイメージの展開準備
sudo rm -rf "${DIR_TOP}"/cdimg/*
sudo mkdir -p "${DIR_TOP}/cdimg/.disk" \
"${DIR_TOP}/cdimg/EFI" \
"${DIR_TOP}/cdimg/boot/grub" \
"${DIR_TOP}/cdimg/isolinux" \
"${DIR_TOP}/cdimg/live" \
"${DIR_TOP}/cdimg/live/config.conf.d" \
"${DIR_TOP}/cdimg/preseed"
DVDイメージ展開用パラメーター
DVDイメージ展開用パラメーター
OS_KERNEL="`find \"${DIR_TOP}\"/fsimg/boot/ -name \"vmlinuz*\" -print | sed -n 's/.*vmlinuz-//gp'`"
OS_NAME="`sed -n '/^NAME=/ s/.*="\([a-zA-Z]*\).*"/\1/p' ${DIR_TOP}/fsimg/etc/os-release | tr A-Z a-z`"
OS_VERSION="`sed -n '/^VERSION=/ s/^.*=\(.*\)/\1/p' ${DIR_TOP}/fsimg/etc/os-release | sed -e 's/\"//g'`"
OS_VERSION_ID="`sed -n '/^VERSION=/ s/^.*="*\([0-9.]*\).*"*$/\1/p' ${DIR_TOP}/fsimg/etc/os-release`"
OS_NAME="${OS_NAME:-${TARGET_DIST}}"
if [ "${OS_VERSION}" = "" ] || [ "${OS_VERSION_ID}" = "" ]; then
OS_VERSION="`cat ${DIR_TOP}/fsimg/etc/debian_version`"
OS_VERSION_ID="${OS_VERSION##*/}"
fi
MNU_LABEL="${OS_NAME} ${OS_VERSION} Live ${TARGET_ARCH} (kernel ${OS_KERNEL})"
DVD_NAME="${OS_NAME}-live-${OS_VERSION_ID}-${TARGET_SUITE}-${TARGET_ARCH}-debootstrap.iso"
DVD_VOLID="d-live ${OS_NAME} ${TARGET_SUITE} ${TARGET_ARCH}"
DVDイメージの展開
DVDイメージの展開
echo -en "${OS_NAME} ${OS_VERSION} Live ${TARGET_ARCH} `date +"%Y-%m-%d %H:%M"`" | sudo tee "${DIR_TOP}/cdimg/.disk/info" > /dev/null
sudo cp -pr "${DIR_TOP}"/_work/grub/* "${DIR_TOP}/cdimg/boot/grub/"
sudo cp -p "${DIR_TOP}/_work/splash.png" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/_work/menu.cfg" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/_work/stdmenu.cfg" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/_work/isolinux.cfg" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/fsimg/usr/lib/ISOLINUX/isolinux.bin" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/fsimg/usr/lib/syslinux/modules/bios/hdt.c32" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/fsimg/usr/lib/syslinux/modules/bios/ldlinux.c32" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/fsimg/usr/lib/syslinux/modules/bios/libcom32.c32" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/fsimg/usr/lib/syslinux/modules/bios/libgpl.c32" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/fsimg/usr/lib/syslinux/modules/bios/libmenu.c32" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/fsimg/usr/lib/syslinux/modules/bios/libutil.c32" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/fsimg/usr/lib/syslinux/modules/bios/vesamenu.c32" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -p "${DIR_TOP}/fsimg/usr/lib/syslinux/memdisk" "${DIR_TOP}/cdimg/isolinux/"
sudo cp -pr "${DIR_TOP}"/fsimg/boot/* "${DIR_TOP}/cdimg/live/"
# 変更するパラメーター関係とユーザー設定関係のシェル
sudo cp -p "${DIR_TOP}"/9999-* "${DIR_TOP}/cdimg/live/config.conf.d/"
sudo chown root.root "${DIR_TOP}"/cdimg/live/config.conf.d/*
sudo chmod +x "${DIR_TOP}"/cdimg/live/config.conf.d/*
# mountpoint="/live/medium" -> "/run/live/medium" の暫定対応
sudo cp -p "${DIR_TOP}/0000-user.conf" "${DIR_TOP}/fsimg/etc/live/config.conf.d/"
sudo chown root.root "${DIR_TOP}/fsimg/etc/live/config.conf.d/0000-user.conf"
sudo chmod +x "${DIR_TOP}/fsimg/etc/live/config.conf.d/0000-user.conf"
メニューの背景(Ubuntuのみ適用)
# メニューの背景(Ubuntuのみ適用)
sudo cp -p "${DIR_TOP}/splash.png" "${DIR_TOP}/cdimg/isolinux/"
sudo chown root.root "${DIR_TOP}/cdimg/isolinux/splash.png"
DVDイメージへEFIファイルの展開
DVDイメージへEFIファイルの展開
sudo rm -rf "${DIR_TOP}"/media/*
sudo mkdir -p "${DIR_TOP}/media/"
sudo mount -r -o loop "${DIR_TOP}/cdimg/boot/grub/efi.img" "${DIR_TOP}/media/"
sudo cp -pr "${DIR_TOP}"/media/efi/* "${DIR_TOP}/cdimg/EFI/"
sudo umount -q "${DIR_TOP}/media/"
ファイルシステムイメージの作成
ファイルシステムイメージの作成
sudo rm -f "${DIR_TOP}/cdimg/live/filesystem.squashfs"
sudo mksquashfs "${DIR_TOP}/fsimg" "${DIR_TOP}/cdimg/live/filesystem.squashfs" -noappend -quiet -mem 1G
ls -lthLgG --time-style="+%Y/%m/%d %H:%M:%S" "${DIR_TOP}/cdimg/live/filesystem.squashfs" 2> /dev/null | cut -c 13-
ブートメニューの作成
ブートメニューの作成
cat <<- _EOT_ | sudo tee -a "${DIR_TOP}/cdimg/boot/grub/grub.cfg" > /dev/null
menuentry "${MNU_LABEL}" {
linux /live/vmlinuz-${OS_KERNEL} boot=live components splash quiet noeject
initrd /live/initrd.img-${OS_KERNEL}
}
set timeout=5
_EOT_
cat <<- _EOT_ | sudo tee "${DIR_TOP}/cdimg/isolinux/menu.cfg" > /dev/null
INCLUDE stdmenu.cfg
MENU title Main Menu
DEFAULT ${MNU_LABEL}
LABEL ${MNU_LABEL}
SAY "Booting ${MNU_LABEL}..."
linux /live/vmlinuz-${OS_KERNEL} noeject
APPEND initrd=/live/initrd.img-${OS_KERNEL} boot=live components splash quiet
_EOT_
sudo sed -i "${DIR_TOP}/cdimg/isolinux/isolinux.cfg" \
-e 's/^\(timeout\) .*/\1 50/'
DVDイメージの作成
DVDイメージの作成
pushd "${DIR_TOP}/cdimg" > /dev/null
sudo bash -c 'find . ! -name "md5sum.txt" -type f -exec md5sum -b {} \; > md5sum.txt'
sudo xorriso -as mkisofs \
-quiet \
-iso-level 3 \
-full-iso9660-filenames \
-volid "${DVD_VOLID}" \
-eltorito-boot isolinux/isolinux.bin \
-eltorito-catalog isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-isohybrid-mbr ../fsimg/usr/lib/ISOLINUX/isohdpfx.bin \
-eltorito-alt-boot \
-e boot/grub/efi.img \
-no-emul-boot -isohybrid-gpt-basdat \
-output "../${DVD_NAME}" \
.
popd > /dev/null
ls -lthLgG --time-style="+%Y/%m/%d %H:%M:%S" "./${DVD_NAME}" 2> /dev/null | cut -c 13-
注意
- --customize-hookで動くコマンドはchrootされていないので注意
(開発環境が破壊される) - /lib/live/config/内のシェルでechoを使う場合は/bin/echoを使用する
(シェルのechoだと期待通りの動作をしない) - Ubuntuで解決できていない課題がある
- systemctlでdisableにしたサービスが起動される
→ mask設定で回避 - バージョン毎に異なる挙動をする
(mbrかuefiかでも異なる場合がある)
- systemctlでdisableにしたサービスが起動される
参考
スクリーンショット
debian 11 stable | ubuntu 22.10 kinetic |
---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |