Home Linux Community Forums Linux System Administration Linux Security To create a bootable iso of a self made distro

To create a bootable iso of a self made distro

Link to this post 28 Aug 10

Hello Everyone,

I have a CentOS Server, running 2.6.29. I have configured a small firewall, with iptables, snort_inline, zebra, keepalived etc. I wanted to make an iso image of my own distro, so that I can give it to my friends so that they can use a ready made Firewall.

To accomplish this, I created an initrd image using busybox that has an init file. The contents of the init file is:


mount -t proc /proc /proc
echo Mounting proc filesystem
echo Mounting sysfs filesystem
mount -t sysfs /sys /sys
echo Creating /dev
mkdir /dev/shm
mount -o mode=0755 -t tmpfs /dev/shm /dev/shm
mkdir /dev/pts
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
echo Creating initial device nodes
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/urandom c 1 9
mknod /dev/systty c 4 0
mknod /dev/tty c 5 0
mknod /dev/console c 5 1
mknod /dev/ptmx c 5 2
mknod /dev/rtc c 10 135
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/ttyS0 c 4 64
mknod /dev/ttyS1 c 4 65
mknod /dev/ttyS2 c 4 66
mknod /dev/root c 3 1
mknod /dev/hdc b 22 0
mknod /dev/sda b 8 0
mknod /dev/sda1 b 8 1
mknod /dev/root b 8 1
echo Setting up hotplug.
echo Creating block device nodes.
echo "Loading ehci-hcd.ko module"
insmod /lib/ehci-hcd.ko
echo "Loading ohci-hcd.ko module"
insmod /lib/ohci-hcd.ko
echo "Loading uhci-hcd.ko module"
insmod /lib/uhci-hcd.ko
mount -t usbfs /proc/bus/usb /proc/bus/usb
echo "Loading scsi_transport_spi.ko module"
insmod /lib/scsi_transport_spi.ko
echo "Loading mptbase.ko module"
insmod /lib/mptbase.ko
echo "Loading mptscsih.ko module"
insmod /lib/mptscsih.ko
echo "Loading mptspi.ko module"
insmod /lib/mptspi.ko
echo "Loading usb-storage.ko module"
insmod /lib/usb-storage.ko
echo My Shell

Along with the initrd.img and vmlinuz, I have made an iso image.

Once I boot the iso image, it gives me the busybox shell. However it is still in initramfs state. Then I try to mount the files in the iso to a /mnt directory and chroot to the environment according to this script:


echo Creating a mount point
mkdir /mnt
echo Mounting the Root File System
mount /dev/hdc /mnt ==> this mounts the iso image in the cd-rom to /mnt
echo changing Root
mount -o bind /proc /mnt/boot/proc/
mount -o bind /sys /mnt/boot/mnt/
export HOME=/root
chroot /mnt/boot

As I have a ram size of around 256Mb, mounting the entire contents of the cd in the ram and then copying from the ram would not be possible.

I cannot do much as the file system mounted is read only. I need a read write environment, so that I can get things modified and certain files that uses /var can write to it.

If possible can I have the entire file system as read only, however have certain directories such as /dev, /var, /proc as read write.

Thanks and Regards,

Link to this post 29 Aug 10

Sorry for interuping...
are this is tutorial ? can i used to remaster other distro (i'm looking how to remaster bt4-r1)?
sorry again for this noob question. i still a newbies in linux :)

Link to this post 30 Aug 10

When I understand you correctly you want to create custom bootable Linux images?
I would recommend to use ISOLINUX as most Linux distributors do. For a short introduction how to use this see here:

Link to this post 30 Aug 10

There is also a wicked-cool application called Remastersys that I used to make bootable iso copies of "Robin's Linux Remix" (sort a Xubuntu-like mixture with custom apps for choreography and music editing) to share with the other kids at the dance studio. Not sure if it's compatible with CentOS or not, but I offer it for other readers as well. Works well on Debian/Ubuntu-based systems.

Link to this post 30 Aug 10

Hi masokis ,

I wish I could do it completely and give to you as a tutorial. However, at present, I am able to boot my distro, mount everything, however it is mounting as read only.

And that too because, after booting up, I get a busybox shell. from there I mount the cd-rom drive and then chroot to the environment. As cd-rom's contain the iso9660 file system, it is always read only. I just need to get a workaround wherein, I can make the /var, /tmp folder as read write, keeping everything else intact.


Link to this post 30 Aug 10

Hi Manko10,

Yes, I am using ISOLINUX as the boot loader to create the iso image.


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board