Ubuntu定制化系统ISO制作

一、安装工具

apt-get install squashfs-tools
apt-get install mkisofs
二、挂载并解压系统ISO文件

  1. 在opt目录下进行操作
    cd /opt/
    mkdir mnt livecd tool
  2. 上传要定制化的系统ISO到 /opt/tool/
  3. 挂载ISO镜像到 /opt/mnt/下
    mount /opt/tool/ubuntu-16.04.2-server-amd64.iso /opt/mnt/
  4. 复制所有的镜像文件到/opt/livecd/下
    cp -rp /opt/mnt/. /opt/livecd/
  5. 取消镜像挂载
    umount /opt/mnt/
    三、定制系统
  6. 解压filesystem.squashfs文件到当前目录,解压出来的目录为squashfs-root
    cd /opt/livecd/install/
    unsquashfs filesystem.squashfs
  7. 切换进新的系统
    chroot squashfs-root
    mount -t proc none /proc
    mount -t sysfs none /sys
    mount -t devpts none /dev/pts
  8. 修改DNS,安装源文件,复制本机已经配置好的DNS和安装源给需要定制的系统机器
    先退出squashfs-root系统
    exit
    cp /etc/apt/sources.list /opt/livecd/install/squashfs-root/etc/apt/sources.list
    cp /etc/resolv.conf /opt/livecd/install/squashfs-root/etc/resolv.conf
  9. 切换进新的系统,安装所需要的软件,等等对系统做定制化修改
    chroot squashfs-root
    apt update
    apt install software-properties-common


    apt update
    aptitude hold linux-generic

  10. 清除系统
    apt-get clean
    apt-get autoremove
    rm -fr /tmp/*
  11. 退回到原来的系统
    umount /proc
    umount /sys
    umount /dev/pts
    exit
  12. 重新配置并压缩根文件系统
    cd /opt/livecd/install
    rm filesystem.squashfs
    mksquashfs squashfs-root filesystem.squashfs
    printf $(du -sx --block-size 1 squashfs-root |cut -f1) >filesystem.size
    rm -r squashfs-root
    cd /opt/livecd/
    rm md5sum.txt
    find -type f -print0 | xargs -0 md5sum|grep -v isolinux/boot.cat |tee md5sum.txt
    8.制作ISO镜像
    cd /opt/livecd/
    mkisofs -D -r -V "ubuntu-16.04.2-server-amd64.iso" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o "../RDCloudInstallOS.iso" .

猜你喜欢

转载自blog.51cto.com/shibingran/2162181