BSDStore
management and repository for FreeBSD jails

Generation of bootable ISO and USB Memstick from jail


Attention! I apologize, but it is automatic machine translation of the text. You can improve it if will send to me more correct version of the text or fix html pages via GITHUB repository.

Command:

% cbsd jail2iso
Description:

The jail2iso script allows to create a bootable image for CD/DVD/Memstick from the specified jail. This script can be applied to creation of custom LiveCD.

Script job:

  • Creation of file hierarchy of next image consisting of mounted base and data of a jail
  • Creation of MFS/UZIP of an image which will remain in memory. It is used generally for work acceleration in the LiveCD mode, allowing for "cache" often caused utilities and libraries, for example from / to / usr.
  • Mount over MFS of hierarchy of data from file system of the media through nullfs/RO
  • Mount through tmpfs over RO file system for modification in LiveCD mode.

    Listing of directory which are necessary for rewriting on RW/tmpfs it is necessary before call jail2iso, stored into file $systemdir/jail/tmpfsdir
    For example, for mc jail it is: /usr/jails/jails-system/mc/tmpfsdir file with, for example, follow content:

/etc
/root
/var/cache
/var/tmp
/var/run
/var/log
/var/db
/tmp
/usr/home
/root
/usr/local/etc

This record will be kept in /etc/rc.d/tmpfsdir in image, which mount these directory through tmpfs also will write down in them contents of original content from bootable media.
As RW areas are mounted through TMPFS, the quantity of memory available to record will depend on quantity of RAM of servers on which LiveCD is started.

Example (fetching from repository Midnight Commander jail and turn it to /tmp/mc.iso):

% cbsd repo action=get sources=img name=mc
% cat > /usr/jails/jails-system/mc/tmpfsdir << EOF
/etc
/root
/var/cache
/var/tmp
/var/run
/var/log
/var/db
/tmp
/usr/home
/root
/usr/local/etc
EOF

% cbsd jail2iso media=iso jname=mc destdir=/tmp
% file -s /tmp/mc.iso
If /tmp/mc.iso is present, it can be burned on CD/DVD. For USB Memstick:

% cbsd jail2iso media=memstick jname=mc destdir=/tmp
% file -s /tmp/mc.img
If /tmp/mc.img is present, it can be written on USB Storage via:

dd if=/tmp/mc.img of=/dev/da0 bs="10240" conv="sync"
command, if /dev/da0 - it correct USB Flash device.