Live System
Live cdrom
What is a live cdrom
A live cd is a cdrom with a complete linux system. We boot on the cdrom and after few minutes we can use it as a normal linux system
Why using a live cdrom
For many reasons, the first one is a computer without an hard drive, or a defective hard drive. We can do some analysis and recover some data.
Netboot a livecd
The gentoo cdrom
We can download this cdrom at the gentoo site. I choose the install-amd64-minimal.iso file.
i explode this file and extract 3 files:
- gentoo -> rename to kernel.gentoo
- gentoo.igz -> rename to initrd.gentoo
- image.squashfs
We only need those files.
netboot the gentoo cdrom
we need to share by nfs the image.squashfs files and the add directory(not present on cdrom)
cdrom tree
.
|-- add
| |-- basic.tar.gz
| `-- softs.tar.gz
|-- image.squashfs
`-- linux
|-- initrd.gentoo
`-- kernel.gentoo
The netboot.conf config file we send bt gPXE looks like
netboot.conf
LABEL Gentoo Live
MENU LABEL Gentoo Live
KERNEL http://bootserver.my.zone.tld/livecd/linux/kernel.gentoo
APPEND initrd=http://bootserver.my.zone.tld/livecd/linux/initrd.gentoo root=/dev/ram0 init=/linuxrc real_root=/dev/nfs looptype=squashfs loop=image.squashfs nfsroot=bootserver.my.zone.tld:/share/livecd udev nodevfs nodhcp cdroot nosound nox docache doscsi ip=dhcp noapic acpi
When the system is booting, we load the squashfs file (taht the real live image) and after we download and untar all the tar ball in the "add" directory.
We have a minimal linux system, but we can add some nice tools by putting tar ball in the add directory.
if we want to add some tools like ntfsprogs, we must do this.
mkdir /data/temporary && cd /data/temporary
quickpkg sys-fs/ntfsprogs
mkdir ntfsprogs && cd ntfsprogs
tar xvfj /usr/portage/packages/sys-fs/ntfsprogs-2.0.0-r1.tbz2
tar cvfz ../ntfsprogs.tar.gz .
mv ../ntfsprogs.tar.gz /share/livecd/add
In fact in the add directory we only untar tar.gz file, that the reason why we convert the tar.bz2 to tar.gz file.
More with our setup
We can imagine to populate with many tar.gz file in the add drirectory to have a licecd with many tools, or we can boot with a bigger gentoo cdrom.
Other linux live cdrom can be used, but with the gentoo it s very simple.
Create a new Live net system
Using Debian as base system
I use live build for this, and some nice docs at this site.
If you system is a debian based system (like ubuntu) or a native debian distro, you must install this package
aptitude install live-build
if not, or if you want the last daily version use source from git.
git clone git://live.debian.net/git/live-build.git
Build the deb files
cd live-build
git pull
dpkg-buildpackage -b
Create a new squeeze minimal system
I want a minimal system, we create a minimal system with tools
lb config --distribution squeeze --memtest none --package-lists minimal
But for some reason we want more than basics packages, so we can add in command line or we can create a new profile setup, it will be better to add it in new profile.
/usr/share/live/build/lists/my_profile
## for use minimal profile as template
#include <minimal>
## add my wishes here
gnupg aptitude curl
openssh-client openssh-server
We can add some new repository inside the chroot and the live system with this directives
echo "deb http://<host>/repository stable main" > config/chroot_sources/live.binary
echo "deb http://<host>/repository stable main" > config/chroot_sources/live.chroot
We must add the gpg files too as config/chroot_sources/live.{chroot,binary}.gpg
Next we create the bootstrap and chroot system with this command.
lb bootstrap
lb chroot
Next we can doo all what we wants in the chroot, like add ssh keys, change root password
mkdir chroot/root/.ssh
cp /root/.ssh/authorized_keys chroot/root/.ssh
echo root:<Password> | chroot chroot chpasswd
ssh-keygen -q -t rsa -C '' -N '' -f chroot/etc/ssh/ssh_host_rsa_key
ssh-keygen -q -t dsa -C '' -N '' -f chroot/etc/ssh/ssh_host_dsa_key
And now juste create the binaries
lb binary
We can now boot the live systelm with this parameters in gpxe config
<snip>
KERNEL http://bootserver.my.zone.tld/linux/vmlinux.debian
APPEND http://bootserver.my.zone.tld/linux/initrd.debian boot=live textonly toram live-getty fetch=http://bootserver.my.zone.tld/linux/filesystem.squashfs
</snip>
Thats it.