3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

日本語版Live DVDを作る:mmdebstrap debian/ubuntu

Last updated at Posted at 2019-01-19

目的

mmdebstrapを使用しDebian/Ubuntuの日本語版Live DVDを作る。
(debootstrap.shに取り込む)

debootstrap.sh のヘルプ画面より
master@sv-ubuntu:~/mkcd$ ./debootstrap.sh
  usage: sudo ./debootstrap.sh [ architecture ] [ suite ]
    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

必要パッケージ

必要パッケージ
master@sv-ubuntu:~/work$ dpkg -l mmdebstrap debootstrap squashfs-tools xorriso isolinux
要望=(U)不明/(I)インストール/(R)削除/(P)完全削除/(H)保持
| 状態=(N)無/(I)インストール済/(C)設定/(U)展開/(F)設定失敗/(H)半インストール/(W)トリガ待ち/(T)トリ >
|/ エラー?=(空欄)無/(R)要再インストール (状態,エラーの大文字=異常)
||/ 名前           バージョン                                 アーキテクチ 説明
+++-==============-==========================================-============-========================>
ii  debootstrap    1.0.126+nmu1ubuntu0.1                      all          Bootstrap a basic Debian>
ii  isolinux       3:6.04~git20190206.bf6db5b4+dfsg1-3ubuntu1 all          collection of bootloader>
ii  mmdebstrap     0.8.4-1                                    all          create a Debian chroot
ii  squashfs-tools 1:4.5-3build1                              amd64        Tool to create and appen>
ii  xorriso        1.5.4-2                                    amd64        command line ISO-9660 an>

準備

インストール作業

インストール作業
sudo apt-get -y install mmdebstrap debootstrap squashfs-tools xorriso isolinux
# 上記パッケージ以外の不足分は各自の環境に合わせて導入

以下のGPGキーをインストるするとDebianでUbuntuの、UbuntuでDebianのイメージが作れる。

  • debian: sudo apt-get install ubuntu-keyring (ubuntuから入手)
  • ubuntu: sudo apt-get install debian-archive-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用パラメーター設定

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=" \
    open-infrastructure-system-boot \
    open-infrastructure-system-build \
    open-infrastructure-system-config \
    open-infrastructure-system-images \
    isolinux syslinux \
    linux-headers-${TARGET_ARCH//i386/686} \
    linux-image-${TARGET_ARCH//i386/686} \
    task-lxde-desktop task-laptop \
    build-essential curl \
    open-vm-tools-desktop \
    clamav \
    bind9 \
    openssh-server \
    samba smbclient cifs-utils \
    isc-dhcp-server \
    minidlna \
    task-japanese-desktop \
    task-japanese-gnome-desktop \
    fonts-noto \
    ibus-mozc mozc-utils-gui \
    libreoffice-l10n-ja libreoffice-help-ja \
    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=" \
    open-infrastructure-system-boot \
    open-infrastructure-system-build \
    open-infrastructure-system-config \
    open-infrastructure-system-images \
    isolinux syslinux \
    linux-headers-generic \
    linux-image-generic \
    ubuntu-desktop ubuntu-server \
    build-essential curl vim \
    open-vm-tools-desktop \
    clamav \
    bind9 \
    openssh-server \
    samba smbclient cifs-utils \
    isc-dhcp-server \
    minidlna \
    language-pack-ja \
    language-pack-gnome-ja \
    fonts-noto \
    ibus-mozc mozc-utils-gui \
    libreoffice-l10n-ja libreoffice-help-ja \
    thunderbird-locale-ja \
"

設定ファイル

inst-net.sh

inst-net.sh
#!/bin/bash
# =============================================================================
#	set -n								# 構文エラーのチェック
#	set -x								# コマンドと引数の展開を表示
	set -o ignoreeof					# Ctrl+Dで終了しない
	set +m								# ジョブ制御を無効にする
	set -e								# ステータス0以外で終了
	set -u								# 未定義変数の参照で終了
	trap 'exit 1' 1 2 3 15
# -- initialize ---------------------------------------------------------------
	ROW_SIZE=25
	COL_SIZE=80
	if [ "`which tput 2> /dev/null`" != "" ]; then
		ROW_SIZE=`tput lines`
		COL_SIZE=`tput cols`
	fi
	if [ ${COL_SIZE} -lt 80 ]; then
		COL_SIZE=80
	fi
	if [ ${COL_SIZE} -gt 100 ]; then
		COL_SIZE=100
	fi
# -- string -------------------------------------------------------------------
fncString () {
	if [ "$2" = " " ]; then
		echo $1      | awk '{s=sprintf("%"$1"."$1"s"," "); print s;}'
	else
		echo $1 "$2" | awk '{s=sprintf("%"$1"."$1"s"," "); gsub(" ",$2,s); print s;}'
	fi
}
# -- print --------------------------------------------------------------------
fncPrint () {
	local RET_STR=""
	MAX_COLS=$((COL_SIZE-1))
	RET_STR=`echo -n "$1" | iconv -f UTF-8 -t SHIFT-JIS | cut -b -${MAX_COLS} | iconv -f SHIFT-JIS -t UTF-8 2> /dev/null`
	if [ $? -ne 0 ]; then
		MAX_COLS=$((COL_SIZE-2))
		RET_STR=`echo -n "$1" | iconv -f UTF-8 -t SHIFT-JIS | cut -b -${MAX_COLS} | iconv -f SHIFT-JIS -t UTF-8 2> /dev/null`
	fi
	echo "${RET_STR}"
}
# -- terminate ----------------------------------------------------------------
fncEnd() {
	fncPrint "--- terminate $(fncString ${COL_SIZE} '-')"
	RET_STS=$1
	history -c
	fncPrint "$(fncString ${COL_SIZE} '=')"
	fncPrint "`date +"%Y/%m/%d %H:%M:%S"` : end [$0]: ${OS_NAME} ${VERSION}"
	fncPrint "$(fncString ${COL_SIZE} '=')"
	exit ${RET_STS}
}
# == main =====================================================================
	OS_NAME=`sed -n 's/^NAME="\(.*\)"$/\1/p' /etc/os-release`
	VERSION=`sed -n 's/^VERSION="\(.*\)"$/\1/p' /etc/os-release`
	fncPrint "$(fncString ${COL_SIZE} '=')"
	fncPrint "`date +"%Y/%m/%d %H:%M:%S"` : start [$0]: ${OS_NAME} ${VERSION}"
	fncPrint "$(fncString ${COL_SIZE} '=')"
	fncPrint "--- initialize $(fncString ${COL_SIZE} '-')"
	export PS1="(chroot) "
#	hostname -b -F /etc/hostname
	if [ -d "/usr/lib/systemd/" ]; then
		DIR_SYSD="/usr/lib/systemd/"
	elif [ -d "/lib/systemd/" ]; then
		DIR_SYSD="/lib/systemd"
	else
		DIR_SYSD=""
	fi
