Difference between revisions of "Creating a Live CD"

From LFScript
(Created page with "This page guides you through the steps required to create a Live CD of your system. The ability to create a Live CD is one of the core reasons of being of LFScript. == Compil...")
 
Line 1: Line 1:
This page guides you through the steps required to create a Live CD of your system. The ability to create a Live CD is one of the core reasons of being of LFScript.
+
This page guides you through the steps required to create a Live CD of your
 +
system. The ability to create a Live CD is one of the core reasons of being of
 +
LFScript.
  
 
== Compile your system ==
 
== Compile your system ==
Although it is not required, it is highly recommended that you compile your system into packages beforehand. For example:
+
Although it is not required, it is highly recommended that you compile your
 +
system into packages beforehand. For example:
 +
 
 
<pre>./lfscript -Bux fsos</pre>
 
<pre>./lfscript -Bux fsos</pre>
This command builds all packages (except those that are only for the 32-bit version) of fsOS.
+
 
 +
This command builds all packages (except those that are only for the 32-bit
 +
version) of fsOS.
  
 
== Create a system image ==
 
== Create a system image ==
 
<pre>dd if=/dev/zero of=sources/rootfs-$(uname -m).img bs=1G count=10 seek=100</pre>
 
<pre>dd if=/dev/zero of=sources/rootfs-$(uname -m).img bs=1G count=10 seek=100</pre>
This command should instantly create a 10GB sparse file. The file will not actually take up 10GB of your precious free disk space. It's actual size will initially be zero. Once it has a file system, has been mounted and starts to contain actual files it will automatically grow and use real disk space as needed (up to 10GB). This means that the actual size of the file will never be greater than the minimum size needed to contain your system.
 
  
The file will be created in the <code>sources</code> directory, because the <code>buildiso</code> script will need to be able to find the image.
+
This command should instantly create a 10GB sparse file. The file will not
 +
actually take up 10GB of your precious free disk space. It's actual size will
 +
initially be zero. Once it has a file system, has been mounted and starts to
 +
contain actual files it will automatically grow and use real disk space as
 +
needed (up to 10GB). This means that the actual size of the file will never be
 +
greater than the minimum size needed to contain your system.
 +
 
 +
The file will be created in the <code>sources</code> directory, because the
 +
<code>buildiso</code> script will need to be able to find the image.
  
The <code>$(uname -m)</code> part will automatically resolve to your host system CPU architecture (<code>i686</code>, <code>x86_64</code>, or something else), giving the image a name like <code>rootfs-i686.img</code>. Using <code>$(uname -m)</code> in these commands makes them suitable for copy-pasting on any machine.
+
The <code>$(uname -m)</code> part will automatically resolve to your host
 +
system CPU architecture (<code>i686</code>, <code>x86_64</code>, or something
 +
else), giving the image a name like <code>rootfs-i686.img</code>. Using
 +
<code>$(uname -m)</code> in these commands makes them suitable for copy-pasting
 +
on any machine.
  
 
== Create a file system on the image ==
 
== Create a file system on the image ==
 
This command should work on any machine with a recent kernel:
 
This command should work on any machine with a recent kernel:
 +
 
<pre>mkfs.ext4 -F sources/rootfs-$(uname -m).img</pre>
 
<pre>mkfs.ext4 -F sources/rootfs-$(uname -m).img</pre>
  
However, if you want to optimize for size at this stage (this does NOT affect the size of the final ISO image) and have <code>btrfs</code> available you could issue this one in stead:
+
However, if you want to optimize for size at this stage (this does NOT affect
 +
the size of the final ISO image) and have <code>btrfs</code> available you
 +
could issue this one in stead:
 +
 
 
<pre>mkfs.btrfs sources/rootfs-$(uname -m).img</pre>
 
<pre>mkfs.btrfs sources/rootfs-$(uname -m).img</pre>
  
A compressed <code>btrfs</code> system image will take up about 500MB of space if you just install a basic LFS system on it, compared to 1.3GB for an uncompressed <code>ext4</code> image.
+
A compressed <code>btrfs</code> system image will take up about 500MB of space
 +
if you just install a basic LFS system on it, compared to 1.3GB for an
 +
uncompressed <code>ext4</code> image.
  
Any file system for Linux should work just fine, and it does not even matter if the OS you will install in it has support for the file system you have selected. Later on, the image will be converted to <code>SquashFS</code> anyway.
+
Any file system for Linux should work just fine, and it does not even matter if
 +
the OS you will install in it has support for the file system you have
 +
selected. Later on, the image will be converted to <code>SquashFS</code>
 +
anyway.
  
 
== Create temporary installation directories ==
 
== Create temporary installation directories ==
 
<pre>mkdir -v rootfs</pre>
 
<pre>mkdir -v rootfs</pre>
  
And if you would like to keep the overhead of <code>sources</code> and <code>tools</code> directories out of the image (only affects the system image size, not the ISO size):
+
And if you would like to keep the overhead of <code>sources</code> and
 +
<code>tools</code> directories out of the image (only affects the system image
 +
size, not the ISO size):
 +
 
 
<pre>mkdir -v rootfs_overhead</pre>
 
<pre>mkdir -v rootfs_overhead</pre>
  
 
== Mount the system image ==
 
== Mount the system image ==
 
If you installed an <code>ext4</code> fle system on the system image:
 
If you installed an <code>ext4</code> fle system on the system image:
 +
 
<pre>mount -o loop sources/rootfs-$(uname -m).img rootfs</pre>
 
