首页 > 其他分享 >x01.os.22: 填补一下

x01.os.22: 填补一下

时间:2023-06-11 22:12:23浏览次数:50  
标签:bin chroot 填补 echo etc usr rm x01 os.22

制作 LiveCD

  • 参考 ubuntu 官方
  • 推荐 一键制作
    在 deepin 上操作, 脚本需要更改为: RELEASE=bionic, makecd.sh 代码如下:
#!/bin/bash

# Author: Redbrother
# Email: [email protected]
# license: None
# data :2019 10
# scripts in /usr/share/debootstrap/scripts
############################################

ARCH=amd64
RELEASE=bionic
installer_url=http://mirrors.aliyun.com/ubuntu/
IMAGE=ubuntu-$RELEASE

set -e
#自定义版本项

if [ "`whoami`" != "root" ]; then
	echo "User must be root 需要root权限."
	exit 0
fi
apt install debootstrap genisoimage p7zip-full squashfs-tools -y
if [ "$?" != "0" ]; then
	echo "Commands required: mkisofs, 7z, wget."
	exit 0
fi
if [ "`which mkisofs`" == "" ]; then
	ln -s /usr/bin/genisoimage /usr/bin/mkisofs
fi

############################################

# debootstrap a base live
umount squashfs-root/* 2>/dev/null || true
rm -rf squashfs-root
mkdir -p squashfs-root
debootstrap --arch=$ARCH $RELEASE squashfs-root $installer_url

############################################

cd squashfs-root
echo "deb $installer_url $RELEASE main restricted universe multiverse"          >  etc/apt/sources.list
echo "deb $installer_url $RELEASE-updates main restricted universe multiverse"  >> etc/apt/sources.list
echo "deb $installer_url $RELEASE-security main restricted universe multiverse" >> etc/apt/sources.list
echo 'APT::Install-Recommends "false";' > etc/apt/apt.conf
chroot . chmod a+s /bin/ping
cp -f /etc/hosts etc/hosts
rm -f etc/resolv.conf
mkdir -p run/NetworkManager/
cp -f /etc/resolv.conf etc/
mount -o bind /dev dev/
mount -o bind /sys sys/
mount -o bind /proc proc/
mount -o bind /dev/pts dev/pts/
chroot . rm -f /sbin/initctl
chroot . dbus-uuidgen > /var/lib/dbus/machine-id
chroot . dpkg-divert --local --rename --add /sbin/initctl
chroot . ln -s /bin/true /sbin/initctl
chroot . apt-get update
chroot . apt-get upgrade --yes
chroot . locale-gen zh_CN.UTF-8
chroot . locale-gen en_US.UTF-8
# kernels and network
echo -e "install kernels and network …… "   
DEBIAN_FRONTEND=noninteractive chroot . apt-get install --no-install-recommends dbus sudo bash-completion grub-pc linux-image-generic xinit xserver-xorg network-manager apt-transport-https --yes
DEBIAN_FRONTEND=noninteractive chroot . apt-get download network-manager --yes
# Livecd necessary 
echo -e "install Livecd necessary  "  
DEBIAN_FRONTEND=noninteractive chroot . apt-get install --no-install-recommends ubuntu-standard casper lupin-casper discover laptop-detect os-prober --yes
# useful tools
echo -e "install useful tools  "  
DEBIAN_FRONTEND=noninteractive chroot . apt-get install --no-install-recommends vim nano gvfs lzma unrar rar unzip zip genisoimage p7zip-full wget aria2 zsync jigdo-file squashfs-tools debootstrap syslinux rsync dump parted gparted mdadm python3 python3-distutils --yes
# auto login
mkdir -p etc/lightdm/lightdm.conf.d
mkdir -p usr/share/lightdm/lightdm.conf.d
echo '. /etc/bash_completion'   >> etc/bash.bashrc
echo '[SeatDefaults]'           >  etc/lightdm/lightdm.conf.d/90-default.conf
echo 'autologin-user=ubuntu'    >> etc/lightdm/lightdm.conf.d/90-default.conf
echo 'autologin-user-timeout=0' >> etc/lightdm/lightdm.conf.d/90-default.conf
echo 'autologin-guest=false'    >> etc/lightdm/lightdm.conf.d/90-default.conf
echo 'allow-guest=false'        >> usr/share/lightdm/lightdm.conf.d/60-lightdm-gtk-greeter.conf
cp -f   ../tools/bin/*  usr/local/bin
chroot . chmod +755 -R /usr/local/bin
chroot . chmod +644 -R /boot
chroot . chmod +755 -R /root
chroot . xsession-config

############################################

# zh_CN language packs and timezone
DEBIAN_FRONTEND=noninteractive chroot . apt-get install --no-install-recommends language-pack-zh-hans language-pack-zh-hans-base language-pack-gnome-zh-hans language-pack-gnome-zh-hans-base --yes
chroot . cp -rf usr/share/locale-langpack/zh_CN/LC_MESSAGES/* usr/share/locale/zh_CN/LC_MESSAGES/
chroot . rm -rf usr/share/locale-langpack/
chroot . rm -f etc/timezone
chroot . rm -f etc/localtime
chroot . rm -f etc/adjtime
chroot . ln -s /usr/share/zoneinfo/Asia/Shanghai etc/localtime
echo '0.0 0 0' >  etc/adjtime
echo '0'       >> etc/adjtime
echo 'LOCAL'   >> etc/adjtime
echo 'Asia/Shanghai'             >  etc/timezone
echo 'export TZ=Asia/Shanghai'   >> etc/profile
echo 'export LANG=zh_CN.UTF-8'   >> etc/profile
echo 'export LC_ALL=zh_CN.UTF-8' >> etc/profile
# user settings
mkdir -p home/ubuntu/Desktop
mkdir -p home/ubuntu/.config
cp -rf ../tools/ubuntu/config/* home/ubuntu/.config/
chmod  +666 -R home/ubuntu/.config/
chmod  +666 -R home/ubuntu/Desktop/
chroot . rm -f home/ubuntu/.config/user-dirs.*
# fcitx-googlepinyin
echo -e "install fcitx-googlepinyin and fonts  " 
DEBIAN_FRONTEND=noninteractive chroot . apt-get install --no-install-recommends ttf-ubuntu-font-family fonts-wqy-microhei fcitx fcitx-ui-classic fcitx-frontend-gtk2 fcitx-config-gtk fcitx-googlepinyin --yes
# fcitx config
echo 'export GTK_IM_MODULE="xim"'    >  etc/X11/Xsession.d/96fcitx_start
echo 'export XMODIFIERS="@im=fcitx"' >> etc/X11/Xsession.d/96fcitx_start
cp -f usr/local/bin/97pinyin*      etc/X11/Xsession.d/
cp -f usr/local/bin/fcitx-pinyin*  usr/bin
cp ../tools/settings/*.desktop               usr/share/applications
cp ../tools/settings/fcitx-config.desktop    etc/xdg/autostart/
# mate desktop environment
echo -e " mate desktop environment " 
DEBIAN_FRONTEND=noninteractive chroot . apt-get install --no-install-recommends mate-desktop-environment-core lightdm pluma engrampa eom mate-calc --yes
# cd usr/share/themes/ && rm -rf `ls | grep -v Default Adwaita Black* Blue* Green* Menta* ` && cd ../../..
cd usr/share/themes/ && rm -rf ContrastHigh* Clearlook* Crux* eOS* HighContrast* Industria* Mist* Raleigh* Redmond* Traditional*  &&  cd ../../..
# add gonme applications Links
chroot . rm -f /usr/bin/gedit
chroot . rm -f /usr/bin/nautilus
chroot . rm -f /usr/bin/gnome-terminal
chroot . rm -f /usr/bin/file-roller
chroot . rm -f /usr/bin/eog
ln -s pluma usr/bin/gedit
ln -s caja  usr/bin/nautilus
ln -s eom   usr/bin/eog
ln -s engrampa      usr/bin/file-roller
ln -s mate-terminal usr/bin/gnome-terminal
#  modify some desktop
cd usr/share/applications
sed -i 's/GenericName\[zh_CN\]/Name\[zh_CN\]/' engrampa.desktop
sed -i 's/GenericName\[zh_CN\]/Name\[zh_CN\]/' mate-terminal.desktop
sed -i 's/GenericName\[zh_CN\]/Name\[zh_CN\]/' caja-browser.desktop
sed -i 's/Exec=fcitx/Exec=im-config/' fcitx.desktop
sed -i 's/Settings/System/' fcitx-con*.desktop
sed -i 's/NoDisplay\=true//' python*.desktop
sed -i 's/System\;//'  mate-terminal.desktop
sed -i 's/System\;//'  caja-browser.desktop
sed -i 's/MATE\ 之眼//' eom.desktop
cd ../../../
# 重新配置网络 and # clean up
chroot . rm -f etc/resolv.conf
chroot . dpkg -i network-manager*.deb
chroot . apt clean
chroot . apt-clean
chroot . apt-get clean
chroot . rm -rf tmp/*
chroot . rm -f network-manager*.deb
chroot . rm -f vmlinu*  initrd.im*
chroot . rm -f etc/init/tty3.conf etc/init/tty4.conf etc/init/tty5.conf
chroot . rm -f /var/lib/dbus/machine-id
chroot . rm -f /sbin/initctl
chroot . dpkg-divert --rename --remove /sbin/initctl
umount -lf sys/
umount -lf proc/
umount -lf dev/pts/
umount -lf dev/
cd ..

############################################

# ubuntu live base system is Success
  echo -e "ubuntu live base system is successful, you can diy it in squashfs-root contents "   
  echo -e ". Do you want to make an ISO image ? [y/n] "           
  read choice
  if [ "$choice" != "y" ]; then
      echo -e "you can run ' sudo bash mkiso.sh ' to build an iso LiveCD;successful "           
      exit 0
  fi

# make iso file ; build an iso image
mkdir -p cdimage/casper
rm -f cdimage/casper/*
rm -f $IMAGE.iso
cp -f squashfs-root/boot/vmlinuz-*-generic cdimage/casper/vmlinuz
cp -f squashfs-root/boot/initrd.img-*-generic cdimage/casper/initrd.lz
mksquashfs squashfs-root cdimage/casper/filesystem.squashfs -e boot
chmod +666 -R cdimage/casper
mkdir -p cdimage/.disk
touch cdimage/ubuntu
touch cdimage/.disk/base_installable
echo "full_cd/single"        > cdimage/.disk/cd_type
echo "Ubuntu Remix $RELEASE" > cdimage/.disk/info
cd cdimage && find . -type f -print0 | xargs -0 md5sum | grep -v "\./md5sum.txt" > md5sum.txt && cd ..
mkisofs -o $IMAGE.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -r -V "$IMAGE" -cache-inodes -J -l cdimage/
chmod  +666 $IMAGE.iso
cd cdimage && rm -f ubuntu md5sum.txt  && cd ..
rm -rf cdimage/.disk
rm -rf cdimage/casper/*
echo -e "successfully done"

其他尝试

  1. 创建虚拟盘 c.img 使用 bximage 即可
  2. 创建分区 (m: 帮助, n: 创建新分区, a: 添加引导标记, p: 查看, w: 保存)
sudo fdisk c.img
  1. 映射到 /dev/mapper
sudo kpartx -av c.img
ls -l /dev/mapper
  1. 根据映射 loop 格式化
sudo mkfs.ext4 /dev/mapper/loop0p1
  1. 安装 grub
sudo mount /dev/mapper/loop0p1 /mnt
sudo grub-install --boot-directory=/mnt/ /dev/loop0
  1. 复制 vmlinz initrd.img
sudo cp /boot/vmlinuz-4.15.0-30deepin-generic /mnt/boot/vmlinuz
sudo cp /boot/initrd.img-4.15.0-30deepin-generic  /mnt/boot/initrd.img
  1. 创建配置文件 grub.cfg,复制到 /mnt/boot/grub/ 中
default=0
timeout=10
insmod ext2
set root='hd0,msdos1'
menuentry 'x01.treeos' {
    insmod gzio
	insmod part_msdos
	insmod ext2
	set root='hd0,msdos1'
	linux /boot/vmlinuz ro --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1
	initrd /boot/initrd.img 
}

Make LiveCD 脚本

# 取消注释即可下载
#wget http://kernel.org/pub/linux/kernel/v4.x/linux-4.10.9.tar.xz
#wget http://busybox.net/downloads/busybox-1.24.2.tar.bz2
#wget http://kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.xz
mkdir isoimage
tar -xvf linux-4.10.9.tar.xz
tar -xvf busybox-1.25.1.tar.bz2
tar -xvf syslinux-6.03.tar.gz
cd busybox-1.25.1
make distclean defconfig
sed -i "s/.*CONFIG_STATIC.*/CONFIG_STATIC=y/" .config
make busybox install
cd _install
rm -f linuxrc
mkdir dev proc sys
echo '#!/bin/sh' > init
echo 'dmesg -n 1' >> init
echo 'mount -t devtmpfs none /dev' >> init
echo 'mount -t proc none /proc' >> init
echo 'mount -t sysfs none /sys' >> init
echo 'setsid cttyhack /bin/sh' >> init
chmod +x init
find . | cpio -R root:root -H newc -o | gzip > ../../isoimage/rootfs.gz
cd ../../linux-4.10.9
make mrproper defconfig bzImage
cp arch/x86/boot/bzImage ../isoimage/kernel.gz
cd ../isoimage
cp ../syslinux-6.03/bios/core/isolinux.bin .
cp ../syslinux-6.03/bios/com32/elflink/ldlinux/ldlinux.c32 .
echo 'default kernel.gz initrd=rootfs.gz' > ./isolinux.cfg
xorriso \
    -as mkisofs \
    -o ../minimal_linux_live.iso \
    -b isolinux.bin \
    -c boot.cat \
    -no-emul-boot \
    -boot-load-size 4 \
    -boot-info-table \
    ./