# -- module update, upgrade, tasksel, install ---------------------------------
	fncPrint "--- module update, install, clean $(fncString ${COL_SIZE} '-')"
	if [ `getconf LONG_BIT` -eq 32 ]; then
		WEB_APPS=""
	else
		fncPrint "---- google-chrome signing key install $(fncString ${COL_SIZE} '-')"
		WEB_APPS="google-chrome-stable"
		set +e
		curl -L -s -R -S -f --connect-timeout 3                               \
		    -O "https://dl-ssl.google.com/linux/linux_signing_key.pub"        \
		                                                                   || \
		    if [ $? -eq 18 -o $? -eq 22 -o $? -eq 28 -o $? -eq 56 ]; then fncEnd $?; fi
		set -e
		if [ ! -d /etc/apt/trusted.gpg.d/ ]; then
			mkdir -p /etc/apt/trusted.gpg.d
		fi
		gpg --dearmor < linux_signing_key.pub > /etc/apt/trusted.gpg.d/google-chrome.gpg
		rm -f ./linux_signing_key.pub
		echo 'deb http://dl.google.com/linux/chrome/deb/ stable main'       \
		    > /etc/apt/sources.list.d/google-chrome.list
	fi
	# ----------------------------------------------------------------------- #
	fncPrint "---- update sources.list $(fncString ${COL_SIZE} '-')"
	sed -i /etc/apt/sources.list \
	    -e 's/\(deb\) \[.*\] \(.*\)$/\1 \2/g'
	# -------------------------------------------------------------------------
	export DEBIAN_FRONTEND=noninteractive
	APT_OPTIONS="-o Dpkg::Options::=--force-confdef    \
	             -o Dpkg::Options::=--force-confnew    \
	             -o Dpkg::Options::=--force-overwrite"
	# ----------------------------------------------------------------------- #
	fncPrint "---- module dpkg $(fncString ${COL_SIZE} '-')"
	dpkg --audit                                                           || fncEnd $?
	dpkg --configure -a                                                    || fncEnd $?
	# ----------------------------------------------------------------------- #
	fncPrint "---- module apt-get update $(fncString ${COL_SIZE} '-')"
	apt-get update       -qq                                   > /dev/null || fncEnd $?
	fncPrint "---- module apt-get upgrade $(fncString ${COL_SIZE} '-')"
	apt-get upgrade      -qq  -y ${APT_OPTIONS}                > /dev/null || fncEnd $?
	fncPrint "---- module apt-get dist-upgrade $(fncString ${COL_SIZE} '-')"
	apt-get dist-upgrade -qq  -y ${APT_OPTIONS}                > /dev/null || fncEnd $?
	fncPrint "---- module apt-get install $(fncString ${COL_SIZE} '-')"
	apt-get install      -qq  -y ${APT_OPTIONS} --auto-remove               \
	    ${WEB_APPS}                                                         \
	                                                           > /dev/null || fncEnd $?
#	fncPrint "---- tasksel $(fncString ${COL_SIZE} '-')"
#	tasksel install                                                         \
#	    _LST_TASK_                                                          \
#	                                                           > /dev/null || fncEnd $?
	fncPrint "---- module autoremove, autoclean, clean $(fncString ${COL_SIZE} '-')"
	apt-get autoremove   -qq -y                                > /dev/null || fncEnd $?
	apt-get autoclean    -qq                                   > /dev/null || fncEnd $?
	apt-get clean        -qq                                   > /dev/null || fncEnd $?
# -- Change system control ----------------------------------------------------
	fncPrint "--- Change system control $(fncString ${COL_SIZE} '-')"
	systemctl --quiet  enable clamav-freshclam
	systemctl --quiet  enable ssh
	if [ -f ${DIR_SYSD}/system/bind9.service ]; then
		systemctl --quiet enable bind9
	elif [ -f ${DIR_SYSD}/system/named.service ]; then
		systemctl --quiet enable named
	fi
	systemctl --quiet  enable smbd
	systemctl --quiet  enable nmbd
	systemctl --quiet disable isc-dhcp-server
	systemctl --quiet disable minidlna
	if [ -f ${DIR_SYSD}/system/unattended-upgrades.service ]; then
		systemctl --quiet disable unattended-upgrades
	fi
	if [ -f ${DIR_SYSD}/system/brltty.service ]; then
		systemctl --quiet disable brltty
	fi
# -- Change service configure -------------------------------------------------
#	if [ -f /etc/systemd/system/multi-user.IMG_TGET.wants/cups-browsed.service ]; then
#		fncPrint "--- Change cups-browsed configure $(fncString ${COL_SIZE} '-')"
#		cat <<- _EOT_ > /etc/systemd/system/multi-user.IMG_TGET.wants/cups-browsed.service.override
#			[Service]
#			TimeoutStopSec=3
#_EOT_
#	fi
# -- Change avahi-daemon configure --------------------------------------------
	if [ -f /etc/nsswitch.conf ]; then
		fncPrint "--- Change avahi-daemon configure $(fncString ${COL_SIZE} '-')"
		OLD_IFS=${IFS}
		IFS=$'\n'
		INS_ROW=$((`sed -n '/^hosts:/ =' /etc/nsswitch.conf | head -n 1`))
		INS_TXT=`sed -n '/^hosts:/ s/\(hosts:[ |\t]*\).*$/\1mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] files myhostname dns mdns/p' /etc/nsswitch.conf`
		sed -e '/^hosts:/ s/^/#/' /etc/nsswitch.conf | \
		sed -e "${INS_ROW}a ${INS_TXT}"                \
		> nsswitch.conf
		cat nsswitch.conf > /etc/nsswitch.conf
		rm nsswitch.conf
		IFS=${OLD_IFS}
	fi
# -- Change resolv configure --------------------------------------------------
	if [ -d /etc/NetworkManager/ ]; then
		fncPrint "--- Change NetworkManager configure $(fncString ${COL_SIZE} '-')"
		touch /etc/NetworkManager/conf.d/10-globally-managed-devices.conf
		cat <<- _EOT_ > /etc/NetworkManager/conf.d/NetworkManager.conf.override
			[main]
			dns=default
_EOT_
		fncPrint "--- Change resolv.conf configure $(fncString ${COL_SIZE} '-')"
		cat <<- _EOT_ > /etc/systemd/resolved.conf.override
			[Resolve]
			DNSStubListener=no
_EOT_
		ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
	fi
# -- Change clamav configure --------------------------------------------------
	if [ -f /etc/clamav/freshclam.conf ]; then
		fncPrint "--- Change clamav configure $(fncString ${COL_SIZE} '-')"
		chmod +w /etc/clamav/freshclam.conf
		sed -i /etc/clamav/freshclam.conf \
		    -e 's/^NotifyClamd/#&/'
		chmod -w /etc/clamav/freshclam.conf
		fncPrint "---- Change freshclam $(fncString ${COL_SIZE} '-')"
		set +e
		freshclam --show-progress --quiet
		set -e
	fi
# -- Change sshd configure ----------------------------------------------------
	if [ -d /etc/ssh/ ]; then
		fncPrint "--- Change sshd configure $(fncString ${COL_SIZE} '-')"
		if [ ! -d /etc/ssh/sshd_config.d/ ]; then
			cat <<- _EOT_ >> /etc/ssh/sshd_config
				
				# --- user settings ---
				PermitRootLogin no
				PubkeyAuthentication yes
				PasswordAuthentication yes
