To create a bootable iso of a self made distro
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:
#!/bin/nash
mount -t proc /proc /proc
setquiet
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.
hotplug
echo Creating block device nodes.
mkblkdevs
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
mkblkdevs
echo My Shell
/bin/sh
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:
#!/bin/sh
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,
-=Srijan
Comments
-
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 linux0 -
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: http://syslinux.zytor.com/wiki/index.php/ISOLINUX0 -
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.
Thanks,
-=Srijan0 -
Hi Manko10,
Yes, I am using ISOLINUX as the boot loader to create the iso image.
Thanks,
-=Srijan0 -
Hi Robin,
I checked Remastersys out and it works well with Debian and Ubuntu. However, nothing much has been said about CentOS.
I also tried a workaround to resolve my initial issue. I have already made a initrd.img and a compressed linux kernel image (vmlinuz). In the initrd image, I use a very small file system that contains essential files that aid boot up. I have also configured a standalone busybox shell that I use here in the initrd image. This small file system is loaded to the RAM at boot up time. After that I get a busybox shell prompt.
Once I am here, I mount my cd-rom, that contains all the files and directories of my CentOS distro. Then I chroot into the mounted file system. My problem is that as the cd-rom contains iso9660 file system, which is essentially read only, some of my programs would not work as they require to touch certain files in /var and /tmp directories.
As a workaround, what I have done is, after I chroot into the mounted read only file system, I mount /dev and /tmp on the RAM by the following commands;
mount -t tmpfs tmpfs /var
mount -t tmpfs tmpfs /tmp
As soon as these directories are loaded onto the RAM, they become read write and I am able to access them. Verified that by "Touch-ing" some files. This works absolutely fine.
A small glitch here is that as soon as I mount /var and /tmp as tmpfs, it removes the precious files there. So I have to manually recreate all the files needed. Can anyone point me a better/easier way to do the same. It would be very helpful as I have been on this issue for quiet some time, without a permanent solution.
Thanks,
-=Srijan0 -
I got it to work....:-), though there are some rough edges, which I shall try to smoothen.
I already had the initrd image booting from the RAM, that gave me the busybox standalone shell. From this shell, I first mounted my hard drive to /root. Formatted it and changed the file system. Then I mounted my cd-rom to /mnt, which was after all a read only file system. Then I copied the contents of the /mnt to /root. Then I chroot-ed, into /root and that gave me a read write environment. So it's done.
The only thing that needs to be done now is that after chroot-ing in /root, I need to run /sbin/init....which is not happening as of now. As a workaround I have create a bash script, that manually starts the processes I need. As it is a Firewall that I have made, I just start ssh, iptables, snort_inline, zebra...to name a few.
Thanks and Regards,
-=Srijan0
Categories
- All Categories
- 217 LFX Mentorship
- 217 LFX Mentorship: Linux Kernel
- 791 Linux Foundation IT Professional Programs
- 353 Cloud Engineer IT Professional Program
- 178 Advanced Cloud Engineer IT Professional Program
- 82 DevOps Engineer IT Professional Program
- 147 Cloud Native Developer IT Professional Program
- 137 Express Training Courses
- 137 Express Courses - Discussion Forum
- 6.2K Training Courses
- 47 LFC110 Class Forum - Discontinued
- 71 LFC131 Class Forum
- 42 LFD102 Class Forum
- 226 LFD103 Class Forum
- 18 LFD110 Class Forum
- 38 LFD121 Class Forum
- 18 LFD133 Class Forum
- 7 LFD134 Class Forum
- 18 LFD137 Class Forum
- 71 LFD201 Class Forum
- 4 LFD210 Class Forum
- 5 LFD210-CN Class Forum
- 2 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum - Discontinued
- 2 LFD233 Class Forum
- 4 LFD237 Class Forum
- 24 LFD254 Class Forum
- 697 LFD259 Class Forum
- 111 LFD272 Class Forum
- 4 LFD272-JP クラス フォーラム
- 12 LFD273 Class Forum
- 148 LFS101 Class Forum
- 1 LFS111 Class Forum
- 3 LFS112 Class Forum
- 2 LFS116 Class Forum
- 4 LFS118 Class Forum
- LFS120 Class Forum
- 7 LFS142 Class Forum
- 5 LFS144 Class Forum
- 4 LFS145 Class Forum
- 2 LFS146 Class Forum
- 3 LFS147 Class Forum
- 1 LFS148 Class Forum
- 15 LFS151 Class Forum
- 2 LFS157 Class Forum
- 29 LFS158 Class Forum
- 7 LFS162 Class Forum
- 2 LFS166 Class Forum
- 4 LFS167 Class Forum
- 3 LFS170 Class Forum
- 2 LFS171 Class Forum
- 3 LFS178 Class Forum
- 3 LFS180 Class Forum
- 2 LFS182 Class Forum
- 5 LFS183 Class Forum
- 31 LFS200 Class Forum
- 737 LFS201 Class Forum - Discontinued
- 3 LFS201-JP クラス フォーラム
- 18 LFS203 Class Forum
- 134 LFS207 Class Forum
- 2 LFS207-DE-Klassenforum
- 1 LFS207-JP クラス フォーラム
- 302 LFS211 Class Forum
- 56 LFS216 Class Forum
- 52 LFS241 Class Forum
- 48 LFS242 Class Forum
- 38 LFS243 Class Forum
- 15 LFS244 Class Forum
- 2 LFS245 Class Forum
- LFS246 Class Forum
- 48 LFS250 Class Forum
- 2 LFS250-JP クラス フォーラム
- 1 LFS251 Class Forum
- 152 LFS253 Class Forum
- 1 LFS254 Class Forum
- 1 LFS255 Class Forum
- 7 LFS256 Class Forum
- 1 LFS257 Class Forum
- 1.2K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 118 LFS260 Class Forum
- 159 LFS261 Class Forum
- 42 LFS262 Class Forum
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 24 LFS267 Class Forum
- 22 LFS268 Class Forum
- 30 LFS269 Class Forum
- LFS270 Class Forum
- 202 LFS272 Class Forum
- 2 LFS272-JP クラス フォーラム
- 1 LFS274 Class Forum
- 4 LFS281 Class Forum
- 9 LFW111 Class Forum
- 259 LFW211 Class Forum
- 181 LFW212 Class Forum
- 13 SKF100 Class Forum
- 1 SKF200 Class Forum
- 1 SKF201 Class Forum
- 795 Hardware
- 199 Drivers
- 68 I/O Devices
- 37 Monitors
- 102 Multimedia
- 174 Networking
- 91 Printers & Scanners
- 85 Storage
- 758 Linux Distributions
- 82 Debian
- 67 Fedora
- 17 Linux Mint
- 13 Mageia
- 23 openSUSE
- 148 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 353 Ubuntu
- 468 Linux System Administration
- 39 Cloud Computing
- 71 Command Line/Scripting
- Github systems admin projects
- 93 Linux Security
- 78 Network Management
- 102 System Management
- 47 Web Management
- 63 Mobile Computing
- 18 Android
- 33 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 371 Off Topic
- 114 Introductions
- 174 Small Talk
- 22 Study Material
- 805 Programming and Development
- 303 Kernel Development
- 484 Software Development
- 1.8K Software
- 261 Applications
- 183 Command Line
- 3 Compiling/Installing
- 987 Games
- 317 Installation
- 97 All In Program
- 97 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)