1. LsLinux documentation
  2. Installation
  3. Naska package manager
  4. Create packages

Create filesystem images containing LsLinux

We're going to learn how to create different types of filesystem images. For each type, I'll give a short definition, describe the step by step procedure to create/build the image using common Unix commands, and what usage can be maid of it.

RamFS

A RamFS image is a compressed cpio archive containing a Linux tree loaded in RAM at boot. Kernel will try to launch any executable file named /init it contains.

RamFS are generally used to load needed storage driver modules, to be able to boot on a full Linux system on a local harddrive. But if your system is small enough, it may be fully loaded in RAM and be run directly from it. The problem is that RAM is not a persistant storage solution, and any changes made on system will be lost on halt/reboot.

Creating RamFS

The easiest way to obtain a working RamFS is to use debootstrap to create the tree, and then use cpio and bzip2 utilities to create the archive. In this example, we'll create a basic RamFS file in /boot/ramfs.bz2, using a debootstrap in /boot/ramfs :

root@lslinux ~ # ./debootstrap.sh -hostname=myramfs /boot/ramfs >> Debootstraping LSL to /boot/ramfs ? /boot/ramfs, directory does not exist, create it? ([y]|n) >> Fetching core packages >> Extracting core packages Installing Busybox v1.20.2 links... ..... ... >> All done! Your LSL environnement is now available in /boot/ramfs (build time : 8s) root@lslinux ~ #

Now we have a LsL tree in /boot/ramfs, now let's create the /boot/ramfs.bz2 archive :

root@lslinux ~ # cd /boot/ramfs root@lslinux /boot/ramfs # find | cpio -o -H newc | bzip2 -9 > /boot/ramfs.bz2 7767 blocks root@lslinux /boot/ramfs # du -sh /boot/ramfs* 4.2M /boot/ramfs 1.5M /boot/ramfs.bz2 root@lslinux /boot/ramfs #

Cpio takes a list of files as input and produces archive on standard output. We use find to build the files list, which is passed to cpio to create (-o option) a 'newc' format archive. Cpio outputs archive to bzip2 utility which compress it using best compression (-9 option), result is redirected to /boot/ramfs.bz2 file.

Editing RamFS

To edit a RamFS content, you have to uncompress and unpack archive, edit needed files in produced tree, and rebuild the RamFS file. Let's say that you have a 'ramfs.bz2' file and that you want to update hostname it contains. First, create a directory to store the tree and unpack files to it :

root@lslinux ~ # ls ramfs.bz2 root@lslinux ~ # mkdir ramfs root@lslinux ~ # ls ramfs ramfs.bz2 root@lslinux ~ # cd ramfs root@lslinux ~/ramfs # bzcat ../ramfs.bz2 | cpio -i 7767 blocks root@lslinux ~/ramfs # ls bin boot data dev etc home init lib lib64 proc root sbin sys tmp usr var root@lslinux ~/ramfs #

You may now edit the needed files/make your modifications. To rebuild the ramfs file :

root@lslinux /boot/ramfs # find | cpio -o -H newc | bzip2 -9 > /boot/ramfs.bz2 7767 blocks root@lslinux /boot/ramfs #

Ext/OtherFS partition images

Definition

Creation

Usage

Full disk images

Definition

Creation

Usage

ISO CDRom images

Definition

Creation

Usage