_EOT_
			if [ "`ssh -V 2>&1 | awk -F '[^0-9]+' '{print $2;}'`" -ge 9 ]; then
				cat <<- _EOT_ >> /etc/ssh/sshd_config
					PubkeyAcceptedAlgorithms +ssh-rsa
					HostkeyAlgorithms +ssh-rsa
_EOT_
			fi
		else
			cat <<- _EOT_ > /etc/ssh/sshd_config.d/sshd_config.override
				PermitRootLogin no
				PubkeyAuthentication yes
				PasswordAuthentication yes
_EOT_
			if [ "`ssh -V 2>&1 | awk -F '[^0-9]+' '{print $2;}'`" -ge 9 ]; then
				cat <<- _EOT_ >> /etc/ssh/sshd_config.d/sshd_config.override
					PubkeyAcceptedAlgorithms +ssh-rsa
					HostkeyAlgorithms +ssh-rsa
_EOT_
			fi
		fi
	fi
# -- Change samba configure ---------------------------------------------------
if [ -f /etc/samba/smb.conf ]; then
		fncPrint "--- Change samba configure $(fncString ${COL_SIZE} '-')"
		SVR_NAME="live-ubuntu"						# 本機のホスト名
		WGP_NAME="workgroup"						# 本機のワークグループ名
		CMD_UADD=`which useradd`
		CMD_UDEL=`which userdel`
		CMD_GADD=`which groupadd`
		CMD_GDEL=`which groupdel`
		CMD_GPWD=`which gpasswd`
		CMD_FALS=`which false`
		# ---------------------------------------------------------------------
		testparm -s -v |                                                                        \
		sed -e 's/\(dos charset\) =.*$/\1 = CP932/'                                             \
		    -e "s/\(workgroup\) =.*$/\1 = ${WGP_NAME}/"                                         \
		    -e "s/\(netbios name\) =.*$/\1 = ${SVR_NAME}/"                                      \
		    -e 's/\(security\) =.*$/\1 = USER/'                                                 \
		    -e 's/\(server role\) =.*$/\1 = standalone server/'                                 \
		    -e 's/\(pam password change\) =.*$/\1 = Yes/'                                       \
		    -e 's/\(load printers\) =.*$/\1 = No/'                                              \
		    -e 's~\(log file\) =.*$~\1 = /var/log/samba/log.%m~'                                \
		    -e 's/\(max log size\) =.*$/\1 = 1000/'                                             \
		    -e 's/\(min protocol\) =.*$/\1 = NT1/g'                                             \
		    -e 's~\(printcap name\) =.*$~\1 = /dev/null~'                                       \
		    -e "s~\(add user script\) =.*$~\1 = ${CMD_UADD} %u~"                                \
		    -e "s~\(delete user script\) =.*$~\1 = ${CMD_UDEL} %u~"                             \
		    -e "s~\(add group script\) =.*$~\1 = ${CMD_GADD} %g~"                               \
		    -e "s~\(delete group script\) =.*$~\1 = ${CMD_GDEL} %g~"                            \
		    -e "s~\(add user to group script\) =.*$~\1 = ${CMD_GPWD} -a %u %g~"                 \
		    -e "s~\(delete user from group script\) =.*$~\1 = ${CMD_GPWD} -d %u %g~"            \
		    -e "s~\(add machine script\) =.*$~\1 = ${CMD_UADD} -d /dev/null -s ${CMD_FALS} %u~" \
		    -e 's/\(logon script\) =.*$/\1 = logon.bat/'                                        \
		    -e 's/\(logon path\) =.*$/\1 = \\\\%L\\profiles\\%U/'                               \
		    -e 's/\(domain logons\) =.*$/\1 = Yes/'                                             \
		    -e 's/\(os level\) =.*$/# \1 = 35/'                                                 \
		    -e 's/\(preferred master\) =.*$/\1 = Yes/'                                          \
		    -e 's/\(domain master\) =.*$/\1 = Yes/'                                             \
		    -e 's/\(wins support\) =.*$/\1 = Yes/'                                              \
		    -e 's/\(unix password sync\) =.*$/\1 = No/'                                         \
		    -e '/idmap config \* : backend =/i \\tidmap config \* : range = 1000-10000'         \
		    -e 's/\(admin users\) =.*$/# \1 = administrator/'                                   \
		    -e 's/\(printing\) =.*$/\1 = bsd/'                                                  \
		    -e 's/\(multicast dns register\) =.*$/\1 = No/'                                     \
		    -e '/[ |\t]*map to guest =.*$/d'                                                    \
		    -e '/[ |\t]*null passwords =.*$/d'                                                  \
		    -e '/[ |\t]*obey pam restrictions =.*$/d'                                           \
		    -e '/[ |\t]*enable privileges =.*$/d'                                               \
		    -e '/[ |\t]*password level =.*$/d'                                                  \
		    -e '/[ |\t]*client use spnego principal =.*$/d'                                     \
		    -e '/[ |\t]*syslog =.*$/d'                                                          \
		    -e '/[ |\t]*syslog only =.*$/d'                                                     \
		    -e '/[ |\t]*use spnego =.*$/d'                                                      \
		    -e '/[ |\t]*paranoid server security =.*$/d'                                        \
		    -e '/[ |\t]*dns proxy =.*$/d'                                                       \
		    -e '/[ |\t]*time offset =.*$/d'                                                     \
		    -e '/[ |\t]*usershare allow guests =.*$/d'                                          \
		    -e '/[ |\t]*idmap backend =.*$/d'                                                   \
		    -e '/[ |\t]*idmap uid =.*$/d'                                                       \
		    -e '/[ |\t]*idmap gid =.*$/d'                                                       \
		    -e '/[ |\t]*winbind separator =.*$/d'                                               \
		    -e '/[ |\t]*acl check permissions =.*$/d'                                           \
		    -e '/[ |\t]*only user =.*$/d'                                                       \
		    -e '/[ |\t]*share modes =.*$/d'                                                     \
		    -e '/[ |\t]*nbt client socket address =.*$/d'                                       \
		    -e '/[ |\t]*lsa over netlogon =.*$/d'                                               \
		    -e '/[ |\t]*.* = $/d'                                                               \
		    -e '/[ |\t]*client lanman auth =.*$/d'                                              \
		    -e '/[ |\t]*client NTLMv2 auth =.*$/d'                                              \
		    -e '/[ |\t]*client plaintext auth =.*$/d'                                           \
		    -e '/[ |\t]*client schannel =.*$/d'                                                 \
		    -e '/[ |\t]*client use spnego principal =.*$/d'                                     \
		    -e '/[ |\t]*client use spnego =.*$/d'                                               \
		    -e '/[ |\t]*domain logons =.*$/d'                                                   \
		    -e '/[ |\t]*enable privileges =.*$/d'                                               \
		    -e '/[ |\t]*encrypt passwords =.*$/d'                                               \
		    -e '/[ |\t]*idmap backend =.*$/d'                                                   \
		    -e '/[ |\t]*idmap gid =.*$/d'                                                       \
		    -e '/[ |\t]*idmap uid =.*$/d'                                                       \
		    -e '/[ |\t]*lanman auth =.*$/d'                                                     \
		    -e '/[ |\t]*lsa over netlogon =.*$/d'                                               \
		    -e '/[ |\t]*nbt client socket address =.*$/d'                                       \
		    -e '/[ |\t]*null passwords =.*$/d'                                                  \
		    -e '/[ |\t]*raw NTLMv2 auth =.*$/d'                                                 \
		    -e '/[ |\t]*server schannel =.*$/d'                                                 \
		    -e '/[ |\t]*syslog =.*$/d'                                                          \
		    -e '/[ |\t]*syslog only =.*$/d'                                                     \
		    -e '/[ |\t]*unicode =.*$/d'                                                         \
		    -e '/[ |\t]*acl check permissions =.*$/d'                                           \
		    -e '/[ |\t]*allocation roundup size =.*$/d'                                         \
		    -e '/[ |\t]*blocking locks =.*$/d'                                                  \
		    -e '/[ |\t]*copy =.*$/d'                                                            \
		    -e '/[ |\t]*winbind separator =.*$/d'                                               \
		    -e '/[ |\t]*domain master =.*$/d'                                                   \
		    -e '/[ |\t]*logon path =.*$/d'                                                      \
		    -e '/[ |\t]*logon script =.*$/d'                                                    \
		    -e '/[ |\t]*pam password change =.*$/d'                                             \
		    -e '/[ |\t]*preferred master =.*$/d'                                                \
		    -e '/[ |\t]*server role =.*$/d'                                                     \
		    -e '/[ |\t]*wins support =.*$/d'                                                    \
		    -e '/[ |\t]*dns proxy =.*$/d'                                                       \
		    -e '/[ |\t]*map to guest =.*$/d'                                                    \
		    -e '/[ |\t]*obey pam restrictions =.*$/d'                                           \
		    -e '/[ |\t]*pam password change =.*$/d'                                             \
		    -e '/[ |\t]*realm =.*$/d'                                                           \
		    -e '/[ |\t]*server role =.*$/d'                                                     \
		    -e '/[ |\t]*server services =.*$/d'                                                 \
		    -e '/[ |\t]*server string =.*$/d'                                                   \
		    -e '/[ |\t]*syslog =.*$/d'                                                          \
		    -e '/[ |\t]*unix password sync =.*$/d'                                              \
		    -e '/[ |\t]*usershare allow guests =.*$/d'                                          \
		    -e '/[ |\t]*\(client ipc\|client\|server\) min protocol = .*$/d'                    \
		    -e '/[ |\t]*security =.*$/d'                                                        \
		> ./smb.conf
		# ---------------------------------------------------------------------
		testparm -s ./smb.conf > /etc/samba/smb.conf
		rm -f ./smb.conf /etc/samba/smb.conf.ucf-dist