cd ..

标签:bin,chroot,填补,echo,etc,usr,rm,x01,os.22
From: https://www.cnblogs.com/china_x01/p/17473721.html

相关文章

  • 将字符串里的\x01,\x02这些替换掉用正则表达式无效?
    大家好,我是皮皮。一、前言前几天在Python白银群【凡人不烦人】问了一个Python正则表达式的问题,这里拿出来给大家分享下。将字符串里的\x01,\x02这些替换掉用my_str=re.sub(r'\x0d','',my_str)这个结果不对,是什么原因呢?他的原始文档如下所示:看上去没有看到特殊二进制字符。二、......
  • Python批量填补遥感影像的无效值NoData
      本文介绍基于Python中ArcPy模块,对大量栅格遥感影像文件批量进行无效值(NoData值)填充的方法。  在处理栅格图像文件时,我们经常会遇到图像中存在有无效值(即NoData值)的情况。如下图所示,这里有一个矢量面要素图层和该矢量图层范围对应的一景栅格图像;可以看到,由于该栅格图像存在......
  • 打破制造业数字化转型困境:华为云助力企业填补数据空白和简化管理
    摘要:制造业数字化转型过程受到历史IT包袱的阻碍,难以有效实现数字化。为了帮助更多制造企业应对云采用的挑战,华为云推出了各种基于场景的解决方案,使企业能够高效转向云端并迅速实现数字化转型。随着中国制造2025计划加速制造业数字化转型的发展,企业越来越多地利用创新技术如云计算、......
  • arcpy孔洞如何填补
     参考:https://blog.csdn.net/weixin_40450867/article/details/85222383带孔洞的polygon坐标是如何存的?如果没有孔洞,那么polygon的坐标最后一个点和第一个点会重合。如果带孔洞的话,就不重合?参考2:https://blog.csdn.net/u010608964/article/details/81567871......
  • PowerBuilder现代编程方法X01:PowerPlume的X模式
     临渊羡鱼,不如退而结网。 PB现代编程方法X01:PowerPlume的X模式 前言PowerPlume是PowerBuilder深度创新的扩展开发框架(免费商用)。它不是一个大而全的类库(取决于你......
  • “全球首款旗舰”填补行业空白,两轮电动车技术创新为何只看绿源?
    作者|曾响铃文| 响铃说乒乓作为我们的“国球”,在数不清的体育赛事里书写辉煌战绩,也进一步被国人熟知、热爱。更难能可贵的是“国球”精神:“别人可能练了一千次,而我们却......
  • linux018之安装mysql
    linux上安装mysql:第一步:查看是否已经安装mariadb,mariadb是mysql数据库的分支,mariadb和mysql一起安装会有冲突,所以需要卸载掉。yumlistinstalled|grepmariadb:查看是......
  • linux017之安装tomcat
    linux安装Tomcat:一、安装tomcat之前,需要先配置好jdk,不会配置jdk可以看着篇文章:https://www.cnblogs.com/FBGG/p/17133711.html二、下载Tomcat,地址:http://tomcat.apache.......
  • linux016之安装JDK
    linux上安装JDK:一:首先检查一下linux上是否已经安装有jdkrpm-qa|grepjdk:查询目前系统已安装的jdk,直接复制该命令执行,如下图就是系统已经安装好的JDK  rpm-qa......
  • linux015之软件包的管理
    linux中软件安装包的管理:RPM:简介:RPM是linux中一种软件安装工具,安装linux之初就已经安装好了的,直接使用它的命令即可。这个工具相当于手动安装软件,需要自行......