如何定制支持用户自定义boot参数的基于debian os的live cd
Step 1 – Installing the necessary software
apt-get install xorriso live-build syslinux squashfs-tools
Step 2 – Create a basic filesystem
mkdir ~/livework && cd ~/livework
debootstrap --arch=amd64 wheezy chroot http://ftp.debian.org/debian/
or debootstrap --arch=amd64 jessie chroot http://ftp.cn.debian.org/debian/
Step 3 – Chroot
cd ~/livework && chroot chroot
mount none -t proc /proc
mount none -t sysfs /sys
mount none -t devpts /dev/pts
export HOME=/root
export LC_ALL=C
export PS1="\e[01;
31m(live):\W \$ \e[00m"
apt-get install dialog dbus
dbus-uuidgen > /var/lib/dbus/machine-id
apt-get install linux-image-amd64
apt-get install live-boot parted efibootmgr ssh expect ctorrent dosfstools
modify hostname and autologin(/etc/inittab) /etc/rc.local and add live-run script in /usr/sbin(chmod 755)
passwd
apt-get clean
rm /var/lib/dbus/machine-id && rm -rf /tmp/*
kill dbus process
umount /proc /sys /dev/pts
exit
Step 4 – ISOLINUX
cd ~/livework
mkdir -p binary/live && mkdir -p binary/isolinux
or mkdir -pv binary/{live,isolinux}
cp chroot/boot/vmlinuz-3.16.0-4-amd64 binary/live/hyperman-clone-livecd.vmlinuz
cp chroot/boot/initrd.img-3.16.0-4-amd64 binary/live/hyperman-clone-livecd.initrd
mksquashfs chroot binary/live/hyperman-clone-livecd.squashfs -comp xz -e boot
cp /usr/lib/syslinux/isolinux.bin binary/isolinux/.
cp /usr/lib/syslinux/menu.c32 binary/isolinux/.
【如何定制支持用户自定义boot参数的基于debian os的live cd】vi binary/isolinux/isolinux.cfg
ui menu.c32
prompt 0
menu title Boot Menu
timeout 300
label live-amd64
menu label ^Live (amd64)
menu default
linux /live/vmlinuz
append initrd=/live/initrd boot=live persistence quiet
label live-amd64-failsafe
menu label ^Live (amd64 failsafe)
linux /live/vmlinuz
append initrd=/live/initrd boot=live persistence config memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal
endtext
Step 5 – Building the iso image
cd ~/livework
xorriso -as mkisofs -r -J -joliet-long -l -cache-inodes \
-isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin -partition_offset 16 \
-A "Debian Live"-b isolinux/isolinux.bin -c \
isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
-boot-info-table -o remaster.iso binary
live-run script:
#!/bin/bash
live_param_file="/proc/cmdline"
live_param_list="$(grep -Ewo "live_run[[:digit:]]*" $live_param_file | uniq | sort -V)"
live_param_list="$(echo $live_param_list)"
if [ -z "$live_param_list" ];
then
exit 1
else
echo "Found live_run* parameter in boot parameters and the order to run: $live_param_list" >> /var/log/syslog
mod_live_param_file="$(mktemp /tmp/mod_live_command.XXXXXX)"
fi
for live_param in $live_param_list;
do
if LC_ALL=C grep -Eq "($live_param=\"|$live_param=\\\\\")" $live_param_file;
then
# For case like live_run="sleep 5" or live_run=\"sleep 5\"
LC_ALL=C grep -oE -- "$live_param=(\"|\\\\\")[^\"]*(\"|\\\\\")([[:space:]]|$)+" $live_param_file | sed -r -e "s|=\\\\\"|=\"|g" -e "s@\\\\\"([[:space:]]|$)+@\"@g" | sed -r -e 's|^\"(.*)=|\1=\"|g' >> $mod_live_param_file
elif LC_ALL=C grep -Eq "\"$live_param=" $live_param_file;
then
# For case live: "live_run=sleep 5", "live_run1=mount UUID=XXXYYZZ /mnt"
LC_ALL=C grep -oE -- "\"$live_param=[^\"]*\"([[:space:]]|$)+" $live_param_file | sed -r -e "s|=\\\\\"|=\"|g" -e "s@\\\\\"([[:space:]]|$)+@\"@g" | sed -r -e 's|^\"(.*=)(.*=.*)*|\1\"\2|g' >> $mod_live_param_file
else
# For case like xxx=xyz, no space in its assignment
LC_ALL=C grep -oE -- "$live_param=([[:alnum:]]|_|-|\.|\/|:)*([[:space:]]|$)+" $live_param_file >> $mod_live_param_file
fi
done
. $mod_live_param_file
for live_param in $live_param_list;
do
eval live_command=\$$live_param
if [ -n "$live_command" ];
then
echo "Now run \"$live_param\": $live_command..." >> /var/log/syslog
if [ "$(LANG=C file -Ls "$live_command" 2>/dev/null | grep -iE "shell script")" ];
then
$live_command
else
eval $live_command
fi
fi
done
[ -f "$mod_live_param_file" ] && rm -f $mod_live_param_file
推荐阅读
- 考研英语阅读终极解决方案——阅读理解如何巧拿高分
- 如何寻找情感问答App的分析切入点
- mybatisplus如何在xml的连表查询中使用queryWrapper
- MybatisPlus使用queryWrapper如何实现复杂查询
- 定制一套英文学习方案
- 如何在Mac中的文件选择框中打开系统隐藏文件夹
- 漫画初学者如何学习漫画背景的透视画法(这篇教程请收藏好了!)
- java中如何实现重建二叉树
- Linux下面如何查看tomcat已经使用多少线程
- thinkphp|thinkphp 3.2 如何调用第三方类库