fi
# -- Change xdg configure -----------------------------------------------------
	if [  -f /etc/xdg/autostart/gnome-initial-setup-first-login.desktop ]; then
		fncPrint "--- Change xdg configure $(fncString ${COL_SIZE} '-')"
		sed -i /etc/xdg/autostart/gnome-initial-setup-first-login.desktop \
		    -e "/^\[Desktop Entry\]/,/^\[.*\]/ s~^\(Exec\)=\(.*\)$~\1=`which true`~"
	fi
# -- Change update-manager configure ------------------------------------------
	if [ -d /etc/update-manager/release-upgrades.d/ ]; then
		fncPrint "--- Change update-manager configure $(fncString ${COL_SIZE} '-')"
		cat <<- _EOT_ > /etc/update-manager/release-upgrades.d/release-upgrades.conf.override
			[DEFAULT]
			Prompt=never
_EOT_
	fi
# -- Change dconf configure ---------------------------------------------------
	if [ "`which dconf 2> /dev/null`" != "" ]; then
		fncPrint "--- Change dconf configure $(fncString ${COL_SIZE} '-')"
		# -- create dconf profile ---------------------------------------------
		fncPrint "--- Create dconf profile $(fncString ${COL_SIZE} '-')"
		if [ ! -d /etc/dconf/db/local.d/ ]; then
			mkdir -p /etc/dconf/db/local.d
		fi
		if [ ! -d /etc/dconf/profile/ ]; then
			mkdir -p /etc/dconf/profile
		fi
		cat <<- _EOT_ > /etc/dconf/profile/user
			user-db:user
			system-db:local
_EOT_
		# -- dconf org/gnome/desktop/screensaver ------------------------------
		fncPrint "---- dconf org/gnome/desktop/screensaver $(fncString ${COL_SIZE} '-')"
		cat <<- _EOT_ > /etc/dconf/db/local.d/01-screensaver
			[org/gnome/desktop/screensaver]
			idle-activation-enabled=false
			lock-enabled=false
_EOT_
		# -- dconf org/gnome/todo ---------------------------------------------
		fncPrint "---- dconf org/gnome/todo $(fncString ${COL_SIZE} '-')"
		cat <<- _EOT_ > /etc/dconf/db/local.d/01-todo
			[org/gnome/todo]
			first-run=false
			window-maximized=true
_EOT_
		# -- dconf update -----------------------------------------------------
		fncPrint "---- dconf update $(fncString ${COL_SIZE} '-')"
		dconf update
	fi
# -- root and user's setting --------------------------------------------------
	fncPrint "--- root and user's setting $(fncString ${COL_SIZE} '-')"
	LST_SHELL="`sed -n '/^#/! s~/~\\\\/~gp' /etc/shells |  sed -z 's/\n/|/g' | sed -e 's/|$//'`"
	for USER_NAME in "skel" `awk -F ':' '$7~/'"${LST_SHELL}"'/ {print $1;}' /etc/passwd`
	do
		fncPrint "---- ${USER_NAME}'s setting $(fncString ${COL_SIZE} '-')"
		if [ "${USER_NAME}" == "skel" ]; then
			USER_HOME="/etc/skel"
		else
			USER_HOME=`awk -F ':' '$1=="'${USER_NAME}'" {print $6;}' /etc/passwd`
		fi
		if [ "${USER_HOME}" != "" ]; then
			pushd ${USER_HOME} > /dev/null
				# --- .bashrc -------------------------------------------------
				cat <<- _EOT_ >> .bashrc
					# --- 日本語文字化け対策 ---
					case "\${TERM}" in
					    "linux" ) export LANG=C;;
					    * )                    ;;
					esac
					export GTK_IM_MODULE=ibus
					export XMODIFIERS=@im=ibus
					export QT_IM_MODULE=ibus
_EOT_
				# --- .vimrc --------------------------------------------------
				cat <<- _EOT_ > .vimrc
					set number              " Print the line number in front of each line.
					set tabstop=4           " Number of spaces that a <Tab> in the file counts for.
					set list                " List mode: Show tabs as CTRL-I is displayed, display $ after end of line.
					set listchars=tab:>_    " Strings to use in 'list' mode and for the |:list| command.
					set nowrap              " This option changes how text is displayed.
					set showmode            " If in Insert, Replace or Visual mode put a message on the last line.
					set laststatus=2        " The value of this option influences when the last window will have a status line always.
					syntax on               " Vim5 and later versions support syntax highlighting.
_EOT_
				if [ "${USER_NAME}" != "skel" ]; then
					chown ${USER_NAME}. .vimrc
				fi
				# --- .curlrc -------------------------------------------------
				cat <<- _EOT_ > .curlrc
					location
					progress-bar
					remote-time
					show-error
