该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
然后新建一个第二工作文件夹
cd进去,lsinitcpio -x 输出目录/initrd.img
这时候,initrd就被解压了
把./init修改成这样(其实里面好多都是注释
)
#!/usr/bin/ash
PATH=/usr/bin
udevd_running=0
if [ -x /usr/bin/systemd-timestamp ]; then
RD_TIMESTAMP=$(systemd-timestamp)
fi
. /init_functions
mount -t proc proc /proc -o nosuid,noexec,nodev
mount -t sysfs sys /sys -o nosuid,noexec,nodev
mount -t devtmpfs dev /dev -o mode=0755,nosuid
mount -t tmpfs run /run -o nosuid,nodev,mode=0755
mkdir -m755 /run/initramfs
# parse the kernel command line
parse_cmdline
#for d in ${disablehooks//,/ }; do
# [ -e "/hooks/$d" ] && chmod 644 "/hooks/$d"
#done
. /config
run_hookfunctions 'run_earlyhook' 'early hook' $EARLYHOOKS
#[ -n "${earlymodules//[[:space:]]}" ] && modprobe -qab ${earlymodules//,/ }
#[ -n "${MODULES//[[:space:]]}" ] && modprobe -qab $MODULES
# If rootdelay is empty or not a non-negative integer, set it to 10
#if [ -z "${rootdelay}" ] || ! [ "${rootdelay}" -ge 0 ]; then
# rootdelay=10
#fi
run_hookfunctions 'run_hook' 'hook' $HOOKS
# honor the old behavior of break=y as a synonym for break=premount
#if [ "${break}" = "y" ] || [ "${break}" = "premount" ]; then
# echo ":: Pre-mount break requested, type 'exit' to resume operation"
# launch_interactive_shell
#fi
rootdev=$(resolve_device "$root") && root=$rootdev
unset rootdev
#fsck_root
# Mount root at /new_root
#${mount_handler:-default_mount_handler} /new_root
run_hookfunctions 'run_latehook' 'late hook' $LATEHOOKS
run_hookfunctions 'run_cleanuphook' 'cleanup hook' $CLEANUPHOOKS
#init=${init:-/sbin/init}
#if [ "$(stat -c %D /)" = "$(stat -c %D /new_root)" ]; then
# Nothing got mounted on /new_root. This is the end, we don't know what to do anymore
# We fall back into a shell, but the shell has now PID 1
# This way, manual recovery is still possible.
# err "Failed to mount the real root device."
# echo "Bailing out, you are on your own. Good luck."
# echo
# launch_interactive_shell --exec
#elif [ ! -x "/new_root${init}" ]; then
# Successfully mounted /new_root, but ${init} is missing
# The same logic as above applies
# err "Root device mounted successfully, but ${init} does not exist."
# echo "Bailing out, you are on your own. Good luck."
# echo
# launch_interactive_shell --exec
#fi
#if [ "${break}" = "postmount" ]; then
# echo ":: Post-mount break requested, type 'exit' to resume operation"
# launch_interactive_shell
#fi
#
#exec env -i \
# "TERM=$TERM" \
# "RD_TIMESTAMP=$RD_TIMESTAMP" \
# /usr/bin/switch_root /new_root $init "$@"
# vim: set ft=sh ts=4 sw=4 et:
echo -e '\e[36mModprobe...\e[0m'
/sbin/modprobe squashfs
/sbin/modprobe aufs
echo -e '\e[36mMounting filesystems...\e[0m'
mount $root /a/
mount -t tmpfs tmpfs /nr_rw/
mount -t squashfs -o loop /a/fs.sfs /nr_ro/
mount -t aufs -o br:/nr_rw/=rw:/nr_ro/=ro none /nr/
ls /nr
#这个ls是debug用的。。
echo -e '\e[36mSwitch root...\e[0m'
exec /usr/bin/switch_root /nr/ /sbin/init $@
创建必须的目录
mkdir ./nr/
mkdir ./nr_ro/
mkdir ./nr_rw/
mkdir ./a/
然后打包回去
find . -print0 | bsdcpio -0oH newc | xz --check=crc32 > 目录/initrd.img
把这个塞进去,还有/boot/vmlinuz什么aufsfriendly
到网上下载一个叫做grub4dos的神奇玩意,把里面的grldr解压过来
建立一个menu.lst
工作文件夹大致是这样
什么什么(squashfs文件)
vmlinuz
initrd.img
grldr
menu.lst
menu.lst写法示例:
title ArchLive
kernel /vmlinuz root=/dev/sr0
initrd /initrd.img
====================分割线====================
接下来是制作iso
cd到工作文件夹
mkisofs -o 目录/iso文件 -R -V "卷标" --no-emul-boot -b grldr .
搞定。妥妥的。
ubuntu在U盘或硬盘的引导参数:boot=casper iso-scan/filename=目录/iso文件名
arch的,看一看改过的init最后一段就明白了。