← 返回

Packing Your Own Gentoo Linux into a bootable ISO Image - 1st edition

1. Installing Necessary Packages

  • schroot
  • squashfs-tools
  • cdrtools
  • syslinux
  • dev-libs/libisoburn
emerge -avt schroot squashfs-tools cdrtools libisoburn
modprobe squashfs

About squashfs:

A compressed read-only file system for Linux.

2. Downloading Gentoo minimal liveCD

https://www.gentoo.org

3. Mounting ISO as a file system

We will mount Gentoo liveCD as directory: /mnt/gentoo, mount Gentoo liveCD squashfs as /mnt/squashfs, mount customize OS root as /mnt/collie

!!! Make sure '/' has enough free space

# Creating Gentoo minimal liveCD mount point, 'gentoo'
# Another directory to mount squashfs in liveCD, 'squashfs'
# And a directory for customizing current OS, 'collie'
mkdir /mnt/{gentoo,squashfs,collie}

mount -o loop /path/to/minimal-livecd /mnt/gentoo

mount -t squashfs -o loop /mnt/gentoo/image.squashfs /mnt/squashfs

4. Copying files in squashfs to customize place

cp -av /mnt/squashfs/* /mnt/collie/

5. Packing current OS

# writing a regex file contains all the directories and files not allowed to packed, adding or deleting lines depends on you own condition.
cat >> /tmp/os.tar.exclude << EOF
/dev/*
/home/*
/media/*
/mnt/*
/proc/*
/root/*
/run/*
/sys/*
/tmp/*
/var/tmp/*
/var/www/*
/var/spool/*
/var/lib
/var/cache
/usr/portage/*
EOF

tar --exclude-backups --exclude-caches --exclude-from="/tmp/os.tar.exclude" -cjvf /any/large/filesystem/collie.stage3.20230622.tar.bz2 /

cp -av /path/of/collie.stage3.20230622.tar.bz2 /mnt/collie/home

6. Regenerating squashfs file

mksquashfs /mnt/collie /any/large/filesystem/image.squashfs
Parallel mksquashfs: Using 4 processors

Creating 4.0 filesystem on /home/vmware/image.squashfs, block size 131072.

[======================================|                             ] 49580/87345  56%

7. Creating customized ISO files

mkdir /any/large/filesystem/collieLiveCD

cp -av /mnt/collie/* /path/to/collieLiveCD
mv /path/to/image.squashfs /path/to/collieLiveCD
Option 1:
mkdir /path/to/collieLiveCD/isolinux
cp -av /usr/share/syslinux/isolinux.bin isolinux/

mkisofs -r -V "Collie-Linux" -b efi.img -c isolinux/boot.cat -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 3 -o /any/large/filesystem/Collie-Linux-X86_64-0.0.1.iso .
Option2:
GRUB_HOME="/path/to/liveCD/boot/grub"

grub-mkrescue --compress=no --fonts=$GRUB_HOME/fonts/unicode.pf2 --locale-directory=$GRUB_HOME/locale --themes=$GRUB_HOME/themes -o Collie-Linux-x86_64-0.0.1.iso --product-name="Collie-Linux" /path/to/comtomized/liveCD/

Related links:

Ask Ubuntu Gentoo's Bugzilla – Bug 533214 GRUB on Gentoo Linux Making a GRUB bootable CD-ROM Mkisofs - OS Dev Configuring the bootloader for Gentoo Linux Syslinux - Gentoo Linux LiveUSB - Gentoo Linux Grub2/ISOBoot - Ubuntu documentation Which package contains mkisofs How to customize the Ubuntu Live CD

Comments

Loading comments...

Leave a comment