_EOT_
				if [ "${USER_NAME}" != "skel" ]; then
					chown ${USER_NAME}. .curlrc
				fi
				# --- xinput.d ------------------------------------------------
				if [ "${USER_NAME}" != "skel" ]; then
					mkdir .xinput.d
					ln -s /etc/X11/xinit/xinput.d/ja_JP .xinput.d/ja_JP
					chown -R ${USER_NAME}:${USER_NAME} .xinput.d .bashrc .vimrc .curlrc
				fi
				# --- .credentials --------------------------------------------
				cat <<- _EOT_ > .credentials
					username=value
					password=value
					domain=value
_EOT_
				if [ "${USER_NAME}" != "skel" ]; then
					chown ${USER_NAME}. .credentials
					chmod 0600 .credentials
				fi
				# --- libfm.conf ----------------------------------------------
				if [   -f .config/libfm/libfm.conf      ] \
				&& [ ! -f .config/libfm/libfm.conf.orig ]; then
					sed -i.orig .config/libfm/libfm.conf   \
					    -e 's/^\(single_click\)=.*$/\1=0/'
				fi
			popd > /dev/null
		fi
	done
# -----------------------------------------------------------------------------
	fncPrint "--- cleaning and exit $(fncString ${COL_SIZE} '-')"
	fncEnd 0
# == EOF ======================================================================

mountpoint="/live/medium" -> "/run/live/medium" の暫定対応

/etc/live/config.conf.d/0000-user.conf
#!/bin/sh

#set -o ignoreeof					# Ctrl+Dで終了しない
#set +m								# ジョブ制御を無効にする
#set -e								# ステータス0以外で終了
#set -u								# 未定義変数の参照で終了
#set -e

