livecd修改linux文件,[制作Ubuntu/Arch Livecd方法]

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

然后新建一个第二工作文件夹

cd进去,lsinitcpio -x 输出目录/initrd.img

这时候,initrd就被解压了

把./init修改成这样(其实里面好多都是注释

58ac00b793f973ba3f0728c6769b58b8.gif)

#!/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用的。。

2d59907ed0fe493f843be9829188bf13.gif

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最后一段就明白了。

e257770fcf6d3c02fa5d60e0abe4008b.gif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值