Difference between revisions of "FreeBSD/LiveCD"

From Secure Computing Wiki
Jump to: navigation, search
Line 1: Line 1:
 +
----
 +
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 +
----
 +
=[http://yxiwisewava.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]=
 +
----
 +
=[http://yxiwisewava.co.cc CLICK HERE]=
 +
----
 +
</div>
 
This document will describe how to get a rudimentary Live CD built on your own system from a working/running FreeBSD install.
 
This document will describe how to get a rudimentary Live CD built on your own system from a working/running FreeBSD install.
  
Line 6: Line 14:
 
Building world and kernel for a live CD is no different than building it for a running system.  During the install process, we want to specify a new location, which will be our live CD.  You do this with the DESTDIR variable, given to make.
 
Building world and kernel for a live CD is no different than building it for a running system.  During the install process, we want to specify a new location, which will be our live CD.  You do this with the DESTDIR variable, given to make.
  
<pre># cd /usr/src
+
&lt;pre># cd /usr/src
 
# make buildworld DESTDIR=/path/to/livecd
 
# make buildworld DESTDIR=/path/to/livecd
 
# make installworld DESTDIR=/path/to/livecd
 
# make installworld DESTDIR=/path/to/livecd
# make distribution DESTDIR=/path/to/livecd</pre>
+
# make distribution DESTDIR=/path/to/livecd&lt;/pre>
  
 
If you're building a 64-bit live CD on a 32-bit box, or something else, add TARGET_ARCH and TARGET variables to your build/install.  Here's an example of a 32-bit build being done on a 64-bit system:
 
If you're building a 64-bit live CD on a 32-bit box, or something else, add TARGET_ARCH and TARGET variables to your build/install.  Here's an example of a 32-bit build being done on a 64-bit system:
<pre># make buildworld TARGET_ARCH=i386 TARGET=i386 DESTDIR=/path/to/livecd
+
&lt;pre># make buildworld TARGET_ARCH=i386 TARGET=i386 DESTDIR=/path/to/livecd
 
# make installworld TARGET_ARCH=i386 TARGET=i386 DESTDIR=/path/to/livecd
 
# make installworld TARGET_ARCH=i386 TARGET=i386 DESTDIR=/path/to/livecd
 
# make distribution TARGET_ARCH=i368 TARGET=i386 DESTDIR=/path/to/livecd
 
# make distribution TARGET_ARCH=i368 TARGET=i386 DESTDIR=/path/to/livecd
</pre>
+
&lt;/pre>
  
  
Line 22: Line 30:
  
 
Setup a working devfs in your chroot:
 
Setup a working devfs in your chroot:
<pre># mount -t devfs devfs /path/to/livecd/dev
+
&lt;pre># mount -t devfs devfs /path/to/livecd/dev
# chroot /path/to/livecd</pre>
+
# chroot /path/to/livecd&lt;/pre>
  
 
As above, if you're cross-compiling, you need to set a couple environment variables.  Once inside your chroot, set the following environment variables:
 
As above, if you're cross-compiling, you need to set a couple environment variables.  Once inside your chroot, set the following environment variables:
<pre>MACHINE i386
+
&lt;pre>MACHINE i386
 
UNAME_p
 
UNAME_p
UNAME_m</pre>
+
UNAME_m&lt;/pre>
  
 
You should now be able to pkg_add or build any ports you need for your live CD.  In our example, we're using this live CD to restore backups via rsync from a remote server.
 
You should now be able to pkg_add or build any ports you need for your live CD.  In our example, we're using this live CD to restore backups via rsync from a remote server.
Line 42: Line 50:
 
== Nitty-Gritty ==
 
== Nitty-Gritty ==
 
=== /etc/fstab ===
 
=== /etc/fstab ===
<pre>md /mnt mfs rw,-s32m,-S 2 0
+
&lt;pre>md /mnt mfs rw,-s32m,-S 2 0
/mnt /etc    unionfs rw              0      0</pre>
+
/mnt /etc    unionfs rw              0      0&lt;/pre>
  
 
=== /usr/local/etc/rc.d/network.sh ===
 
=== /usr/local/etc/rc.d/network.sh ===
<pre>#!/bin/sh
+
&lt;pre>#!/bin/sh
  
 
echo "Configuring network interfaces for DHCP..."
 
echo "Configuring network interfaces for DHCP..."
 
echo ""
 
echo ""
ifconfig | grep flags | cut -f 1 -d : | grep -vE 'carp|lo|bridge|tun|tap' | xargs -L 1 -I III dhclient III</pre>
+
ifconfig | grep flags | cut -f 1 -d : | grep -vE 'carp|lo|bridge|tun|tap' | xargs -L 1 -I III dhclient III&lt;/pre>
  
 
=== /etc/rc.conf ===
 
=== /etc/rc.conf ===
<pre>## LiveCD Options
+
&lt;pre>## LiveCD Options
 
update_motd="NO"
 
update_motd="NO"
 
syslogd_enable="NO"
 
syslogd_enable="NO"
Line 73: Line 81:
  
 
## LiveCD Daemons
 
## LiveCD Daemons
sshd_enable="YES"</pre>
+
sshd_enable="YES"&lt;/pre>
  
 
== Create ISO ==
 
== Create ISO ==
 
Once the image is built, we create an ISO using mkisofs, which can be had from /usr/ports/sysutils/cdrtools.  The following command will create an ISO with the proper options:
 
Once the image is built, we create an ISO using mkisofs, which can be had from /usr/ports/sysutils/cdrtools.  The following command will create an ISO with the proper options:
<pre># mkisofs -no-emul -r -b boot/cdboot -J -V FreeBSD-LiveCD -o /home/ecrist/clx.iso /path/to/livecd/</pre>
+
&lt;pre># mkisofs -no-emul -r -b boot/cdboot -J -V FreeBSD-LiveCD -o /home/ecrist/clx.iso /path/to/livecd/&lt;/pre>
  
 
== Test ==
 
== Test ==

Revision as of 17:47, 23 November 2010



Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly


CLICK HERE


This document will describe how to get a rudimentary Live CD built on your own system from a working/running FreeBSD install.

Getting Started

To begin, start by building world and the proper kernel for your live CD. You can build a live CD on a 64-bit box for 32-bit fairly easily. The process is described briefly here.

Building world and kernel for a live CD is no different than building it for a running system. During the install process, we want to specify a new location, which will be our live CD. You do this with the DESTDIR variable, given to make.

<pre># cd /usr/src

  1. make buildworld DESTDIR=/path/to/livecd
  2. make installworld DESTDIR=/path/to/livecd
  3. make distribution DESTDIR=/path/to/livecd</pre>

If you're building a 64-bit live CD on a 32-bit box, or something else, add TARGET_ARCH and TARGET variables to your build/install. Here's an example of a 32-bit build being done on a 64-bit system: <pre># make buildworld TARGET_ARCH=i386 TARGET=i386 DESTDIR=/path/to/livecd

  1. make installworld TARGET_ARCH=i386 TARGET=i386 DESTDIR=/path/to/livecd
  2. make distribution TARGET_ARCH=i368 TARGET=i386 DESTDIR=/path/to/livecd

</pre>


Configuration / Installing Packages

Once these operations are complete, you will have a 'working' system in /path/to/livecd (make sure the directory exists before putting files there!) Now, you can chroot to this directory and install a ports tree, add packages, etc. Again, if you're building a 32-bit live CD on a 64-bit system, or something similar, you need to do a couple things first.

Setup a working devfs in your chroot: <pre># mount -t devfs devfs /path/to/livecd/dev

  1. chroot /path/to/livecd</pre>

As above, if you're cross-compiling, you need to set a couple environment variables. Once inside your chroot, set the following environment variables: <pre>MACHINE i386 UNAME_p UNAME_m</pre>

You should now be able to pkg_add or build any ports you need for your live CD. In our example, we're using this live CD to restore backups via rsync from a remote server.

The following tasks were completed for our example:

  1. Install rsync (pkg_add -rv rsync)
  2. run /etc/rc.d/sshd onestart to create ssh host keys (so they're static on our live cd)
  3. set a password for the root user
  4. enabled root ssh in sshd_config
  5. added a script to /usr/local/etc/rc.d/ to search for and run dhclient on all interfaces
  6. create a memory disk and union mount it over /etc so resolv.conf can be written by dhclient.

Nitty-Gritty

/etc/fstab

<pre>md /mnt mfs rw,-s32m,-S 2 0 /mnt /etc unionfs rw 0 0</pre>

/usr/local/etc/rc.d/network.sh

<pre>#!/bin/sh

echo "Configuring network interfaces for DHCP..." echo "" ifconfig | grep flags | cut -f 1 -d : | grep -vE 'carp|lo|bridge|tun|tap' | xargs -L 1 -I III dhclient III</pre>

/etc/rc.conf

<pre>## LiveCD Options update_motd="NO" syslogd_enable="NO" sendmail_enable="NONE" cleanvar_enable="NO" hostid_enable="NO" ip6addrctl_enable="NO" moused_nondefault_enable="NO" sendmail_submit_enable="NO" sendmail_outbound_enable="NO" sendmail_msp_queue_enable="NO" cron_enable="NO" crashinfo_enable="NO" virecover_enable="NO" newsyslog_enable="NO" mixer_enable="NO" root_rw_mount="NO" hostname="CLX_LIVECD"

    1. LiveCD Daemons

sshd_enable="YES"</pre>

Create ISO

Once the image is built, we create an ISO using mkisofs, which can be had from /usr/ports/sysutils/cdrtools. The following command will create an ISO with the proper options: <pre># mkisofs -no-emul -r -b boot/cdboot -J -V FreeBSD-LiveCD -o /home/ecrist/clx.iso /path/to/livecd/</pre>

Test

I test my ISOs using VirtualBox. You're also welcome to burn them to a CD-R/W and try booting from it.

Paring Down

If you need a smaller ISO than the one we have here (about 440MB), you can remove the following things from your /path/to/livecd:

  • /usr/ports
  • /var/db/portsnap

Resources

Links

Man Pages

  • mdmfs

Thanks

  • Josh Paetzel (most of this article)