<pre>mount -o loop sources/rootfs-$(uname -m).img rootfs</pre>
  
 
Or if you used <code>btrfs</code>:
 
Or if you used <code>btrfs</code>:
 +
 
<pre>mount -o loop,compress sources/rootfs-$(uname -m).img rootfs</pre>
 
<pre>mount -o loop,compress sources/rootfs-$(uname -m).img rootfs</pre>
  
Line 41: Line 72:
 
<pre>./lfscript { base system and extra package options } -i rootfs -I rootfs_overhead</pre>
 
<pre>./lfscript { base system and extra package options } -i rootfs -I rootfs_overhead</pre>
  
If you did not create the overhead directory, leave out <code>-I rootfs_overhead</code>.
+
If you did not create the overhead directory, leave out
 +
<code>-I rootfs_overhead</code>.
  
 
For example:
 
For example:
 +
 
<pre>./lfscript -Bux fsos -i rootfs -I rootfs_overhead</pre>
 
<pre>./lfscript -Bux fsos -i rootfs -I rootfs_overhead</pre>
  
Line 52: Line 85:
 
<pre>./lfscript -Bux buildiso</pre>
 
<pre>./lfscript -Bux buildiso</pre>
  
The script that builds the ISO image could just as well be designed for use outside of LFScript (and in fact, with LFScript 3 it was). However, by executing <code>buildiso</code> through LFScript the ISO is created by your own system, which removes the need to have the utilities required to run <code>buildiso</code> (like <code>SquashFS</code> and <code>cdrtools</code> for example) installed on your host system. This reduces the risk of build failures considerably.
+
The script that builds the ISO image could just as well be designed for use
 +
outside of LFScript (and in fact, with LFScript 3 it was). However, by
 +
executing <code>buildiso</code> through LFScript the ISO is created by your own
 +
system, which removes the need to have the utilities required to run
 +
<code>buildiso</code> (like <code>SquashFS</code> and <code>cdrtools</code> for
 +
example) installed on your host system. This reduces the risk of build failures
 +
considerably.
 +
 
 +
Once completed, your Live CD ISO image will be saved to your
 +
<code>packages</code> directory.
 +
 
 +
== Cleanup ==
 +
This command removes both the temporary installation directories, and the
 +
original system image which you probably don't need anymore:
  
Once completed, your Live CD ISO image will be saved to your <code>packages</code> directory.
+
<pre>rm -rv rootfs rootfs_overhead sources/rootfs-$(uname -m).img</pre>

Revision as of 14:27, 30 January 2012

This page guides you through the steps required to create a Live CD of your system. The ability to create a Live CD is one of the core reasons of being of LFScript.

Compile your system

Although it is not required, it is highly recommended that you compile your system into packages beforehand. For example:

./lfscript -Bux fsos

This command builds all packages (except those that are only for the 32-bit version) of fsOS.

Create a system image

dd if=/dev/zero of=sources/rootfs-$(uname -m).img bs=1G count=10 seek=100

This command should instantly create a 10GB sparse file. The file will not actually take up 10GB of your precious free disk space. It's actual size will initially be zero. Once it has a file system, has been mounted and starts to contain actual files it will automatically grow and use real disk space as needed (up to 10GB). This means that the actual size of the file will never be greater than the minimum size needed to contain your system.

The file will be created in the sources directory, because the buildiso script will need to be able to find the image.

The $(uname -m) part will automatically resolve to your host system CPU architecture (i686, x86_64, or something else), giving the image a name like rootfs-i686.img. Using $(uname -m) in these commands makes them suitable for copy-pasting on any machine.

Create a file system on the image

This command should work on any machine with a recent kernel:

mkfs.ext4 -F sources/rootfs-$(uname -m).img

However, if you want to optimize for size at this stage (this does NOT affect the size of the final ISO image) and have btrfs available you could issue this one in stead:

mkfs.btrfs sources/rootfs-$(uname -m).img

A compressed btrfs system image will take up about 500MB of space if you just install a basic LFS system on it, compared to 1.3GB for an uncompressed ext4 image.

Any file system for Linux should work just fine, and it does not even matter if the OS you will install in it has support for the file system you have selected. Later on, the image will be converted to SquashFS anyway.

Create temporary installation directories

mkdir -v rootfs

And if you would like to keep the overhead of sources and tools directories out of the image (only affects the system image size, not the ISO size):

mkdir -v rootfs_overhead

Mount the system image

If you installed an ext4 fle system on the system image:

mount -o loop sources/rootfs-$(uname -m).img rootfs

Or if you used btrfs:

mount -o loop,compress sources/rootfs-$(uname -m).img rootfs

Install your system to the image

./lfscript { base system and extra package options } -i rootfs -I rootfs_overhead

If you did not create the overhead directory, leave out -I rootfs_overhead.

For example:

./lfscript -Bux fsos -i rootfs -I rootfs_overhead

Unmount the system image

umount rootfs

Build the ISO image

./lfscript -Bux buildiso

The script that builds the ISO image could just as well be designed for use outside of LFScript (and in fact, with LFScript 3 it was). However, by executing buildiso through LFScript the ISO is created by your own system, which removes the need to have the utilities required to run buildiso (like SquashFS and cdrtools for example) installed on your host system. This reduces the risk of build failures considerably.

Once completed, your Live CD ISO image will be saved to your packages directory.

Cleanup

This command removes both the temporary installation directories, and the original system image which you probably don't need anymore:

rm -rv rootfs rootfs_overhead sources/rootfs-$(uname -m).img