# Reading configuration files from filesystem and live-media
set -o allexport
for _FILE in /run/live/medium/live/config.conf /run/live/medium/live/config.conf.d/*.conf \
	         ${rootmnt}/lib/live/mount/medium/live/config.conf ${rootmnt}/lib/live/mount/medium/live/config.conf.d/*.conf
do
	if [ -e "${_FILE}" ]; then
		. "${_FILE}"
	fi
done
set +o allexport

変更するパラメーター関係

DVD内の/live/config.conf.d/9999-user.conf
#!/bin/sh

#set -o ignoreeof					# Ctrl+Dで終了しない
#set +m								# ジョブ制御を無効にする
#set -e								# ステータス0以外で終了
#set -u								# 未定義変数の参照で終了
#set -e
#set -o allexport
#set -o | tee

# === Fix Parameters ==========================================================
# /bin/live-config or /lib/live/init-config.sh
#  LIVE_HOSTNAME="debian"
#  LIVE_USERNAME="user"
#  LIVE_USER_FULLNAME="Debian Live user"
#  LIVE_USER_DEFAULT_GROUPS="audio cdrom dip floppy video plugdev netdev powerdev scanner bluetooth debian-tor"

# === Fix Parameters [ /lib/live/config/0030-live-debconfig_passwd ] ======
#_PASSWORD="8Ab05sVQ4LLps"				# '/bin/echo "live" | mkpasswd -s'

# === Fix Parameters [ /lib/live/config/0030-user-setup ] =================
#_PASSWORD="8Ab05sVQ4LLps"				# '/bin/echo "live" | mkpasswd -s'

# === User parameters =========================================================
export LIVE_CONFIG_CMDLINE				# この変数はブートローダのコマンドラインに相当します。(/proc/cmdline)
export LIVE_CONFIG_COMPONENTS			# この変数は「live-config.components=構成要素1,構成要素2, ...  構成要素n」パラメータに相当します。
export LIVE_CONFIG_NOCOMPONENTS			# この変数は「live-config.nocomponents=構成要素1,構成要素2,  ... 構成要素n」パラメータに相当します。
export LIVE_DEBCONF_PRESEED				# この変数は「live-config.debconf-preseed=filesystem|medium|URL1|URL2|  ...  |URLn」パラメータに相当します。
export LIVE_HOSTNAME					# この変数は「live-config.hostname=ホスト名」パラメータに相当します。
export LIVE_USERNAME					# この変数は「live-config.username=ユーザ名」パラメータに相当します。
export LIVE_PASSWORD					# ユーザーパスワード
export LIVE_EMPTYPWD					# TRUEで空パスワード
export LIVE_CRYPTPWD					# 暗号化パスワード
export LIVE_USER_DEFAULT_GROUPS			# この変数は「live-config.user-default-groups="グループ1,グループ2  ... グループn"」パラメータに相当します。
export LIVE_USER_FULLNAME				# この変数は「live-config.user-fullname="ユーザのフルネーム"」パラメータに相当します。
export LIVE_LOCALES						# この変数は「live-config.locales=ロケール1,ロケール2 ...  ロケールn」パラメータに相当します。
export LIVE_TIMEZONE					# この変数は「live-config.timezone=タイムゾーン」パラメータに相当します。
export LIVE_KEYBOARD_MODEL				# この変数は「live-config.keyboard-model=キーボードの種類」パラメータに相当します。
export LIVE_KEYBOARD_LAYOUTS			# この変数は「live-config.keyboard-layouts=キーボードレイアウト1,キーボードレイアウト2... キーボードレイアウトn」パラメータに相当します。
export LIVE_KEYBOARD_VARIANTS			# この変数は「live-config.keyboard-variants=キーボード配列1,キーボード配列2 ... キーボード配列n」パラメータに相当します。
export LIVE_KEYBOARD_OPTIONS			# この変数は「live-config.keyboard-options=キーボードオプション」パラメータに相当します。
export LIVE_SYSV_RC						# この変数は「live-config.sysv-rc=サービス1,サービス2  ... サービスn」パラメータに相当します。
export LIVE_UTC							# この変数は「live-config.utc=yes|no」パラメータに相当します。
export LIVE_X_SESSION_MANAGER			# この変数は「live-config.x-session-manager=Xセッションマネージャ」パラメータに相当します。
export LIVE_XORG_DRIVER					# この変数は「live-config.xorg-driver=XORGドライバ」パラメータに相当します。
export LIVE_XORG_RESOLUTION				# この変数は「live-config.xorg-resolution=XORG解像度」パラメータに相当します。
export LIVE_WLAN_DRIVER					# この変数は「live-config.wlan-driver=WLANドライバ」パラメータに相当します。
export LIVE_HOOKS						# この変数は「live-config.hooks=filesystem|medium|URL1|URL2| ... |URLn」パラメータに相当します。
export LIVE_CONFIG_DEBUG				# この変数は「live-config.debug」パラメータに相当します。
export LIVE_CONFIG_NOAUTOLOGIN			#
export LIVE_CONFIG_NOROOT				#
export LIVE_CONFIG_NOX11AUTOLOGIN		#
export LIVE_SESSION						# 固定値
export LIVE_DEBUGOUT					# Debug変数

LIVE_HOSTNAME="debian"					# hostname

LIVE_USER_FULLNAME="Debian Live user"	# full name
LIVE_USERNAME="user"					# user name
LIVE_PASSWORD="live"					# password
#LIVE_CRYPTPWD='8Ab05sVQ4LLps'			# '/bin/echo "live" | mkpasswd -s'

LIVE_LOCALES="ja_JP.UTF-8"				# locales
LIVE_KEYBOARD_MODEL="pc105"				# keybord
LIVE_KEYBOARD_LAYOUTS="jp"
LIVE_KEYBOARD_VARIANTS="OADG109A"
LIVE_TIMEZONE="Asia/Tokyo"				# timezone
LIVE_UTC="yes"
LIVE_XORG_RESOLUTION="1024x768"			# xorg resolution

# === Change hostname =========================================================
if [ -n "${LIVE_HOSTNAME:-""}" ]; then
	/bin/echo "${LIVE_HOSTNAME}" > /etc/hostname
fi

# === Copy shell file =========================================================
for _FILE in /lib/live/mount/medium/live/config.conf.d/????-user-* \
            /run/live/medium/live/config.conf.d/????-user-*
do
	if [ -e "${_FILE}" ]; then
		cp -p "${_FILE}" /lib/live/config/
	fi
done

# === Creating state file =====================================================
touch /var/lib/live/config/9999-user-config

# =============================================================================
#set +e
# === Memo ====================================================================
#	/lib/live/init-config.sh
#	/lib/live/config/0020-hostname
#	/lib/live/config/0030-live-debconfig_passwd
#	/lib/live/config/0030-user-setup
#	/lib/live/config/1160-openssh-server
# *****************************************************************************

ユーザー設定関係のシェル

/lib/live/config/9999-user-setting
#!/bin/sh

#set -o ignoreeof					# Ctrl+Dで終了しない
#set +m								# ジョブ制御を無効にする
#set -e								# ステータス0以外で終了
#set -u								# 未定義変数の参照で終了
#set -e
#set -o allexport
#set -o | tee

/bin/echo ""
/bin/echo "Start 9999-user-setting :::::::::::::::::::::::::::::::::::::::::::::::::::::::"

#. /lib/live/config.sh

#set -e

Cmdline ()
{
	# Reading kernel command line
	for _PARAMETER in ${LIVE_CONFIG_CMDLINE}
	do
		case "${_PARAMETER}" in
			debug   | \
			debugout)
				LIVE_DEBUGOUT="true"
				;;
			username=*)
				LIVE_USERNAME="${_PARAMETER#*username=}"
				;;
			password=*)
				LIVE_PASSWORD="${_PARAMETER#*password=}"
				;;
			emptypwd=*)
				LIVE_EMPTYPWD="${_PARAMETER#*emptypwd=}"
				;;
		esac
	done
}

Init ()
{
	:
}

Config ()
{
	# === Change user password ================================================
	if [ -n "${LIVE_USERNAME:-""}" ]; then
#		useradd ${LIVE_USERNAME}
		if [ "${LIVE_EMPTYPWD:-""}" = "true" ]; then
			/bin/echo ""
			/bin/echo "Remove user password ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
			passwd -d ${LIVE_USERNAME}
			LIVE_PASSWORD=""
		elif [ -n "${LIVE_PASSWORD:-""}" ]; then
			/bin/echo ""
			/bin/echo "Change user password ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
			/bin/echo -e "${LIVE_PASSWORD}\n${LIVE_PASSWORD}" | passwd ${LIVE_USERNAME}
		fi
		# === Change smb password =============================================
		if [ -n "`which smbpasswd 2> /dev/null`" ]; then
			/bin/echo ""
			/bin/echo "Create an smb user ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
			smbpasswd -a ${LIVE_USERNAME} -n
			/bin/echo ""
			/bin/echo "Change smb password :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
			/bin/echo -e "${LIVE_PASSWORD}\n${LIVE_PASSWORD}" | smbpasswd ${LIVE_USERNAME}
		fi
		# === Change user mode ====================================================
		if [ `passwd -S ${LIVE_USERNAME} | awk '{print $7;}'` -ne -1 ]; then
			/bin/echo ""
			/bin/echo "Change user mode ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
			usermod -f -1 ${LIVE_USERNAME}
		fi
	fi

	# === Change sshd configure ===============================================
	if [ -f /etc/ssh/sshd_config ]; then
		/bin/echo ""
		/bin/echo "Change sshd configure :::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
		sed -i /etc/ssh/sshd_config \
		    -e 's/^#*[ \t]*\(PasswordAuthentication\)[ \t]*.*$/\1 yes/g'
	fi

	# === Setup VMware configure ==============================================
	if [ "`lscpu | grep -i vmware`" != "" ]; then
		/bin/echo ""
		/bin/echo "Setup VMware configure ::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
		mkdir -p /media/hgfs
		chmod a+w /media/hgfs
		cat <<- _EOT_ >> /etc/fstab
			.host:/ /media/hgfs fuse.vmhgfs-fuse allow_other,auto_unmount,defaults,users 0 0
_EOT_
		cat <<- _EOT_ >> /etc/fuse.conf
			user_allow_other
_EOT_
	fi

	# === Change gdm3 configure ===============================================
	if [ -f /etc/gdm3/custom.conf ] && [ -n "${LIVE_USERNAME:-""}" ]; then
		/bin/echo ""
		/bin/echo "Change gdm3 configure :::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
		IFS= INS_STR=$(
			cat <<- _EOT_ | sed ':l; N; s/\n//; b l;'
				WaylandEnable=false\\n
				AutomaticLoginEnable=true\n
				AutomaticLogin=${LIVE_USERNAME}\\n
				TimedLoginEnable=false\\n
_EOT_
		)
		IFS=${OLD_IFS}
		sed -i /etc/gdm3/custom.conf \
		    -e '/^\[daemon\]/,/^\[/ {/^[#|\[]/! s/\(.*\)$/#  \1/g}' \
		    -e "/^\\[daemon\\]/a ${INS_STR}"
		if [ ! -f /etc/gdm3/daemon.conf ]; then
			/bin/echo ""
			/bin/echo "Create gdm3 daemon.conf :::::::::::::::::::::::::::::::::::::::::::::::::::::::"
			touch /etc/gdm3/daemon.conf
		fi
	fi

	# === Change video mode configure =========================================
	if [ -f /etc/X11/Xsession.d/21xvidemode ]; then
		/bin/echo ""
		/bin/echo "Change video mode configure :::::::::::::::::::::::::::::::::::::::::::::::::::"
		sed -i /etc/X11/Xsession.d/21xvidemode \
		    -e '1i {\nsleep 3' \
		    -e '$a } &'
	fi
}

Debug ()
{
	if [ -z ${LIVE_DEBUGOUT:-""} ]; then
		return 0
	fi
	# === Display of parameters ===============================================
	/bin/echo ""
	/bin/echo "Display of parameters :::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
	set | grep -e "^LIVE_.*=" | tee
	/bin/echo "-------------------------------------------------------------------------------"
	dconf dump /org/gnome/desktop/screensaver/
	/bin/echo "-------------------------------------------------------------------------------"
	dconf dump /org/gnome/todo/
	/bin/echo "-------------------------------------------------------------------------------"
	printenv | sort
	/bin/echo "-------------------------------------------------------------------------------"
	for F in  /lib/systemd/system/*.service
	do
		S=`basename $F`
		R=`systemctl is-enabled "$S"`
		/bin/echo "$S: $R"
	done
	/bin/echo "-------------------------------------------------------------------------------"
	mount | sort
	/bin/echo "-------------------------------------------------------------------------------"
	set -o | tee
	/bin/echo "-------------------------------------------------------------------------------"
}

Cmdline
Init
Config
Debug

# === Creating state file =====================================================
/bin/echo ""
/bin/echo "Creating state file :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
touch /var/lib/live/config/9999-user-setting

/bin/echo ""
/bin/echo "End 9999-user-setting :::::::::::::::::::::::::::::::::::::::::::::::::::::::::"

作成作業

必須ファイルの事前準備

必須ファイルの事前準備
master@sv-ubuntu:~/work$ ls -l
合計 48
-rwxr-xr-x 1 master master   599  6月  1 08:23 0000-user.conf
-rwxr-xr-x 1 master master  5817  6月  1 08:25 9999-user-setting
-rwxr-xr-x 1 master master  6059  6月  1 08:24 9999-user.conf
-rwxr-xr-x 1 master master 24642  6月  1 08:21 inst-net.sh

mmdebstrap

mmdebstrap
sudo rm -rf ./fsimg/
sudo mkdir -p ./fsimg
sudo mmdebstrap \
    --components="${TARGET_COMPONENTS}" \
    --variant=standard \
    --mode=sudo \
    --aptopt='Apt::Install-Recommends "true"' \
    --include="${TARGET_PACKAGE} " \
    --architectures=${TARGET_ARCH} \
    --customize-hook=" \
        cp -p ./inst-net.sh ./fsimg/; \
        chown root.root ./fsimg/inst-net.sh; \
        chmod 755 ./fsimg/inst-net.sh; \
        chroot ./fsimg/ /bin/bash /inst-net.sh; \
        rm -f ./fsimg/inst-net.sh; \
    " \
    ${TARGET_SUITE} \
    ./fsimg/ \
    ${TARGET_MIRROR}

DVDイメージの作成

クリーニング

クリーニング
sudo find ./fsimg/var/log/ -type f -name \* -exec cp -f /dev/null {} \;
sudo rm -rf ./fsimg/inst-net.sh                  \
            ./fsimg/root/.bash_history           \
            ./fsimg/root/.viminfo                \
            ./fsimg/tmp/*                        \
            ./fsimg/var/cache/apt/*.bin          \
            ./fsimg/var/cache/apt/archives/*.deb

DVDイメージの展開準備

DVDイメージの展開準備
sudo mkdir -p ./cdimg/boot/grub          \
              ./cdimg/isolinux           \
              ./cdimg/EFI                \
              ./cdimg/preseed            \
              ./cdimg/live               \
              ./cdimg/live/config.conf.d \
              ./cdimg/.disk
wget "https://cdimage.debian.org/debian/dists/stable/main/installer-amd64/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"
mkdir -p ./_work
sudo tar -xzf "./debian-cd_info.tar.gz" -C "./_work/"

DVDイメージ展開用パラメーター

DVDイメージ展開用パラメーター
OS_KERNEL="`find ./fsimg/boot/ -name "vmlinuz*" -print | sed -n 's/.*vmlinuz-//gp'`"
OS_NAME="`sed -n '/^NAME=/ s/^.*="\([a-zA-Z]*\)"*$/\1/p' ./fsimg/etc/os-release | tr A-Z a-z`"
OS_VERSION="`sed -n '/^VERSION=/ s/^.*=\(.*\)/\1/p' ./fsimg/etc/os-release | sed -e 's/\"//g'`"
OS_VERSION_ID="`sed -n '/^VERSION=/ s/^.*="*\([0-9.]*\).*"*$/\1/p' ./fsimg/etc/os-release`"
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 ${TARGET_SUITE} ${TARGET_ARCH}"

DVDイメージの展開

DVDイメージの展開
echo -en "${OS_NAME} ${OS_VERSION} Live ${TARGET_ARCH} `date +"%Y-%m-%d %H:%M"`" | sudo tee ./cdimg/.disk/info > /dev/null
sudo cp -pr ./_work/grub/*                                     ./cdimg/boot/grub/
sudo cp -p  ./_work/menu.cfg                                   ./cdimg/isolinux/
sudo cp -p  ./_work/stdmenu.cfg                                ./cdimg/isolinux/
sudo cp -p  ./_work/isolinux.cfg                               ./cdimg/isolinux/
sudo cp -p  ./fsimg/usr/lib/ISOLINUX/isolinux.bin              ./cdimg/isolinux/
sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/hdt.c32      ./cdimg/isolinux/
sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/ldlinux.c32  ./cdimg/isolinux/
sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/libcom32.c32 ./cdimg/isolinux/
sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/libgpl.c32   ./cdimg/isolinux/
sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/libmenu.c32  ./cdimg/isolinux/
sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/libutil.c32  ./cdimg/isolinux/
sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/vesamenu.c32 ./cdimg/isolinux/
sudo cp -p  ./fsimg/usr/lib/syslinux/memdisk                   ./cdimg/isolinux/
sudo cp -pr ./fsimg/boot/*                                     ./cdimg/live/
# メニューの背景
sudo cp -p  ./splash.png ./cdimg/isolinux/
sudo chown root.root ./cdimg/isolinux/splash.png
# 変更するパラメーター関係とユーザー設定関係のシェル
sudo cp -p ./9999-* ./cdimg/live/config.conf.d/
sudo chown root.root ./cdimg/live/config.conf.d/*
sudo chmod +x ./cdimg/live/config.conf.d/*
# mountpoint="/live/medium" -> "/run/live/medium" の暫定対応
sudo  cp -p ./0000-user.conf ./fsimg/etc/live/config.conf.d/
sudo  chown root.root ./fsimg/etc/live/config.conf.d/0000-user.conf
sudo  chmod +x ./fsimg/etc/live/config.conf.d/0000-user.conf

DVDイメージへEFIファイルの展開

DVDイメージへEFIファイルの展開
mkdir -p ./media/
sudo mount -r -o loop ./cdimg/boot/grub/efi.img ./media/
sudo cp -pr ./media/efi/* ./cdimg/EFI/
sudo umount -q ./media/

ファイルシステムイメージの作成

ファイルシステムイメージの作成
sudo rm -f ./cdimg/live/filesystem.squashfs
sudo mksquashfs ./fsimg ./cdimg/live/filesystem.squashfs -noappend
ls -lthLgG --time-style="+%Y/%m/%d %H:%M:%S" ./cdimg/live/filesystem.squashfs 2> /dev/null | cut -c 13-

ブートメニューの作成

ブートメニューの作成
cat <<- _EOT_ | sudo tee -a ./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 ./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 ./cdimg/isolinux/isolinux.cfg \
    -e 's/^\(timeout\) .*/\1 50/'

