美文网首页
ubuntu 定制 ISO

ubuntu 定制 ISO

作者: chocolee911 | 来源:发表于2018-05-30 18:03 被阅读0次

想要 ubuntu 系统装好就拥有自己想要的软件、环境?
试试 ubuntu 定制 ISO

步骤

  1. 准备工作
  2. 解压 ISO
  3. 解压 filesystem.squashfs 文件
  4. 切换至新系统
  5. 自定义
  6. 重新压缩新的根文件系统
  7. 制作新 ISO

1. 准备工作

  • 切换至 root 账户
    su - root
  • 安装 squashfs-tools 和 genisoimage
    apt-get install -y squashfs-tools genisoimage

  • 下好需要安装的软件(能 yum 的就不用下了)

2. 解压 ISO

root@chocolee-ubuntu:~# pwd
/root
root@chocolee-ubuntu:~# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
root@chocolee-ubuntu:~# cp -v -a /mnt/ newiso

root@chocolee-ubuntu:~/newiso# ls -a
.   boot    .disk  EFI      isolinux    pics  preseed             ubuntu
..  casper  dists  install  md5sum.txt  pool  README.diskdefines

特别注意:复制完成后,看看 .disk 目录有没有拷贝成功,这个隐藏目录必须存在。

3. 解压 filesystem.squashfs 文件

root@chocolee-ubuntu:~/newiso# unsquashfs casper/filesystem.squashfs
Parallel unsquashfs: Using 3 processors
188525 inodes (204212 blocks) to write

[====================================================-] 204212/204212 100%

created 124061 files
created 17766 directories
created 64357 symlinks
created 79 devices
created 0 fifos


## 将解压出来的 quashfs-root 目录放到上一层
root@chocolee-ubuntu:~/newiso# mv squashfs-root ../
root@chocolee-ubuntu:~/newiso# cd ..
root@chocolee-ubuntu:~# pwd
/root

ps. 此时可将本系统的一些配置文件,如:sources.list、resolv.conf 等移至 quashfs-root 中的对应目录中

4. 切换至新系统

chroot squashfs-root/

mount -t proc none /proc

mount -t sysfs none /sys

mount -t devpts none /dev/pts

5. 自定义

此时可以在切换到的系统中编译、apt-get安装各种文件,配置环境等
配置完成后退出

exit
pwd
/root

6. 重新压缩新的根文件系统

chmod +w newiso/casper/filesystem.manifest
chroot squashfs-root dpkg-query -W --showformat='${Package} ${Version}\n' > newiso/casper/filesystem.manifest
cp newiso/casper/filesystem.manifest newiso/casper/filesystem.manifest-desktop
sed -i '/ubiquity/d' newiso/casper/filesystem.manifest-desktop
sed -i '/casper/d' newiso/casper/filesystem.manifest-desktop
rm newiso/casper/filesystem.squashfs
mksquashfs squashfs-root newiso/casper/filesystem.squashfs
printf $(sudo du -sx --block-size=1 squashfs-root | cut -f1) > newiso/casper/filesystem.size

(注:最好用cat newiso/casper/filesystem.size查看一下大小)
cd newiso
rm md5sum.txt
find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt

7. 制作新 ISO

mkisofs -D -r -V "My ubuntu-14.04.1" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-16.04-desktop-customed.iso .

相关文章

网友评论

      本文标题:ubuntu 定制 ISO

      本文链接:https://www.haomeiwen.com/subject/jhzzjftx.html