Maragda: Running Linux from CD
There are three things to do:
Prepare a software installation containing all the packages you want on Maragda; we'll call it source installation.
Distribute the source installation between two big files, ROOT.FS and WHOLE.FS; they both should fit inside an ext2 file system.
Develop a boot mechanism in charge of detecting the CD-ROM drive and locating ROOT.FS on it. Then, it should load ROOT.FS as a RAM disk, preparing it to be the root file system, and finally it should leave the boot process to continue on the root file system.
All the necessary pieces that do the work (mainly shell scripts) are arranged into two working directories:
boot: in charge of developing the boot mechanism
system: contains the tools to create ROOT.FS and WHOLE.FS from the source installation
I should mention that, perhaps, some device files (files under /dev) might not be correct due to the copy from an ext2 file system to a CD file system (iso9660). In this case, you should replace those files by the corresponding /dev files from your system.
Now, let's outline the relevant steps in the building process and describe the purpose of each shell script as well as the main configuration files. Minor details are left out of the explanation; if you decide to build your own Maragda-like system, you should consult doc/developer.html on the CD and carefully read each shell script on the working directories.
Figure 1 shows the main steps to be taken in the boot process.
The target here is to create a bootable floppy disk that will be merged into the CD to make it bootable.
The boot loader for setting up the floppy is syslinux. It can boot a Linux system from a DOS-formatted floppy containing a kernel and an initial RAM disk file (compressed) with the root file system inside.
So, we'll need a kernel along with its loadable modules. (Only the kernel is required now.) I will not explain here how to compile a kernel but will only remark that it should support
CD-ROM (iso9660 file system)
initial RAM disk
(You can find my kernel configuration on doc/developer.html.)
Now we have to build the initial RAM disk (initrd) holding the root file system for the first-stage boot. The easiest way to obtain one is to borrow it from a floppy rescue disk. But, I follow the “do it yourself” philosophy. The directory boot/initrd is a skeleton of the contents of my RAM disk. The script named Init_initrd fills that directory from scratch, copying files from the source installation. It creates directories, copies a subset of dev-files onto initrd/dev and populates initrd/bin. The size of an initrd must be kept small, so you should leave only the essential binaries on initrd/bin. Then you must run Cp_lib; it will copy the libraries on initrd/lib for the binaries you left before.
When you are finished, run Make_initrd_fs_gz. It will create a file (Minix formated), copying to it the files on boot/initrd and then compress it.
Now you have a kernel and an initial RAM disk. Next, you should generate the bootable floppy with syslinux. The syslinux configuration file, SYSLINUX.CFG, is contained in boot/syslinux_boot_floppy-20MB. The line:
append initrd=initrd.gz ramdisk_size=20480 vga=0x315
instructs the boot loader to load the initial RAM disk file on the floppy and passes two parameters to the kernel to inform it of the size of the RAM disk and the framebuffer video mode. The RAM disk size should be customized to the size of the ROOT.FS used.
Finally, the bootable floppy is created by the Write_syslinux_boot_floppy script. It will also extract a raw image of the floppy to be merged onto the CD.
The most relevant file here is boot/initrd/linuxrc (/linuxrc on the initial RAM disk) because this script is executed at boot up. It performs the main tasks intended for this stage:
It searches for the device holding the files:
/MARAGDA /system/ROOT.FS /system/WHOLE.FS
If that is found, it then states which device will be the new root file system:
mount -n /proc /proc -t proc echo 0x101 > /proc/sys/kernel/real-root-dev (0x101 represents /dev/ram1)
It dumps WHOLE.FS on /dev/ram1.
Finally, it writes on cdrom_dev which device the .FS files were found. This file will be consulted during the second-stage boot.
If everything goes okay, the boot process will continue by executing init, already in the new root file system. The old file system (initrd) will remain mounted under /initrd on the new one.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Devuan Beta Release
- May 2016 Issue of Linux Journal
- EnterpriseDB's EDB Postgres Advanced Server and EDB Postgres Enterprise Manager
- The US Government and Open-Source Software
- The Humble Hacker?
- BitTorrent Inc.'s Sync
- Tech Tip: Really Simple HTTP Server with Python
- Open-Source Project Secretly Funded by CIA
- The Death of RoboVM
- New Container Image Standard Promises More Portable Apps
In modern computer systems, privacy and security are mandatory. However, connections from the outside over public networks automatically imply risks. One easily available solution to avoid eavesdroppers’ attempts is SSH. But, its wide adoption during the past 21 years has made it a target for attackers, so hardening your system properly is a must.
Additionally, in highly regulated markets, you must comply with specific operational requirements, proving that you conform to standards and even that you have included new mandatory authentication methods, such as two-factor authentication. In this ebook, I discuss SSH and how to configure and manage it to guarantee that your network is safe, your data is secure and that you comply with relevant regulations.Get the Guide