DVDイメージの作成

DVDイメージの作成
pushd ./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-

作業ログ

作業ログ(Ubuntuイメージの作成)
master@sv-ubuntu:~/work$ TARGET_SUITE="kinetic"
master@sv-ubuntu:~/work$ TARGET_ARCH="amd64"
master@sv-ubuntu:~/work$ TARGET_COMPONENTS="main multiverse restricted universe"
master@sv-ubuntu:~/work$ TARGET_MIRROR="http://archive.ubuntu.com/ubuntu/"
master@sv-ubuntu:~/work$ TARGET_PACKAGE=" \
・・・省略
"
master@sv-ubuntu:~/work$ ls -l
合計 48
-rwxr-xr-x 1 master master   599  6月  1 08:23 0000-user.conf
-rwxr-xr-x 1 master master  5817  6月  1 08:25 9999-user-setting
-rwxr-xr-x 1 master master  6059  6月  1 08:24 9999-user.conf
-rwxr-xr-x 1 master master 24642  6月  1 08:21 inst-net.sh
master@sv-ubuntu:~/work$ sudo rm -rf ./fsimg/
master@sv-ubuntu:~/work$ sudo mkdir -p ./fsimg
master@sv-ubuntu:~/work$ sudo mmdebstrap \
・・・省略
master@sv-ubuntu:~/work$ sudo rm -rf ./fsimg/inst-net.sh                  \
・・・省略
master@sv-ubuntu:~/work$ sudo mkdir -p ./cdimg/boot/grub          \
・・・省略
master@sv-ubuntu:~/work$ wget "https://cdimage.debian.org/debian/dists/stable/main/installer-amd64/current/images/cdrom/debian-cd_info.tar.gz"
・・・省略
master@sv-ubuntu:~/work$ wget "http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/current/legacy-images/netboot/ubuntu-installer/amd64/boot-screens/splash.png"
・・・省略
master@sv-ubuntu:~/work$ mkdir -p ./_work
master@sv-ubuntu:~/work$ sudo tar -xzf "./debian-cd_info.tar.gz" -C "./_work/"
master@sv-ubuntu:~/work$ OS_KERNEL="`find ./fsimg/boot/ -name "vmlinuz*" -print | sed -n 's/.*vmlinuz-//gp'`"
master@sv-ubuntu:~/work$ OS_NAME="`sed -n '/^NAME=/ s/^.*="\([a-zA-Z]*\)"*$/\1/p' ./fsimg/etc/os-release | tr A-Z a-z`"
master@sv-ubuntu:~/work$ OS_VERSION="`sed -n '/^VERSION=/ s/^.*=\(.*\)/\1/p' ./fsimg/etc/os-release | sed -e 's/\"//g'`"
master@sv-ubuntu:~/work$ OS_VERSION_ID="`sed -n '/^VERSION=/ s/^.*="*\([0-9.]*\).*"*$/\1/p' ./fsimg/etc/os-release`"
master@sv-ubuntu:~/work$ MNU_LABEL="${OS_NAME} ${OS_VERSION} Live ${TARGET_ARCH} (kernel ${OS_KERNEL})"
master@sv-ubuntu:~/work$ DVD_NAME="${OS_NAME}-live-${OS_VERSION_ID}-${TARGET_SUITE}-${TARGET_ARCH}-debootstrap.iso"
master@sv-ubuntu:~/work$ DVD_VOLID="d-live ${TARGET_SUITE} ${TARGET_ARCH}"
master@sv-ubuntu:~/work$ echo -en "${OS_NAME} ${OS_VERSION} Live ${TARGET_ARCH} `date +"%Y-%m-%d %H:%M"`" | sudo tee ./cdimg/.disk/info > /dev/null
master@sv-ubuntu:~/work$ sudo cp -pr ./_work/grub/*                                     ./cdimg/boot/grub/
master@sv-ubuntu:~/work$ sudo cp -p  ./_work/menu.cfg                                   ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -p  ./_work/stdmenu.cfg                                ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -p  ./_work/isolinux.cfg                               ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -p  ./fsimg/usr/lib/ISOLINUX/isolinux.bin              ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/hdt.c32      ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/ldlinux.c32  ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/libcom32.c32 ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/libgpl.c32   ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/libmenu.c32  ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/libutil.c32  ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -p  ./fsimg/usr/lib/syslinux/modules/bios/vesamenu.c32 ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -p  ./fsimg/usr/lib/syslinux/memdisk                   ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo cp -pr ./fsimg/boot/*                                     ./cdimg/live/
master@sv-ubuntu:~/work$ sudo cp -p  ./splash.png ./cdimg/isolinux/
master@sv-ubuntu:~/work$ sudo chown root.root ./cdimg/isolinux/splash.png
master@sv-ubuntu:~/work$ sudo cp -p 9999-* ./cdimg/live/config.conf.d/
master@sv-ubuntu:~/work$ sudo chown root.root ./cdimg/live/config.conf.d/*
master@sv-ubuntu:~/work$ sudo chmod +x ./cdimg/live/config.conf.d/*
master@sv-ubuntu:~/work$ sudo  cp -p ./0000-user.conf ./fsimg/etc/live/config.conf.d/
master@sv-ubuntu:~/work$ sudo  chown root.root ./fsimg/etc/live/config.conf.d/0000-user.conf
master@sv-ubuntu:~/work$ sudo  chmod +x ./fsimg/etc/live/config.conf.d/0000-user.conf
master@sv-ubuntu:~/work$ mkdir -p ./media/
master@sv-ubuntu:~/work$ sudo mount -r -o loop ./cdimg/boot/grub/efi.img ./media/
master@sv-ubuntu:~/work$ sudo cp -pr ./media/efi/* ./cdimg/EFI/
master@sv-ubuntu:~/work$ sudo umount -q ./media/
master@sv-ubuntu:~/work$ ls -lthLgG --time-style="+%Y/%m/%d %H:%M:%S" ./cdimg/live/filesystem.squashfs 2> /dev/null | cut -c 13-
 2.6G 2022/06/01 15:21:56 ./cdimg/live/filesystem.squashfs
master@sv-ubuntu:~/work$ cat <<- _EOT_ | sudo tee -a ./cdimg/boot/grub/grub.cfg > /dev/null
・・・省略
_EOT_
master@sv-ubuntu:~/work$ cat <<- _EOT_ | sudo tee ./cdimg/isolinux/menu.cfg > /dev/null
・・・省略
_EOT_
master@sv-ubuntu:~/work$ sudo sed -i ./cdimg/isolinux/isolinux.cfg \
・・・省略
master@sv-ubuntu:~/work$ pushd ./cdimg > /dev/null
master@sv-ubuntu:~/work/cdimg$     sudo bash -c 'find . ! -name "md5sum.txt" -type f -exec md5sum -b {} \; > md5sum.txt'
master@sv-ubuntu:~/work/cdimg$     sudo xorriso -as mkisofs                                  \
・・・省略
master@sv-ubuntu:~/work/cdimg$ popd > /dev/null
master@sv-ubuntu:~/work$ ls -lthLgG --time-style="+%Y/%m/%d %H:%M:%S" ${DVD_NAME} 2> /dev/null | cut -c 13-
 2.7G 2022/06/01 15:23:31 ubuntu-live-22.10-kinetic-amd64-debootstrap.iso

注意

  • --customize-hookで動くコマンドはchrootされていないので注意
    開発環境が破壊される)
  • /lib/live/config/内のシェルでechoを使う場合は/bin/echoを使用する
    (シェルのechoだと期待通りの動作をしない)
  • Ubuntuで解決できていない課題がある
    • systemctlでdisableにしたサービスが起動される
    • Welcome画面が表示される

参考

3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?