# [mini-HowTo] Gentoo Linux LiveCD for Dummies!

## veezi

LiveCD: A Gentoo Linux running off a CD 

Dummies: People like me that want to do it manually not through catalyst  :Smile: 

Introduction

A LiveCD is very handy. It allows you to boot a computer into linux from the CD-ROM drive. This gives flexibilty and power to do whatever you want with your machine. Fix it, repartition or resize the drives, install Gentoo, etc.

Catalyst (http://www.gentoo.org/proj/en/releng/catalyst/index.xml) is a great tool that allows you to make Gentoo LiveCDs the same way the release engineering team creates them for us. However, the tool is designed with automation in mind, and with that you loose some flexibility.

This mini-HowTo will show you how simple it is to create your own LiveCD by hand. It will also allow you to have the following advantages over the catalyst way:

1. The build source will be kept intact and will not get deleted between iterations of LiveCD creation. This will allow you to sync, update, merge, and customize your environment incrementally the same way you do it with a real system.

2. The CD will boot using GRUB, not ISOLINUX. This gives you the same flexibility you have with a real system, that it, changing kernel parameters, discovering devices, etc.

3. As a nice side effect of keeping your build source between iterations, the build time will be reduced dramatically.

Requirements

You need to have enough space on your system. Depending on what packages you need to include in your LiveCD, this will vary. I'd say in average a 4GB free space is fair enough.

You must be familiar with installing Gentoo using a stage2 tarball because that's what we're going to use in this mini-HowTo. If you're in doubt, consult the Gentoo Handbook (http://www.gentoo.org/doc/en/handbook/).

Setting up the build environment

Our build environment is just a directory that we will 'chroot' to and install Gentoo in. Its contents will make the LiveCD later on. I will use the name 'source' for it, and will create it under a directory in my home called 'livecd'.

```

cd ~

mkdir -p livecd/source

```

Download a stage2 tarball from one of the Gentoo mirrors to your home directory. I'm using an i686 stage2 in this mini-HowTo since I thought it's generic enough to run on most of todays PCs. Once downloaded untar it to 'source'. Then create necessary 'newroot' directory which will be used during initial boot

```

cd livecd/source

tar jxvpf ~/stage2-i686-2004.2.tar.bz2 

mkdir newroot

```

Now, download the latest portage snapshot to your home directory and untar it to your new build directory

```

cd livecd/source/usr/

tar jxvf ~/portage-whatever.tar.bz2

```

If you need to download packages during the installation, then setup whatever files in 'livecd/source/etc' required to reach the internet. For example 'resolv.conf'.

Your source directory is now ready to start installating Gentoo.

Installing Gentoo

Setup necessary mount points before you 'chroot' to your build directory and start installation. On my system I keep 'distfiles' under the default '/usr/portage' directory. I'm going to use it instead of downloading distfiles again during the installation.

```

cd livecd/source

mount -o bind /proc proc

mount -o bind /usr/portage/distfiles usr/portage/distfiles

```

Now 'chroot' to source and start the installation. A few points about modifying '/etc/make.conf'

1. Be concious with USE variables. The more you use, the bigger your envirnoment will get. It might even be so big that it won't fit on a CD! I use kde only, and don't care about docs and java, so I added the follwoing: '-gnome -gtk -java -doc'

2. Make sure you add 'livecd' to your USE variables. This, along with a 'cdroot' parameter that we'll pass to the kernel at boot time, will make init scripts aware of the fact that we're booting off a cdrom, so it doesn't do inappropriate things like checking the root filesystem!

Here're the installation steps roughly

```

cd livecd/source

chroot . /bin/bash --login

env-update

source /etc/profile

emerge system

ln -sf /usr/share/zoneinfo/<path to time zone file> /etc/localtime

emerge <required packages, as you like, e.g. logger hotplug udev>

rc-update add <the services required, e.g. hotplug, net.eth0, sysklogd> default <or boot, as fits>

emerge <optional packages, as you like, e.g. kde, mplayer>

```

Before we merge the kernel and boot loader, let's modify important files in '/etc'. First, fstab

```

/dev/loop0              /               squashfs        ro,defaults             0 0

none                    /proc           proc            defaults                0 0

none                    /dev/shm        tmpfs           defaults                0 0

none                    /dev/pts        devpts          defaults                0 0

```

Notice that we're mouting root over a loop device with filesystem type 'squashfs', more on that later. Now, modify other '/etc' files as you see fits (e.g. hostname, rc.conf, conf.d/*, and so on)

Now merge your desired kernel. I'm using development-sources (2.6) which I patched with the things I need (vesafb-tng, reiser4, mppe-mppc, etc.). We're going to use squashfs (http://squashfs.sourceforge.net) as our root filesystem. So, be sure to patch your kernel with it if it's not already included. Also, this guide assumes that we're booting of an IDE cdrom.

When configuring your kernel, make sure the following is compiled in

1. squashfs filesystem

2. iso9660 cdrom filesystem

3. initrd support, set size to 8MB

4. loopback block device support

5. IDE/ATAPI cdrom device support

6. ext2 filesystem support (which we use for our initrd image)

7. tmpfs filesystem support

```

emerge development-sources #add patches after this

cd /usr/src/linux

make menuconfig #configure your kernel

make bzImage modules modules_install

cp arch/i386/boot/bzImage /boot/vmlinuz

```

The final step is merging and configuring the boot loader. We're going to use the latest GRUB since it has support for booting a cdrom.

```

ACCEPT_KEYWORDS="~x86" emerge grub

```

And here's '/boot/grub/grub.conf'

```

default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Gentoo Linux

        root (cd)

        kernel (cd)/boot/vmlinuz video=vesafb:1024x768-32 root=/dev/ram0 rw init=/linuxrc cdroot

        initrd (cd)/boot/initrd

```

You can discard the 'video' kernel parameter if you want, but the rest are necessary. Our next step is to create the 'initrd' image.

Creating the initrd image

This is where most of the action occures during booting. It's a very simple task once you get the hang of it. First create the image, I'm using an 8MB initrd but feel free ot expand that if you need more, just remember to set the option in your kernel configuration for the maximum ramdisk size properly.

```

touch /boot/initrd

dd if=/dev/zero of=/boot/initrd bs=1024k count=8

losetup /dev/loop0 /boot/initrd

mke2fs /dev/loop0

mkdir /mnt/initrd

mount /dev/loop0 /mnt/initrd

```

Now populate the image with required directories and files:

```

cd /mnt/initrd

mkdir etc dev lib bin proc new cdrom

touch linuxrc

chmod +x linuxrc

touch etc/mtab

touch etc/fstab

```

linuxrc is what will get executed when linux boots. More on it below.

Now you need to copy necessary files into bin and lib. For bin, copy the following:

```

/bin/sh

/bin/cat

/bin/mount

/bin/umount

/bin/mkdir

/bin/chroot

/bin/tar

/sbin/pivot_root

```

For lib, you'll need to find out which lib files are needed by each of the binaries above. The way to do it is to run 'ldd' for each file above and copy the required libs over. Example

```

ldd /bin/mount

        linux-gate.so.1 =>  (0xffffe000)

        libc.so.6 => /lib/libc.so.6 (0x4002e000)

        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

cp /lib/libc.so.6 /mnt/initrd/lib/

cp /lib/ld-linux.so.2 /mnt/initrd/lib/

```

And so on for the rest of the binaries. 

Now, we need to create necessary devices under dev directory:

```

mknod /mnt/initrd/dev/console c 5 1

mknod /mnt/initrd/dev/null c 1 3 

mknod /mnt/initrd/dev/hda b 3 0

mknod /mnt/initrd/dev/hdb b 3 64

mknod /mnt/initrd/dev/hdc b 22 0

mknod /mnt/initrd/dev/hdd b 22 64

mknod /mnt/initrd/dev/tty c 4 0

mknod /mnt/initrd/dev/loop0 b 7 0

```

Finally, we need to create our linuxrc script. The script will do the follwoing:

1. Save whatever is passed to the kernel to pass it later on to /sbin/init

2. Locate the CDROM device (we search only in hda, hdb, hdc, and hdd, which are the most common IDE cdrom drives)

3. Mount the cdrom on /cdrom

4. Mount the squashed filesystem image (which is our whole gentoo installation shrinked to a single file) on /new. This will become our root filesystem, which is read-only

5. Create necessary read-write mount points (etc, var, tmp, and root) as tmpfs filesystems and fill them up

6. Finally, pivot the root filesystem on newroot and start the real init process

```

#!/bin/sh

export PATH=/bin

# Get kernel CMDLINE

mount -t proc none /proc

CMDLINE=`cat /proc/cmdline`

umount /proc

# Mount CD device

CDROM=""

for x in hda hdb hdc hdd

do

  mount -t iso9660 -r /dev/${x} /cdrom > /dev/null 2>&1

  if [ "$?" = "0" ]

  then

    CDROM="${x}"

    break

  fi

done

# CD not found

if [ "${CDROM}" == "" ]

then

  exec /bin/sh

  exit

fi

# Mount root and create read-write directories

mount -t squashfs -o loop /cdrom/files/source.img /new > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/var > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/etc > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/tmp > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/root > /dev/null 2>&1

cd /new/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /new/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /new/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

# Pivot root and start real init

cd /new

pivot_root . newroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}

EOF

```

Notice that I'm using 4 x 32MB tmpfs filesystems. That's a lot of RAM! Reduce it if your wish. It's just that all the systems I work with have plenty of RAM (servers) so I don't worry about it. 

That's it! Our source directory is ready. But before we move on we need to do some modifications. First, since '/var' holds portage directories 'cache' and 'db', and these are big, we'll move them to '/usr/lib/portage' to save space on '/var'

```

cd /var

mv cache db /usr/lib/portage/

ln -s /usr/lib/portage/cache cache

ln -s /usr/lib/portage/db db

```

Second, if you're using 'udev' for device management like I do, and relying on gentoo to save devices state before rebooting, you'll need to do this

```

cd /lib

mv udev-state /var/lib

ln -s /var/lib/udev-state udev-state

```

This is because /lib is not writable on our cdrom!

We're done with our source directory. Exit 'chroot' and unmount proc and distfiles. Now, off to creating the CD!

Building the LiveCD

Building the LiveCD invloves the follwoing steps

1. Clean up unnecissary directories in source (like /tmp and /var/tmp)

2. Create the target directory that will be used to make the iso image

3. Save the read-write directories (like /etc and /var) using tar to target

4. Using squashfs tools, convert the source directory to a squashed image

5. And finally, make the iso image

To help automate these steps, create a simple 'build' script inside 'livecd'

```

cd livecd

touch build

chmod +x build

```

And here's the script

```

 #!/bin/bash

rm -rf target

mkdir target

cp -a source/boot target/

mkdir target/files

rm -rf source/var/tmp/*

rm -rf source/var/run/*

rm -rf source/var/lock/*

rm -rf source/tmp/*

rm -f source/etc/mtab

touch source/etc/mtab

cd source/etc/

tar cvpf ../../target/files/etc.tar * .[[:alnum:]]*

cd ../var/

tar cvpf ../../target/files/var.tar * .[[:alnum:]]*

cd ../root/

tar cvpf ../../target/files/root.tar * .[[:alnum:]]*

cd ../../

mksquashfs source/ target/files/source.img

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size \

4 -boot-info-table -iso-level 4 -hide boot.catalog -o ~/livecd.iso target/

```

Always check that the size of each tar file produced is within the size of tmpfs ram drive that you create (32MB in this howto).

Squashing a large 'source' directory takes some time, so be patient. Once done, just burn your ISO image, boot it, and enjoy  :Smile: 

Tips

I use a simple script to chroot to my build source each time I need to sync portage, merge new packages, customize kde. I called it 'work'

```

cd livecd

touch work

chmod +x work

```

Here it is

```

#!/bin/bash

mount -o bind /proc source/proc

mount -o bind /sys source/sys

mount -o bind /dev source/dev

mount -o bind /dev/pts source/dev/pts

mount -o bind /usr/portage/distfiles source/usr/portage/distfiles

chroot source/ /bin/bash --login

umount source/proc

umount source/sys

umount source/dev/pts

umount source/dev

umount source/usr/portage/distfiles

```

Mounting /dev is important to get things like X to work from a chroot environment.

Another thing to consider is the size of your build source. As you can see, there're things that take a lot of space that are strictly not needed on a LiveCD. Two major candidates are '/usr/src' and '/usr/portage'. If you don't want to include them on your LiveCD don't delete them, you can utilize an option in 'mksquashfs' to exclude any directory from the squashed image. This will keep your build source directory intact.

If booting the CD fails at some point during linuxrc script execution, you can always change your grub line to 'init=/bin/sh' instead of linuxrc. This will give you a nice little shell inside the initrd image at boot time. From there you can type the commands in the linuxrc script manually and try to find out with one is failing and why.

I hope I didn't miss anything, and hope you find this mini-HowTo usefull. Your corrections/feedback are always welcome  :Smile: Last edited by veezi on Wed Dec 01, 2004 10:20 pm; edited 7 times in total

----------

## fennec

great work, I was a little lost looking at all posts around and the doc is really obscure for beginners

thanks a lot for your hard work!!!!

----------

## fennec

 *Quote:*   

> Setup necessary mount points before you 'chroot' to your build directory and start installation. I keep my 'distfiles' and 'packages' in atop level directory I call 'data' in my system, and modify '/etc/make.conf' to point there. So, I'm going to use it instead of downloading distfiles again.
> 
> ```
> cd livecd/source
> 
> ...

 

would you mean that if we keep this standard, you would mount your local /usr/portage/distfiles to /mnt/livecd/usr/portage/distfiles ?

[/code]

----------

## veezi

 *fennec wrote:*   

>  *Quote:*   Setup necessary mount points before you 'chroot' to your build directory and start installation. I keep my 'distfiles' and 'packages' in atop level directory I call 'data' in my system, and modify '/etc/make.conf' to point there. So, I'm going to use it instead of downloading distfiles again.
> 
> ```
> cd livecd/source
> 
> ...

 

Yes! Also, by same token, /usr/portage/packages. This will

1. Allow you to use distfiles from both locations (your system, and your livecd build environment).

2. Allow you to compile once, on your system, and use binary pkg for livecd environment if you choose to.

----------

## chunderbunny

You have no idea how long I spent trying to achieve this, but I could never get it to boot properly (my kernel always failed to find init.) This will really help, thanks!

Edit: Why is the HOWTO listed twice?

----------

## cron0

Thank you SO much for taking the time to write this!

I've wanted to create a personnal LiveCD for very long and I I couldn't find out how to do it!

Thank you!!

PS: Yeah, why is it listed twice? They seem to be different. The 2nd one seem to be more refined.

----------

## veezi

 *JF_Cron0 wrote:*   

> 
> 
> PS: Yeah, why is it listed twice? They seem to be different. The 2nd one seem to be more refined.

 

Oops! Editing mistake .. fixed it.   :Smile: 

----------

## fennec

another question is which packages includes mkisofs mksquashfs ?

----------

## veezi

 *fennec wrote:*   

> another question is which packages includes mkisofs mksquashfs ?

 

mksquashfs -> sys-fs/squashfs-tools

mkisofs -> Not sure! maybe cdrtools or cdrecord

----------

## fennec

 *fennec wrote:*   

> another question is which packages includes mkisofs mksquashfs ?

 

I found them...

squashfs-tools

cdrtools

----------

## frenkel

Great howto!! But there's one typo...

 *Quote:*   

> 
> 
> Now, we need to create necessary devices under dev directory:
> 
> ```
> ...

 

The last hdc should be hdd.

Thanks for the great howto!

Frank

----------

## veezi

Thanks for the tip .. fixed it.

----------

## chunderbunny

Well, I finally got it all working, thanks a lot! 

I think you should make it clear that the data directory is actually required on the cd, even if you don't normally keep distfiles and packages in that directory. 

Also you could change the last line of the build script so that people like me don't accidentally copy it directly and get errors since the "boot.catalog -o ~/livecd.iso target/ " part is on a new line.   :Razz: 

----------

## veezi

 *chunderbunny wrote:*   

> Well, I finally got it all working, thanks a lot! 
> 
> I think you should make it clear that the data directory is actually required on the cd, even if you don't normally keep distfiles and packages in that directory. 
> 
> Also you could change the last line of the build script so that people like me don't accidentally copy it directly and get errors since the "boot.catalog -o ~/livecd.iso target/ " part is on a new line.  

 

Thanks for the feedback. I removed all references to data since it's confusing! I replaced with standard location of distfiles (/usr/portage).

Also, fixed the last line of script  :Smile: 

----------

## Illissius

Thanks for the howto; I've been looking for something like this. Three questions:

(1) Is it required to do this in your home directory? I only have ~1GB of space free on / which includes /home, but I also have /misc (FAT32, for files I want to access from windows) which has 7GB free. I tried doing it there, but untarring the stage thingy gave a bunch of errors about not being able to create (sym)links.

(2) What, if any, is the difference between a Knoppix kernel, a kernel generated with genkernel, and one you create by just editing the .config by hand? So, basically, I want whatever has the highest compatibility, except I want to patch it with the staircase scheduler - which option would that be?

(3) Is there any way to tell how big the stuff in the source directory will be after it's squashed? ie, you have 700MB of (compressed) space on the CD; how much actual space in the source directory does that translate to?

----------

## monkey89

 *Illissius wrote:*   

> (1) Is it required to do this in your home directory? I only have ~1GB of space free on / which includes /home, but I also have /misc (FAT32, for files I want to access from windows) which has 7GB free. I tried doing it there, but untarring the stage thingy gave a bunch of errors about not being able to create (sym)links.

 

No, but FAT32 won't work because it can't store permissions or handle symlinks.  You need a linux (ext2/3, reiserfs, jfs, xfs) partition.

 *Illissius wrote:*   

> (2) What, if any, is the difference between a Knoppix kernel, a kernel generated with genkernel, and one you create by just editing the .config by hand? So, basically, I want whatever has the highest compatibility, except I want to patch it with the staircase scheduler - which option would that be?

 

Genkernel just generates a config and compiles a generic kernel - you can use any sources you want with it.  If you choose, use development-sources and manually patch it, then use genkernel to configure it - I think the staircase scheduler doesn't require a new config option.  The knoppix kernel is premade though, so unless you figure out what patches the knoppix kernel has, you have to stick with whatever they patched it with and however they configured it (which is probably pretty well) even if they have no staircase support.

----------

## chunderbunny

The point about Genkernel and the Knoppix is that they use automatic hardware detection scripts to load the correct kernel modules. In order to use the kernel on any system you will need to get hold of (or write) a hardware detection script and have it load all the appropriate kernel modules, the kernel on it's own will only be optimised for one system.

----------

## fxlamare

Hi !

Followed this howto but did not test it yet.

What if we want to boot from USB sticks ?

My hardware is able to boot from USB (I don't have any floppy drive, nor CD-ROM on it)

I guess we must setup some USB-related stuffs inside the kernel :

usb-[u,o,e]hci

usb-storage

SCSI sub system

Disk support

... and we must modify grub.conf and fstab files  accordingly.

Won't have time to do this right now, but if someone can elaborate on this in the mean time (hey guys it's O:18AM here in France, but thanks to the time shift it's your turn to work  :Wink: 

I also guess some tips about this may be present in the forums...

Thank you all anyway !

... and happy halloween !

----------

## veezi

 *Illissius wrote:*   

> 
> 
> (1) Is it required to do this in your home directory? I only have ~1GB of space free on / which includes /home, but I also have /misc (FAT32, for files I want to access from windows) which has 7GB free. I tried doing it there, but untarring the stage thingy gave a bunch of errors about not being able to create (sym)links.
> 
> 

 

One workaround would be to use a loop device on an image stored on that FAT32 space. Here's how:

```

touch /misc/my.img

dd if=/dev/zero of=/misc/my.img bs=1M count=4000 

mke2fs /misc/my.img

mount -o loop /misc/my.img ~/livecd

```

This will give you 'livecd' under your home, with ext2 fileysystem, and with 4GB of free space.

 *Illissius wrote:*   

> 
> 
> (2) What, if any, is the difference between a Knoppix kernel, a kernel generated with genkernel, and one you create by just editing the .config by hand? So, basically, I want whatever has the highest compatibility, except I want to patch it with the staircase scheduler - which option would that be?
> 
> 

 

All are just kernels. Compatibility is achieved by creating a modular kernel (one that has most things compiled as modules) with support for every possible piece of hardware. You don't need genkernel or knoppix to do that, just 'make menuconfig'.

For hardware detection, you could try something like 'kudzu'. I never used it. All I have on my LiveCD is 'udev' and 'hotplug' enabled, and it works fine for me.

 *Illissius wrote:*   

> 
> 
> (3) Is there any way to tell how big the stuff in the source directory will be after it's squashed? ie, you have 700MB of (compressed) space on the CD; how much actual space in the source directory does that translate to?

 

None to my knowledge (Anyone, correct me if I'm mistaken). Because it highly depends on the nature of files you are going to squash (size for example). So, there's no hard coded formula to calculate the resultant squashed file size. After you take a couple of rounds at squashing your 'source', you might get a rough figure on that.

----------

## veezi

 *fxlamare wrote:*   

> 
> 
> (hey guys it's O:18AM here in France, but thanks to the time shift it's your turn to work 
> 
> 

 

What's "O:18AM"? Is it a military time code?   :Laughing: 

----------

## veezi

Just figured why 'konsole' won't work when testing kde from the chroot environment.

Fix: Updated 'work' script by adding 

```

mount -o bind /dev/pts source/dev/pts

```

Not sure if anyone is experiencing same problem or it's just me  :Smile: 

----------

## nsahoo

thanks veezi, you are indeed "tux' lil helper"  :Very Happy: 

edit: is there a way to make sure that the image is alright before burning it onto the cd ?  :Razz: 

----------

## nsahoo

 *Quote:*   

> 
> 
> 3. initrd support, set size to 8MB 
> 
> 

 

you meant size of the ram disk, .. right ?

I was a little confused 'cause, there were two options

one for ramdisk support

one for Initial ramdisk support, called initrd.

----------

## nsahoo

I can remove /usr/src/* after kernel installation, can't i ? I mean before doing squashfs? 'cause it's 342 M   :Confused: 

----------

## chunderbunny

Sure, but if you want to keep it there but leave it off the liveCD you can exclude it during the Squashfs procedure. Simply change the "build" script from 

```
mksquashfs source/ target/files/source.img 
```

 to 

```
 mksquashfs source/ target/files/source.img -e usr/src 
```

Personally I like to exclude a few directories

```
mksquashfs source/ target/files/source.img -e usr/src usr/portage usr/lib/gcc-lib
```

----------

## nsahoo

thanks .. i just noticed OP saying the same thing in the head post.    :Embarassed: 

MY first image was 2.1 G  :Razz: 

also it complains about boot/grub/stage2_eltorito .. should it be boot/grub/grub.conf ?

edit: just figured out that the stage2_eltorito appears in grub 0.95 and that is masked in portage. so, the usual drill, 

```

echo sys-boot/grub ~x86 >>/etc/portage/package.keywords

emerge -va grub

```

----------

## nsahoo

still 761MB, do I need to include the proc file system ? it weighs at 1017MB

I don't have much package actually. The "system" a logger, hotplug, cron, vim and java5. no X, no kde, no gnome or anything .. still 761MB   :Evil or Very Mad: 

----------

## chunderbunny

Thta's insanely large. You don't need the proc file system (the kernel should generate it on boot) but it shouldn't be that large. You should make sure you exclude /usr/portage from the squashfs since you can't emerge stuff once you have booted the livecd anyway.

----------

## nsahoo

 *chunderbunny wrote:*   

> Thta's insanely large. You don't need the proc file system (the kernel should generate it on boot) but it shouldn't be that large. You should make sure you exclude /usr/portage from the squashfs since you can't emerge stuff once you have booted the livecd anyway.

 

ya .. i have usr/src and usr/portage excluded. I mounted the img file and verified. 

There is a file called kcore in /proc of the host which is 1016M and that goes into the squashed file. that is why it's so large.

 *Quote:*   

> 
> 
> You don't need the proc file system (the kernel should generate it on boot)
> 
> 

 

so .. i unmount the proc and do the stuff again .. right ?

----------

## nsahoo

In fact all my troubles are because, I didn't closely follow the excellent how to. They would be taken careof if one follows OP line by line.   :Embarassed: 

edit: is there a way to auto login the root or another user while booting ? with a scrambled passwd may be ?

edit2: hmm .. so it's up  :Very Happy:  with network, sshd, java5 and all that stuff. Now I just need a little writable space to work in .. is mounting some tmpfs at a directory the best way to go about it ?

edit3: I used the livecd in my machine and it started alright. Also, I tested the cd with a friends machine having somewhat similar specification as mine, and it booted alright. 

Now I am trying to use it in another machine. and getting some error while booting. The text scrolled by too fast and then I have only this much text visible.

```

Simple Boot Flag at 0x7a set to 0x1

Machine check exception polling timer started.

gx-suspmod: error: no MediaGX/Geode processor found!

apm: BIOS version 1.2 Flags 0x03 (Driver version 1.16ac)

apm: overridden by ACPI

devfs: 2004-01-31 Richard Gooch (...)

devfs: boot_option: 0x0

Installing knfsd (copyright ...)

SGI XFS with large block numbers, no debug enabled.

Initializing Cryptographic API 

inotify init: minor=63

Real Time Clock Driver v1.12

```

Then it seems to have a deadlock.

I used stage2 for pentium 4 system to make the build.  Also, I used gentoo-dev-sources-2.6.9-r1 and genkernel to configure it, so that I'll have all the modules and hence it'll be compatible with many system.

I tried compiling the kernel with processor type pentium4 and with i486 with high mem support on and off. Got the same result.

Gentoo official livecd is starting alright.

The machine on which it's NOT starting is a dell optiplex gx270 with a p4 3.2 ghz processor with 1gb ram and on board sound and video.

edit4: I tried booting by removing the video parameter, i.e. when grub starts .. i edited the second line to remove video parameter. But, that also lead to the lockup, but, I get a little more text

```

Non-volatile memory driver v1.2

hw_random: RNG not detected.

vesafb: Intel Corporation, Intel(r)865G graphics controller, Hardware Version 0.

0 (OEM: Intel(r) 865G Graphics chip Accelerated VGA BIOS

vesafb: VBE version: 3.0

vesafb: hardware supports DCC2 transfers

vesafb: monitor limits: vf = 75 Hz, hf = 80 kHz, clk = 140 MHz

vesafb: scrolling: redraw

```

Then the lockup. 

Any help ? 

Thanks.

edit:5: 

I switched to gentoo-dev-sources-2.6.8-r<latest> from gentoo-dev-sources-2.6.9-r1 and removed the video parameter from the kernel line in grub.conf. Then it started alright, although I have fewer rows and columns in the terminal.Last edited by nsahoo on Fri Nov 05, 2004 12:18 am; edited 2 times in total

----------

## bin-doph

Hi,

the whole thing looks pretty good, but if I boot from the cd I get this error message

 *Quote:*   

> warning: can't open /etc/fstab: No such file or directory
> 
> Unable to identify CD-ROM format.

 

Then I get timeouts on the IDE-drives but the image boot's after a couple of minutes and works. Did I miss something?

----------

## veezi

 *bin-doph wrote:*   

> Hi,
> 
> the whole thing looks pretty good, but if I boot from the cd I get this error message
> 
>  *Quote:*   warning: can't open /etc/fstab: No such file or directory
> ...

 

You probably forgot to include some of the required settings in kernel configuration of your livecd. Check all required kernel config as mentioned in the doc.

If all will, try to boot into '/bin/sh' (by changing the grub line on livecd boot from 'init=/linuxrc' to 'init=/bin/sh') and manually execute each line in linuxrc to figure out what's going wrong.

----------

## Illissius

Thanks for the help, I did the thing with the ext2 image on /misc mounted to ~/livecd, and that part seems to be working well; however, emerge system does this:

```
>>> md5 src_uri ;-) gawk-3.1.3.tar.gz

>>> Unpacking source...

>>> Unpacking gawk-3.1.3.tar.gz to /var/tmp/portage/gawk-3.1.3-r1/work

 * Applying 64bitnumfile.patch ...                                          [ ok ]

 * Using GNU config files from /usr/share/gnuconfig

 *  Updating config.sub                                                     [ ok ]

 *  Updating config.guess                                                   [ ok ]

>>> Source unpacked.

nls

configure: WARNING: If you wanted to set the --build type, don't use --host.

    If a cross compiler is detected then cross compile mode will be used.

configure: loading cache /dev/null

./configure: line 1: ./configure:: No such file or directory

checking for a BSD-compatible install... ./install-sh -c

checking whether build environment is sane... yes

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking for i586-pc-linux-gnu-strip... no

checking for strip... strip

checking for egrep... grep -E

checking for bison... bison -y

checking whether ln -s works... yes

checking for i586-pc-linux-gnu-gcc... gcc

checking for C compiler default output... a.out

checking whether the C compiler works... yes

checking whether we are cross compiling... no

checking for suffix of executables...

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ANSI C... none needed

checking for style of include used by make... GNU

checking dependency style of gcc... gcc3

checking how to run the C preprocessor... /lib/cpp

configure: error: C preprocessor "/lib/cpp" fails sanity check

See `config.log' for more details.

!!! ERROR: sys-apps/gawk-3.1.3-r1 failed.

!!! Function src_compile, Line 45, Exitcode 1

!!! (no error message)

```

Why?

----------

## veezi

Try 'env-update; source /etc/profile' before 'emerge system'.

Is this the first package, or did other packages compile successfully before it.

Doesn't sound like a problem with your particular setup (root on loop file on FAT32). Sounds more like a regular installation problem.

I usually get better success by running 'emerge -u system'. I think.

----------

## Illissius

I did do env-update and source /etc/profile. It's the first package that fails -- with emerge -u system, ncurses is the first package, but that fails also:

```
lenti / # env-update; source /etc/profile; emerge -u system

 * Caching service dependencies...

Calculating system dependencies ...done!

>>> emerge (1 of 84) sys-libs/ncurses-5.4-r5 to /

>>> md5 src_uri ;-) ncurses-5.4.tar.gz

>>> Unpacking source...

>>> Unpacking ncurses-5.4.tar.gz to /var/tmp/portage/ncurses-5.4-r5/work

 * Applying ncurses-5.4-xterm.patch ...                                     [ ok ]

 * Applying ncurses-5.4-share-sed.patch ...                                 [ ok ]

 * Using GNU config files from /usr/share/gnuconfig

 *  Updating config.sub                                                     [ ok ]

 *  Updating config.guess                                                   [ ok ]

>>> Source unpacked.

unicode

configure: WARNING: If you wanted to set the --build type, don't use --host.

    If a cross compiler is detected then cross compile mode will be used.

configure: loading cache /dev/null

./configure: line 1: ./configure:: No such file or directory

Configuring NCURSES 5.4 ABI 5 (Wed Nov  3 15:05:33 Local time zone must be set--see zic manual page 2004)

checking build system type... i686-pc-linux-gnu

checking host system type... i586-pc-linux-gnu

checking target system type... i586-pc-linux-gnu

Configuring for linux-gnu

checking for prefix... /usr

checking for i586-pc-linux-gnu-gcc... gcc

checking for C compiler default output... a.out

checking whether the C compiler works... yes

checking whether we are cross compiling... no

checking for executable suffix...

checking for object suffix... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking version of gcc... 3.3.3

checking how to run the C preprocessor... gcc -E

checking whether gcc needs -traditional... no

checking for POSIXized ISC... no

checking for gcc option to accept ANSI C... -DCC_HAS_PROTOS

checking for ldconfig... /sbin/ldconfig

checking if you want to ensure bool is consistent with C++... yes

checking for i586-pc-linux-gnu-g++... g++

checking whether we are using the GNU C++ compiler... yes

checking whether g++ accepts -g... yes

checking for g++... /usr/bin/g++

checking version of g++... g++ (GCC) 3.3.3 20040412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)

checking if you want to build C++ binding and demo... yes

checking if you want to build with Ada95... no

checking if you want to build programs such as tic... yes

checking if you wish to install curses.h... yes

checking for mawk... no

checking for gawk... gawk

checking whether make sets ${MAKE}... yes

checking for a BSD compatible install... /bin/install -c

checking for long file names... yes

checking if filesystem supports mixed-case filenames... yes

checking whether ln -s works... yes

checking for ctags... no

checking for etags... no

checking for tdlint... no

checking for lint... no

checking for alint... no

checking for man... no

checking for man_db... no

checking for i586-pc-linux-gnu-ranlib... no

checking for ranlib... ranlib

checking for i586-pc-linux-gnu-ld... no

checking for ld... ld

checking for i586-pc-linux-gnu-ar... no

checking for ar... ar

checking for archiver options (symbol AR_OPTS)... rv

checking for makeflags variable...

checking if you have specified an install-prefix...

checking if you want to build libraries with libtool... no

checking if you want to build shared libraries... yes

checking if you want to build static libraries... yes

checking if you want to build debug libraries... no

checking if you want to build profiling libraries... no

checking for specified models...  shared normal

checking for default model... shared

checking if you want to build a separate terminfo library... no

checking if you want to link with dbmalloc for testing... no

checking if you want to link with dmalloc for testing... no

checking if you want to link with the gpm mouse library... no

checking for default loader flags...

checking if rpath option should be used... no

checking if release/abi version should be used for shared libs... auto

checking which gcc option to use... -fPIC

checking if you wish to install ncurses overwriting curses... yes

checking if external terminfo-database is used... yes

checking which terminfo source-file will be installed... ${top_srcdir}/misc/terminfo.src

checking for list of fallback descriptions...

checking for list of terminfo directories... /etc/terminfo:/usr/share/terminfo

checking for default terminfo directory... /usr/share/terminfo

checking if big-core option selected... yes

checking if you want termcap-fallback support... no

checking if ~/.terminfo is wanted... checking for remove... yes

checking for unlink... yes

checking if link/symlink functions work...  link symlink

checking if tic should use symbolic links... yes

checking if you want broken-linker support code... no

checking for type of bool... auto

checking for type of ospeed... short

checking if tputs should process BSD-style prefix padding... no

checking if RCS identifiers should be compiled-in... yes

checking format of man-pages... normal

checking for manpage renaming... no

checking if manpage aliases will be installed... yes

checking if manpage symlinks should be used... yes

checking for manpage tbl... no

checking if you want to build with function extensions... yes

checking for extended use of const keyword... no

checking if you want $NCURSES_NO_PADDING code... yes

checking if you want SIGWINCH handler... yes

checking if you want user-definable terminal capabilities like termcap... yes

checking if you want all development code... no

checking if you want hard-tabs code... no

checking if you want to use restrict environment when running as root... yes

checking if you want limited support for xmc... no

checking if you do not want to assume colors are white-on-black... yes

checking if you want hashmap scrolling-optimization code... yes

checking if you want colorfgbg code... no

checking if you want experimental safe-sprintf code... no

checking if we must define _GNU_SOURCE... yes

checking if you want experimental wide-character code... yes

checking if we must define _XOPEN_SOURCE... no

checking checking for compatible value versus 500... yes

checking if we must define _XOPEN_SOURCE_EXTENDED... no

checking for putwc... yes

checking for btowc... yes

checking for wctob... yes

checking for mbtowc... yes

checking for wctomb... yes

checking for mblen... yes

checking for mbrlen... yes

checking for mbrtowc... yes

checking if we must include wchar.h to declare mbstate_t... yes

checking if we must include wchar.h to declare wchar_t... no

checking if we must include wchar.h to declare wint_t... no

checking for terminal capabilities file... Caps

checking if you want to display full commands during build... yes

checking if you want to see compiler warnings...

configure: checking for gcc __attribute__ directives...

... scanf

... printf

... unused

... noreturn

checking if you want to enable runtime assertions... no

checking whether to add trace feature to all models...

checking for gettimeofday... yes

checking if -lm needed for math functions... yes

checking for ANSI C header files... yes

checking for dirent.h that defines DIR... no

checking for sys/ndir.h that defines DIR... no

checking for sys/dir.h that defines DIR... no

checking for ndir.h that defines DIR... no

checking for opendir in -lx... no

checking whether time.h and sys/time.h may both be included... yes

checking for regular-expression headers... regex.h

checking for fcntl.h... yes

checking for getopt.h... yes

checking for libc.h... no

checking for limits.h... no

checking for locale.h... yes

checking for poll.h... yes

checking for sys/bsdtypes.h... no

checking for sys/ioctl.h... no

checking for sys/param.h... no

checking for sys/poll.h... yes

checking for sys/select.h... yes

checking for sys/time.h... yes

checking for sys/times.h... yes

checking for ttyent.h... yes

checking for unistd.h... yes

checking for wctype.h... yes

checking if sys/time.h works with sys/select.h... yes

checking for gcc option to accept ANSI C... none needed

checking for an ANSI C-conforming const... yes

checking for inline... inline

checking if unsigned literals are legal... yes

checking for type of chtype... long

checking if external errno is declared... no

checking if external errno exists... no

checking if data-only library module links... yes

checking for getcwd... yes

checking for getegid... yes

checking for geteuid... yes

checking for getttynam... yes

checking for issetugid... no

checking for memccpy... yes

checking for nanosleep... yes

checking for poll... yes

checking for remove... (cached) yes

checking for select... yes

checking for setbuf... yes

checking for setbuffer... yes

checking for setvbuf... yes

checking for sigaction... yes

checking for sigvec... yes

checking for strdup... yes

checking for strstr... yes

checking for tcgetpgrp... yes

checking for times... yes

checking for vsnprintf... yes

checking for isascii... yes

checking whether sigaction needs _POSIX_SOURCE... unknown

checking for termio.h... no

checking for termios.h... yes

checking for unistd.h... (cached) yes

checking whether termios.h needs _POSIX_SOURCE... no

checking for tcgetattr... yes

checking for vsscanf function or workaround... vsscanf

checking for working mkstemp... yes

checking whether setvbuf arguments are reversed... no

checking return type of signal handlers... int

checking for type sigaction_t... no

checking declaration of size-change... no

checking for memmove... yes

checking if poll really works... yes

checking if we should include stdbool.h... yes

checking for builtin bool type... no

checking for library stdc++... no

checking how to run the C++ preprocessor... /usr/bin/g++ -E

checking for typeinfo... yes

checking if we should include stdbool.h... (cached) yes

checking for builtin bool type... yes

checking for size of bool... unsigned char

checking for special defines needed for etip.h... none

checking if /usr/bin/g++ accepts parameter initialization... no

checking for strstream.h... no

checking if /usr/bin/g++ supports vscan function... stdio

checking for library subsets... termlib+ext_tinfo+base+widechar+ext_funcs

checking default library suffix... w

checking default library-dependency suffix... w.so

checking default object directory... obj_s

checking c++ library-dependency suffix... w.a

checking where we will install curses.h... ${prefix}/include

checking for src modules... ncurses progs tack panel menu form

configure: creating ./config.status

config.status: creating include/MKterm.h.awk

config.status: creating include/curses.head

config.status: creating include/termcap.h

config.status: creating include/unctrl.h

config.status: creating man/Makefile

config.status: creating include/Makefile

config.status: creating ncurses/Makefile

config.status: creating progs/Makefile

config.status: creating tack/Makefile

config.status: creating panel/Makefile

config.status: creating menu/Makefile

config.status: creating form/Makefile

config.status: creating test/Makefile

config.status: creating misc/Makefile

config.status: creating c++/Makefile

config.status: creating misc/run_tic.sh

config.status: creating Makefile

config.status: creating include/ncurses_cfg.h

Appending rules for shared model (ncurses: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for normal model (ncurses: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for shared model (progs: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for normal model (progs: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for shared model (tack: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for normal model (tack: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for shared model (panel: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for normal model (panel: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for shared model (menu: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for normal model (menu: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for shared model (form: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for normal model (form: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for shared model (test: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for normal model (test: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for shared model (c++: termlib+ext_tinfo+base+widechar+ext_funcs)

Appending rules for normal model (c++: termlib+ext_tinfo+base+widechar+ext_funcs)

creating headers.sh

** Configuration summary for NCURSES 5.4 20040208:

      bin directory: /usr/bin

      lib directory: /lib

  include directory: /usr/include

      man directory: /usr/share/man

 terminfo directory: /usr/share/terminfo

cd man && make DESTDIR="" sources

make[1]: Entering directory `/var/tmp/portage/ncurses-5.4-r5/work/ncurses-5.4/man'

sh ./MKterminfo.sh ./terminfo.head ./../include/Caps ./terminfo.tail >terminfo.5

make[1]: Leaving directory `/var/tmp/portage/ncurses-5.4-r5/work/ncurses-5.4/man'

cd include && make DESTDIR="" sources

make[1]: Entering directory `/var/tmp/portage/ncurses-5.4-r5/work/ncurses-5.4/include'

cat curses.head >curses.h

AWK=gawk sh ./MKkey_defs.sh ./Caps >>curses.h

sh -c 'if test "cchar_t" = "cchar_t" ; then cat ./curses.wide >>curses.h ; fi'

cat ./curses.tail >>curses.h

sh ./MKhashsize.sh ./Caps >hashsize.h

AWK=gawk sh ./MKncurses_def.sh ./ncurses_defs >ncurses_def.h

AWK=gawk sh ./MKparametrized.sh ./Caps >parametrized.h

gawk -f MKterm.h.awk ./Caps > term.h

sh ./edit_cfg.sh ../include/ncurses_cfg.h term.h

** edit: HAVE_TCGETATTR 1

** edit: HAVE_TERMIOS_H 1

** edit: HAVE_TERMIO_H 0

** edit: BROKEN_LINKER 0

make[1]: Leaving directory `/var/tmp/portage/ncurses-5.4-r5/work/ncurses-5.4/include'

cd ncurses && make DESTDIR="" sources

make[1]: Entering directory `/var/tmp/portage/ncurses-5.4-r5/work/ncurses-5.4/ncurses'

sh ./base/MKlib_gen.sh "gcc -E -DHAVE_CONFIG_H -I../ncurses -I. -I. -I../include-D_GNU_SOURCE -DNDEBUG" "gawk" generated <../include/curses.h | \

        fgrep undef >../include/nomacros.h

gawk -f ./tinfo/MKnames.awk ./../include/Caps

cat namehdr boolnames boolfnames numnames numfnames strnames strfnames nameftr >names.c

cat namehdr boolcodes numcodes strcodes codeftr >codes.c

rm -f namehdr nameftr codeftr boolnames boolfnames boolcodes numnames numfnames numcodes strnames strfnames strcodes

gcc -o make_hash -DHAVE_CONFIG_H -I../ncurses -I. -DHAVE_CONFIG_H -I../ncurses -I. -I. -I../include  -D_GNU_SOURCE -DNDEBUG -march=i586 -mcpu=i686 -02 -pipe -fomit-frame-pointer -fPIC -DMAIN_PROGRAM ./tinfo/comp_hash.c

gcc: unrecognized option `-02'

In file included from /usr/include/errno.h:36,

                 from ../ncurses/curses.priv.h:94,

                 from tinfo/comp_hash.c:40:

/usr/include/bits/errno.h:25:26: linux/errno.h: No such file or directory

In file included from /usr/include/signal.h:326,

                 from ../ncurses/curses.priv.h:115,

                 from tinfo/comp_hash.c:40:

/usr/include/bits/sigcontext.h:28:29: asm/sigcontext.h: No such file or directory

In file included from tinfo/comp_hash.c:40:

../ncurses/curses.priv.h:511: error: `MB_LEN_MAX' undeclared here (not in a function)

In file included from tinfo/comp_hash.c:68:

../ncurses/tinfo/doalloc.c: In function `_nc_doalloc':

../ncurses/tinfo/doalloc.c:52: error: `ENOMEM' undeclared (first use in this function)

../ncurses/tinfo/doalloc.c:52: error: (Each undeclared identifier is reported only once

../ncurses/tinfo/doalloc.c:52: error: for each function it appears in.)

make[1]: *** [make_hash] Error 1

make[1]: Leaving directory `/var/tmp/portage/ncurses-5.4-r5/work/ncurses-5.4/ncurses'

make: *** [sources] Error 2

!!! ERROR: sys-libs/ncurses-5.4-r5 failed.

!!! Function src_compile, Line 78, Exitcode 2

!!! make sources failed

```

----------

## bin-doph

 *veezi wrote:*   

> 
> 
> If all will, try to boot into '/bin/sh' (by changing the grub line on livecd boot from 'init=/linuxrc' to 'init=/bin/sh') and manually execute each line in linuxrc to figure out what's going wrong.

 

That sounds pretty good, I'll try that

thx

----------

## bin-doph

hmmm. if it tries to mount proc I get that error (fstab). after that the cdrom-mount-function ends up in timeoutin

----------

## veezi

Sounds like your initrd is read only. Are you sure you specified 'rw' in the grub kernel line?

----------

## veezi

@Illissius

Sorry, don't have any other hint.

But, really seeams something is broken with your source environment. Double check that you downloaded the right stage2, and double check your make.conf (flags, march, etc.).

Can't think of anything else.  :Sad: 

Good luck

----------

## Illissius

Would using an x86 (=i386?) stage2 along with chost=i586-linux-gnu and CFLAGS=-march=i586 -mcpu=i686 cause any problems? I'm at a loss as to what else it could be.

----------

## veezi

 *Illissius wrote:*   

> Would using an x86 (=i386?) stage2 along with chost=i586-linux-gnu and CFLAGS=-march=i586 -mcpu=i686 cause any problems? I'm at a loss as to what else it could be.

 

Not sure if chost of i586 is correct when using an x86 stage2. 

For mcpu, people usually advise against it (since it opimizes for a specific architecture, and you don't want that on a livecd).

Why don't you try my combination. It worked fine here:

i686 stage2: http://gentoo.osuosl.org/releases/x86/2004.2/stages/i686/stage2-i686-2004.2.tar.bz2

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=i686 -O3 -pipe -fomit-frame-pointer"

----------

## Illissius

The problem with i686 is three out of five of the computers that it'll be used most likely/often on are K6s or P1 equivalents (read: Cyrix).... so guess I'll try straight i386 then.

As for -mcpu, isn't it supposed to be completely backwards compatible with the older stuff while optimized to be faster on newer stuff?

----------

## dcoyaz

 *nsahoo wrote:*   

> thanks veezi, you are indeed "tux' lil helper" 
> 
> edit: is there a way to make sure that the image is alright before burning it onto the cd ? 

 

Thanks for a great howto veezi  :Very Happy: 

One way is to emerge qemu and then issue a

```
qemu -cdrom livecd.iso -boot d
```

This will allow you to test before burning, and maybe even throwing some qemu options to alter the running hardware.  :Very Happy: 

HTH,

----------

## nsahoo

 *dcoyaz wrote:*   

>  *nsahoo wrote:*   thanks veezi, you are indeed "tux' lil helper" 
> 
> edit: is there a way to make sure that the image is alright before burning it onto the cd ?  
> 
> Thanks for a great howto veezi 
> ...

 

aha, why didn't it occure to me earlier, I can do the same using the vmware that i use.

Thanks

----------

## Match

Hey all,

To start off let me say that I'm reasonably new to Linux and Gentoo, having installed my first system back in June and having reinstalled a couple of times since then. I'm eager to learn, but to be honest I don't know that much.

I do, however, understand about half of what has been written in this excellent guide, and just have a few questions.

1) I would like to make a LiveCD that works on most systems, like the Gentoo LiveCD or Knoppix. I gather the best idea would be to use genkernel to configure my kernel - however, that creates its own initrd image which the Handbook says "will be started immediately after booting to perform hardware autodetection (just like on the Live CD) before your 'real' system starts up." Can I just create the initrd as this guide explains and ignore the one created by genkernel? I'd assume yes, but the Handbook says that it "performs hardware autodetection just like on the LiveCD" which is what I want. Does the initrd created above do this also?

2) How would I, having followed the above instructions, then go back and install/upgrade a program for my LiveCD? Is it as simple as just "chroot /source etc., env-update, source /etc/profile, emerge package"? (Obviously I'd then recreate the ISO file.)

3) In this piece of code from the guide

```

ldd /bin/mount

        linux-gate.so.1 =>  (0xffffe000)

        libc.so.6 => /lib/libc.so.6 (0x4002e000)

        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

cp /lib/libc.so.6 /mnt/initrd/lib/

cp /lib/ld-linux.so.2 /mnt/initrd/lib/ 
```

what is the linux-gate.so.1 thing about, and why don't you copy that as well?

4) Would it be possible to create a splash screen for it such as in https://forums.gentoo.org/viewtopic.php?t=206778 (this is obviously not as important as my other questions; I can do this later, if at all.)

5) Any problems with using gentoo-dev-sources or do you just like the default ones?  :Smile: 

6) What is udev and why might I need it? Bear in mind I don't use it on my normal install, that I know it's an alternative for devfs (or something, not sure) and manages /dev, but not much else. Is it worth me learning about it? Will it increase or decrease the chances of my LiveCD working on other computers?

----------

## nsahoo

 *Quote:*   

> 
> 
> 1) I would like to make a LiveCD that works on most systems, like the Gentoo LiveCD or Knoppix. I gather the best idea would be to use genkernel to configure my kernel - however, that creates its own initrd image which the Handbook says "will be started immediately after booting to perform hardware autodetection (just like on the Live CD) before your 'real' system starts up." Can I just create the initrd as this guide explains and ignore the one created by genkernel? I'd assume yes, but the Handbook says that it "performs hardware autodetection just like on the LiveCD" which is what I want. Does the initrd created above do this also? 
> 
> 

 

I had some confusion at that point as well. But, I ignored the genkernel created initrd and used the one created in this tutorial. Livecd has worked so far on three different system. I guess most of the "auto-detection" work is achieved by having all the kernel modules compiled and hotplug installed. That way kernel can load the required driver module, on the fly. But, I guess someone can give a better answer than this.

 *Quote:*   

> 
> 
> 2) How would I, having followed the above instructions, then go back and install/upgrade a program for my LiveCD? Is it as simple as just "chroot /source etc., env-update, source /etc/profile, emerge package"? (Obviously I'd then recreate the ISO file.) 
> 
> 

 

You are right. It's that simple. Thanks to Veezi.

 *Quote:*   

> 
> 
> 5) Any problems with using gentoo-dev-sources or do you just like the default ones?
> 
> 

 

No problem at all. I use it. With kernel 2.6.9 I had some issues on some system. So, I downgraded it to 2.6.8-r<latest> and removed the video parameter from the kernel line in grub.conf. It has worked fine after that.

 *Quote:*   

> 
> 
> 6) What is udev and why might I need it? Bear in mind I don't use it on my normal install, that I know it's an alternative for devfs (or something, not sure) and manages /dev, but not much else. Is it worth me learning about it? Will it increase or decrease the chances of my LiveCD working on other computers?
> 
> 

 

There is nothing much to learn actually. You just have to emerge it like any other package and uncheck dev filesystem support in kernel. Even if you decide to keep the devfs support in kernel, uncheck the automount option right below it. You are good to go. No configuration nothing.

----------

## Match

 *nsahoo wrote:*   

> [
> 
> I had some confusion at that point as well. But, I ignored the genkernel created initrd and used the one created in this tutorial. Livecd has worked so far on three different system. I guess most of the "auto-detection" work is achieved by having all the kernel modules compiled and hotplug installed. That way kernel can load the required driver module, on the fly. But, I guess someone can give a better answer than this.
> 
> 

 

Well, I'll go with what you say and if someone's got a better answer I'd love to hear it also  :Smile: 

 *Quote:*   

> No problem at all. I use it. With kernel 2.6.9 I had some issues on some system. So, I downgraded it to 2.6.8-r<latest> and removed the video parameter from the kernel line in grub.conf. It has worked fine after that.

 

I shall do as you say  :Smile: 

 *Quote:*   

> 
> 
> There is nothing much to learn actually. You just have to emerge it like any other package and uncheck dev filesystem support in kernel. Even if you decide to keep the devfs support in kernel, uncheck the automount option right below it. You are good to go. No configuration nothing.

 

I add it to the default runlevel, right? Anyway, I'll try it out on my normal system at some point but I think I'll stick with what I know for this LiveCD  :Smile: 

----------

## nsahoo

 *Match wrote:*   

> 
> 
> I add it to the default runlevel, right? Anyway, I'll try it out on my normal system at some point but I think I'll stick with what I know for this LiveCD 

 

No man, you don't even have to do that. It's not a service .. just emerge and uncheck devfs menuconfig and recompile kernel .. if it's unchecked already .. leave it as it is. you are good to go. too easy to believe, eh? but, thats all there is to udevs.

----------

## Match

Cool - and the syntax of fstab remains the same?

Another question. I've just got onto creating initrd, and have run the first two commands:

```
touch /boot/initrd

dd if=/dev/zero of=/boot/initrd bs=1024k count=8
```

which have worked fine, I think. However, when I run the next command:

```
losetup /dev/loop0 /boot/initrd
```

I get the message:

 *Quote:*   

> /dev/loop0: No such device or address

 

What do I need to do now?

----------

## chunderbunny

Your fstab will mostly be the same with the switch to udev, anything relating to hard drives will be unchanged. If you currently use the /dev/cdrom symlink as you cdrom device you will have to replace this entry in your fstab with /dev/cdroms/cdrom0. Another thing to watch out for is that the default mouse device moves to /dev/input/mice, so you might need to adjust your /etc/X11/xorg.conf accordingly. 

/dev/loop0 is part of the loopback interface, and needs to be compiled into your kernel as either a built in driver or as a module. The loopback interface option is located in "device drivers > block devices > loopback device support" in your kernel config.

----------

## Match

It's enabled - compiled in. But what good would that do when I'm in a chrooted environment anyway? Does compiling it automatically set it up?

*goes off to recompile the kernel just to make sure*

(Thanks for all the info on udev by the way, it's really helpful  :Very Happy: )

Edit: I've done an ls /dev and loop0 is certainly there. I get the same error though.

----------

## Match

I'm going to try booting from the partition I've been doing all this on, see if that works. I can't think of anything else. Does anyone have any other ideas?

----------

## veezi

 *Match wrote:*   

> I'm going to try booting from the partition I've been doing all this on, see if that works. I can't think of anything else. Does anyone have any other ideas?

 

May be your forgot to 'mount -o bind /dev source/dev'. Not really sure.

Anyway, you can always create the initrd image from outside the chroot environment. It really doesn't make a difference.

Good luck

----------

## chunderbunny

Gah, this is irritating me now. I made a new image with a load of extra programs on, but now it hangs when trying to run /sbin/init. If I press some keys I get the error message "vt: argh, driver_data is NULL". 

I edited linuxrc to execute /bin/sh instead of /sbin/init and it all works up until "exec /sbin/init ${CMDLINE}" which just hangs. I tried using "exec /sbin/init 3" (as well as various other runlevels) but that hangs as well.  

Is there anyway I can get some debug info on what's going wrong?

----------

## Cqwense

 *Quote:*   

> warning: can't open /etc/fstab: No such file or directory 

 

I also recieved this message, I carelessly forgot to :

```
mkdir newroot
```

inside the souce directory.

I  added it, rebuilt the image, and seems to be working now.

Hope this helps,

~ Cqwense

----------

## Match

 *veezi wrote:*   

>  *Match wrote:*   I'm going to try booting from the partition I've been doing all this on, see if that works. I can't think of anything else. Does anyone have any other ideas? 
> 
> May be your forgot to 'mount -o bind /dev source/dev'. Not really sure.
> 
> Anyway, you can always create the initrd image from outside the chroot environment. It really doesn't make a difference.
> ...

 

I didn't mount /dev to source/dev because it's not in your guide, but I tried it now and it still doesn't work  :Sad: 

Also, even if I did make the initrd image outside of the chroot, if I can't do this step then surely nothing's going to work anyway?

Incidently, I just tried running the losetup command outside the chroot, on my normal installation: I get the same error message.

Is there any way of me doing this if I keep on getting this message, or does anyone know of how to solve this problem? Otherwise I guess I'll just have to give up  :Sad: 

(Thanks for the tutorial anyway, veezi  :Smile:  - not your fault if I can't get it to work)

----------

## veezi

 *Match wrote:*   

> 
> 
> I didn't mount /dev to source/dev because it's not in your guide, but I tried it now and it still doesn't work 
> 
> Also, even if I did make the initrd image outside of the chroot, if I can't do this step then surely nothing's going to work anyway?
> ...

 

You're right about that. :Embarassed: 

Can you post the output of the following commands:

```

cat /usr/src/linux/.config | grep LOOP

ls -l /dev/loop*

modinfo loop

```

----------

## duby2291

I can boot to the cd and it loads the kernel. Then it craps out saying that it couldnt find init. Then it says to edit "init=" line in grub.conf. I don't have an exact copy of the error, but it is something along that line. 

Any suggestions?

----------

## Match

 *veezi wrote:*   

> 
> 
> Can you post the output of the following commands:
> 
> ```
> ...

 

These are the bits of my .config:

```
CONFIG_BLK_DEV_LOOP=y

CONFIG_BLK_DEV_CRYPTOLOOP=y
```

Here are the loop*s:

```
brw-rw----  1 root disk 7, 0 Jul 18 01:13 /dev/loop0

brw-rw----  1 root disk 7, 1 Jul 18 01:13 /dev/loop1

brw-rw----  1 root disk 7, 2 Jul 18 01:13 /dev/loop2

brw-rw----  1 root disk 7, 3 Jul 18 01:13 /dev/loop3

brw-rw----  1 root disk 7, 4 Jul 18 01:13 /dev/loop4

brw-rw----  1 root disk 7, 5 Jul 18 01:13 /dev/loop5

brw-rw----  1 root disk 7, 6 Jul 18 01:13 /dev/loop6

brw-rw----  1 root disk 7, 7 Jul 18 01:13 /dev/loop7

```

modinfo tells me it can't find module loop, though.

 *Quote:*   

> modinfo: could not find module loop

 

----------

## veezi

 *Match wrote:*   

> 
> 
> These are the bits of my .config:
> 
> ```
> ...

 

Very strange. Your setup seems fine.  :Rolling Eyes: 

Can you do this as root:

```

touch test.img

dd if=/dev/zero of=test.img bs=1M count=10

mke2fs test.img <--- answer yes

mount -o loop test.img /mnt/floppy

```

----------

## AnGel_Guardian

 *Quote:*   

> modinfo: could not find module loop

 

and what returns: 

```
modprobe loop
```

and then:

```
modinfo loop
```

and what returns:

```
find /lib/modules/ | grep loop
```

----------

## chunderbunny

You're not going to have any luck with the loop module, since from your kernel config you appear to have compiled it right into the kernel, and not as a module. It's possible that if you recompiled your kernel with the loop device as a module rather than built in then it might work.

----------

## Match

 *veezi wrote:*   

> 
> 
> Very strange. Your setup seems fine. 
> 
> Can you do this as root:
> ...

 

This gives:

```
mount: Could not find any loop device. Maybe this kernel does not know

       about the loop device? (If so, recompile or `modprobe loop'.)
```

modprobe loop returns:

```
FATAL: Module loop not found.
```

 *AnGel_Guardian wrote:*   

> 
> 
> and what returns:
> 
> ```
> ...

 

Nothing.

Now, these are all with the loop thing as a module.

 *veezi wrote:*   

> 
> 
> ```
> 
> touch test.img
> ...

 

This gives the same message as before:

```
mount: Could not find any loop device. Maybe this kernel does not know

       about the loop device? (If so, recompile or `modprobe loop'.)
```

modprobe loop now gives this error:

```
FATAL: Error inserting loop (/lib/modules/2.6.8-gentoo-r10/kernel/drivers/block/loop.ko): Invalid module format
```

modinfo loop now gives this:

```
parm:           max_loop:Maximum number of loop devices (1-256)

license:        GPL

alias:          block-major-7-*

vermagic:       2.6.8-gentoo-r10 486 gcc-3.3

depends:
```

----------

## veezi

Perhaps you should start a new thread with your 'loop device' issue. Or, even file a bug report. The 'invalid module format' message is strange.

I would test another kernel. Different version, or even plain vanilla one, just to make sure. Loop devices shouldn't be that hard to get working after all, we all just take them for granted  :Very Happy: 

----------

## duby2291

I finally was able to boot up my first livecd   :Cool:   :Very Happy:  My next question is there a way that X can be configured on the fly, each time the disc is booted? Also is there a way that a user can be automagicaly logged in on boot up?

----------

## veezi

 *duby2291 wrote:*   

> I finally was able to boot up my first livecd    My next question is there a way that X can be configured on the fly, each time the disc is booted? Also is there a way that a user can be automagicaly logged in on boot up?

 

For X config, there's a script around (I thing it's called makexconfig) that's borrowed from knoppix. It does that.

However, I personally use a generic X config that uses 'vesa' device. It's guaranteed to work on most PCs.

----------

## Nutterpc

after finding this guide, following it to the letter, I'm stuck on the emerge system bit, and its complaining to me while trying to update groff that it needs a working C++ compiler :S:S

Any idea whats goin on?

----------

## Nutterpc

looks like all I had to do atm, not sure till it finishes, was to logout of the chroot, copy some config files across, namely resolv.conf & sysctl.conf, relogin....and then re emerge gcc

hopefully, all goes well   :Very Happy: 

----------

## AnGel_Guardian

 *Quote:*   

> duby2291 wrote: way that X can be configured on the fly, each time the disc is booted?

 

I am using mkxorgconf.sh and xorg.conf.in (xorg.conf.in is basic configuration file, which is used by mkxorgconf.sh and output is xorg.conf modified for your monitor and VGA) from the Jollix livecd. If you are using xorg-x11, you can download it here: 

http://193.179.144.16/files/mkxorgconf.tar.gz

(i hope, both files are gpl-2 licensed......perhaps yes, because are derived from mkxf86config).

Info: mkxorgconf.sh is using ddcxinfo-knoppix tool to recognize your monitor!

Info: mkxorgconf.sh is using hwdata-knoppix tool to recognize your vga!Last edited by AnGel_Guardian on Sun Nov 14, 2004 11:43 am; edited 2 times in total

----------

## AnGel_Guardian

 *Quote:*   

> duby2291 wrote: Also is there a way that a user can be automagicaly logged in on boot up?

 

Yes, there is the way:

! Warning ! Method used in next lines is unsecure, bacause automatical root rights can be dangerous using incompetent hands....blah blah. 

```
emerge mingetty -av
```

this line in your /etc/inittab

```
c1:12345:respawn:/sbin/agetty 38400 tty1 linux
```

replace with:

```
c1:12345:respawn:/sbin/mingetty --autologin root tty1
```

Try restart your system - wow - root is logged in!

Info: I have no idea, if RMNOLOGIN daemon can affect autologin. I take precautions against:

```
rc-update del rmnologin boot default
```

----------

## Illissius

Well, emerge system is working now. Guess what the problem was? Emerge listed linux-headers as a blocker, so I unmerged it. It then failed to compile, apparently because linux-headers was missing. Emerging linux26-headers seems to have fixed it.

*smacks head against desk*

EDIT -

Also. There isn't anything that would theoretically prevent me from installing the 'livecd' on a random USB mass storage device of choice or something, is there? (in my case, an iRiver iHP-120)

----------

## veezi

 *AnGel_Guardian wrote:*   

>  *Quote:*   duby2291 wrote: Also is there a way that a user can be automagicaly logged in on boot up? 
> 
> Yes, there is the way:
> 
> ! Warning ! Method used in next lines is unsecure, bacause automatical root rights can be dangerous using incompetent hands....blah blah. 
> ...

 

Just keep in mind that when using 'livecd' flag the init scripts will change all the getty lines in /etc/inittab with a default value automatically at boot time. So, don't be surprized if you see that whatever getty line you put in /etc/inittab is not working  :Smile: 

----------

## AnGel_Guardian

 *Quote:*   

> veezi said: Just keep in mind that when using 'livecd' flag the init scripts will change all the getty lines in /etc/inittab with a default value automatically at boot time. So, don't be surprized if you see that whatever getty line you put in /etc/inittab is not working Smile

 

Yes you right. After livecd boot is the line in inittab changed to:

```
c1:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty1 linux
```

.....but it is still working for me. My login is automatical and logged user is root. No problem for me. (i don't know why is it so, but ti is functional). (perhaps the "-nl" option behind the AGETTY.....)

----------

## duby2291

 *Quote:*   

> Also. There isn't anything that would theoretically prevent me from installing the 'livecd' on a random USB mass storage device of choice or something, is there? (in my case, an iRiver iHP-120)

 

I don't see any reason why it wouldn't work, but you will need to find a boot loader that supports USB booting. I don't think that grub does. Also it may be a good idea to leave the filesystem readonly, and use a ramdrive, the same way the livecd does. I'd be interested in making a bootable flashdrive  :Smile:  if anyone has any idea's feel free to share  :Smile: 

----------

## Illissius

Yes, I still intend to use SquashFS (possibly with a few strategically chosen dirs mounted rw from the other partition), mainly because 700MB-1GB is acceptable, but 4GB is not.

Speaking of which. Is it possible to mount /etc from a seperate partition than /? I'm just asking, because fstab itself is in /etc, so...

----------

## veezi

 *Illissius wrote:*   

> Yes, I still intend to use SquashFS (possibly with a few strategically chosen dirs mounted rw from the other partition), mainly because 700MB-1GB is acceptable, but 4GB is not.
> 
> Speaking of which. Is it possible to mount /etc from a seperate partition than /? I'm just asking, because fstab itself is in /etc, so...

 

I'm not sure I'm getting you right about mounting read-write. Anyway, just in case, squashfs is a read-only file system.  :Smile: 

About mounting /etc on another partition. There should be no problem there. Just replace the line in the guide where it's mounted with your preferred one.

Cheers,

----------

## skipsargent

I have been using Catalyst for a bit now and I have found certain parts of it a little to automatic and I wanted a little more control over my build. Then I found this thread and thought I would give it a try. I ran into a problem. When I boot I get an error message that says it can not find /etc/fstab. I double checked my kernel (2.6.9) configuration and I have all of the listed options compiled in. So I dug through the threads and found the suggestion to edit the grub line and boot right to /bin/sh and then manually run through the linuxrc commands.

The first command mounts proc, when I execute that command I get the same error about the fstab, but it seems to mount proc just the same because I can manually call /proc/cmdline. All of the rest of the commands execute just fine until the very end, that usually results in a seg fault. I have managed to get to a login prompt, when I try to login I get an error about tty. I forget the exact message, I'll post it when I get it.

Any help would be greatly appreciated, instead of taking a step forward with my builds I seem to be a step behind and I need to make this work ASAP for a project. So like I said any suggestions on things to try/check are more than welcome!

Thanks!

----------

## Illissius

 *veezi wrote:*   

>  *Illissius wrote:*   Yes, I still intend to use SquashFS (possibly with a few strategically chosen dirs mounted rw from the other partition), mainly because 700MB-1GB is acceptable, but 4GB is not.
> 
> Speaking of which. Is it possible to mount /etc from a seperate partition than /? I'm just asking, because fstab itself is in /etc, so... 
> 
> I'm not sure I'm getting you right about mounting read-write. Anyway, just in case, squashfs is a read-only file system. 
> ...

 

Yes, I'm aware it's read only. What I'm saying is that the iRiver has a 20GB drive, and since it only sees the first one anyways, I can safely cut off 700MB-1GB from the end for a SquashFS partition to (try to) boot from. I'll still have 19GB left over with which to either make some small ext2-3 partitions, or more likely I'll just make an image of them on the existing one and use loop (or a single image and loop + bind, or whatever).

As for the /etc thing... my problem is that I want to mount it from a seperate partition, which I specify in fstab, but fstab itself is in /etc, which doesn't get mounted until fstab is read, which can't be read until /etc is mounted...

I'm assuming the way it works is I'd have two copies of /etc, one on the same partition as /, and the other on the seperate partition, and once the seperate one is mounted the old one becomes invisible -- so I'd have to specify the new partition in the fstab on the old one. My concern, though, is couldn't there be issues where some programs read their settings from /etc before the new one is mounted? Or is fstab the absolutely first thing that's read?

----------

## skipsargent

Ok I have went line by line through these instructions several times. This has to be something simple that I am missing. I have tried 3 different kernels, currently 2.6.8-r9. Here is what I see when I change the grub config from init=/linuxrc cdroot to init=/bin/sh.

 *Quote:*   

> 
> 
> sh-2.05b# mount -t proc none /proc
> 
> warning: can't open /etc/fstab: No such file or directory
> ...

 

My grub.conf looks like this:

 *Quote:*   

> 
> 
> root (cd)
> 
> kernel (cd)/boot/vmlinuz root=dev/ram0 rw init=/linuxrc cdroot
> ...

 

My fstab looks like this: 

 *Quote:*   

> 
> 
> /dev/loop0              /               squashfs        ro,defaults             0 0 
> 
> none                    /proc           proc            defaults                0 0 
> ...

 

This is a fresh build environment and I have tried everything I can think of and have seen in a post. Maybe I am missing something really simple and I am trying to hard to see the problem. I'm going nuts! HELP!!!

----------

## veezi

skipsargent,

What's your cdrom device name? is it IDE? Boot into sh again (with init=/bin/sh), what does the following give assuming your cdrom device is /dev/hdb:

```

mount -t iso9660 -r /dev/hdb /cdrom

```

----------

## skipsargent

I am testing the iso in vmware, which I use all the time for my catalyst based images, so the IDE cdrom is a virtual drive.

When I run the mount I get:

sh-2.05b# mount -t iso9660 -r /dev/hdb /cdrom

Warning: can't open /etc/fstab: No such file or directory

mount: /dev/hdb is not a valid block device

Looks like my cdrom is /dev/hdc

EDIT:

With the cdrom mounted to hdc stepping through the rest of the commands seems to work until I try to envoke the init, that earns me:

 *Quote:*   

> PANIC: segmentation violation at 0x804a1ad (code)! sleeping for 30 seconds.

 

Then after 30 seconds I get dropped to a login prompt. If I try to login I get:

 *Quote:*   

> FATAL: cannot change permissions of TTY: Read-Only file system

 

----------

## veezi

Strange one! Really no thoughts here to help  :Rolling Eyes: 

Do you have the same results with a real PC? I've had several problems running 2.6 kernels under vmware (be it Gentoo Linux, or other distros)

Good luck!

----------

## skipsargent

After many many many compiles I got it working. Seems it was an unfortunate combination of things. First of which was testing the ISO in VMware. I didn't even consider this until you mentioned it, mainly because I use it to test all of my images that are built in Catalyst and they work perfectly. Very strange. I'm not sure why one works and the other doesn't, especially since I have used it with both 2.4 and 2.6 series kernels. It is possible that is is a filesystem thing, this setup uses squashfs and catalyst uses zisofs. Just a thought. 

Anyways it seems that my major pain in the rear is a thing of the past, and now it is time to start building up the image a little. Can't thank you enough for the HowTo, it is such a time saver over catalyst!

----------

## stamperb

Ok i've been at this now for 3 days or so.  I've tried over and over again and there must be something dumb that i'm missing.  I've read this thread thru and thru over and over.  HELP!!!  

I get everything done and made up till my iso is created.  Its roughly about 235MG...makes me think something is wrong right there but all i've added to the mix was samba and dosemu.  So i use vmware to boot the image and/or i've put it on a disk and no matter what i get part of the way booted and  it just stops with a bash prompt sh-2.05b#

The lines right before this prompt don't seem to show any errors:

EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended

VFS: Mounted root (ext2 filesystem).

Mounted devfs on /dev

Freeing unused kernel memory: 264k freed

sh-2.05b#

Anyone have any ideas where i've gone wrong?

----------

## Cqwense

I assume you compiled your kernel with devfs, do you have it set to automaticly mount on boot? I know that caused me some grief, and your error is occuring right after /dev/ is mounted.

----------

## stamperb

After a few more hours of pulling out hair the error was somewhat simple. On bootup i dno't seem to get /dev/hdx for my cdrom and instead its /dev/cdroms/cdrom0...<anyone have any idea why this is?  Anyway this is my problem and as soon as i added cdroms/cdrom0 to the end of the x line everything started working.

----------

## skipsargent

Sounds like your system is trying to use udev instead of devfs. Which is a good thing since devfs is a thing of the past. Try this 

```

emerge --umerge devfsd

emerge udev

```

Compile your kernel and remove devfs support.

See this great quote from chunderbunny

 *Quote:*   

> 
> 
> Your fstab will mostly be the same with the switch to udev, anything relating to hard drives will be unchanged. If you currently use the /dev/cdrom symlink as you cdrom device you will have to replace this entry in your fstab with /dev/cdroms/cdrom0. Another thing to watch out for is that the default mouse device moves to /dev/input/mice, so you might need to adjust your /etc/X11/xorg.conf accordingly. 
> 
> /dev/loop0 is part of the loopback interface, and needs to be compiled into your kernel as either a built in driver or as a module. The loopback interface option is located in "device drivers > block devices > loopback device support" in your kernel config.
> ...

 

As for VMware I'd skip it for testing it has proven to be flakey at best with these images.

----------

## linux_on_the_brain

I've been working on this for almost a week now. I can't get the cd to boot. The message I get is this. ANy thoughts 

```
warning: can't open /etc/fstab: Input/Output Error

Unable to identify CD-ROM format.

```

If I try it manually I get this

```
mount -t proc none /proc

warning: can't open /etc/fstab: Input/Output Error

sh-2.05b# mount -t squashfs -o loop /cdrom/files/source.img /new

/cdrom/files/source.img: Input/Output Error
```

----------

## linux_on_the_brain

well I finally got the cd to boot, but I still get this message on boot.

```
Unable to identify CD-ROM format
```

----------

## veezi

 *linux_on_the_brain wrote:*   

> well I finally got the cd to boot, but I still get this message on boot.
> 
> ```
> Unable to identify CD-ROM format
> ```
> ...

 

I think that results from trying to locate the cdrom by going through the four devices (hda, hdb, hdc, hdd) and trying to mount as iso9660. 

You can safely ignore it.

----------

## Cqwense

Ok, i've gotten my cd to boot, and even launch gnome, but I still have a few problems I hope someone can help me with:

 Durring init, the system hangs for a minute or two durring " calculating modules dependencies" .   and then I get the "!!" failed to calculate module dependencies, and init continues.

I've compiled almost every network and sound modules ( as modules ) , and still on boot the system cant find net or sound. I was under the impression that emerging hotplug is what would probe your hardware and load the appropirate modules ? If thats not correct, what exactly should I use to have the system auto detect the hardware? 

Thanks for any help in advance, and thanks for a great howto.

~ Cqwense

----------

## veezi

 *Cqwense wrote:*   

>  Durring init, the system hangs for a minute or two durring " calculating modules dependencies" .   and then I get the "!!" failed to calculate module dependencies, and init continues.
> 
> 

 

I modified my modules script according to https://forums.gentoo.org/viewtopic.php?t=231170, so I'm not sure if the original script doesn't work well with LiveCD. You might want to give it a try since it speeds up booting. Just before creating the CD do 'modules-update' in the build environment.

 *Quote:*   

> 
> 
> I've compiled almost every network and sound modules ( as modules ) , and still on boot the system cant find net or sound. I was under the impression that emerging hotplug is what would probe your hardware and load the appropirate modules ? If thats not correct, what exactly should I use to have the system auto detect the hardware? 
> 
> 

 

Hotplug has changed lately. Installed devices don't get detected by it anymore. Search around for that. Basically, you'll need to do this to get the same functionality:

```

emerge coldplug

rc-update del hotplug boot

rc-update add coldplug boot

```

Also, for sound I'd rely on alsa init script detecting devices, unless of course if you're still using OSS  :Smile: 

----------

## Cqwense

Thanks, worked perfectly.

Unfortunatly, with every success comes another frustration =)

I mounted dev into the source/dev directory, chrooted in, and started X, I spent a good ammout of time trying to configure gnome ( desktop, menu's, ect ) , thinking that saving them, and then rebuilding the CD would have them default to the saved settings.  Either I did something wrong, or my idea is just wrong.  Got any advice? 

Thanks again ,

~ Cqwense

----------

## veezi

 *Cqwense wrote:*   

> Thanks, worked perfectly.
> 
> Unfortunatly, with every success comes another frustration =)
> 
> I mounted dev into the source/dev directory, chrooted in, and started X, I spent a good ammout of time trying to configure gnome ( desktop, menu's, ect ) , thinking that saving them, and then rebuilding the CD would have them default to the saved settings.  Either I did something wrong, or my idea is just wrong.  Got any advice? 
> ...

 

The above should be done as root, since only his home directory is saved. Hope, you wheren't customizing some other users's settings.  :Smile: 

If you did have root settings customized, then double check that your build script is copying hidden files and folders from '/root'. The bit that does that in the script is 

```
.[[:alnum:]]*
```

 in the tar command.

Good luck

----------

## Cqwense

All hail veezi, creater of the howto, and helper of the newbs.

----------

## veezi

 *Cqwense wrote:*   

> All hail veezi, creater of the howto, and helper of the newbs.

 

 :Laughing:   :Laughing:   :Laughing:   Thanks.

Note: I'm still a n00b at heart   :Cool: 

----------

## skipsargent

I have tried playing around with getting Xorg up and running and have had various degrees of success. My goal is to be able to pop this CD into any of my machines, all with different video hardware, and be able to have a nice XFCE4 session going. Looking through the thread I have seen a couple thoughts on this, and I have tried the mkxorgconf script but it doesn't seem to be even remotely reliable. Has anyone come up with a nice truely flexible solution for this?

----------

## duby2291

I didn't get that script to work either. I just set video device to vesa, and it works, just not with hardware 3d

----------

## chunderbunny

Yeah, Vesa ought to work. Or, you cna play arounf with Xfbdev, the framebuffer implementation of X. It uses a lot less space than Xorg but it's even slower.

----------

## tigerike

 *Match wrote:*   

>  *veezi wrote:*    *Match wrote:*   I'm going to try booting from the partition I've been doing all this on, see if that works. I can't think of anything else. Does anyone have any other ideas? 
> 
> May be your forgot to 'mount -o bind /dev source/dev'. Not really sure.
> 
> Anyway, you can always create the initrd image from outside the chroot environment. It really doesn't make a difference.
> ...

 

I may be totally off base, but it sounds like we are getting the two environments confused here. if you are booted into your normal Linux system, then chrooted into your build fs. when you check /usr/src/linux/.config for the presence of LOOP and for /dev/loop* you are looking at the chrooted system not the base system. In order to mount anything on a loopback, in either your chroot or your base, you have to have loop back in your base kernel. 

You should be able to go to /usr/src/linux in your base system and add loopback support in the xconfig, recompile the modules and insmod cloop. Then you should be able to mount the initrd to loop0.

----------

## skipsargent

Ok so this is what I did for the video. I took that mkxorgconf.sh script and butchered the heck out of it. Since I am planning on using the Vesa drivers all I wanted to do was have proper detection of the monitor. Well it might be ugly but mission accomplished. As soon as I do some more testing on it I will post the script. 

On another note, does anyone know if there is a way to keep the boot cd-rom up and spinning? This is a real pain on a slower laptop and seems to cause problems.

----------

## maserding

Hello, I would just like to add a few suggestions to be put into the howot.

1. You should add the trick of booting into /bin/sh for debugging purposes, just to make it easier so people don't have to search through this whole thread.

2. Make sure to have users run passwd, so they can set the root password before they make an image.

3. I had problems with using udev and devfsd together, so make  your howto choose one or the other. I suggest choosing udev, which in case you need to make sure to emerge unmerge devfsd, and to not compile in support for devfs.

Besides that, it is a GREAT howto!

Thanks!

Jordan Wilberding

----------

## maserding

Also, I saw people had troubles running their images in vmware, I did too for a while, but using udev, and unmerging devfsd and taking support for it out of the kernel fixed my problem. My problem was that /dev/hdc was not reference correctly as the cdrom.

----------

## rommel

first thank you for the howto... its very useful. i have a couple  of issues and was wondering if anyone was having them as well. i started with stage1 and building the iso i am getting this error...

```
 

tmp/.keep

.keep

tar: *: Cannot stat: No such file or directory

.bash_history

.keep

tar: Error exit delayed from previous errors

Creating little endian filesystem on target/files/source.img, block size 65536.
```

it doesnt seem to be effecting anything as the iso works but i am not sure what the error is referring to.

the second thing i noticed is that using "~x86" in make.conf i am not able to emerge grub... it errors with the familiar 

```
...your c compiler cant create executables
```

i used quickpkg and emerge -K to get around this... emerge -e world is able to recompile everything but grub..

this is using gcc-3.4.3. i also receive this error with gcc-config even after sourcing /etc/profile and env-update

```
JaiBaba / # gcc-config -l

 * /usr/bin/gcc-config: Profile does not exist or invalid setting for /etc/env.d/gcc/i686-pc-linux-gnu-3.4.3

[1] i686-pc-linux-gnu-3.3.4

[2] i686-pc-linux-gnu-3.4.3 *

[3] i686-pc-linux-gnu-3.4.3-hardened

[4] i686-pc-linux-gnu-3.4.3-hardenednopie

[5] i686-pc-linux-gnu-3.4.3-hardenednossp
```

possibly related to this bug? #69799....any input would be great... ciao

----------

## loonix

Hello:

I am new to Gentoo (however not new to Linux). I was very ingtrigued by the idea having my own live-cd when I saw this post.

I am in the process of following the how-to and have a couple of questions:

```
1. Be concious with USE variables. The more you use, the bigger your envirnoment will get. It might even be so big that it won't fit on a CD! I use kde only, and don't care about docs and java, so I added the follwoing: '-gnome -gtk -java -doc' 
```

Does this mean I add "USE=-gnome -gtk -java -doc" to my chrooted /etc/make.conf?

```
2. Make sure you add 'livecd' to your USE variables. This, along with a 'cdroot' parameter that we'll pass to the kernel at boot time, will make init scripts aware of the fact that we're booting off a cdrom, so it doesn't do inappropriate things like checking the root filesystem! 
```

I am not really sure how to add 'livecd' and 'cdroot' to the USE variable. Like above would I then add "USE=-gnome -gtk -java -doc livecd cdroot" to my chrooted /etc/make.conf?

Thanks

AR

----------

## frenkel

 *loonix wrote:*   

> 
> 
> I am not really sure how to add 'livecd' and 'cdroot' to the USE variable. Like above would I then add "USE=-gnome -gtk -java -doc livecd cdroot" to my chrooted /etc/make.conf?
> 
> 

 

Short: Yes  :Smile: 

Frank

----------

## veezi

 *loonix wrote:*   

> 
> 
> Does this mean I add "USE=-gnome -gtk -java -doc" to my chrooted /etc/make.conf?
> 
> 

 

Yest that's true.

 *Quote:*   

> I am not really sure how to add 'livecd' and 'cdroot' to the USE variable. Like above would I then add "USE=-gnome -gtk -java -doc livecd cdroot" to my chrooted /etc/make.conf?
> 
> 

 

Not quite. livecd is a USE flag that you should add like you describe. But, cdroot is just a parameter that needs to be passed to the kernel at boot time. Look closely at the grub configuration file in the post, it's there.

----------

## veezi

 *rommel wrote:*   

> first thank you for the howto... its very useful. i have a couple  of issues and was wondering if anyone was having them as well. i started with stage1 and building the iso i am getting this error...
> 
> ```
>  
> 
> ...

 

For 'Can't stat..' error, double check the commands syntax. Especially around [[:alnum:]] bit.

For gcc-3.4, I never really got to test it although I'm interested in switching completely to it.

----------

## veezi

 *maserding wrote:*   

> Also, I saw people had troubles running their images in vmware, I did too for a while, but using udev, and unmerging devfsd and taking support for it out of the kernel fixed my problem. My problem was that /dev/hdc was not reference correctly as the cdrom.

 

Thanks maserding for your nice feedback.  :Very Happy: 

I'll modify it soon.

----------

## gungholady

I'm using this excellent how-to to create my own livecd. When I exit out of chroot and do "umount /proc", I get the following message:

umount: /proc: device is busy

umount: /proc: device is busy

The "umount /usr/portage/distfiles" works just fine. Has anyone else had the problem with not being able to unmount /proc? How did you solve it? The only way I've found so far is to reboot my system. I'd like to find another way if possible.

----------

## rommel

gungholady i think your trying to unmount /proc rather then /livecd/source/proc

----------

## gungholady

 *rommel wrote:*   

> gungholady i think your trying to unmount /proc rather then /livecd/source/proc

 

Thanks, I'll try that.

Edit:

When I try that, here is what I get:

umount: /livecd/source/proc: not found

----------

## rommel

ok well i am not always as clear as i should but was that the directory struc you created for your livecd build. i was logged in as root from an osx machine and followed the howto literally so in /root i have livecd/source in which the directories are located. 

if you mount /proc to the proc in your build dir and then umount it does that work... this would be before chrooting.

```
JaiBaba livecd # mount -o bind /proc/ source/proc/

JaiBaba livecd # 

JaiBaba livecd # umount source/proc/

JaiBaba livecd #
```

if you do this does it work?

----------

## gungholady

I'm following the howto exactly too. I'll have to try the umount source/proc later. I'm chrooted at the moment.

Edit:

That did the trick. That's what I was doing was forgetting to put source in front of /proc when trying to unmount it.Last edited by gungholady on Sat Nov 27, 2004 4:08 am; edited 1 time in total

----------

## neilhwatson

veezi, very informative Howto.  There is something I don't understand.  In your script that creates the iso image:

```

...

mksquashfs source/ target/files/source.img

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size \

4 -boot-info-table -iso-level 4 -hide boot.catalog -o ~/livecd.iso target/ 

```

At this point I'm at the top level directory where there are three sub directories: build, source and target.  The mkisofs command references a sub directory boot at the -b option.  Where is that?

----------

## veezi

 *neilhwatson wrote:*   

> veezi, very informative Howto.  There is something I don't understand.  In your script that creates the iso image:
> 
> ```
> 
> ...
> ...

 

Hi,

'build' is a script, not a directory! 

The build script copies 'boot/' from 'source/' to 'target/'. The mkisofs -b option is always relative to the directory that you're making an iso image of (the last argument). It's 'target/' in this case.

----------

## The_Paya

First of all, thanks for the howto, and second, I've had problems with grub to boot from my SCSI CD-ROM on our servers at work, so looking for an alternative (since grub was always a pain in the *ss for me, I've been using lilo for -way-too-long- time) I've found ISOLINUX (which is the current bootloader of the officials gentoo livecds IIRC), and here is the info to make it work (instead of grub) if someone needs it:

First, emerge the "syslinux" package in your system (it can be installed on the livecd, but it isn't neccesary like grub)

```
# emerge syslinux
```

Next make a directory 'isolinux' in your livecd path, in the same place where the build/work scripts are/usr/lib/syslinux/ found and the source/ target/ directories reside, and copy the generated image 'isolinux.bin' into this directory:

```
# mkdir isolinux

# cp /usr/lib/syslinux/isolinux.bin isolinux/
```

Now you have to copy there your vmlinuz, initrd, the isolinux configuration file and a "message" text file with a "welcome" screen or a boot menu:

```
# cp source/boot/vmlinuz source/boot/initrd isolinux/
```

And my "example" configuration:

isolinux.cfg:

```
DEFAULT gentoo

DISPLAY display.txt

TIMEOUT 100

PROMPT 1

LABEL gentoo

    KERNEL vmlinuz

    APPEND initrd=initrd root=/dev/ram0 rw init=/linuxrc video=vesafb:1024x768-32 

```

Iif you want more options just add another "LABEL" example:

```
LABEL gentoo-nofb

    KERNEL vmlinuz-nofb

    APPEND initrd=initrd root=/dev/ram0 rw init=/linuxrc
```

display.txt:

```

This cd boots my Gentoo LiveCD :+)

```

The next step, is to copy the isolinux directory containing our configuration inside the target/ directory:

```
cp -a isolinux target/
```

And the mkisofs line should look like this:

```
mkisofs -R -b isolinux/isolinux.bin -no-emul-boot -boot-load-size \

4 -boot-info-table -iso-level 4 -hide boot.catalog -o ~/livecd.iso target/
```

Also, I've managed to boot this with gensplash (or fbsplash, aka the gentoo "bootsplash"), using the "inkernel" patched method (putting the initramfs into /usr/src/linux/usr/initramfs_data.cpio). It looks awesome btw :+P

Salu2.

----------

## gungholady

 *veezi wrote:*   

> For X config, there's a script around (I thing it's called makexconfig) that's borrowed from knoppix. It does that.
> 
> However, I personally use a generic X config that uses 'vesa' device. It's guaranteed to work on most PCs.

 

What did you use to create this generic X config? I have looked at the xorg.conf example, I don't understand from looking at the example what changes I need to make so that it will work with most systems.

----------

## gungholady

I used the xorconfig to try to come up with a generic xorg.conf file. I haven't tested it yet to see if it works.

The following error message occurs using the build script:

spool/cron/lastrun/

spool/cron/lastrun/.keep

spool/cups/

spool/cups/tmp/

spool/mail/

spool/mail/.keep

spool/.keep

state/

state/.keep

tmp/

tmp/.keep

.keep

tar: *: Cannot stat: No such file or directory

.bash_history

.gconf/

.gconfd/

.gconfd/saved_state

.gnome/

Is this something that I need to be concerned about? It does go ahead and do the livecd.iso file.

----------

## rommel

no its not a problem... its telling you there is nothing in the root dir to tar up.

----------

## neilhwatson

 *veezi wrote:*   

> 'build' is a script, not a directory!

 

That is correct.  That was a typo.  I'm in a diretory that contains the build script and the directories source and target.  When I run the build scripts I receive this error:

```

Warning: Creating ISO-9660:1999 (version 2) filesystem.

Warning: ISO-9660 filenames longer than 31 may cause buffer overflows in the OS.

mkisofs: Uh oh, I cant find the boot image 'source/boot/grub/stage2_eltorito' !

```

And yet there is the file:

```

valetta livecd # ls -al source/boot/grub/stage2_eltorito

-rw-r--r--  1 root root 105928 Nov 26 16:03 source/boot/grub/stage2_eltorito

```

----------

## veezi

Can you post the build script

----------

## neilhwatson

```
 #!/bin/bash

rm -rf target

mkdir target

cp -a source/boot target/

mkdir target/files

rm -rf source/var/tmp/*

rm -rf source/var/run/*

rm -rf source/var/lock/*

rm -rf source/tmp/*

rm -f source/etc/mtab

touch source/etc/mtab

cd source/etc/

tar cvpf ../../target/files/etc.tar * .[[:alnum:]]*

cd ../var/

tar cvpf ../../target/files/var.tar * .[[:alnum:]]*

cd ../root/

tar cvpf ../../target/files/root.tar * .[[:alnum:]]*

cd ../../

pwd

mksquashfs source/ target/files/source.img

mkisofs -R -b source/boot/grub/stage2_eltorito -no-emul-boot -boot-load-size \

4 -boot-info-table -iso-level 4 -hide boot.catalog -o ~/livecd.iso target/ 

```

----------

## veezi

Use '-b boot/grub/stage2_eltorito' instead of '-b source/boot/grub/stage2_eltorito'

mkiso will append 'target/' to it (that is; the folder you're making an iso image of), and that's where the file should reside (target/boot/grub/stage2_eltorito).

----------

## neilhwatson

Thanks Veezi, I'm getting closer.  Before untaring the stage2 ball in the setup you mention creating the 'newroot' directory in 'source'.  The linuxrc script mounts the source.img file at '/new'.  Where is this directory new?  I could not find it mentioned in your howto.

----------

## veezi

'new' is in the initrd image. 'newroot' is in source folder, it's used to pivot the root (the last few lines in linuxrc script).

Coming to think of it, it's a bit confusing. I should have used names like 'newroot' and 'oldroot' instead of 'newroot' and 'new'.   :Embarassed: 

Good luck

----------

## neilhwatson

My live CD works.  I now have a working router on CD (an alpha version anyway).  I still notice an error at boot:

```

can't open /etc/fstab: input/output error

```

Still the system boots and seems to run fine.  I just don't understand the error.

----------

## frenkel

This error is created by the mount program in the initrd. In the initrd is no fstab needed, but to hide the error you can make an empty one. (just using "touch fstab")

Good luck,

Frank

----------

## veezi

Did anyone figure out how to keep the cd spinning to make it more responsive?

Thanks,

----------

## veezi

I added 'touch etc/fstab' and 'touch etc/mtab' to the initrd building section. This should suppress mount messages.

Also added a small tip about using 'init=/bin/sh' instead of 'init=/linuxrc' for troubleshooting.

I don't think the mini-HowTo should cover any issues related to installing Gentoo since it's just the standard way which is covered everywhere  :Smile: 

Haven't tried GCC 3.4 with this yet. If anyone tried and has some tips to work around errors, please let me know so I can add it.

Any other tips to improve are appreciated.

----------

## rommel

vezzi wrote:

 *Quote:*   

> Haven't tried GCC 3.4 with this yet. If anyone tried and has some tips to work around errors, please let me know so I can add it.

 

seems to be fine... i used nptl in USE and after bootstrap from a stage1 added "~x86" to make.conf and am using gcc-3.4.3 and linux26-headers.... but then i've used "~x86" or "~amd64" on all my boxen since ~arch was created.

the trouble i had earlier with gcc-config was fixed upstream so it should all be ok now.

vezzi i am however having trouble getting past the linuxrc script after recompiling the kernel to add splash... passing init=/bin/sh is failing too. 

the errors are, 

```
linuxrc: line 34: cd: /new/var: No such file or directory

linuxrc: line 35: cd: /new/etc: No such file or directory

linuxrc: line 36: cd: /new/root: No such file or directory

linuxrc: line 41: dev/console: No such file or directory

Kernel panic - not syncing: Attempted to kill init!

```

any clue what i need to do differently after compling a new kernel?

----------

## veezi

Nice to hear that gcc 3.4 is fine. Guess I have to try it  :Very Happy: 

For splash, if it's the old bootsplash you're using, then it should be no problem. Just append the splash image to your initrd (a simple cat).

I haven't tried the newer gensplash from spock (http://dev.gentoo.org/~spock/. But, my understanding is that the initrd image in this case is not just a simple splash, but rather a fs image just like the one we create for the livecd. So, you'd need to figure out how to merge both. More details in spock's web site.

Cheers,

----------

## rommel

well i am using the splashutils pkg since anything after 2.6.7 or 8 no longer uses bootsplash.... but that isnt the problem i am having. it loads the splash image just fine but i get the errors i posted above which result in a kernel panic.. when you recompile your kernel and add a new feature do you recreate the initrd image?

----------

## TanNewt

I had trouble with a 

```
test -s perlmain.c && touch perlmain.c

cd x2p; make depend

make[1]: Entering directory `/var/tmp/portage/libperl-5.8.3/work/perl-5.8.3/x2p'

makefile:157: *** target pattern contains no `%'. Stop.

make[1]: Leaving directory `/var/tmp/portage/libperl-5.8.3/work/perl-5.8.3/x2p'

make: *** [depend] Error 2 
```

 error while doing this with a 2004.3 stage 2 tarball.

The solution was to 

```
cd livecd/source

mount -o bind /dev dev
```

before chrooting.  I hope that helps others.

----------

## BodOrange

This is my first attempt at creating a livecd.  I have two problems so far.  One is compiling acx100 drivers whilst in the chroot environment but first is booting the livecd.  I'm testing using vmware using the livecd.iso as a virtual cdrom.  After selecting the entry in grub menu, I get

```
Error 2: Bad file or directory type
```

My grub.conf

```
default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title Gentoo Linux

        root (cd)

        kernel (cd)/boot/vmlinuz root=/dev/ram0 rw init=/linuxrc cdroot

        initrd (cd)/boot/initrd

```

I think the initrd is ok.  I can mount it ok and check the contents at any rate.  I have default ramdisk size as 8192 in the kernel config and initrd is 8MB and is 2.5MB full when mounted.

Any idea what I need to check?

Thanks for any help.

[EDIT]

I had symlinked vmlinuz to the kernel in boot.  Having specified the actual kernel rather than the symlink, it now works.

----------

## TanNewt

I'm having trouble with booting the cd.  It gives me an error saying that dev/console is read-only and then a kernel panic saying its not syncing and attempted to kill init.

Any advice would be greatly appreciated.

----------

## Gatta

What percentage of system RAM should the ramdisks (the four 32MB ones) be?

How much does SquashFS compress the system by (aka-how large can the livecd/ directory be)?

What modifications do you need to make a LiveDVD (if you can)? Just change iso9660 support to DVD support?

----------

## blixel

Would this method work for a CD I want to create ... I want to create a super small CD that just contains DHCP and TFTP.  I don't want X, I don't want portage, I don't want cd burners, music players, text based browsers, gui anything, etc... 

I just want a bootable DHCP+TFTP server that also has a directory for some other files I need.  I have some headless (no video card, keyboard, or mouse), embedded computers that can only boot via the network for their initial setup.  Once they are setup, they boot from their own internal media.  I only need to set one of these boxes up every now and then so I don't really want to have an extra DHCP and TFTP server running on my Desktop.

It would be awesome to have a CD that I could just stick in my laptop, and then use a cross over network cable to the embedded box so I could boot it up and install the image files.

But in following your directions, the first thing I notice is the enormity of the build directory.  I don't see a point in the instructions where I create an empty /mnt/mydistro directory tree, and then populate it with only the stuff I want.

I don't mind starting with a 5 or 10 megabyte base system that gives me a sane starting point.  Such as common /bin and /sbin files the necessary /libs and other files to go along with them.   And then from there I add the DHCP server and TFTP server.

But I don't want to start with a multi gigabyte "build" system and then cut out what I don't need.  That would take forever.

Am I barking up the wrong tree with these directions?  Should I look elsewhere?

Also, while attempting to follow your directions anyway ... hoping that I would get to a point of understanding where I could then adapt your directions to fit my own needs ... I run into this problem when I do an emerge system.

```
Finding dependencies for perlmain.o.

make[1]: Entering directory `/var/tmp/portage/libperl-5.8.4-r1/work/perl-5.8.4'

echo Makefile.SH cflags.SH config_h.SH makeaperl.SH makedepend.SH makedir.SH myconfig.SH writemain.SH pod/Makefile.SH | tr ' ' '\n' >.shlist

make[1]: Leaving directory `/var/tmp/portage/libperl-5.8.4-r1/work/perl-5.8.4'

Updating makefile...

test -s perlmain.c && touch perlmain.c

cd x2p; make depend

make[1]: Entering directory `/var/tmp/portage/libperl-5.8.4-r1/work/perl-5.8.4/x2p'

makefile:157: *** target pattern contains no `%'.  Stop.

make[1]: Leaving directory `/var/tmp/portage/libperl-5.8.4-r1/work/perl-5.8.4/x2p'

make: *** [depend] Error 2

!!! ERROR: sys-devel/libperl-5.8.4-r1 failed.

!!! Function src_compile, Line 218, Exitcode 2

!!! Couldn't make libperl.so depends

!!! If you need support, post the topmost build error, NOT this status message.
```

----------

## hielvc

Count up 4 post before yours blixel for the libperl fix  :Wink: 

----------

## blixel

 *hielvc wrote:*   

> Count up 4 post before yours blixel for the libperl fix 

 

did that ... more errors followed ... bah ... I don't think this is what I'm looking for.  It just has a weird vibe about it.  For what I want, this howto feels like I'm trying to repair a loose shingle on my roof by tearing the house down and building a 10 story hotel in its place.  Overkill.

----------

## _SkeLeToN_

Hi,

I'm in the proces of making a livecd using this nice howto.    What I'm trying to do is more a maintenance livecd  and I need to have the auto-probing hardware like knoppix or Gentoo livecd.

I searched gentoo forum but didn't found what I was looking for.   I looked at detect for hardware probing but the on in portage segfault when I try running it ...  

Anyone can point me out where I could have more info ?

----------

## veezi

 *_SkeLeToN_ wrote:*   

> Hi,
> 
> I'm in the proces of making a livecd using this nice howto.    What I'm trying to do is more a maintenance livecd  and I need to have the auto-probing hardware like knoppix or Gentoo livecd.
> 
> I searched gentoo forum but didn't found what I was looking for.   I looked at detect for hardware probing but the on in portage segfault when I try running it ...  
> ...

 

You could start with the initrd image used in Gentoo's LiveCD. Look at the scripts inside it. You might find something useful.

----------

## veezi

 *blixel wrote:*   

>  *hielvc wrote:*   Count up 4 post before yours blixel for the libperl fix  
> 
> did that ... more errors followed ... bah ... I don't think this is what I'm looking for.  It just has a weird vibe about it.  For what I want, this howto feels like I'm trying to repair a loose shingle on my roof by tearing the house down and building a 10 story hotel in its place.  Overkill.

 

You might find Dman Small Linux (DSL) usefull http://www.damnsmalllinux.org.

----------

## skipsargent

 *_SkeLeToN_ wrote:*   

> Hi,
> 
> I'm in the proces of making a livecd using this nice howto.    What I'm trying to do is more a maintenance livecd  and I need to have the auto-probing hardware like knoppix or Gentoo livecd.
> 
> I searched gentoo forum but didn't found what I was looking for.   I looked at detect for hardware probing but the on in portage segfault when I try running it ...  
> ...

 

Try using Coldplug for your hardware detection. For detecting things like your monitor and video take a look at the ddcxinfo-knoppix package.

----------

## videoman

Hi,

I have created a bootable CD based on these instructions.

I can't get framebuffers to work.

I can get a splashscreen, but I can't seem to set a videomode.

I tried adding

vga= (various modes)

and

video= (various settings)

to the end of the kernel line

but no matter what I put  the setting seems to be ignored.

Any ideas?

thanks

----------

## BodOrange

I'm trying to build a livecd image and all works fine apart from when I try to build acx100 drivers.  I can build these when booted up in the livecd but want to build them in the chroot environment.

The kernel on the system on which I am creating the livecd is different to the one I have chosen for the livecd. Whilst chrooted in the livecd directory, when I try to compile the acx100 module I get the warning about kernel source not matching the running kernel, so the prebuild checks and compile won't work. How would I make the acx100 build use the livecd kernel config? 

Thanks for any help.

----------

## Kampi

to build the bin and lib directory for the initrd, is use the following script, because finding the libs is painstaking. its a bit dirty, but it works for me. in the chroot environment:

```

#!/bin/sh

for x in sh ls cat mount umount mkdir chroot tar

do

   cp -v /bin/${x} /mnt/initrd/bin

done

cp -v /sbin/pivot_root /mnt/initrd/bin

cd /lib

for x in sh ls cat mount umount mkdir chroot tar

do

   cp -v `ldd /bin/${x}|egrep lib|cut -d "=" -f1` /mnt/initrd/lib

done

cp -v `ldd /sbin/pivot_root|egrep lib|cut -d "=" -f1` /mnt/initrd/lib

```

----------

## vibidoo

Hello and thanks to Veezi .

That's a very good job you done   :Razz: 

Well I sucess to build an image and boot on it , but durçing the boot process I get this error  : 

```

RAMDISK : Could'nt find calid RAM disk image Starting at 0 

freeing initrd 8192 K freed

Kernel panic : VFS Unable to mount root fs on 01:00

```

And the unit hang .

Could somebody give me some advises ? 

my grub 

```

default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Boot CD Linux-2.4.26

root (cd)

kernel (cd)/boot/vmlinuz video=vesafb:800x600-16 root=/dev/ram0 rw init=/linuxrc cdroot

initrd (cd)/boot/initrd

```

----------

## veezi

 *vibidoo wrote:*   

> Hello and thanks to Veezi .
> 
> That's a very good job you done  
> 
> Well I sucess to build an image and boot on it , but durçing the boot process I get this error  : 
> ...

 

Check your initrd image. Mount it on a loop device just to make sure it works. Check it's size (your kernel has a max 8MB initrd size set). Check that its filesystem type (ext2 in the howto) is compiled in your kernel (The one you boot the CD with).

----------

## vibidoo

Hello Veezi 

and thanks for your help for this new year   :Laughing: 

Well I have done modification .

That resolve somme issue but other issue are comming .

Now on boot I get : 

```

RAMDISK : ext2 filesystem found at block 0

RAMDISK : Loading 8192 blocks [1 disk] into ramdisk... done

Freeing initrd memory : 8192 freed 

VFS: Mounted root (ext2 filesystem)

freeing unused Kernel memory : 112k freed

Kernel panic : No init found try passing init= option to kernel .

```

I have mount the initrd file in a loop device : 

```

ls /mnt/loop0 -l

total 21

drwxr-xr-x    2 root     root         1024 Dec 29 22:15 bin

drwxr-xr-x    2 root     root         1024 Dec 29 22:03 cdrom

drwxr-xr-x    2 root     root         1024 Dec 29 22:18 dev

drwxr-xr-x    2 root     root         1024 Dec 29 22:03 etc

drwxr-xr-x    2 root     root         1024 Dec 29 22:12 lib

-rwxr-xr-x    1 root     root         1072 Dec 29 22:20 linuxrc

drwx------    2 root     root        12288 Dec 29 22:01 lost+found

drwxr-xr-x    2 root     root         1024 Dec 29 22:03 new

drwxr-xr-x    2 root     root         1024 Dec 29 22:03 proc

```

 :Confused:  [/code]

----------

## vibidoo

I have success to boot completely   :Cool: 

But I had to modify the initrd script : 

```

#!/bin/sh 

export PATH=/bin 

# Get kernel CMDLINE 

mount -t proc none /proc 

CMDLINE=`cat /proc/cmdline` 

umount /proc 

# Mount CD device 

##CDROM="" 

##for x in hda hdb hdc hdd 

##do 

mount -t iso9660 -r /dev/hdc /cdrom > /dev/null 2>&1 

##if [ "$?" = "0" ] 

 ##then 

##CDROM="${x}"

   ## break

  ##fi

##done 

# CD not found

##if [ "${CDROM}" == "" ]

##then

 ## exec /bin/sh

  ##exit

##fi

# Mount root and create read-write directories

mount -t squashfs -o loop /cdrom/files/source.img /new > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/var > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/etc > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/tmp > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/root > /dev/null 2>&1

cd /new/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /new/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /new/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

# Pivot root and start real init

cd /new

pivot_root . newroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}

EOF 

```

Don't know why but I have two unit and with the original initrd script I can not boot to the end

----------

## stahlsau

Hi,

first of all: thanks for the howto, i know it´s been a lot of work.

second: mmh...it doesn´t work for me  :Sad: 

when booting off the iso, it says

```
Uncompressing Linux..Ok, booting the kernel.

Blink Blink Blink...
```

and then there was silence.

I recompiled the kernel, checking all option and removing unnecassary ones, tried /bin/sh instead of linuxrc, edited the grub-boot-lines in all possible ways, no go.

Anyone an idea?

----------

## s4kk3

I'm not sure if this have been asked before in this thread. I was too lazy to read whole topic but..

Succesfully managed to make image and burn it. When I try to boot it gives a error. It says something about iso9660+something else and after that "Bad file or directory type". If you need I can post full error message.

----------

## AAAle

Hello all

Finally i got my first livecd works in all the ways but i need a little help for finish it.

I emerge hwdata-knoppix and kudzu-knoppix for making the hw detection work but it doesn't start at boot.

Was anyone able to make it work?

thanks a lot at all and to this beautifull How-to.

***SOLVED***

while i am in chroot do a: rc-update add autoconfig defaultLast edited by AAAle on Sat Jan 15, 2005 2:23 pm; edited 1 time in total

----------

## chup

Please help.... My cd does boot, but i get thrown in a very limited bash shell. I cannot login or anything. It stops booting right after starting devfs. I get no errors at all, just that lame bash shell...   :Sad: 

Hmm, it seems that the cd is just booting initrd, and not the whole cd  :Sad: 

Any help would be appreciated  :Wink: 

I think I know what's the problem: when I execute the build script, I get this error:

tar: *: Cannot stat: No such file or directory

I'm guessing that's why I get the bash shell, since something else isn't on the cdrom.

Any idea on how to fix it?

//edit: changed the tar commands, the tars are now on the cd but still the same  :Sad: 

----------

## invalid account

Chup

I had a similar problem till I spotted that I had compiled squashfs as a module and not directly into the kernel. 

The result of this was that the .img file was not mounted, but all errors were being sent to /dev/null so I didn't notice.

A simple mistake as the other options I used only required one tap of the keyboard in menuconfig  :Smile: 

Neil

----------

## chup

Do you mean compiled as a module on the live cd? I just checked the config, and it's compiled in, not as a module  :Sad: 

//edit: never mind, I think you mean just my base system which I'm running my comp on. I'll compile squashfs into the kernel and retry  :Very Happy:  Thanks!

//edit2: Tried that, still no luck  :Sad: 

//edit3: Yes, another edit  :Wink:  I think my problem is that the script doesn't find the cdrom, and therefor starts /bin/sh. I'm going to try to just put the cdrom at /dev/hdd as it is under my 'normal'  Gentoo installation, and check the outcome of that  :Smile: 

//edit4:  :Razz:  That has to be the problem, since when I remove the "if cd not found -> init=/bin/sh" I get a kernel panic stating no init found. Now I'm going to have a great time changing the drive letter, making a iso, booting it, etc etc...

----------

## invalid account

I did mean that livecd kernel should have squashfs compiled in.

You don't need to keep making iso' s to check this, during boot at the grub window, press 'e' to edit then change

```

init=/linuxrc

```

to 

```

init=/bin/sh

```

then carry out the linuxrc script command by hand. Then you can see what is going on.

You could also change the linuxrc command to see what mount is doing:

```

mount -t iso9660 -r /dev/${x} /cdrom > /dev/null 2>&1

```

to 

```

mount -t iso9660 -r /dev/${x} /cdrom

```

----------

## AAAle

is there a way to get /home/ writable ?

I did that:

 *Quote:*   

> root@Alien livecd # ./work
> 
>            Alien / # useradd gendem -m -G users,wheel,audio -s /bin/bash        
> 
>            Alien / # passwd gendem

 

then i emerge all packages that i wanted, kde too.

when i boot livecd and i try to start kde from gendem user, it doesn't start because gendem don't have permission to write in /home/gendem.

AAAle

----------

## invalid account

Great how to! I have used this with much more success than catalyst so far.

AAAle: add a new line to the linuxrc script to create a new temp fs mount

mount -t tmpfs none /new/home

I have tried to use busybox within initd, but the mount command does not seem to work  :Sad: 

To make the process easier to manage I have make myself a script for the job, I am posting it in case it is of anyuse to someone:

```

#!/bin/sh

SOURCE="livecd_src"

BUILD="build"

STAGE="stage2-x86-2004.3.tar.bz2"

SNAPSHOT="portage-20041022.tar.bz2"

ISO="livecd.iso"

LIVEUSE="livecd cdr"

TIMEZONE="GB"

PACKAGES="metalog vixie-cron slocate dhcpcd udev hotplug coldplug udev openssh"

KERNELPACKAGES="pcmcia-cs"

RCBOOT="coldplug hotplug hostname"

RCDEFAULT="domainname metalog vixie-cron sshd net.eth0"

KERNELRCBOOT=""

KERNELRCDEFAULT="pcmcia"

KERNEL="gentoo-dev-sources"

HOSTNAME="livecd"

CDSEARCH="hda hdb hdc hdd"

OVERLAYSEARCH="hda hdb hdc hdd"

NAME=`basename $0`

## print mesage and exit

die()

{

    echo $1

    exit

}

## prepare the chroot

prep_chroot()

{

mkdir -p $SOURCE/usr/portage/distfiles

mount -o bind /proc $SOURCE/proc

mount -o bind /sys $SOURCE/sys

mount -o bind /dev $SOURCE/dev

mount -o bind /dev/pts $SOURCE/dev/pts

mount -o bind /usr/portage/distfiles $SOURCE/usr/portage/distfiles

cp $0 $SOURCE/tmp

}

## clean the chroot

clean_chroot()

{

rm -rf source/tmp/*

umount $SOURCE/proc

umount $SOURCE/sys

umount $SOURCE/dev/pts

umount $SOURCE/dev

umount $SOURCE/usr/portage/distfiles 

}

## set the environment

set_env()

{

env-update

source /etc/profile

}

## run chroot commands on this script

chroot_livecd()

{

prep_chroot

chroot $SOURCE /tmp/$NAME set_env $@

clean_chroot

}

## login command

bash_login()

{

/bin/bash --login

}

## sync command

emerge_sync()

{

emerge sync

}

## emerge system command

emerge_system()

{

emerge system

emerge baselayout

}

## set local time

local_time()

{

ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime || die "Failed to link localtime"

}

## emerge packages

emerge_packages()

{

emerge $PACKAGES

}

## emerge kernel packages

emerge_kernel_packages()

{

emerge $KERNELPACKAGES

}

## update the use flags

mk_make()

{

if [ -e /etc/make.conf.bak ]

then

    cp /etc/make.conf.bak /etc/make.conf

else

    cp /etc/make.conf /etc/make.conf.bak

fi

echo "

## added by livecd script

USE=\"$LIVEUSE\"

" >> /etc/make.conf

}

## run the rc-updates

rc_update()

{

for R in $RCBOOT

do

   rc-update add $R boot || die "Failed rc-update"

done

for R in $RCDEFAULT

do

   rc-update add $R default || die "Failed rc-update"

done

}

## run the post kernel rc-updates

kernel_rc_update()

{

for R in $KERNELRCBOOT

do

   rc-update add $R boot || die "Failed rc-update"

done

for R in $KERNELRCDEFAULT

do

   rc-update add $R default || die "Failed rc-update"

done

}

## build the kernel

build_kernel()

{

emerge $KERNEL

cd /usr/src/linux || die "Failed to cd to the kernel build directory"

kernel_req

make menuconfig || die "Failed to run menuconfig"

make || die "Failed to run kernel make"

make modules_install || die "Failed to run make modules_install"

cp arch/i386/boot/bzImage /boot/vmlinuz || die "Failed to copy kernel"

emerge_kernel_packages

kernel_rc_update

}

## install grub

install_grub()

{

echo "** Using unstable grub version **"

ACCEPT_KEYWORDS="~x86" emerge grub || die "Failed to emerge grub"

echo "

default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Gentoo Linux

        root (cd)

        kernel (cd)/boot/vmlinuz root=/dev/ram0 rw init=/linuxrc cdroot

        initrd (cd)/boot/initrd

" > /boot/grub/grub.conf

}

build_initrd()

{

dd if=/dev/zero of=/boot/initrd bs=1024k count=8 || die "Failed to make initrd file"

mke2fs -Fv /boot/initrd || die "Failed to format initrd with ext2"

mkdir -p /mnt/initrd

mount -o loop /boot/initrd /mnt/initrd || die "Failed to mount initrd"

cd /mnt/initrd

mkdir etc dev lib bin proc new cdrom

touch etc/mtab

touch etc/fstab

cd /

## populate the bin directory

BINS="more rmdir sh cat mount umount mkdir chroot tar ls gzip ../sbin/pivot_root"

for BIN in $BINS

do

  cp /bin/$BIN /mnt/initrd/bin 

  LIB=`ldd /bin/$BIN | grep "=>" | grep -v "linux-gate.so.1" | awk '{print $3}'`

  cp -f $LIB /mnt/initrd/lib/

done

mknod /mnt/initrd/dev/console c 5 1

mknod /mnt/initrd/dev/null c 1 3

mknod /mnt/initrd/dev/hda b 3 0

mknod /mnt/initrd/dev/hdb b 3 64

mknod /mnt/initrd/dev/hdc b 22 0

mknod /mnt/initrd/dev/hdd b 22 64

mknod /mnt/initrd/dev/tty c 4 0

mknod /mnt/initrd/dev/loop0 b 7 0

echo "#!/bin/sh

export PATH=/bin

echo \"Starting initrd...\"

# Get kernel CMDLINE

mount -t proc none /proc

CMDLINE=\`cat /proc/cmdline\`

umount /proc

# Mount CD device

CDROM=\"\"

for x in $CDSEARCH

do

  mount -t iso9660 -r /dev/\${x} /cdrom > /dev/null 2>&1

  if [ \"\$?\" = \"0\" ]

  then

    CDROM=\"\${x}\"

    break

  fi

done

# CD not found

if [ -z \"\${CDROM}\" ]

then

  exec /bin/sh

  exit

fi

echo \"CDROM found on: /dev/\${CDROM}\"

echo \"Mount root and create RAM directories...\"

mount -t squashfs -o loop /cdrom/files/source.img /new

mount -t tmpfs  none /new/var 

mount -t tmpfs  none /new/etc 

mount -t tmpfs  none /new/tmp 

mount -t tmpfs  none /new/root 

mount -t tmpfs  none /new/mnt

cd /new/var && tar zxpf /cdrom/files/var.tar.gz

cd /new/etc && tar zxpf /cdrom/files/etc.tar.gz

cd /new/root && tar zxpf /cdrom/files/root.tar.gz

echo \"Looking for overlay...\"

cd /new

mkdir /new/mnt/over

for x in $OVERLAYSEARCH

do

  mount /dev/\${x} /new/mnt/over > /dev/null 2>&1

  if [ \"\$?\" == \"0\" ]

  then

    if [ -e /new/mnt/over/overlay.tar.gz ]

    then

      echo \"Found overlay on /dev/\${x}\...\"

      tar zxf /new/mnt/over/overlay.tar.gz

    fi

    umount /new/mnt/over

  fi

done

rmdir /new/mnt/over

echo \"Pivot root...\"

cd /new

pivot_root . newroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

echo "In new chroot..."

exec /sbin/init \${CMDLINE}

EOF

" > /mnt/initrd/linuxrc

chmod +x /mnt/initrd/linuxrc

cd /

umount /mnt/initrd || die "Failed to unmount initrd loop device"

}

## prepare the file system

prep_fs()

{

cd /var

mv -f cache db /usr/lib/portage/

ln -s /usr/lib/portage/cache cache

ln -s /usr/lib/portage/db db

cd /lib

mv -f udev-state /var/lib

ln -s /var/lib/udev-state udev-state

echo $HOSTNAME > /etc/hostname

echo "root:" | chpasswd -e

if [ ! -e /etc/conf.d/net.bak ]

then

cp /etc/conf.d/net /etc/conf.d/net.bak

fi

echo "

iface_eth0=\"dhcp\"

dhcpcd_eth0=\"-h $HOSTNAME\"

" > /etc/conf.d/net

}

################

## user commands

################

chroot_sh()

{

chroot_livecd bash_login

}

mk_source()

{

rm -rf $SOURCE

mkdir -p $SOURCE

if [ ! -e $STAGE ]

then

   echo "Download stage...[Enter to continue]" && read r

   links http://www.gentoo.org/main/en/mirrors.xml

fi

if [ ! -e $SNAPSHOT ]

then

   echo "Download snapshot...[Enter to continue]" && read r

   links http://www.gentoo.org/main/en/mirrors.xml

fi

tar jxvpf $STAGE -C $SOURCE || die "Failed to extract stage"

tar jxvpf $SNAPSHOT -C $SOURCE/usr || die "Failed to extract snapshot"

mkdir -p $SOURCE/newroot

}

resolv()

{

if [ ! -e $SOURCE/etc/resolv.conf ]

then

   cp /etc/resolv.conf $SOURCE/etc/

fi

}

emu()

{

qemu -cdrom $ISO -boot c

}

sync()

{

chroot_livecd emerge_sync || die "Failed to emerge sync"

}

set_use()

{

chroot_livecd mk_make

}

system()

{

chroot_livecd emerge_system

chroot_livecd local_time

echo "

/dev/loop0 /        squashfs ro,defaults 0 0

none       /proc    proc     defaults    0 0

none       /dev/shm tmpfs    defaults    0 0

none       /dev/pts devpts   defaults    0 0

" > $SOURCE/etc/fstab

}

packages()

{

chroot_livecd emerge_packages rc_update

}

kernel()

{

chroot_livecd build_kernel

}

kernel_req()

{

echo "

Kernel Settings (2.6)

=====================

Code maturity level options --->

  [*] Prompt for development and/or incomplete code/drivers

General setup --->

  [*] Kernel .config support

  [*]   Enable access to .config through /proc/config.gz 

Device Drivers  --->

  Block devices  --->

    <*> Loopback device support

    <*> RAM disk support

    (8192) Default RAM disk size (kbytes)

    [*]   Initial RAM disk (initrd) support

File systems --->

  Pseudo Filesystems --->

    [*] /dev file system support (OBSOLETE)

  Miscellaneous filesystems --->

    <*> SquashFS 2.0 - Squashed file system support

 " | less

}

grub()

{

chroot_livecd install_grub

}

initrd()

{

chroot_livecd build_initrd

}

prep()

{

chroot_livecd prep_fs

}

iso()

{

rm -rf $BUILD

mkdir $BUILD

cp -a $SOURCE/boot $BUILD/

mkdir $BUILD/files

rm -rf $SOURCE/var/tmp/*

rm -rf $SOURCE/var/run/*

rm -rf $SOURCE/var/lock/*

rm -rf $SOURCE/tmp/*

rm -f $SOURCE/etc/mtab

touch $SOURCE/etc/mtab

cp $0 $SOURCE/sbin/

cd $SOURCE/etc/

tar zcvpf ../../$BUILD/files/etc.tar.gz * .[[:alnum:]]*

cd ../var/

tar zcvpf ../../$BUILD/files/var.tar.gz * .[[:alnum:]]*

cd ../root/

tar zcvpf ../../$BUILD/files/root.tar.gz * .[[:alnum:]]*

cd ../../

mksquashfs $SOURCE/ $BUILD/files/source.img -e usr/src usr/portage || die "Failed to build squashfs"

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 \

-boot-info-table -iso-level 4 -hide boot.catalog -o $ISO $BUILD/ || die "Failed to make iso"

}

###################

## command handling

###################

if [ "$#" == "0" ]

   then

   echo "Usage: $NAME [command]

   commands:

   chroot_sh   chroot into the livecd.

   mk_source   make a clean SOURCE directory with the given STAGE

         and SNAPSHOT.

   resolv      make sure the SOURCE has a resolv.conf file

   sync      run emerge sync in the SOURCE.

   set_use      build the make.conf file with the LIVEUSE flags.

   system      build the system.

   packages   build the PACKAGES.

   kernel_req   list the kernel requirements.

      kernel      build the KERNEL.

   grub      install grub.

      initrd      build the initrd.

      prep      prepare the file system.

      iso      build the ISO file.

   emu      run qemu for the ISO file.

   To build a live cd from scratch run:

     $NAME mk_source resolv sync set_use system packages kernel grub initrd prep iso

   script variables:

   SOURCE      the source directory for building the livecd ($SOURCE)

   BUILD      the build directory ($BUILD)

   STAGE      the initial state tarball ($STAGE)

   ISO      the iso name ($ISO)

   SNAPSHOT   the portage snapshot to use ($SNAPSHOT)

   LIVEUSE      the livecd use flags ($LIVEUSE)

   TIMEZONE   the local time zone setting ($TIMEZONE)

   PACKAGES   the system packages to install ($PACKAGES)

   RCBOOT      the rc boot additions ($RCBOOT)

   RCDEFAULT   the rc default additions ($RCDEFAULT)

   KERNEL      the kernel source ($KERNEL)

   KERNELPACKAGES  the post kernel packages ($KERNELPACKAGES)

   KERNELRCBOOT   the post kernel rc boot additions ($KERNELRCBOOT)

   KERNELRCDEFAULT   the post kernel rc default additions ($KERNELRCDEFAULT)

   CDSEARCH   the devices to search for the boot cd from initrd ($CDSEARCH)

   OVERLAYSEARCH   the devices to search for the overlay file from initrd ($OVERLAYSEARCH)

"

fi

for CMD in $@

do

   echo "Running '$CMD'..."

   $CMD

done

```

Cheers

Neil

----------

## GentooBox

Thanks for the howto

Is there a way to choose a keymap on bootup ?

----------

## invalid account

You could alter the initrd script, to read a kernel argument or prompt for an option, and then ammend the rc.conf file in the new root.

----------

## platojones

This is fantastic!  I have a question though.  Is it strictly necessary to download the portage snapshot, or could I just mount my sytem's portage tree the way it was done with the portage/distfiles directory?  It seems a shame to waste all that space with an entirely seperate portage tree, when I have one of my system that 100% up to date and fully populated.  Is there some danger of corrupting or changing the state of my system portage tree by doing this?

Thanks Again!

----------

## invalid account

platojones,

Sorry, I'm not sure if there could be difficulties with a shared protage tree, though you can share the portage/distfiles directory fine. My approach however is that if the cd root has it's own portage tree, then I don't need to keep the host machines tree in sync with the cd root. 

Neil

----------

## ZeroSkunk

Hey pinguins and cows

first I have to say that this thread is one of the best I've seen in hear *g*, but I have a small problem! I think the grub eltorito patch is not working on all systems!!

I've made some X-live-CDs for testing on different systems, but the grub loads only on newer DESKTOP-SYSTEMS!!

My laptop doesn't like this bootloader, I think there's any memory problem with some BIOSs. So I figured out that there is a fantastic methode to boot those nice little LIVE-CDs.

I don't realy know the name of this tools which gentoo-live-cds are working with, but I want to try working with the gentoo-pinguins rocking INITRDs ect.

The folders say anything about ISOLINUX, and there are some nice .cfg files which look a little bit like lilo configs.

So my question! Is anybody out there working with this boot methode?? The only thing I found is a slackware way, but I'm not getting realy intelligent out of this!   :Rolling Eyes: 

http://www.linuxpackages.net/howto.php?page=livecd&title=livecd+HOWTO

 :Question:  Daniel  :Question: 

----------

## flickerfly

Thanks for this guide!

What's the version of grub needed to make this work (i.e. with CD boot support)? Is it still masked? Also, the guide uses the outdated way of 

emerging masked packages.

Any reason I can't just bind the entire /usr/portage tree and not just /usr/portage distfiles?

----------

## platojones

Hi invalid account,

   Sorry this took so long, but my job keeps interfering with my life!  Anyway, thank you for the nifty script and the reply.  I'm a little queazy about messing with my system portage since I've got my machine working like a "machine", so I'll do some more research before I risk that.  Better safe than sorry.  

   This is a great thread and your script provided a terrific starting place for me to get a viable iso burned.  I've got a working livecd right now with everything I need to restore my backups.  Life is good!

   It has a minor glitch or two and I'm working to iron those out with a few customizations of that super handy script you wrote.  But no matter what, I sleep a lot better at night now that I know I can completely restore my system with minimum fuss if the HD dies on me.  

   Call me nuts, but this stuff is fun, especially when it works.

Thanks again,

Richard

----------

## platojones

flickerfly,

   Yes the grub version you need is still masked as ~x86.  The version you need is 0.95.  Make sure you are in the livecd chroot environment before you emerge it.  I don't think it's considered stable enough for day to day use just yet.  Works great so far on the live cd though.

  Just use /etc/portage.keywords in the chroot environment if you don't want to use the deprecated method.  If you use Niell's very handy script posted above, you just use the 'livecdscript chroot_sh' command to go into the chroot environment, and you are running inside the the livecd as if it were a different and completely seperate box.  You can emerge --sync, update files and do anything you can do on your normal system completely safe in the livecd.  I love it.

----------

## platojones

ZeroSkunk,

   I don't have any answers for you at this point, but I'm about to travel the same road you are on very soon.  Now that I have my desktop 'rescue' ISO ready to go, I've got an old gentoo laptop, which I use as my broadband router, that I'm going to try this on next.  It's an old Dell Inspiron 5000e, so I'll find out soon enough if the unstable grub is up to the job.  I'll post my results here for you and others to see.

Richard

----------

## Match

 *tigerike wrote:*   

>  *Match wrote:*   
> 
> I didn't mount /dev to source/dev because it's not in your guide, but I tried it now and it still doesn't work 
> 
> Also, even if I did make the initrd image outside of the chroot, if I can't do this step then surely nothing's going to work anyway?
> ...

 

You know, I really should have kept on reading this thread. Then it wouldn't be now (in January) that I just figured this out for myself - I could have just read your reply back in November. I feel reasonably stupid now. Thankyou for your help, and I'm sorry I didn't respond sooner!

----------

## Match

...and now I'm stuck again, but I've got so far! This is a fantastic tutorial, I can't believe I've got this far  :Smile: 

I boot my LiveCD and I get Grub which is fine. I then get a load of text on the screen like a normal boot-up for me, except I then get an error message.

```
VFS: Mounted root (ext2 filesystem)

Freeing unused kernel memory: 184k freed

cdroot: cdroot: No such file or directory

Kernel panic - not syncing: Attempted to kill init!
```

Any ideas what could be wrong?

Edit: just in case, here's my grub.conf:

```
default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Gentoo Linux

root (cd)

kernel (cd)/boot/kernel root=/dev/ram0 rw init=/linuxrc cdroot

initrd (cd)/boot/initrd

```

It's probably to do with the cdroot parameter, I get that much: but the tutorial says to put it there. Not sure what's going on  :Sad: 

----------

## flickerfly

 *Match wrote:*   

> 
> 
> ```
> VFS: Mounted root (ext2 filesystem)
> 
> ...

 

That is a pretty standard kernel panic. You can probably find some stuff about it via google. In the past I have gotten this error related to either modulatizing or not building something related to the filesystem such as RAID drivers or fs type drivers. Having not done this myself yet, I can't comment on this in relation to chroot or squashfs.

----------

## Match

Google gives me nothing much, and the kernel definitely* contains squashfs  :Sad: 

*Experience has taught me never to say definitely, but cat .config | grep SQUASH gives me one value that's definitely a y...

----------

## platojones

I was getting that too, but it was the framebuffer stuff in my boot opts that was causing it.  Have a really close look at your linuxrc.  That panic is at the transition from the initrd to the cdrom environment.  Also, did you put the 'livecd' USE variable in your make.conf before you built you packages for your livecd?  Remember, that you can pass 'init=/bin/sh' on the boot loader config line from the gentoo splash screen.  That will drop you into a basic shell where the linuxrc was being booted before.  That is great for debugging.

----------

## invalid account

Match,

I have also seen this when there is a problem with linuxrc itself. Grub seems to try to run linuxrc, fails then tries to run cdrom. Is linuxrc executable and available in the initrd? I think the best way to start with this is to use init=/bin/sh as platojones suggests. If this doesn't work make sure /bin/sh and the needed libs are avaliable, as if this is missing you can get the same problem with grub trying to run cdrom.

Also if you do try adding init=/bin/sh place it after cdrom:

```

... cdrom init=/bin/sh

```

Neil

----------

## lothar

Excellent guide  :Smile:  I was having some problems at first, but I just read the whole thread and the solutions where right there..

Thanks

Edit: Still got one problem.. Im using this livecd to make a mp3player, the computer boots, mounts an nfs filesystem and starts mpg123.. but theres no sound and mpg123 freezes..

The output from mpg123 looks like this:

```

High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3.

Version 0.59s-r9 (2000/Oct/27). Written and copyrights by Michael Hipp.

Uses code from various people. See 'README' for more!

THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!

Title  : kake                          Artist: skrell

Album  :                                 Year  : 2002

Comment:                                 Genre : Other

Playing MPEG stream from xx - xx.mp3 ...

Found new ID3 Header

MPEG 1.0 layer III, 128 kbit/s, 44100 Hz stereo

```

So It looks normal, this is what usually comes up, but I cant use CTRL-C to stop the program and theres no sound..

Anyone has any idea what this can be?

I've got Portmap in the default runlevel, and I can browse the remote filesystem.

Edit2: It's the hardware, it worked 100% on a different computer..

----------

## Match

Okay, I've definitely got livecd in my USE flags. But where exactly should the linuxrc be in the initrd? At the moment it's top level (in other words, I mount the initrd and cd /mnt/initrd and it's there).

I've just chmodded +x linuxrc, but stupidly didn't check to see if it'd been set before. I shall go burn it and see what happens.

----------

## Match

It seems that linuxrc wasn't set to executable before because with that one change, I now get different errors:

```
VFS: Mounted root (ext2 filesystem)

Freeing unused kernel memory: 184k freed

Unable to identify CD-ROM format.

pivot_root: No such file or directory

/linuxrc: line 41: cannot create temp file for here document: Read only file system

Kernel panic etc.
```

So, pivot_root is causing problems and that then messes up line 41 (exec chroot etc.) from the original linuxrc? I shall go back and figure out what pivot_root is all about, but does anyone have any ideas?

Edit: Two questions. One, does the pivot_root binary have to go in /bin or /sbin in the initrd? Mine's in /bin. Two, in my linuxrc file I have the line pivot_root . newroot - what's "newroot" all about? Cheers  :Smile: 

----------

## invalid account

It doesn't matter where the pivot_root is really, as long as it is available on the path and the required libraries are in lib. So if your path is set to /bin then it should be in there.  There isn't really any point in making an /sbin on initrd.

Neil

----------

## Match

Well, I assume it's in my path because other commands work - and it seems to work itself it just has problems with whatever's passed to it, I think.

Anyone have any ideas about what's causing this problem?

----------

## invalid account

What have you got at the end of you linuxrc script?

Also what is you grub kernel settings, is the initial root writable?

----------

## platojones

Match,

   I've got pivot_root in the initrd /bin directory.  In your linuxrc script, make sure you have a line like this at the very top:

export PATH=/bin

Also, make sure that your initrd bin contains an 'sh' executable and that the libraries to support everything in bin are in your 'lib' directory.  The missing pivot_root is the key to your problems at this point, but getting that resolved should be a fairly straightforward matter.

Richard

----------

## Match

End of linuxrc:

```
# Pivot root and start real init

cd /new

pivot_root . newroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}

EOF
```

I've got the export PATH=/bin line, and I have all the libraries for all the executables (which all have +x set).

Here's the grub file:

```
default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Gentoo Linux

root (cd)

kernel (cd)/boot/kernel root=/dev/ram0 rw init=/linuxrc cdroot

initrd (cd)/boot/initrd
```

The bootup appears to pause on the line "Unable to identify CD-ROM format" - could this have anything to do with it?

Thanks for your help guys, I'm sunk without you  :Smile: 

----------

## Match

Just hang on one sec... I think it's the newroot that's the problem.

Right near the start of the installation veezi said to create a newroot directory "to be used in the inital boot process". I think I managed to skip that line due to knowing I could install stage 2 without this howto. I'll go try it out (and I'm guessing it should work now and I've just been really stupid...)

Edit: Yep, that was it. I now feel really bad for making you guys flex your brains for what was just a stupid mistake on my part. Thankyou. I probably wouldn't have thought of this without you giving me the alternatives.

Aaanyways, it's now booting but I've still got a load of error messages. Firstly, the same old "Unable to identify CD-ROM format." Secondly after init starts I get the messages:

```
fsck: fsck squashfs: not found

fsck: Error 2 while executing fsck.squashfs for /dev/loop0
```

I'm guessing a fsck is unnecessary as it's on a read-only medium so can I turn it off? And if I can, how would I go about doing that?  :Smile: 

```
Calculating module dependencies...

Failed to calculate dependencies
```

I'm going to go back and read over the thread as I remember there being someone with a similar problem so I might be able to fix this myself. Edit: I did!

```
Bringing eth0 up via DHCP...

Error: Problem starting need services

"netmount" was not started
```

Now, I'm guessing this has something to do with my DHCP daemon, which it appears is installed but isn't running on boot (a file for it doesn't exist in /etc/init.d/). Not sure what to do here. Edit: Okay, somehow this now works. Not quite sure how, but last time I booted the internet was working...

On logging in I get this error:

```
PAM-env[7218]: Unknown PAM_ITEM: <DISPLAY>

login[7218]: PAM pam_putenv: delete non-existant entry: DISPLAY

PAM-env[7218]: Unknown PAM_ITEM: <XAUTHORITY>

login[7218]: PAM pam_putenv: delete non-existant entry: XAUTHORITY

login(pam_unix)[7218]: session opened for user root by (uid=0)
```

I'm going to try and solve this problem by following the instructions in this thread, unless anyone has a better idea. Edit: It appears to be working now without this error, but I'm not sure why I was getting in the first place - any ideas?

Finally, on shutdown I get this error as the final message before power off:

```
awk: cmd. line:2: fatal: cannot open file  /proc/mounts for reading (no such file or directory)
```

I'm not sure what awk is, so I'm going to have a look. Meanwhile, any help would be fantastic. Edit: Okay, I now know what awk is but it doesn't help  :Sad: 

----------

## Gruffi

I installed sys-apps/hwdata-knoppix and sys-apps/kudzu-knoppix, also tried sys-apps/kudzu but when i launch autoconfig it complains about a missing /etc/init.d/kudzu  :Evil or Very Mad: 

Anyone have this file for me   :Question: 

----------

## invalid account

Match,

The error with fsck looks like you didn't have livecd in your USE settings when baselayout was emerged.

What looks like is happening is that the the root system is being checked like a normal HD install, but this is a feature that is disabled with the livecd setting.

To fix this just add "livecd" to the USE list and run emerge baselayout

I am not sure if your DHCP server is on the livecd or not. If not then you either need to make sure the DHCP server is running before you boot, or set a static IP address. If the livecd runs the DHCP server, then set the static net details for the livecd in /etc/conf.d/net.

If you need DHCP to run on boot, then execute 

```

rc-update add <DHCP server name>

```

You need all this before creating the squashfs or tarballs for the cd.

Neil

----------

## Match

Hmm, it's odd because one of the first things I did was add livecd to my USE variable. I shall do as you say though - my memory is probably deficient.

Running rc-update add dhcpcd boot results in:

```
/sbin/rc-update: /etc/init.d/dhcpcd not found; aborting.
```

However, the internet appeared to work last time I tried to boot. I shall remake the iso and try again. Thanks for your help!

----------

## Match

I now don't have the file system check on startup, which is good. I've decided enough of the initial bugs are fixed and so am starting to configure X.

Now, I've tried using a default xorg.conf file and it just results in a blank screen. Could someone please explain to me exactly how I would go about getting an xorg.conf file created depending on the monitor? I've downloaded the mkxorgconf.sh script which some people say works and some people say doesn't, but have no idea how to get it working.

Edit: I've now tried running the script manually and have got twm up, but no mouse input. Not sure how to do it automatically though. Anyone know of a better way?

Thanks for all your help so far, everyone  :Smile: 

----------

## GentooBox

I got a problem - I got the "no init found, try passing init= to kernel" - even if i pass init=/bin/sh to grub, then the error comes up.

so i wanted to see if /bin/sh worked like it should:

```

GentooBox / # cp /bin/sh /mnt/initrd/bin/

cp: overwrite `/mnt/initrd/bin/sh'? y

GentooBox / # chroot /mnt/initrd/

chroot: cannot run command `/bin/sh': No such file or directory

```

thats inside my 32bit livecd chroot (i run 64 bit)

as you can see, /bin/sh IS there, but it cant find it.

what can i do ?

EDIT: never mind - i found the initrd from a old livecd i made and used that instead.  :Smile: 

----------

## platojones

GentooBox,

   Did you make sure you copied the libs required for /bin/sh to the lib directory as well?

----------

## dma147

First: very much thanks to veezi for this great howto!

But I've a little problem:

I've read the howto several times to prevent any errors. But I still can't get it to work.

```

INIT: version 2.86 booting

INIT: no inittab file found

Enter runlevel:

```

Well, I can type in a runlevel then, for example "3".

But then this happens:

```

INIT: version 2.86 booting

INIT: no inittab file found

Enter runlevel: 3

INIT: Enterint runlevel: 3

INIT: no more processes left in this runlevel

```

And here it hangs. Nothing more happens.

Okay, I've then reemerged baselayout. Still the same result.

I've then emerged sysvinit. Still the same result.

Btw. there *is* a /etc/inittab. Should this be in the initrd/etc/?

Btw.2. I've also rc-update'ed all the services I need.

Any help would be really fine...

[edit]

Is it correct that the /etc/fstab and /etc/mtab in the initrd are empty?

[/edit]

[edit2]

I've copied the /etc/inittab to /mnt/initrd/etc/inittab, but this doesn't change anything...

[/edit2]

----------

## Bre_Rea

Gr8 Job   :Idea: 

----------

## invalid account

Bre_Rea,

It may be that the squash fs isn't mounted properly.

Try passing 

```

init=/bin/sh 

```

to the kernel and then runing linuxrc by hand without sending the output to /dev/null.

----------

## platojones

Ok, I've gotten this to do everything I want it to do, save one issue.  Here's a quick overview.  I've used this thread/Neil's script to create an emergency rescue disk build environment customized exactly to the machines I have, including all networking, security, etc.  I basically want the ability to quickly restore either of my boxen should a disk drive on either crap out.  

It works beautifully, even my laptop, but I've got some sensitve info on these boot disks (like my ssh keys) and I want to at least password protect the login on these rescue disks.  Anybody got any idea how to go about that?  I've been searching through all the startup scripts, but still haven't been able to figure out how to force the cdrom to prompt for a password when I boot it.  And, yes, I did use the passwd command in the chroot environment to try to set it before I built the iso, and no joy.

Oh, and one other thing.  Just a minor annoyance, but does anybody know how to avoid the '/proc/mounts' error message when rebooting.  I know where it's happening, but I don't know how to turn it off without changing one of the baselayout scripts (halt.sh).

----------

## invalid account

platojones,

When I boot from the cd, I am prompted for my login details. I guess this isn't happening for you, and you are auto logged in as root like a normal livecd is?

If this is the case, then check your inittab to see if there is a line with 

```

... -- autologin root ...

```

If there is then this is proably reing replaced by the /sbin/livecd-functions.sh script during boot, so you can alter this file, not to add the autologin entry.

I had this problem when working with catalyst. 

Hope this is of some help.

Neil

----------

## platojones

Neil,

   That was it, you nailed it again.  Thanks for the help.  You are the 'livecd' guy around these parts now   :Wink: 

----------

## neilhwatson

I've had success is building a liveCD to act as a router.  I've been thinking of creating other liveCDs that could act as emergency DNS or email servers.  For this to work I would need a non volatile storage medium for certain files systems.  For DNS I would need /etc to be stored on a USB key.  For email I would need /etc and /var to be stored on USB key.

How would I go about having the LiveCD mount /etc or /var on a USB key at boot time?

----------

## danielha

It just took me three days  :Smile:  But I now have a working base to create a full livecd !

Many thanks to veezi for this tutorial and to Neil (Invalid Account) for his script which is a lifesaver for a newbee like me  :Smile: 

Daniel

----------

## invalid account

Thank you guys for the positive feedback.

neilhwatson, 

You could just mount the USB drive in fstab. 

Another thing that I do is in linuxrc I look for an overlay.tar.gz file on the floppy drive (you can do the same thing with the USB/scsi drive) this overlay is unpacked in the new root file system, and in the overlay.tar.gz I have an updated fstab and/or an updated /etc/conf.d/local.start file that mounts any partitions that I need. 

If I then only want to use part of the newly mounted partitions I just use 

```

mount -o bind mounted_dir new_filesystem_dir

```

in the updated local.start file

This is how I manage my server running from a livecd with my persisted email, web site and subversion service.

This way I can use a vanilla server livecd in a range of hardware, the aim being that if one machine dies I can put the cd in another box and only have to change a config file on a floppy and it is back in action.

Neil

----------

## pi-cubic

 *dcoyaz wrote:*   

> 
> 
> ```
> qemu -cdrom livecd.iso -boot d
> ```
> ...

 

when i start qemu as above, nothing happens. are there any additional parameter nessecary?

greetings,

pi

----------

## invalid account

pi-cubiq,

are you using x windows? is there an error message?

Neil

----------

## pi-cubic

no, i am not using X windows, just starting it remote from the command line after emerging qemu... with extra useflag "softmmu"

----------

## x-cnc

My $.02, which may or may not help out people having trouble:

- Untarring the stage tarball while not root will give you a lot of errors about not being able to make nodes, and then the livecd will not work.  You will get errors about the console and then a kernel panic.

- You can put an entry into the grub.conf

```
title=Troubleshooting

   root (cd)

   kernel (cd)/boot/vmlinuz root=/dev/ram0 rw init=/bin/sh

   initrd (cd)/boot/initrd
```

so you don't have pounce on the 'e' key and then delete and retype.

- It might be good to put the passwd step in the howto.  I believe someone above mentioned this also.

- If you chmod a-x /sbin/depmod. you can disable module dependency checking.  However, you'll still get an error message when booting.  You can also change /etc/init.d/modules as in the Flying with Gentoo thread.

- If your cdrom is always not found you can change this line in linuxrc:

```

for x in hda hdb hdc hdd

```

to:

```

for x in hda hdb hdc hdd cdroms/cdrom0 cdroms/cdrom1

```

Thanks to everyone participating in this thread.  I was trying to get this to work for a long time before I found this.

----------

## Alogon

Alright I think i did everything right, i made sure to unmount my proc and distfiles, and i added -e usr/portage usr/src to the build script so i dont get those in my image, but i am still getting a 900+ mb iso file, all i have emerged were xorg, xfce, gaim, firefox, and the 3 knoppix scripts, whats going on here?

----------

## frenkel

Did you clean out /tmp /var/tmp and /usr/tmp?

Frank

----------

## Alogon

That build script does that fore you :-\

----------

## invalid account

Alogon,

Have you checked that all directories have been unmounted in the the new livecd image. This is often the problem for me when the ISO's come out too big.

----------

## Alogon

I decided to start over and i am keeping a close eye on how big the file system gets. I was wondering how much stuff can you get to compress down to under 700mb, I know the way knoppix is done its around 3.5gb I know it depends on what you are compressing, but i was just wanting to see what people were averaging. Also I was wondering if anyone can tell me how to get this qemu thing to work. I do emerge qemu and the only binarys i get are qemu-arm qemu-i386 qemu-img qemu-ppc and qemu-sparc and they don't seem to take the same flags as the qemu command does. 

Thanks,

----------

## platojones

Alogon,

      Add "softmmu' to your USE flags and re-emerge qemu to get that thing to install properly.  As for the size thing, I dunno.  Just make sure you are not picking up the distfiles symbolic link from portage (you did make that a symbolic link didn't you?).  I've got 2 fairly basic, very specialized, iso set up for 2 boxen, and they are both about 140 mb compressed.  I don't have X or anything really big like that, but you would have to have a lot of stuff to max out a livecd.  Capture the output of the script when you run it and go over everything to see if any 'big' things show up is all I can recommend.

Richard

----------

## Alogon

Well i got my cd and it is only 232mb with Xorg xfce4 firefox xchat hotplug coldplug distcc and more  :Smile:  but, now when i try to boot it i get...

```
Kernel Panic - not syncing: No init found. Try passing init=option to kernel
```

when i try to change init= to /bin/sh i get 

put into my mini linux (initrd) and i am having trouble getting anything going with out stuff like ls  :Razz: 

I got qemu to emerge properly but now when i try the...

```
# qemu -cdrom ~/livecd.iso -boot d
```

I get an error about svgalib_helper in the kernel, my kernel is gentoo-dev-sources 2.6.10-r6 and i couldnt find this option in makemenu config and i searched .config for svgalib and found nothing also, where can i get the kernel patch i need for this or what do i need to do to get this working

Thanks, Alogon

Edit:

ok when i do the linuxrc script by hand everything works perfectly untill i get to the pivot_root part, filename completion works for this file... but  when i do 

```
# pviot_root . newroot
```

i get

```
pviot_root: No such file or directory
```

any hints?

Thanks, Alogon

Edit:

Son of a, son of a...

had i followed instructions where it says to 

```
mkdir newroot
```

i could have saved my self alot of trouble.. o well guess it gets mounted on /home instead of new root for now... no one is using home anyways  :Smile: 

and the best gentoo live cd is born  :Twisted Evil: 

Thanks, Alogon

Edit: 

After i got qemu to emerge correctly (adding softmmu to my USE flags in make.conf) I found that i needed to emerge svgalibs because they contain the svgalibs_helper (module?) after that everything has been going goodLast edited by Alogon on Fri Feb 25, 2005 2:38 am; edited 1 time in total

----------

## platojones

Alogon,

Glad to see things seem to be working for ya!  Yeah, I made that mistake myself too.  As far as qemu goes, use the command that is indicated in Neils' script.  Instead of the '-boot d' that you are using just use '-boot c' like it says.  Works perfect for me (it is slow, but it works).

Best Luck!

Richard

----------

## aminal

 *stahlsau wrote:*   

> Hi,
> 
> first of all: thanks for the howto, i know it´s been a lot of work.
> 
> second: mmh...it doesn´t work for me 
> ...

 

I get the same exact thing.  Anyone have any ideas??

----------

## pi-cubic

dumb question: is it possible to exclude /usr/lib/portabe? because it has 168 MB which is a lot on the livecd...

i'ld also like to exclude /usr/lib/python2.3 which as arout 60 MB. is it possible that excluding these directories destroy your livecd?

one thing i didn't mention yet: 

thank you very much for this great howto! i really appriciate it!

----------

## aminal

Also - has anyone else noticed an error in the build script?  I get a tar error - saying 

```

spool/cron/

spool/cron/.keep

spool/cron/lastrun/

spool/cron/lastrun/.keep

spool/cron/crontabs/

spool/cron/crontabs/.keep

spool/mail/

spool/mail/.keep

state/

state/.keep

tmp/

tmp/.keep

.keep

tar: *: Cannot stat: No such file or directory

.bash_history

.keep

.mozilla/

.ssh/

.ssh/known_hosts

tar: Error exit delayed from previous errors

```

It looks to me like it's trying to tar a "*" file - which doesn't make much sense.  Is this an err with the build script?  Should I even worry about it?

Thanks!

----------

## pi-cubic

 *aminal wrote:*   

> 
> 
> It looks to me like it's trying to tar a "*" file - which doesn't make much sense.  Is this an err with the build script?  Should I even worry about it?
> 
> Thanks!

 

don't worry about it. it's just fine. browse this thread for detailed information about it. this question is already answered  :Smile: 

----------

## aminal

 *pi-cubiq wrote:*   

>  *aminal wrote:*   
> 
> It looks to me like it's trying to tar a "*" file - which doesn't make much sense.  Is this an err with the build script?  Should I even worry about it?
> 
> Thanks! 
> ...

 

Whoops - musta missed it.  I swear I've been through this thread about 1000 times by now!   :Smile: 

Thanks!

----------

## aminal

Well, maybe a livecd just isn't in my future.  I've gone over the how-to countless times, checked, re-checked and checked the kernel again, and I can't figure out what the problem is.

http://2riyal.com/qemu.png

```
qemu -cdrom livecd.iso -boot c
```

Everything looks good, until it tries to boot....Then it just sits there. 

Anyone have any ideas?   :Sad: 

Thanks...

----------

## Alogon

I know this is going to sound simple but the problem could be in your qemu line.

You have...

```
 qemu -cdrom livecd.iso -boot c 
```

in the man page for qemu it says

 *Quote:*   

> ...
> 
> -boot [a|c|d]
> 
>           Boot on floppy (a), hard disk (c), or CD-ROM (d). Hard disk boot is the default
> ...

 

So try 

```
 qemu -cdrom livecd.iso -boot d 
```

since you want it to emulate booting from a CD not the hard disk, or try burning it to a cd and running it, since qemu is so slow

Note: this is all i can think of if you are sure that your kernel is ok

----------

## TheRepublican

First off I would just like to say great howto! I've been looking for months on decent documentation on how to remaster knoppix, but as a gentooer I rather like the idea of building a livecd from bottom up. Thanks veezi!

Anyway, I've been going over the whole thread looking for various tips to try and get my livecd working right, but I think I might have one to add. Those of you installing xorg on your system can enjoy a dynamically-created xorg.conf too! Simply emerge mkxf86config as the docs say, it appears as if gentoo has tweaked the script to create a xorg.conf file by default, instead of a xfree86.conf file like the name would have you believe. For hardware autodetection on my cd, I'm using hotplug, coldplug, udev, hwdata-knoppix, hwsetup, kudzu-knoppix, ddcxinfo-knoppix, and livecd-tools. To set this up, use:

```
emerge -a hotplug coldplug dev hwdata-knoppix hwsetup kudzu-knoppix ddcxinfo-knoppix mkxf86config livecd-tools

rc-update add autoconfig default

rc-update add coldplug default

rc-update add mkxf86config default

rc-update add x-setup default
```

I haven't had a chance to test this yet, as the cd is still building, but from the docs it seems sound. I will let you know the results. I might also add more packages such as hal and gnome-volume-manager for even better hardware support.

//EDIT: removed genkernel, did not create a modular kernel as expected, used make allmodconfig&&make menuconfig to configure the kernel and then worked backwords, disabling or compiling in support as neededLast edited by TheRepublican on Mon Feb 28, 2005 5:10 am; edited 1 time in total

----------

## aminal

 *Alogon wrote:*   

> I know this is going to sound simple but the problem could be in your qemu line.
> 
> You have...
> 
> ```
> ...

 

Thanks for the reply.  I tried using -d first, with the same results.  There was a very long script posted earlier in the thread, to automate the whole process - in this script, the -c option was used.  I'm not that familiar with qemu, so I assumed that the -c switch was needed since it wasn't *really* running from a cd.  

Anyway, still stuck.  

Thanks again.

----------

## Alogon

I am also going to start off and say thank you to veezi for the awesome how-to. Like TheRepublican i had been trying to sort out what people were saying about remastering knoppix and when i stumbled upon this.

TheRepublican:

Your setup sounds good on paper but I tryed many similar configurations and had no luck (none that looked as sound as yours) I had been thinking about writing my own script to set up everything for Radeon cards(w/hardware accel) and making everything else use vesa  Anyways please let me know if that works out well because I would much rather just modify those configs for the case of my Radeon cards than to set up my own that runs my stuff great but might not do anything for other hardware configs.

Also wanted to let you know when I read the gentoo handbook about genkernel (never used it till now) it gave me the impression that genkernel pretty much compiled all the drivers I would ever need as modules. This was not the case, I had to go back and make the module for my network card on my own. So I don't know if i found an exception or if what genkernel really does is just make a kernel with the modules that you currently have running (if i am making any since)

Alogon

----------

## Alogon

animal: I would look at the kernel then, try using genkernel it seemed to work well for me. Other than that I don't know what else to tell you.  :Sad: 

----------

## aminal

 *Alogon wrote:*   

> animal: I would look at the kernel then, try using genkernel it seemed to work well for me. Other than that I don't know what else to tell you. 

 

Well, it must have been an issue with qemu, because I burned the cd and it booted fine.  I got many of the same errors that I've seen in this thread, but long story short - it worked  :Smile: 

Success!  :Smile: 

Thanks again.

----------

## Scen

The boot process of my livecd stops with this error:

```

SQUASHFS error: Major/Minor mismatch, filesystem is (2:1), I support (1 : x) or (2 : <=0)

[...]

```

Any idea? :Question:   :Question:   :Question:   :Question:   :Question:   :Question: 

Thanks!

----------

## aminal

 *veezi wrote:*   

> Did anyone figure out how to keep the cd spinning to make it more responsive?
> 
> Thanks,

 

Try emerging "livecd-tools."  It comes with (among others), "spind" - I'm not very good at bash scripting, but after reading the script, I'm pretty sure this is what it does.

----------

## aminal

Anyone else have a problem using mkxconfig and getting a fatal server error "unable to find default font 'fixed'?"  I'm having trouble figuring out how to resolve this.

Thanks

----------

## yoshi314

that's a neat topic. i have a quick question - i want to make a livecd to run on variety of machines, so i'll use the knoppix scripts for HW autodetection i guess. :]

is there a script for autodetecting videocards and building an xorg.conf file? i mean i'd like my livecd to work both on nvidia and ati cards with 3d acceleration, but i don't know how to pull it off. and that would be similar for other external kernel modules, like eagle-usb or speedtouch. i'd like them to be autoloaded on start if need be. some tips, anyone?

i'm sorry if this has been already mentioned, i might have not noticed this one.

thanks in advance, and sorry for my stupidity, i'm just getting started with livecds :]

----------

## Alogon

I dont know that anyone has found a decent solution for getting it to generate a xorg.conf on boot that is specific to the hardware it has booted on, most people are just going with a generic vesa version of xorg.conf that runs on most systems. I have been kicking around the idea of starting a thread where people post thier results for `lshw -short` and their xorg.conf then I would make a database of xorg.conf files and a script that chooses one bassed on that computers `lshw -short` output. The only way I know how to get extermal kernel modules like fglrx (for radeon cards) or ipw2200 (for some centrino laptops) is to add thoese to /etc/modules.autoload/ (think that is where it is) but the problem I have with this solution is that if a system doesnt have a radeon card then they get this ulgy message about fglrx not being able to load, or sometimes it will load even with out the hardware present and then you have all these modules loaded that have no purpose. In the case of fglrx I can choose to load it bassed on the results of `lshw -short` because it will list the radeon card under display, but I do not have a laptop to test if stuff like IPW shows up under `lshw -short` or if other hardware shows up.

NOTE: you are not being stupid... look back on page 9 how many mistakes I made  :Embarassed: 

----------

## invalid account

In case it may be of any use to anyone, I have posted my latest livecd script on my site after a few updates:

http://www.icu.isa-geek.org/

Sorry no Xorg support yet.

Neil

----------

## aminal

I've had pretty good success with the automated xorg scripts available in portage.  Look at the last post by "The Republican" for the name(s) of them all.  I havent been able to test on a high-end card that would require module loading yet, but the "x-setup" script does a check for which gl type it should use, then automatically does an opengl-update.

My biggest problem so far has been auto configuring the network stuff.  The problem is, when I use the net-setup script available in the "livecd-tools" ebuild, it gives me a "no such device" error after I put all the info in.  So, I have to manually "ifconfig eth1 up" before I run the script, or it isn't recognized.  I tried putting net.eth1 in default runlevel, but since there aren't any network settings in conf.d, it fails out without bringing the card up.  I'm gonna try tweaking the scripts to see what I can do.

Also, I don't know why, but for some reason root's $HOME is set set to / and not /root.  So I have to set HOME=/root each time before I startx, or else fluxbox won't start since / isn't writable.  I know it's pretty simple, but honestly I don't know where to change that setting at.  Can someone give me a heads up?

----------

## Alogon

look in /etc/passwd it has that information, root is always UID 0, even if his username is not root. I will try out the xorg setup that TheRepublican talked about a few pages back.

----------

## aminal

 *Alogon wrote:*   

> look in /etc/passwd it has that information, root is always UID 0, even if his username is not root. I will try out the xorg setup that TheRepublican talked about a few pages back.

 

Yeah, /etc/passwd has root's dir as /root, I checked that, which is why I was stumped.  The only thing I can think of is that I don't have to login after the system boots - I get a bash prompt.  Honestly I don't know why that is, but Im thinking it has something to do with it.

----------

## TheRepublican

To see what kinda card you have, look at /usr/sbin/x-setup from livecd-tools. It should detect hw accelerated cards, but does not see my ATI 9600 SE (I think the problem is in an awk one-liner near the middle) from the output of an lspci. In theory one could do a modprobe fglrx or a modprobe nvidia in that script and then edit the xorg.conf generated by mkxf86config.sh (part of mkxf86config) using the sed scripts that game knoppix uses ( I extracted these from the games knoppix iso, pm me if you're interested, I'll probably post them later). This is what I'm trying to do on my live cd, but I have to get the damn thing to boot first  :Embarassed: 

sorry I cant be of more help, but I think I have to bite the bullet and risk a few coasters testing as I go, I screwed up in my livecd and dont know where, so I'm starting over  :Embarassed:  (yeah Alogon, I know I know  :Wink:  ) I've been looking at these scripts as its compiling, and think it should work (I'll know in about 3 days, portage: can't live without it, can't wait for it either  :Very Happy:  ) Please tell me if you have any luck with these scripts![/i]

----------

## yoshi314

 *Quote:*   

> I dont know that anyone has found a decent solution for getting it to generate a xorg.conf on boot that is specific to the hardware it has booted on, most people are just going with a generic vesa version of xorg.conf that runs on most systems. 

 well Xandros Linux didn't have any trouble with that. it loaded nvidia module for my GF2 at boot.

well i thought at first about my own solution for card detecting. i was thinking of grep-ing through lspci output for NV11 NV22 etc. strings in order to find nvidia card. i don't know for what it's like with ati.

and most monitor stuff can be found by ddcxinfo-knoppix script [it's in the portage], or i could use some safe parameters. but it has some trouble with simple vsync/hsync detection.

btw. what's the average amount of software you managed to stuff onto livecd?

i'm planning on making a programming-only livecd, but i don't know if i will stuff it all in. :/

----------

## Alogon

I have been able to fit quite a bit onto a cd. Had a base system xorg xfce4 firefox xchat gaim nvu gvim vim xmms xine-ui, distcc (which was very bad ass) a 6mb mp3 and a 3mb movie and it was around 350mb, but things like nvu and gaim need alot to run. I made another version where for my kernel I did...

```
make allmodconfig; make menuconfig (configured what I NEEDED for it to boot into the kernel)
```

Thanks to the tip from TheRepublican, but then my live cd with just a base system, xorg, xfce, firefox, xchat, and gaim, ended up being 477mb!

I did edit the build script from

```
mksquashfs source/ target/files/source.img
```

to

```
mksquashfs source/ target/files/source.img -e usr/src usr/portage
```

Like chunderbunny suggested on bottom of the first page of this thread. Since portage would have trouble installing stuff to a read-only file system, and I wouldnt be recompiling the kernel either, this saved me alot of space. 

As far as Radeon Video card detection, just make sure not to compile any radeon drivers into the kernel then AFTER the kernel is compiled, and installed run...

```
emerge ati-drivers 

```

Make a xorg.conf for it by

```
fglrxconfig

mv /etc/X11/xorg.conf /etc/X11/fglrxorg.conf
```

Then every time you boot run this. (in an init script, ofcorse)

```
lspci | grep 'Radeon' && modprobe fglrx && opengl-update ati && cp /etc/X11/fglrxorg.conf /etc/X11/xorg.conf
```

----------

## yoshi314

okay, i'm starting to get the hang of it  :Very Happy: 

what about udev? in the first post there was something about saving your dev nodes before making a livecd. does it mean it's impossible to make an udev livecd? /it can create nodes from scratch, at least that's what i heard/

oh, about that portage thing. i'm going to leave portage in but without the distfiles dir, just in case  :Very Happy:  hopefully i won't waste too much space.

there are still some things that bother me, like how can i make myself a knoppix-like bootmenu, where one could choose desktop to run, or e.g. disable dma for hard drives, or give some troubleshooting options. maybe i could put video card/external modules selection in there so i would save myself a lot of trouble? 

and how to incorporate external config-files support? [like external /home or /etc support] i'd like to include an option to use external directory/device as a holder for user configs. e.g. mandrake move uses an pendrive-ish device to store its configs. maybe i could go for a floppy for start (just for some small&simple configs, like cached hardware config, to speed up second and latter boots by skipping some hw detection on the same hardware)

----------

## Alogon

I am under the impression that udev and devfs do not get along too well, so what I did was...

```
emerge -av udev

emerge -C devfsd

            (then as the guide said)

cd /lib

mv udev-state /var/lib

ln -s /var/lib/udev-state udev-state
```

 This setup has caused me no problems. To see how much space the /usr/portage will take up w/o the distfiles exit your chroot (if you use the script at the bottom of the howto) and it should unmount distfiles then do...

```
du -ms /usr/portage
```

This will return the amount of disk space in megs that is being used in that directory. You would need to do some research on grub, or what ever bootloader Knoppix uses for the boot menus. There is a line in the linuxrc already that will send what ever you pass to the kernel to init, I dont know what you do with it from there though  :Confused:   Then as for external config-files, I don't feal like it takes long enough to detect my hardware justify doing all this, but if you wanted to do it you would need to write an init script that ran before the hardware configuration got your config-file(s) and then tell init to skip the xorg.conf generation or something. The external home would be much easier, you would just add some more devices to your /dev/ in your ramdisk (initrd) for floppy or usb (if you can) and then edit the linuxrc script to mount it at home if it finds it.

----------

## LarryLeffa

veezi: You did a very very good job! Many thanks for your howto by me!

After reading all posts and producing the LiveCD step-by-step it works like a charm!

Many thanks to the others for any hint and/or clue I found here (i.e. qemu, udev etc.), too!

Will do my best to support this LiveCD-project as best as I can.

----------

## aminal

People using qemu:  have you been able to successfully boot all the way?  I've tried loading from both the .iso file and the burned cd, but it always freezes up at "ok, booting the kernel..."  I've been using 

qemu -cdrom livecd.iso -boot c

and / or 

qemu -cdrom /dev/cdrom -boot d

I've used both the c & d option for the 'boot' parameter as well.  qemu will boot the official gentoo livecd perfectly.  I don't know what's going wrong and to be honest I don't really even know where to start looking.  

Oh, it boots up fine when actually booting from the cd.

----------

## LarryLeffa

 *aminal wrote:*   

> People using qemu:  have you been able to successfully boot all the way?  I've tried loading from both the .iso file and the burned cd, but it always freezes up at "ok, booting the kernel..."  I've been using 
> 
> qemu -cdrom livecd.iso -boot c
> 
> and / or 
> ...

 

Booting my ISO with qemu works fine. Boots up very quickly but's quite slow when entering rc.3 and calculating it's depencies. Used qemu with 

```
qemu -cdrom livecd.iso -boot d
```

qemu is emerged with 

```
USE="softmmu" emerge qemu
```

ISO also tested with VMWARE and works PERFECTLY. My 1st ISO was set-up with devfs but doesn't worked in VMWARE. Changed to udev, then success.

----------

## TheRepublican

For a knoppix like boot menu, you need to use isolinux, the bootloader knoppix uses. There is a way to configure isolinux to show graphics and provide a menu, as an example look at the knoppix iso in the isolinux directory. It is more flexible than grub in this regard, however it does not allow you (as far as I can tell, correct me if wrong) to enter a command prompt to boot operating systems already on the hard drive, a useful feature on a rescue cd. This may be a reasonable trade off, and isolinux must have something working for it as it is the bootloader that most livecds (including the gentoo minimal cd IIRC) use nowadays. To set this up, see the post by The Paya on pg 5.

https://forums.gentoo.org/viewtopic-p-1808367.html#1808367

----------

## aminal

 *LarryLeffa wrote:*   

>  *aminal wrote:*   People using qemu:  have you been able to successfully boot all the way?  I've tried loading from both the .iso file and the burned cd, but it always freezes up at "ok, booting the kernel..."  I've been using 
> 
> qemu -cdrom livecd.iso -boot c
> 
> and / or 
> ...

 

Hi - thanks for the reply.  Yes, I've done both of what you mentioned, but no luck.  I'm wondering if it's an issue with the cpu type that qemu emulates, and the cpu types I have supported in the kernel.  I'll see what I can dig up.

Thanks again.

**edit ** 

Well, after reading around, I guess qemu doesn't emulate the processor.  That makes sense, I should have known that.  Anyway, I've done an emerge -C qemu && USE="softmmu" emerge qemu and still no luck.  I'm about to give up on qemu I think.

----------

## deckernico

I've gotten it to boot, but i'm having a problem with it not loading the cdrom.

in the kernel bootup it says found cdrom device /dev/hdc but when i boot the system (under Vmware) it drops to sh because it can't find the drive. If i try and mount it manually it tells me "special device /dev/hdc does not exist".

Any clues? i've wracked my brain for hours and i can't figure it out.

****ADDITION*****

ok must be using UDEV, i'm not super used to it yet  :Very Happy: 

/dev/cdroms/cdrom0 works

----------

## Alogon

It has worked fine in both of my comptuers, but I have seen a few posts where people said their cdrom was /dev/cdroms/cdrom0 or cdrom1. What are the device numbers for these /dev nodes? Did you solve your problem by adding cdroms/cdrom0 to that loop where hda hdb hdc hdd are in linuxrc and adding that device node to your initrd (ramdisk)? Wanting to make sure my disk is compatable with most hardware.

Thanks, Alogon

----------

## _mikec_

can you guys post a picture of your livecd boot screen? 

i am just trying to get involved to create my own livecd with a professional look and perhaps installing bastille for when i will start using the internet to install gentoo.

I have no experience with commands for gentoo, emerge to install what i need and other commands, is it possible for me to create a live cd? 

what would be SO great would be if an experience user/programmer created an program to create livecd's.. how that sounds, perhaps LiveCD creator?

adding support to install a firewall like bastille for using the internet to install gentoo, bootsplash, programs.. compilers, this is only what i can think of, i am new with gentoo but still i think it would be cool to have my own LiveCD and be proud that i did it myself.

i am currently using gentoo on my AMD.

thanks!.

----------

## deckernico

[quote="deckernico"]I've gotten it to boot, but i'm having a problem with it not loading the cdrom.

in the kernel bootup it says found cdrom device /dev/hdc but when i boot the system (under Vmware) it drops to sh because it can't find the drive. If i try and mount it manually it tells me "special device /dev/hdc does not exist".

Any clues? i've wracked my brain for hours and i can't figure it out.

****ADDITION*****

ok must be using UDEV, i'm not super used to it yet  :Very Happy: 

/dev/cdroms/cdrom0 works[/quo

Ok, if your boot goes directly to /bin/sh (ie shell) while loading your linuxrc , then you should probably try removing devfs from the kernel. this help me.

also i don't know why but i keep getting a /dev/console read-only filesystem after i run it.

----------

## LarryLeffa

deckernico *Quote:*   

> Ok, if your boot goes directly to /bin/sh (ie shell) while loading your linuxrc , then you should probably try removing devfs from the kernel. this help me.

 

Yep; as I wrote, my 1st try won't continue to boot with devfs in kernel, also stopped as you described. Changed to udev on 2nd try with perfect results!

----------

## LarryLeffa

aminal: *Quote:*   

> Well, after reading around, I guess qemu doesn't emulate the processor. That makes sense, I should have known that. Anyway, I've done an emerge -C qemu && USE="softmmu" emerge qemu and still no luck. I'm about to give up on qemu I think.

 

Well, have no idea for ya.

So go ahead and try VMWARE. Costs 're about Euro 200 but it's a worth to buy it!

Realised so much testings with VMWARE, so give it a try.

```
emerge vmware-workstation

/opt/vmware/vmware-config.pl
```

Demo-Key available at http://www.vmware.com/vmwarestore/newstore/wkst_eval_login.jsp

----------

## ahorn

i think, i did everything well, but this:

```

RAMDISK: ext2 filesystem found at block 0

RAMDISK: Loading 8192KiB [1 disk] into ram disk... done

UDF-fs: No partition found (1)

Kernel panic - not syncing: VFS: Unable to mount root fs on unknow-block (1,0)

```

I burned the iso on a CD-RW. Same kernel works with HDD. What is wrong?

Oh, and is there a good way to test without booting all the time? VMWare may good, but i dont wanna emulate.

----------

## LarryLeffa

 *ahorn wrote:*   

> UDF-fs: No partition found (1)

 UDF? How did you burned your ISO?

Uh, oh, and did you emerged GRUB from unstable? As described somewhere in this thread, this is VERY IMPORTANT, 'cause old versions of GRUB can't boot from CDROM!

If you didn't:

```
ACCEPT_KEYWORDS="~x86" emerge grub
```

Note: Change "x86" to platform you're using...  :Wink: 

 *Quote:*   

> Oh, and is there a good way to test without booting all the time? VMWare may good, but i dont wanna emulate.

 Just some klicks above we've discussed using qemu. Try this and we're happy to hear your report  :Wink: 

----------

## ahorn

As you see, the kernel boots, so grub is working fine. UDF is simply an added feature i dont use (a relict of by .config). i deactivated it and the error msg is the same like above but without the UDF line. So it's not UDF and, of course, i burned the iso normally. i'm using an athlon64 and i have gcc with multilib and i use also ~amd64, not ~x86 for ACCEPT_KEYWORDS. It's a kernel issue or maybe the initrd must be other as the x86 way.

----------

## LarryLeffa

 *ahorn wrote:*   

> As you see, the kernel boots, so grub is working fine. UDF is simply an added feature i dont use (a relict of by .config). i deactivated it and the error msg is the same like above but without the UDF line. So it's not UDF and, of course, i burned the iso normally. i'm using an athlon64 and i have gcc with multilib and i use also ~amd64, not ~x86 for ACCEPT_KEYWORDS. It's a kernel issue or maybe the initrd must be other as the x86 way.

 

Ah, yes! Okay; I compiled my BootCD entirely using -march=pentium and ARCH="x86" (except grub) to ensure it's working on all x86-platforms beginning from pentium.

My goal was creating a BootCD which is capable of scanning for viruses on NTFS-Partitions  :Wink: 

So no clue by me for now for AMD64. But stay tuned: I'm using Gentoo64 very successfully on AMD64 about one year. Will try to reproduce my steps creating this BootCD on AMD64; maybe this weekend, ok?

BTW:

- Running my x86-BootCD on AMD64 works PERFECTLY!

- What version of kernel you're using on your AMD64?

----------

## ahorn

I'm using 2.6.10-morph25, it's my favorite patchset and it works very well if it is not on livecd :p

At first, i was also trying to make a x86 cd, but some less or more packages detect automaticly my cpu and used another compiler, but this was fixable. the to the end my big problem was, i never got it to run on my pentium classic, i forced the arch to x86 anytime in this creation but without luck.

anyway, i see you're a german, my too, so maybe we can talk in the IRC. i'm on #gentoo at irc.freenet.de, it would be nice if you talk to me if you have more tipps or you can tell me how you done it x86 on amd64.

----------

## MixMax

ahorn: Did you compile squasfs support in to the kernell?

----------

## Wolven

Hello. I've been working on a LiveCD for the past few days and I have a question: Does anyone know how to make /home/username work? I've managed to get /home to be writeable, but there is no username in /home on boot.

I have added a regular user with 'useradd'  and I would like to have a /home/username just like Knoppix has /home/knoppix.

I've read all the posts in this tread a few times, but I don't see it mentioned anywhere. Mabye I'm just blind or there is something about the nauture of the LiveCD I'm not grasping.

Any hints on how to do this, or explanation to why this is not necessary/feasible would be appreciated.

----------

## MixMax

I used the same kind of method for other users as for the root.

Here is the part from the build script

```

cd ../home/(username)/

tar zcvpf ../../../target/files/(username).tar.gz * .[[:alnum:]]*

```

and the extra lines in linuxrc

```

mkdir /new/home/(username)

mount -t tmpfs  none /new/home/(username)

cd /new/home/(username) && tar zxpf /cdrom/files/(username).tar.gz

```

----------

## schneekater

Hi! This thread seems still alive and healthy afetr all those months, so maybe I could get an answer for a question that has been bothering me for the last few days: 

My livecd works quite nicely now, except for man. Whenever I try to view a man page that has never been viewed on the source system, man complains that groff can not find libstdc++.so.5. I am 99% sure that this is bogus: Looks like the real problem is that man is trying to store the formatted man pages and the catdir is not writable.

So, what to do? I tried preformatting all man pages, but that took up about 150MB - more than I am willing to invest. My other thought was to have the catdir reside on a tmpfs. Would that be a viable approach? Or is there a way to turn off the saving of preformatted man pages?

I would really appreciate any help that you could give me.

Thanks for your attention

----------

## ahorn

 *MixMax wrote:*   

> ahorn: Did you compile squasfs support in to the kernell?

 

Yeah, i did it. I checked it over teen times.

The kernel boots, but it hangs at the root fs init.

----------

## Wolven

 *MixMax wrote:*   

> I used the same kind of method for other users as for the root.
> 
> Here is the part from the build script
> 
> ```
> ...

 

Thank you for the reply. I feel I'm getting closer, but I still have no /home/username dir. On boot

Here is my linuxcr

```

#!/bin/sh

export PATH=/bin

# Get kernel CMDLINE

mount -t proc none /proc

CMDLINE=`cat /proc/cmdline`

umount /proc

# Mount CD device

CDROM=""

for x in hda hdb hdc hdd cdroms/cdrom0 cdroms/cdrom1

do

  mount -t iso9660 -r /dev/${x} /cdrom > /dev/null 2>&1

  if [ "$?" = "0" ]

  then

    CDROM="${x}"

    break

  fi

done

# CD not found

if [ "${CDROM}" == "" ]

then

  exec /bin/sh

  exit

fi

# Mount root and create read-write directories

mount -t squashfs -o loop /cdrom/files/source.img /new > /dev/null 2>&1

mount -t tmpfs -o size=16m none /new/var > /dev/null 2>&1

mount -t tmpfs -o size=16m none /new/etc > /dev/null 2>&1

mount -t tmpfs -o size=16m none /new/tmp > /dev/null 2>&1

mount -t tmpfs -o size=16m none /new/root > /dev/null 2>&1

cd /new/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /new/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /new/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

# Establishing the /home/wolvix dir. (Thanks to MixMax)

mkdir /new/home/wolvix

mount -t tmpfs  none /new/home/wolvix

cd /new/home/wolvix && tar xpf /cdrom/files/wolvix.tar

# Pivot root and start real init

cd /new

pivot_root . newroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}

EOF

```

And here is my build script

```
#!/bin/bash

rm -rf target

mkdir target

cp -a source/boot target/

mkdir target/files

rm -rf source/var/tmp/*

rm -rf source/var/run/*

rm -rf source/var/lock/*

rm -rf source/tmp/*

rm -f source/etc/mtab

touch source/etc/mtab

cd source/etc/

tar cvpf ../../target/files/etc.tar * .[[:alnum:]]*

cd ../var/

tar cvpf ../../target/files/var.tar * .[[:alnum:]]*

cd ../root/

tar cvpf ../../target/files/root.tar * .[[:alnum:]]*

# Saving the /home/wolvix dir. (Thanks to MixMax)

cd ../home/wolvix/

tar cvpf ../../../target/files/wolvix.tar * .[[:alnum:]]*

cd ../../../

mksquashfs source/ target/files/source.img -e usr/src usr/portage usr/lib/gcc-lib

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size \

4 -boot-info-table -iso-level 4 -hide boot.catalog -o ~/livecd.iso target/

```

The wolvix.tar file is made and I can see it in the /target/files dir. I can make a /home/wolvix directory, mount it and extract the tar maually after boot, but it's not being done automagicaly. Does the linuxcr and build script look right?

----------

## aminal

 *chunderbunny wrote:*   

> Personally I like to exclude a few directories
> 
> ```
> mksquashfs source/ target/files/source.img -e usr/src usr/portage --->usr/lib/gcc-lib <---
> ```
> ...

 

Man, I tried excluding that dir and it hosed the boot process up pretty bad.

----------

## schneekater

 *Wolven wrote:*   

> 
> 
> [...]
> 
> # Establishing the /home/wolvix dir. (Thanks to MixMax)
> ...

 

Now the $10 question is: Might using 'mkdir -p /new/home/wolvix' help?

mkdir might not create /new/home/wolfix at all if /new/home does not exist yet, but the -p flag should cause it to create the /new/home directory on the fly.

----------

## MixMax

Wolven: Add this line to linuxrc b4 you try to mkdir /home/(username). Then you should be all set  :Smile: 

```
mount -t tmpfs  none /new/home
```

EDIT: just a thought that if you want you can just pack and unpack the whole home directory instead of specific user

ahorn: Ok sorry I can't help much more with those morph. I first tryed to use morph sources also but had a lot of trouble with them so I changed to ck sources and had a lot better luck.

----------

## ahorn

 *MixMax wrote:*   

> 
> 
> ahorn: Ok sorry I can't help much more with those morph. I first tryed to use morph sources also but had a lot of trouble with them so I changed to ck sources and had a lot better luck.

 

Yeah, i hope 2.6.11 will bring the livecd flavour.

edit: https://forums.gentoo.org/viewtopic-t-303714.html somebody else got the same problem, it's the kernel.

----------

## Wolven

 *MixMax wrote:*   

> Wolven: Add this line to linuxrc b4 you try to mkdir /home/(username). Then you should be all set 
> 
> ```
> mount -t tmpfs  none /new/home
> ```
> ...

 

Thanks again for the reply, but I can't get this working. In my linuxcr I've tried:

This:

```

mount -t tmpfs  none /new/home

mkdir /home/wolvix

mount -t tmpfs  none /new/home/wolvix

cd /new/home/wolvix && tar xpf /cdrom/files/wolvix.tar 
```

This:

```
mount -t tmpfs  none /new/home

mkdir -p /home/wolvix

mount -t tmpfs  none /new/home/wolvix

cd /new/home/wolvix && tar xpf /cdrom/files/wolvix.tar 

```

This:

```
mount -t tmpfs  none /new/home

mkdir -p /home/wolvix

cd /new/home/wolvix && tar xpf /cdrom/files/wolvix.tar 

```

And this:

```
mount -t tmpfs  none /new/home

mkdir -p /home/wolvix

cd /new/home/wolvix && tar xpf /newroot/cdrom/files/wolvix.tar 

```

The build script is still the same as posted above.

There must be something I do wrong. When I extracted the stage tar.gz2 and the portage snapshot  I was root. Does this have anything to say?

Is there a way to do this:

```
mkdir /home/wolvix

cd /home/wolvix && tar xpf /newroot/cdrom/files/wolvix.tar

```

Automaticly after the CD is booted? Since I can manage to make /home writable with the linuxcr. And then make the /home/wolvix dir and extract the wolvix.tar manually after bootup.

----------

## MixMax

Do you get any error messages when the linuxrc runs?

could you try this in linuxrc:

```

mount -t tmpfs  none /new/home

cd /new/home/ && tar xpf /cdrom/files/home.tar

```

and this in build:

```
cd ../home/

tar cvpf ../../target/files/home.tar * .[[:alnum:]]*

```

 *Quote:*   

> Is there a way to do this:
> 
> ```
> 
> mkdir /home/wolvix
> ...

 

If you login with root you could plase those lines in to the root's .bashrc file or if you don't make a small script with those lines and call it from some initscript.

----------

## Farkenell

I've done everything I can to get a valid chrooted system up: (that I know of)

I'm wondering why my img file is so small? its around 400 megs...and I've got stuff like X installed (it totals around gig or two I'm using a dvdr )

the build script seemed to do that, I just did a 

mksquashfs source/ target/files/source.img -e source/usr/portage/distfiles

and its still relatively small 400megs or so

*edit: I think I may have found my problem, the grub thingy  :Wink:  **lets see if it changes much

----------

## yoshi314

i have a few more of my stupid (IMHO) questions. 

linux has rather lots of programs. i wonder how much space would i save by toying with CFLAGS (especially -Os) and switching to uclibc??

and second thing, how can i mount all existing partitions like knoppix does (it created mountpoints like /mnt/hda1 /mnt/hda5 etc, for existing partitions)?

----------

## Wolven

 *MixMax wrote:*   

> Do you get any error messages when the linuxrc runs?
> 
> could you try this in linuxrc:
> 
> ```
> ...

 

No, I'm not getting any error messages about linuxrc. Infact I don't see any message at all about linuxrc on boot.

I tried the new entries in linuxrc and the build script as you describe here, but still no go. This is what I tried before making my first post here, but since that faild me, so I thought it was the wrong way to go abut it. This time I removed the /livecd/target directory before building just to make shure I build a new image with the /home options.

There must be something I've done wrong in the build process of the LiveCD since this will not work. I'm gonna try making a script that extracts the tar into home like you suggested, if that fails I'm gonna start over from scratch.

Thank you for your time.

----------

## MixMax

That sucks  :Sad:  I've use the apove method in here with out problems. I still can't see anything wrong with your script.

Try adding these line to the very top and the other one to the very  buttom of linuxrc.

```

#!/bin/sh

export PATH=/bin

echo "Starting initrd..."

```

```
echo In new chroot...

exec /sbin/init ${CMDLINE}

EOF

```

And then let us know if you see any text during the boot between those lines.

----------

## Farkenell

well got my disc working  :Smile: 

thanks for the howto  :Smile: 

I was getting the problem mounting something

UDF-fs no partition found

THe reason was the script wasn't mounting the cdrom properly....I used the method previously which added the cdrom to the for loop in the linuxrc script  :Smile:  thanks for that  :Smile: 

Spent 5 days on this too lol, persistence does pay off  :Very Happy: 

ere we are  :Smile: 

 *x-cnc wrote:*   

> My $.02, which may or may not help out people having trouble:
> 
> If your cdrom is always not found you can change this line in linuxrc:
> 
> ```
> ...

 

----------

## Jerri

I'm really confused with the code below, from what I gather, it creates a tarball of all the files in target/etc/, var/, and root/

so what is the purpose of the last part => .[[:alnum:]]*

A quick look around, reveals that alnum is a predefined class of characters: [0-9A-Za-z].  is this to ensure that all files are tarred.. isn't * sufficient?  

```
tar cvpf ../../target/files/etc.tar * .[[:alnum:]]*

cd ../var/

tar cvpf ../../target/files/var.tar * .[[:alnum:]]*

cd ../root/

tar cvpf ../../target/files/root.tar * .[[:alnum:]]* 
```

this is what i get when i try to run the code above:

```
tar: Removing leading `/' from member names

tar: /root/livecd/etc/.[[\:alnum\:]]*: Cannot stat: No such file or directory

tar: Error exit delayed from previous errors

tar: /root/livecd/root/*: Cannot stat: No such file or directory

tar: Error exit delayed from previous errors
```

----------

## Jerri

ok, more problems:

after creating a squashed image, i get the following when I try and run mkisofs:

(livecd is the source directory)

```
[root][~/livecd]: mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 4 -hide boot.catalog -o /mnt/storage/livecd/livecd.iso /mnt/storage/livecd/ 

Warning: Creating ISO-9660:1999 (version 2) filesystem.

Warning: ISO-9660 filenames longer than 31 may cause buffer overflows in the OS.

call to search_tree_file with an absolute path, stripping

initial path separator. Hope this was intended...

mkisofs: Uh oh, I cant find the boot image '/root/livecd/boot/grub/stage2_eltorito' !

[root][~/livecd]: 

```

I can't figure it out, stage2_eltorito exists:

```
[root][~/livecd]: ls /root/livecd/boot/grub/stage2_eltorito -l

-rw-r--r--  1 root root 143948 Mar  9 21:05 /root/livecd/boot/grub/stage2_eltorito
```

man mkisofs explains that "The pathname must be relative to the source path specified to mkisofs."

Isn't the path relative to the source?   I'm so confused now...

----------

## MixMax

Seems like your not running the tar code exactly like you posted otherwise you shouldn't get the full path in the error message (tar: /root/livecd/etc/.[[\:alnum\:]]*: Cannot stat: No such file or directory)

if you want to use the full path in your tar command it should be something like this:

```
 

tar cvpf (path to your target folder)/files/var.tar /root/livecd/etc/* /root/livecd/etc/.[[:alnum:]]*
```

Your right on what [[:alnum:]] means. Reason why you should have the .[[:alnum:]]* is that it will include all the hiden files in the folder and exlude the . and .. in there (if you would use .* you would have your tar command to follow the .. and you would end up packing everything in there also)Last edited by MixMax on Thu Mar 10, 2005 7:55 am; edited 1 time in total

----------

## MixMax

```
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 4 -hide boot.catalog -o /mnt/storage/livecd/livecd.iso /mnt/storage/livecd/
```

You've specified the source path as "/mnt/storage/livecd/" so the apove command is trying to find the boot image from /mnt/storage/livecd/boot/grub/stage2_eltorito not in /root/livecd/boot/grub/stage2_eltorito as it seems youd like it to. Try changing the command to:

```

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 4 -hide boot.catalog -o /mnt/storage/livecd/livecd.iso /root/livecd/
```

and see if that helps  :Smile: 

----------

## Farkenell

does anyone know how to get mkxf86config.sh to boot into 1280x1024  :Smile:  it seems to only want to do a maximum of 1024x768....

----------

## Jerri

MixMax, much obliged for you assistance...

but.. :)

I'm haing troubles with grub, after burning the cd, I reboot, grub loads, and then i'm left with a "Minimal BASH-like editing.."

I'm not quite sure how to procede, as it doesn't give me any errors, it doesn't crash, or hang, it just sits there.  There are a number of help commands, but none of them do anything (like boot/kernel/ can't recall any of the others).  Yeah, so, i'm not terribly familiar with grub (i have never used it before) but if anyone has any ideas on how I should go about diagnosing the problem.. i'm all ears.

----------

## Farkenell

its probably because of your linuxrc script off the initrd image  :Wink: 

/mnt/linuxrc (I think)

u can remount it without having to redo it which was what I was doin  :Embarassed: 

mount -o loop /boot/initrd /mnt/linuxrc 

the problem I think it is, its not finding the cdrom

/mnt/linuxrc

```

# CD not found

if [ "${CDROM}" == "" ]

then

  exec /bin/sh

  exit

fi 

```

which is giving you a limited bash which have only the functions of the stuff you copied to /bin in the initrd  :Wink: 

you should check that 

- you have the proper libraries copied over for each file in the /bin 

```

ldd /bin/mount    

        linux-gate.so.1 =>  (0xffffe000)

        libc.so.6 => /lib/libc.so.6 (0x4002e000)

        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

cp /lib/libc.so.6 /mnt/initrd/lib/

cp /lib/ld-linux.so.2 /mnt/initrd/lib/ 

```

then you would do it through each of the files you copied into /bin

```

ldd /bin/sh

etc

```

the other thing is it isn't finding the cdrom...

which is the problem I was having for a few days....if you check my post the previous page it has the fix that someone has already posted....

also it could be you haven't compiled iso9660 support into the kernel (then the kernel won't recognise the cdrom)

----------

## MixMax

Try using grub version  0.95.20040823  :Wink: 

----------

## Jerri

ok...  so it works (sort of)

I have made a little progress with grub, but i'm still having some serious issues trying to get this thing to work (properly).  I guess it might be easiest to specify each problem in a list and then include all the appropriate config / scripts at the end.  The two scripts are used to create the initrd image, and create ISO livecd image.

1) grub will not boot automatically, i have to manully specify the paramters.  It always drops me into grubs command shell...

```
    GNU GRUB  version 0.94  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB

   lists possible command completions.  Anywhere else TAB lists the possible

   completions of a device/filename. ]

grub> 
```

2) I get a kernel panick if i try to specify init=/linuxrc, however, if i specify init=/bin/sh and then manually run 'sh linuxrc' it works...  :Rolling Eyes: 

```
VFS: Mounted root (ext2 filesystem).

Freeing unused kernel memory: 344k freed

Kernel pnaic - not syncing: No init found.  Try passing init= option to kernel
```

Here is a peek at the initrd directory, so it appears that linuxrc is there... but, i dunno  :Sad: 

```
[root][/mnt/storage/livecd/source/mnt/initrd]: ls -l

total 21

drwxr-xr-x  2 root root  1024 Mar 10 22:30 bin

drwxr-xr-x  2 root root  1024 Mar 10 22:30 cdrom

drwxr-xr-x  2 root root  1024 Mar 10 22:30 dev

drwxr-xr-x  2 root root  1024 Mar 10 22:30 etc

drwxr-xr-x  2 root root  1024 Mar 10 22:30 lib

-rwxr-xr-x  1 root root  1038 Mar 10 22:30 linuxrc

drwx------  2 root root 12288 Mar 10 22:30 lost+found

drwxr-xr-x  2 root root  1024 Mar 10 22:30 new

drwxr-xr-x  2 root root  1024 Mar 10 22:30 proc
```

3) I can't specify cdroot and the grub command shell when typing in the paramters for kernel, this results in a kernel panick (this happens with both init=/linuxrc and init=/bin/sh) and I'm not even sure what cdroot is supposed to do.. I haven't found any relevent documentation for that one...

```
cdroot: cdroot: No such file or directory

Kernel panic - not syncing: Attempted to kill init!
```

4) I can't reboot or shutdown the system

```
sh-2.05b#shutdown-r now

init: /dev/initctl: No such file or directory

sh-2.05b#reboot

Wanring: could not determine runlevel doing soft reboot
```

5) The section in linuxrc that executes /sbin/init, doesn't do anything except this:

```
Usage: init 0123456SsQqAaBbCcUu
```

again, not sure why it is necessary, or what its intended for...

Any ideas on how to fix these, i'm all ears...  for number 4, i thought of just copying /dev/initctl from my workingin system, to the livecd dev directory.. don't know if that is a good idea or not.. 

Oh, and i'm running version: GNU GRUB 0.96

configs:

```
# grub.conf

default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Gentoo Linux

root (cd)

kernel (cd)/boot/vmlinuz root=/dev/ram0 rw init=/linuxrc

initrd (cd)/boot/initrd 
```

linuxrc:

```

#!/bin/sh

export PATH=/bin

# Get kernel CMDLINE

mount -t proc none /proc

CMDLINE=`cat /proc/cmdline`

umount /proc

# Mount CD device

CDROM=""

for x in hda hdb hdc hdd

do

  mount -t iso9660 -r /dev/${x} /cdrom > /dev/null 2>&1

  if [ "$?" = "0" ]

  then

    CDROM="${x}"

    break

  fi

done

# CD not found

if [ "${CDROM}" == "" ]

then

  exec /bin/sh

  exit

fi

# Mount root and create read-write directories

mount -t squashfs -o loop /cdrom/files/source.img /new > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/var > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/etc > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/tmp > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/root > /dev/null 2>&1

cd /new/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /new/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /new/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

# Pivot root and start real init

cd /new

pivot_root . newroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}
```

scripts:

```
#!/bin/bash

#

# Create initrd:

# Create initrd image

rm -f /boot/initrd

touch /boot/initrd

dd if=/dev/zero of=/boot/initrd bs=1024k count=8

losetup /dev/loop0 /boot/initrd

mke2fs /dev/loop0

rm -rf /mnt/initrd

mkdir /mnt/initrd

mount /dev/loop0 /mnt/initrd 

# populate files in initrd

cd /mnt/initrd

mkdir etc dev lib bin proc new cdrom

rm -f linuxrc

touch linuxrc

chmod +x linuxrc

touch etc/mtab

touch etc/fstab 

#

# Binaries and libraries

#

bin_directory="/mnt/initrd/bin/"

lib_directory="/mnt/initrd/lib/"

lookup="

/bin/sh

/bin/cat

/bin/mount

/bin/umount

/bin/mkdir

/bin/chroot

/bin/tar

/sbin/pivot_root"

echo -e "Copying files:\n"

for i in $lookup; do

        cp -v $i $bin_directory

        files="$files `ldd $i  | awk '{print $3}' | sed 's/(0xffffe000)//'`"

done

for i in $files; do

        cp -v $i $lib_directory

done

# Setup device nodes:

mknod /mnt/initrd/dev/console c 5 1

mknod /mnt/initrd/dev/null c 1 3

mknod /mnt/initrd/dev/tty c 4 0

mknod /mnt/initrd/dev/loop0 b 7 0 

# Hard disks:

mknod /mnt/initrd/dev/sda b 8 0

mknod /mnt/initrd/dev/sdb b 8 16

mknod /mnt/initrd/dev/hda b 3 0

# CD drives:

mknod /mnt/initrd/dev/hdc b 22 0

mknod /mnt/initrd/dev/hdd b 22 64

# Create linuxrc file

cat > /mnt/initrd/linuxrc << "EOF"

#!/bin/sh

export PATH=/bin

# Get kernel CMDLINE

mount -t proc none /proc

CMDLINE=`cat /proc/cmdline`

umount /proc

# Mount CD device

CDROM=""

for x in hda hdb hdc hdd

do

  mount -t iso9660 -r /dev/${x} /cdrom > /dev/null 2>&1

  if [ "$?" = "0" ]

  then

    CDROM="${x}"

    break

  fi

done

# CD not found

if [ "${CDROM}" == "" ]

then

  exec /bin/sh

  exit

fi

# Mount root and create read-write directories

mount -t squashfs -o loop /cdrom/files/source.img /new > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/var > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/etc > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/tmp > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/root > /dev/null 2>&1

cd /new/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /new/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /new/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

# Pivot root and start real init

cd /new

pivot_root . newroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}
```

```
#!/bin/bash

# Create ISO image and burn to cd

livecd_root="/mnt/storage/livecd"

livecd_target="$livecd_root/target"

livecd_source="$livecd_root/source"

livecd_output="$livecd_root/livecd.iso"

# Excluded directories from squashfs:

exclude_dir="/usr/portage /usr/src /mnt/initrd"

# unmount proc:

umount $livecd_source/proc > /dev/null 2>&1

# Delete old ISO image

rm  -f "$livecd_output"

# Remove old target directory

rm -rf "$livecd_target"

mkdir  "$livecd_target"

mkdir  "$livecd_target"/files

# Clean unecessary files

rm -rf "$livecd_source"/tmp/*

rm -rf "$livecd_source"/var/tmp/*

rm -rf "$livecd_source"/var/lock/*

cp -a  "$livecd_source"/boot "$livecd_target"

rm -f  "$livecd_source"/etc/mtab

touch  "$livecd_source"/etc/mtab

echo -e "\nCreating tarballs...\n"

# Create tarballs (etc/root/var):

cd "$livecd_source"/etc/

tar --ignore-failed-read -cpf "$livecd_target"/files/etc.tar  * .[[:alnum:]]*

cd ../var/

tar --ignore-failed-read -cpf "$livecd_target"/files/var.tar  * .[[:alnum:]]*

cd ../root/

tar --ignore-failed-read -cpf "$livecd_target"/files/root.tar * .[[:alnum:]]*

echo -e "\nCreating squashfs...\n"

for i in $exclude_dir; do

        exclude_sqfs="$exclude_sqfs $livecd_source$i"

done

mksquashfs "$livecd_source" "$livecd_target"/files/source.img -e $exclude_sqfs

echo -e "\nCreating ISO image...\n"

cd /

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size \

   4 -boot-info-table -iso-level 4 -hide boot.catalog -quiet \

   -o $livecd_output $livecd_target/ > /dev/null 2>&1

# Blank CD-RW & Burn image

echo -en "\nBlanking CD..  "

cdrecord dev=ATAPI:0,0,0 blank=fast gracetime=2 >/dev/null 2>&1

echo "done"

echo -en "\nBuring image..  "

cdrecord fs=8m -dao -data dev=ATAPI:0,0,0 speed=10 driveropts=burnfree -overburn -eject gracetime=2 $livecd_output >/dev/null 2>&1

echo "done"

exit 0
```

----------

## MixMax

Downgrade to the grub version I previously mentioned.

ps. you don't realy have to create a script for the initrd image. You can just mount it to a loop back device just like Farkenell mentioned and do the changes you need in there.

----------

## Jerri

Ok, more problems.

I downgraded to grub 0.95, wich solved a number of them, however, things have gone a bit sour.  The funny thing about all this is, I had it working at one point.. I then decided to add a number of packages, and things have gone completely screwy, and I can't quite retrace my steps backwards.

Anyways, problems I'm facing right now are more often one of the following examples:

1) Sometimes this happens, although not always... I'm having a real hard time recreating each error.  They just sort of come and go..

```
Kernel panic - not syncing. VFS: Unable to mount root fs on unknown-block (1,0)
```

2) Again, same thing.

```
Kernel panic - not syncing: No init found try passing init= option to kernel
```

3) This one is always fun.. the system boots, init is loaded, and a login screen comes up, however, when you try and login, i get this:

```
FATAL: cannot change permissions of TTY: Read-only file system
```

I think i have reached the end of my rope, I might just have to start from scratch.  Hell, I have probably borked it so well, that its well beyond repair.  But if any one has any ideas why these problems keep popping up... i'm all ears.    

One more thing, is it necessary that /dev be empty or populated when making a squashfs... I have tried both, and each one gives a me a different version of the above... usually dependent on whether i'm cranky or extra cranky..

linuxrc:

```
#!/bin/sh

export PATH=/bin

# Get kernel CMDLINE

mount -t proc none /proc

CMDLINE=`cat /proc/cmdline`

umount /proc

# Mount CD device

CDROM=""

for x in hdc hdd

do

  mount -t iso9660 -r /dev/${x} /cdrom > /dev/null 2>&1

  if [ "$?" = "0" ]

  then

    CDROM="${x}"

    break

  fi

done

# CD not found

#if [ "${CDROM}" == "" ]

#then

#  exec /bin/sh

#  exit

#fi

# Mount root and create read-write directories

mount -t squashfs -o loop /cdrom/files/source.img /new > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/var > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/etc > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/tmp > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/root > /dev/null 2>&1

cd /new/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /new/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /new/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

# Pivot root and start real init

cd /new

pivot_root . newroot

exec chroot . /bin/sh << EOF 

exec /sbin/init ${CMDLINE}

EOF 
```

grub.conf:

```
default 0

timeout 10

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Gentoo Linux

root (cd)

kernel (cd)/boot/bzImage root=/dev/ram0 rw init=/linuxrc

initrd (cd)/boot/initrd

title=Gentoo Linux (/bin/sh)

root (cd)

kernel (cd)/boot/bzImage root=/dev/ram0 rw init=/bin/sh

initrd (cd)/boot/initrd
```

----------

## Farkenell

try the cd thing that I mentioned before  :Wink: 

and uncomment the cd section of your linuxrc....

I was getting similar issues....

----------

## Jerri

Ok, well...

I feel stupid.  Apparently i forgot to add livecd to the USE flags...

RTFM... yes yes.  lesson learned  :Rolling Eyes: 

If your having trouble getting this working, have a peek at invalid account's livecd script

I made a substantial number of changes to get it working with my own system, but its a great place to start.

----------

## yoshi314

okay i've already tried building everything twice. first time, manually. second time from livecd making script, someone is linking in here (i forgot your name. sorry) but it does not work as well.

1. grub cannot find its config file (i had to type parameters in. now i switched to isolinux, so that's okay)

2. i cannot use MTRR in kernel with livecd somehow ("size and base must be multiples of 4Kib" error and halt, i disabled mtrr in kernel, but it sucks)

3. right after pivot_root command in linuxrc something bad happens and system does not go any further (what to do?)

so i guess i'm stuck for now. any suggestions?

----------

## MixMax

If you want to use grub you should be using  version 0.95.20040823. newer won't work.

What does your emerge info say? (I'd like to know the kernel version and use flags)

Have you emerged the baselayout?

What do you get when you type "rc-status boot"?

----------

## yoshi314

 *MixMax wrote:*   

> If you want to use grub you should be using  version 0.95.20040823. newer won't work.

 ahh i see now, but i'm now using syslinux anyway  :Very Happy: 

 *Quote:*   

> What does your emerge info say? (I'd like to know the kernel version and use flags)

 

kernel is gentoo-dev-sources 2.6.11-r3 and emerge info goes : 

```
Portage 2.0.51.19 (default-linux/x86/2004.3, gcc-3.4.3-20050110, glibc-2.3.4.20050125-r0, 2.6.11-gentoo-r3 i686)

=================================================================

System uname: 2.6.11-gentoo-r3 i686 Intel(R) Celeron(R) CPU 1.70GHz

Gentoo Base System version 1.6.10

Python:              dev-lang/python-2.3.5 [2.3.5 (#1, Mar 15 2005, 16:37:31)]

dev-lang/python:     2.3.5

sys-devel/autoconf:  2.13, 2.59-r6

sys-devel/automake:  1.5, 1.9.5, 1.6.3, 1.7.9-r1, 1.4_p6, 1.8.5-r3

sys-devel/binutils:  2.15.92.0.2-r6

sys-devel/libtool:   1.5.14

virtual/os-headers:  2.6.8.1-r2

ACCEPT_KEYWORDS="x86 ~x86"

AUTOCLEAN="yes"

CFLAGS="-march=i586 -O2 -pipe -fomit-frame-pointer"

CHOST="i586-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"

CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"

CXXFLAGS="-march=i586 -O2 -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="autoaddcvs autoconfig candy ccache cvs distlocks moo sandbox sfperms userpriv usersandbox"

GENTOO_MIRRORS="http://src.gentoo.pl http://gentoo.prz.rzeszow.pl http://gentoo.oregonstate.edu http://gentoo.zie.pg.gda.pl http://www.ibiblio.org/pub/Linux/distributions/gentoo"

LANG="pl_PL"

LC_ALL="pl_PL"

LDFLAGS="-W1,-O1"

MAKEOPTS="-j2"

PKGDIR="/usr/portage/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"

USE="x86 apm arts avi berkdb bitmap-fonts cdr crypt cups emboss encode font-server foomaticdb fortran gdbm gif gpm imlib jpeg libg++ libwww livecd mad mikmod motif mp3 mpeg ncurses nls nptl nptlonly oggvorbis opengl oss pam pdflib perl pic png python qt quicktime readline sdl spell ssl svga tcpd truetype truetype-fonts type1-fonts userlocales xml2 xmms xv zlib linguas_en linguas_pl"

Unset:  ASFLAGS, CBUILD, CTARGET, PORTDIR_OVERLAY
```

 *Quote:*   

> Have you emerged the baselayout?

 of course i did

 *Quote:*   

> What do you get when you type "rc-status boot"?

 nothing is set yet, because i'm only trying to get the init to start

i turned mtrr off so that one is gone. grub problem is gone, but now it cannot find init (linuxrc) somehow :/

----------

## MixMax

Your settings should be ok  :Smile: 

Try emerging sysvinit.

----------

## yoshi314

 *MixMax wrote:*   

> Your settings should be ok 
> 
> Try emerging sysvinit.

 

ok i'll do that. 

now i have cannot find init bug :/ even trough it's right there in parameters... :Confused:  i'm trying grub again. [sheesh]

[edit]gcc told me a funny thing - it cannot create 32bit code. i sent all the livecd source dir straight to hell. trying again. argh  :Evil or Very Mad: 

----------

## Farkenell

has anyone got xmms to properly work? I only get the cd writer plugin for output :/....

I've built it with the required flags (even though by default it should have oss I think - trying alsa flag now)

hrmm....what else....

I wish to make a rc-script for transparencies....someone able to point me in the right direction? I just want to make a basic script maybe a choice and a timeout whether to startx with xcomp  :Smile:  (if chosen it will append the proper data to the files xorg, and the /etc/X11/Sessions/file  :Smile: ) --nm found it on the wiki  :Smile: 

----------

## MixMax

Not sure what you've tryed to play with xmms. 

If your trying to play stream remember to emerge xmms-mpg123 also.

----------

## dirtbag

Finding dependencies for pp_pack.o.

Finding dependencies for pp_sort.o.

Finding dependencies for miniperlmain.o.

Finding dependencies for perlmain.o.

make[1]: Entering directory `/var/tmp/portage/libperl-5.8.5/work/perl-5.8.5'

echo Makefile.SH cflags.SH config_h.SH makeaperl.SH makedepend.SH makedir.SH myconfig.SH writemain.SH pod/Makefile.SH | tr ' ' '\n' >.shlist

make[1]: Leaving directory `/var/tmp/portage/libperl-5.8.5/work/perl-5.8.5'

Updating makefile...

test -s perlmain.c && touch perlmain.c

cd x2p; make depend

make[1]: Entering directory `/var/tmp/portage/libperl-5.8.5/work/perl-5.8.5/x2p'

makefile:157: *** target pattern contains no `%'.  Stop.

make[1]: Leaving directory `/var/tmp/portage/libperl-5.8.5/work/perl-5.8.5/x2p'

make: *** [depend] Error 2

!!! ERROR: sys-devel/libperl-5.8.5 failed.

!!! Function src_compile, Line 217, Exitcode 2

!!! Couldn't make libperl.so depends

!!! If you need support, post the topmost build error, NOT this status message.

dellbox / # 

when I do emerge system..

any idears? seems to have something to do with proc

but I did 

mount -o bind /proc proc

mount -o bind /usr/portage/distfiles usr/portage/distfiles

----------

## abasme

hello to all:

 I have had problems with the booteo of livecd especificamente when linuxrc does chroot requests to me to load I module binfmt-9653 which I have reviewed in kernel and this compiled not as I module.

I think that the problem was that the tapeworm that to put as I module but the problem persists, that if use zisofs, but if use squashfs does not mount the image to me although I put the support to him in kernel of squashfs and I did 

emerge squashfs-tools.

  I am using kernel gentoo-dev-sources-2.6.10-gentoo-r8 some idea to solve this problem.

Thanks.

----------

## Bonkie

wanted to say thanx for the howto, works like a charm here, got myself my own working live-cd  :Very Happy: 

----------

## MixMax

Just a small idea. Since we pack the root, etc and var directories to a seperate tar file. It might be a good idea to exlude them when you make the squashfs image, since now you have them twice in the cd.

Now the hard part, It's not quite that simple as it might sound, since you need the directory for mount point. So you can't just add the hole directory to mksquashfs line (not like this  mksquashfs ... -e root etc var).

It might be possible to use a file that has a list of all the files in those directories and then use the -ef option in mksquashfs command (if that makes any sense  :Wink: ). Oh well I don't realy have a good working solution for this yet.  :Sad: 

I'll do some more work with this sometimes early next week (if no one has a working solution yet).

----------

## mpalencia

Thanks Man!! this is a great how to!, 

I ran into some problems, but most of them were dumb mistakes I made, exec for this part in the linuxrc script::

```

[color=green# Mount CD device

CDROM=""

for x in hda hdb hdc hdd cdroms/cdrom0 cdroms/cdrom1

do

  mount -t iso9660 -r /dev/${x} /cdrom > /dev/null 2>&1

  if [ "$?" = "0" ]

  then

    CDROM="${x}"

    break

  fi

done] [/color]

```

Changing that line worked for me, without it, my cd wouldnt boot.

Thanks again to everyone on this forum, reading about your solutions helped a lot.

 :Laughing: 

----------

## Illissius

OK, I finally got around to completing the howto  :Cool: .

Unfortunately, I keep getting the kernel panic: no init found error, whether I pass init=/linuxrc or init=/bin/sh -- both of which most certainly exist. Any ideas why this could be happening?

(This is using the isolinux method and qemu, if it is relevant.)

----------

## MixMax

Do you have sysvinit installed?

----------

## Illissius

 *MixMax wrote:*   

> Do you have sysvinit installed?

 

No. Do I need it? I don't remember seeing it mentioned in the howto... and this error is occurring right after loading the initrd, so it should be initing with linuxrc, not init.

EDIT - Never mind. Apparently I missed one of the libraries in /lib, after putting it in the initrd it works just fine now. Accurate error messages would've been a help...

Now I just need to troubleshoot all the errors in the post-pivot_root initing :/

bunch of stuff about no space left on device when writing to stdout (or something?), a segmentation fault in coldplug, atd and bootmisc don't start, duplicate id fields in inittab when starting xdm, nano says error opening terminal: linux, lots of stuff I've forgotten that's scrolled off screen already, etc., etc.... ugh.

Think I'll burn it first, to see what it does with actual hardware...

EDIT #2 - It seems at least part of the troubles was me misunderstanding the size argument for tmpfs... I thought it was the initial size, while it is actually the maximum size.

----------

## Illissius

omfg, it works completely!  :Cool:  seems most if not all of the errors were due to the tmpfs thing... a few may have been to restrictive permissions on /dev/null and /dev/tty.

observations...

- qemu is slow as shit, even with the accelerator thingy. it takes like half a minute for kicker to slide on/off the screen, and several for things to actually start.

- KDE 3.4 :drool:

I updated stuff to use unionfs, and others I've forgotten, will prob. post about it tomorrow...

----------

## pi-cubic

hi guys,

i build myself a livecd and really like the approach of creating such a system. my intendency now is to create a CompactFlash system in this style for CF-based routers. since i want to reduce program/erase-cycles on the CF to increase the lifetime of the system, i want to push almost everything in the ram (except /etc). i don't want to lose the flexibility of this chroot though, that's why i want to start from this aproch. this is the main concept, now i still have some questions i like to debate about and would like to have some feedback about since this howto will be my base.

1) which filesystem would be suitable for the CF disk?

i read something about JFFS (journaling flash file system), but i don't know how widepread it has been used in practical enviroments yet and how it is supported by gentoo.

2) how would the boot process look like compared to a CD-ROM?

i have the following in my mind: initrd loads the necessary modules for the CF-controller. after that, the created tarballs (from a script) will be extracted and put into a ramdisk (ramfs?). just /etc will be directly on the CF to adjust some configuration settings without losing the changes.

thanks in advance for your opinions!

greetings,

pi-cubic

----------

## Illissius

OK, here's my current build and linuxrc and other stuff, for those who want to play with it, before I start changing it all around (problem is mksquashfs takes forever, so I'm experimenting in large chunks).

```
# cat build

#!/bin/bash

rm -rf target

mkdir target

cp -a isolinux target/

rm -rf source/var/tmp/*

rm -rf source/var/run/*

rm -rf source/var/lock/*

rm -rf source/tmp/*

rm -f source/etc/mtab

touch source/etc/mtab

mksquashfs source/ target/source.img -e usr/src usr/share/doc usr/share/man boot

mkisofs -R -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 4 -hide boot.catalog -o /livecd/livecd.iso target/

# ls isolinux/

display.txt  initrd  isolinux.bin  isolinux.cfg  vmlinuz

# cat isolinux/isolinux.cfg

DEFAULT LinuKS

DISPLAY display.txt

TIMEOUT 100

PROMPT 1

LABEL LinuKS

    KERNEL vmlinuz

    APPEND cdroot initrd=initrd root=/dev/ram0 rw init=/linuxrc video=vesafb-tng:ywrap,mtrr,800x600@70 splash=verbose,theme:emergence CONSOLE=/dev/tty1

LABEL LinuKS-debug

    KERNEL vmlinuz

    APPEND cdroot initrd=initrd root=/dev/ram0 rw init=/bin/sh video=vesafb-tng:ywrap,mtrr,800x600@70 splash=verbose,theme:emergence CONSOLE=/dev/tty1

LABEL LinuKS-qemu

    KERNEL vmlinuz

    APPEND cdroot initrd=initrd root=/dev/ram0 rw init=/linuxrc video=vesafb-tng:ywrap,mtrr,800x600@70 splash=verbose,theme:emergence CONSOLE=/dev/tty1 clock=pit

LABEL LinuKS-qemu-debug

    KERNEL vmlinuz

    APPEND cdroot initrd=initrd root=/dev/ram0 rw init=/bin/sh video=vesafb-tng:ywrap,mtrr,800x600@70 splash=verbose,theme:emergence CONSOLE=/dev/tty1 clock=pit

//I haven't gotten gensplash actually working yet

# mkdir initrd; mount -o loop isolinux/initrd initrd/

# ls -lR initrd/       /* created by merging the geninitramfs initrd with the one in the howto + custom modifications */

initrd/:

total 11

drwxr-xr-x  2 root root 1024 Apr  3 19:07 bin

drwxr-xr-x  2 root root 1024 Apr  2 23:09 cdrom

drwxr-xr-x  5 root root 1024 Apr  3 00:52 dev

drwxr-xr-x  3 root root 1024 Apr  3 00:53 etc

drwxr-xr-x  3 root root 1024 Apr  3 19:07 lib

-rwxr-xr-x  1 root root  940 Apr  3 20:56 linuxrc

drwxr-xr-x  2 root root 1024 Apr  2 23:09 new

drwxr-xr-x  2 root root 1024 Apr  2 23:09 proc

drwxr-xr-x  2 root root 1024 Apr  3 00:53 root

drwxr-xr-x  2 root root 1024 Apr  3 00:53 sbin

drwxr-xr-x  2 root root 1024 Apr  3 00:53 sys

initrd/bin:

total 1483

-rwxr-xr-x  1 root root 304852 Apr  3 18:47 awk

-rwxr-xr-x  1 root root  23532 Apr  2 23:11 cat

-rwxr-xr-x  1 root root  19296 Apr  2 23:11 chroot

-rwxr-xr-x  1 root root  57348 Apr  3 18:49 du

-rwxr-xr-x  1 root root  32508 Apr  2 23:11 mkdir

-rwxr-xr-x  1 root root  85460 Apr  3 18:11 modprobe

-rws--x--x  1 root root  82356 Apr  2 23:11 mount

-rwxr-xr-x  1 root root   5916 Apr  2 23:11 pivot_root

-rwxr-xr-x  1 root root 843748 Apr  2 23:11 sh

-rws--x--x  1 root root  44340 Apr  2 23:11 umount

initrd/cdrom:

total 0

initrd/dev:

total 3

crw-r--r--  1 root root  5,  1 Apr  2 23:14 console

drwxr-xr-x  2 root root   1024 Apr  3 00:52 fb

brw-r--r--  1 root root  3,  0 Apr  2 23:14 hda

brw-r--r--  1 root root  3, 64 Apr  2 23:14 hdb

brw-r--r--  1 root root 22,  0 Apr  2 23:14 hdc

brw-r--r--  1 root root 22, 64 Apr  2 23:14 hdd

brw-r--r--  1 root root  7,  0 Apr  2 23:14 loop0

drwxr-xr-x  2 root root   1024 Apr  3 00:52 misc

crw-rw-rw-  1 root root  1,  3 Apr  2 23:14 null

crw-rw-rw-  1 root root  4,  0 Apr  2 23:14 tty

drwxr-xr-x  2 root root   1024 Apr  3 00:52 vc

initrd/dev/fb:

total 0

initrd/dev/misc:

total 0

initrd/dev/vc:

total 0

initrd/etc:

total 1

-rw-r--r--  1 root root    0 Apr  2 23:10 fstab

-rw-r--r--  1 root root    0 Apr  2 23:10 mtab

drwxr-xr-x  3 root root 1024 Apr  3 00:53 splash

initrd/etc/splash:

total 1

drwxr-xr-x  3 root root 1024 Apr  3 00:53 emergence

initrd/etc/splash/emergence:

total 3

-rw-r--r--  1 root root 1083 Apr  3 00:53 800x600.cfg

drwxr-xr-x  2 root root 1024 Apr  3 00:53 images

initrd/etc/splash/emergence/images:

total 376

-rw-r--r--  1 root root  76287 Apr  3 00:53 silent-800x600-256.png

-rw-r--r--  1 root root  16947 Apr  3 00:53 silent-800x600.jpg

-rw-r--r--  1 root root 232630 Apr  3 00:53 verbose-800x600-240.png

-rw-r--r--  1 root root  52837 Apr  3 00:53 verbose-800x600.jpg

initrd/lib:

total 1568

-rwxr-xr-x  1 root root   96952 Apr  3 13:10 ld-linux.so.2

-rwxr-xr-x  1 root root   32364 Apr  2 23:13 libblkid.so.1

-rwxr-xr-x  1 root root 1271360 Apr  2 23:12 libc.so.6

-rwxr-xr-x  1 root root   10976 Apr  2 23:12 libdl.so.2

-rwxr-xr-x  1 root root  165032 Apr  3 18:48 libm.so.6

-rwxr-xr-x  1 root root   15028 Apr  2 23:13 libuuid.so.1

drwxr-xr-x  3 root root    1024 Apr  3 18:09 modules

initrd/lib/modules:

total 1

drwxr-xr-x  3 root root 1024 Apr  3 19:51 2.6.11-morph5

initrd/lib/modules/2.6.11-morph5:

total 102

drwxr-xr-x  2 root root   1024 Apr  3 18:10 fs

-rw-r--r--  1 root root 102227 Apr  3 19:51 modules.dep

initrd/lib/modules/2.6.11-morph5/fs:

total 219

-rw-r--r--  1 root root 222751 Apr  3 18:10 unionfs.ko

initrd/new:

total 0

initrd/proc:

total 0

initrd/root:

total 0

initrd/sbin:

total 427

-rwxr-xr-x  1 root root 433380 Apr  3 00:53 splash_helper

initrd/sys:

total 0

# cat initrd/linuxrc

#!/bin/sh

export PATH=/bin

# Get kernel CMDLINE and total physical memory / 4

mount -t proc none /proc

CMDLINE=`cat /proc/cmdline`

RDSIZE=`du -m /proc/kcore | awk '{ print $1 / 4 }'`M

umount /proc

# Mount CD device

CDROM=""

for x in hda hdb hdc hdd cdroms/cdrom0 cdroms/cdrom1 cdroms/cdrom2 cdroms/cdrom3

do

  mount -t iso9660 -r /dev/${x} /cdrom > /dev/null 2>&1

  if [ "$?" = "0" ]

  then

    CDROM="${x}"

    break

  fi

done

# CD not found

if [ "${CDROM}" == "" ]

then

  exec /bin/sh

  exit

fi

# Mount root and create read-write directories

modprobe unionfs

mount -t squashfs -o loop /cdrom/source.img /new > /dev/null 2>&1

mount -t tmpfs -o size=$RDSIZE none /new/ramdisk > /dev/null 2>&1

mount -t unionfs -o dirs=/new/ramdisk=rw:/new=ro none /new > /dev/null 2>&1

# Pivot root and start real init

cd /new

pivot_root . oldroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}

EOF

```

I can't quite remember all the changes I've done, so it's possible I missed something.

Planned modifications:

- see if putting the tmpfs/unionfs part of it in fstab works

- experiment with multisession discs, iso9660 in one session and udf (or maybe even a normal fs? mkisofs doesn't say you can't...) in the other, to save the unionfs 'overlay' ( :Cool: )

- figure out how the whole dmix thing works

- captive-ntfs

- other stuff I've probably forgotten

questions:

- what's the highest hdparm settings i586-era hardware can safely be expected to support?

 *gentoo handbook wrote:*   

> Activate Safe Performance Options:  # hdparm -d 1 -A 1 -m 16 -u 1 - a 64 /dev/hda

 

For example, is that safe to use on anything Pentium or later? (everything is compiled i586 anyways so earlier doesn't interest me.) What about CDROMs? Can the same settings be used?

- the only device found by media:/ in KDE was /dev/loop0, with +hal in USE, HAL installed and in the default bootlevel, and the media manager kdaemon enabled. what gives? do I have to do any special configuration for HAL to work properly?

- livecd-tools contains opengl-update-livecd. what's the difference between it and vanilla opengl-update? (speaking of which, the various autodetection scripts detected and loaded the proprietary nvidia drivers automatically, with no intervention on my part -- hopefully they do the same for ATi, can't test it myself) EDIT - seems this is just used internally by x-setup, so don't have to concern myself with it...

- how much size reduction does compiling with -Os (vs -O2) usually yield? is it safe? should I use it?

- oh, another. is it possible to change the fbsplash resolution once it's already set? ideally I'd like to have it use the same settings autodetected by the X detection scripts... (mkxf86config, x-setup, et al)

to be updated as I remember the rest of the stuff I was going to ask...

----------

## univac^

Hi

I make it but when i booting live cd i have kernel panic (dev/console is isn't in rw mode) in 41 line of linuxrc, its 41 line

```
exec chroot . /bin/sh <<- EOF >dev/console 2>&1
```

How can i fix it?  :Sad: 

----------

## Illissius

 *univac^ wrote:*   

> Hi
> 
> I make it but when i booting live cd i have kernel panic (dev/console is isn't in rw mode) in 41 line of linuxrc, its 41 line
> 
> ```
> ...

 

mount -o loop initrd somedir

chmod +rw somedir/dev/console (or a+rw?)

umount somedir

(I had permissions problems with /dev/null as well, so might want to change that also.)

----------

## Shiner_Man

Wow this guide is totally awesome.  I need to create a livecd for my job that will join a windows domain so I can recover files off a busted hard drive and put them up on the network shares.  I think this might help.

----------

## gieltje

I guess;

title=Gentoo Linux

        root (cd)

        kernel (cd)/boot/vmlinuz video=vesafb:1024x768-32 root=/dev/ram0 rw init=/linuxrc cdroot

        initrd (cd)/boot/initrd 

should be

title=Gentoo Linux

        root (cd)

        kernel /boot/vmlinuz video=vesafb:1024x768-32 root=/dev/ram0 rw init=/linuxrc cdroot

        initrd /boot/initrd 

 :Embarassed: 

Because my grub just keeps reapearing as a command line, if I enter the commands manualy my system boots with only 1 error, and that for my first run  :Twisted Evil: 

Damn that doesnt work as well, can anyone help me to get grub working?

I have allready read this entire thread.

And is there a way to make the cd eject just before shutdown or restart?

----------

## gctaylor

When I follow the instructions (and seemingly follow the tips in this

thread), I can't get my CD to boot past the grub command line.  When I try to

use grub manually by doing this:

```

grub>  root (cd)

grub>  kernel (cd)/boot/vmlinuz   root=/dev/ram0 rw init=/bin/sh cdroot initrd

(cd)/boot/initrd 

grub> boot

```

I get part way into the boot but end with a 

```

UDF-fs No partition found (1)

Kernel panic -not syncing: VFS: unable to mount root fs on uknown block (1,0)

```

Can anyone give me a clue as to whether this is the correct order or what

should come next, or last?  I'm kind of lost on some of this.

I can mount my initrd via loop?

I have four ramdisks of 32768k each

Here are what I think are the correct kernel options.

CONFIG_SQUASHFS=y

CONFIG_ISO9660_FS=y

CONFIG_BLK_DEV_INITRD=y

CONFIG_BLK_DEV_LOOP=y

CONFIG_BLK_DEV_IDECD=y

CONFIG_EXT2_FS=y

CONFIG_TMPFS=y

```

# cat /boot/grub/grub.conf

default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Gentoo Linux

        root (cd)

   #       kernel (cd)/boot/vmlinuz video=vesafb:1024x768-32

   #       root=/dev/ram0 rw init=/linuxrc cdroot

           kernel /boot/vmlinuz root=/dev/ram0 rw init=/bin/sh cdroot

      initrd /boot/initrd

```

# cat ./build.sh

```

#!/bin/bash

rm -rf target

mkdir target

cp -a source/boot target/

mkdir target/files

rm -rf source/var/tmp/*

rm -rf source/var/run/*

rm -rf source/var/lock/*

rm -rf source/tmp/*

rm -f source/etc/mtab

touch source/etc/mtab

cd source/etc/

tar cvpf ../../target/files/etc.tar * .[[:alnum:]]*

cd ../var/

tar cvpf ../../target/files/var.tar * .[[:alnum:]]*

cd ../root/

tar cvpf ../../target/files/root.tar * .[[:alnum:]]*

cd ../../

rm ./livecd.iso

mksquashfs source/ target/files/source.img -info -e usr/src -e usr/portage -e

usr/share/doc usr/share/man

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size \

4 -boot-info-table -iso-level 4 -hide boot.catalog -o ./livecd.iso target/

/usr/bin/cdrecord blank=fast fs=64M -v gracetime=2 dev=/dev/hda speed=4 -tao

-eject -data ./livecd.iso

```

----------

## gieltje

I don't get this, when I start the cd I get the minimal grub bash.

When I run configfile /boot/grub/grub.conf, it runs like a charm.

What Am I doint wrong here?????? :Rolling Eyes: 

Btw, will grub 0.96-r1 work?

----------

## Illissius

 *gctaylor wrote:*   

> 
> 
> ```
> 
> UDF-fs No partition found (1)
> ...

 

From this one gets the impression that you might've accidentally burned the disk as UDF (ie packet write) instead of iso9660 (or alternately, tried to mount it as such)... if it's not that, then dunno.

----------

## gieltje

I have been working on my own version of scripts for building and working

Here is what I call "work", it simply mounts, chroots, and updates the environment (not sure if the env-update works for some reason);

```

mount -o bind /sys source/sys

mount -o bind /dev source/dev

mount -o bind /proc source/proc

chroot source/ /bin/bash --login

env-update

source /etc/profile

```

And "afterwork", this unmounts and updates the environment back to the normal system

```

umount source/sys

umount source/dev

umount source/proc

env-update

source /etc/profile

```

And finaly "build";

```

#!/bin/bash

rm -rf target

mkdir target

cp -a source/boot target/

mkdir target/files

rm -rf source/var/tmp/*

rm -rf source/var/run/*

rm -rf source/var/lock/*

rm -rf source/tmp/*

rm -f source/etc/mtab

touch source/etc/mtab

cd source/etc/

tar cvpf ../../target/files/etc.tar * .[[:alnum:]]*

cd ../var/

tar cvpf ../../target/files/var.tar * .[[:alnum:]]*

cd ../root/

tar cvpf ../../target/files/root.tar * .[[:alnum:]]*

cd ../../

cp /usr/lib/syslinux/isolinux.bin isolinux/

cp source/boot/vmlinuz source/boot/initrd isolinux/

cp -r -a isolinux target/

mkdir target/files/source

cp -p -R -P -d source/ target/files

rm -rf target/files/source/usr/portage

rm -rf target/files/source/usr/lib/portage

rm -rf target/files/source/var/cache

rm -rf target/files/source/usr/share/doc

rm -rf target/files/source/root/.mc

rm target/files/source/root/.bash_history

rm target/files/source/root/.ccache

rm target/files/source/var/log/emerge.log

mksquashfs target/files/source target/files/source.img

rm -rf target/files/source

mkisofs -R -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 4 -hide boot.catalog -o ~/liv$

```

Now here I have made some major changes, first it depends on IsoLinux, and automates isolinux.

Second it makes a exact copy of the source folder and then removes the documentation (not man files), and a lot of temp files.

Third it REMOVES emerge from the cd, since I find this a useless tool to be on a simple live cd.

This saves me about 60megs.

I am sure there are much more things there can removed, and that there are some flaws in these scripts.

Please give feedback on this.Last edited by gieltje on Thu Apr 14, 2005 10:17 am; edited 3 times in total

----------

## desertstalker

I have the same problem as gctaylor.  I cannot get it too boot past grub without manually specifying kernel etc.  I used the same config file as in the first post (making sure all filenames are correct) but is does not seem to read the config file.

Any ideas?

----------

## gctaylor

 *desertstalker wrote:*   

> I have the same problem as gctaylor.  I cannot get it too boot past grub without manually specifying kernel etc.  I used the same config file as in the first post (making sure all filenames are correct) but is does not seem to read the config file.
> 
> Any ideas?

 

Just a few hours ago I was able to get past the grub command line and a little further by using the version of grub-0.95.20040823.  For overall livecd building I'm using the script from http://www.icu.isa-geek.org/download/livecd and for the grub issue I modified the grub line in there with emerge =grub-0.95.20040823.    

Me... I've got a new error I'm working on: Kernel panic - not syncing: No init found.  Try passing init= option to kernel.

----------

## desertstalker

Thanks, ill try that.

EDIT: Nope didnt work

----------

## desertstalker

Found out what does work to fix the prbolem.  If i use menu.lst instaed of grub.conf it works.

Seems the symlink does not work on an iso9660 filesystem.

----------

## gieltje

 *desertstalker wrote:*   

> Found out what does work to fix the prbolem.  If i use menu.lst instaed of grub.conf it works.
> 
> Seems the symlink does not work on an iso9660 filesystem.

 

Damn this should be listed on the front page, should save a lot of people a lot of work.

This shitty problem costed me 8 hours  :Crying or Very sad: .

And isnt this system supposed to be bootstrapped?

----------

## gctaylor

 *desertstalker wrote:*   

> Found out what does work to fix the prbolem.  If i use menu.lst instaed of grub.conf it works.
> 
> Seems the symlink does not work on an iso9660 filesystem.

 

Could you elaborate on this?  I see the symbolic link betwen menu.lst and grub.conf.  What did you do exactly?

I seem to be having all kinds of problems

```

livecdtwo # mount -o loop livecd_src/boot/initrd livecd_src/mnt/initrd

ioctl: LOOP_CLR_FD: Device or resource busy

mount: you must specify the filesystem type

```

```

livecdtwo # mount

/dev/hdb3 on / type reiserfs (rw,noatime,notail)

none on /proc type proc (rw)

none on /sys type sysfs (rw)

none on /dev type ramfs (rw)

none on /dev/pts type devpts (rw)

/dev/hdb1 on /boot type ext2 (rw,noatime)

none on /dev/shm type tmpfs (rw)

none on /proc/bus/usb type usbfs (rw)

```

Thanks,

gary

----------

## desertstalker

I removed the menu.lst symlink and copied grub.conf to menu.lst so that menu.lst has the same information as grub.conf.

As for the other error you need to run losetup first i believe to create the loop device before you can mount it.  Other than that i am not sure, im new to this livecd buisness as well.

Hope this helps.Last edited by desertstalker on Sat Apr 16, 2005 12:45 am; edited 1 time in total

----------

## gieltje

First is there a way to get mingetty NOT display the lines "Login session opened for ........" Because I open al 6 shells which is realy irritating.

Second maybe its an good idea to make a Gentoo-Wiki of it (http://gentoo-wiki.com/HOWTO_Index).

In this way there can be more people editing this howto to keep it up to date, and more people will easily be able to find this guide.

As I find this guide way better (since the grub issue has been solved) then catalyst.

----------

## gieltje

I have made a gentoo wiki of it;

http://gentoo-wiki.com/HOWTO_build_a_LiveCD_from_scratch

I have added my own build script and other nice things. (and a fix for the grub bug)..

Please add other things if I missed something.

----------

## drio

Hi,

I am trying to run my livecd with qemu but every time I get this error:

```

pivot_root: not such file or directory

/linuxrc: line 41 : cannot create temp file for here document. read only filesystem.

```

I am using the original version of the howto. Pivot_root is in the initrd for sure.

Anyone had the same problem?

Thanks.

----------

## Kampi

 *Illissius wrote:*   

> 
> 
> ```
> 
> RDSIZE=`du -m /proc/kcore | awk '{ print $1 / 4 }'`M
> ...

 

first of all: great "howto", i really like unionfs, but '/4' could be dangerous. in qemu i got

```

tmpfs: Bad value '32.25M' for mount option size

```

i had to use qemu -m 127

----------

## Kampi

 *drio wrote:*   

> Hi,
> 
> I am trying to run my livecd with qemu but every time I get this error:
> 
> ```
> ...

 

do you have created the "newroot" directory? once i forgot this step. if it does not work try to get /bin/sh started (via linuxrc) and type in the mount commands by hand. imho the best method to debug

----------

## Illissius

 *Kampi wrote:*   

>  *Illissius wrote:*   
> 
> ```
> 
> RDSIZE=`du -m /proc/kcore | awk '{ print $1 / 4 }'`M
> ...

 

Hm, thanks for the tip. Apparently, only whole numbers are allowed...

----------

## drio

 *Illissius wrote:*   

>  *Kampi wrote:*    *Illissius wrote:*   
> 
> ```
> 
> RDSIZE=`du -m /proc/kcore | awk '{ print $1 / 4 }'`M
> ...

 

Perhaps this is very dirty bad this is what I did to fix that:

```

RDSIZE=`du -m /proc/kcore | awk '{ print $1 / 4 }'`

RDSIZE=`echo $RDSIZE | awk -F. '{print $1}'`

RDSIZE=$[$RDSIZE + 1]

```

----------

## drio

 *Kampi wrote:*   

> 
> 
> do you have created the "newroot" directory? once i forgot this step. if it does not work try to get /bin/sh started (via linuxrc) and type in the mount commands by hand. imho the best method to debug
> 
> 

 

Ok I have change some stuff (I am using unionfs now. Much better)... and still have the same problem.

I have debug linuxrd and the problem is here:

```

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}

EOF

```

It is complainning that there is no space left on the device (cannot create temp file for here document).

I have the oldroot directory on /new/

and I have mounted the devices like this:

```

modprobe unionfs

mount -t squashfs -o loop /cdrom/files/jail.img /new > /dev/null 2>&1

mount -t tmpfs -o size=$RDSIZE none /new/ramdisk > /dev/null 2>&1

mount -t unionfs -o dirs=/new/ramdisk=rw:/new=ro none /new > /dev/null 2>&1

```

Any idea?

UPDATE:

I justed added df to the initrd image and I launched /bin/sh right before pivoting.

df is telling me that /cdrom is 100% , /new is 100%  and /new/ramdisk is 100% also.

----------

## drio

Hi,

I finally found the problem. tmpfs was too small. I was using the RDSIZE directly as a parameter to mount. RDSIZE was

32. So i was passing -size=32 as a parameter.

I just changed that to 32m and everything is fine now.

Uff.. finally.  :Very Happy: 

Thanks for this howto again, it is really terrific. 

I am gonna try to make this through pxe. I will keep you posted.

Thanks

----------

## drio

Hi guys, 

I would like to know how did you solve the autodetection. I have been looking the gentoo livecd linuxrc and init scripts 

and apparently in linuxrc they do some basic autodetection for critical hardware and after that they launch an initscript 

call autoconfig which is the one that do the magic. 

Do you know what package I have to emerge in order to have that initscript? 

Have you add autodetection features to your personal livecds? What did you do?

The other solution is to compile more device drivers in the kernel instead of compiling them as a modules but that

is a very dirty approach. 

Thanks,

----------

## tkole

I'm trying to put nessus on my livecd but i've encountered a number of problems:

1. By default 'nessus-mkcert' is needed to create SSL certs and set up

nessusd.conf and nessusd.rules. 'nessus-mkcert' writes the CA certs to

/usr/com/nessus... which is part of the livecd's READ-ONLY filesystem.

I can fix this either by editing the 'nessus-mkcert' to write to a

writable filesystem such as /etc, or I could use a livecd/root_overlay

and have standard CA certs and conf files copied over to /etc/nessus

when making livecd-stage2. How exactly did you get around this

problem?

2. When starting nessus with '/etc/init.d/nessus start' a whole list

of errors flood the screen as it trys to load the plugins. I'm

guessing this is because its trying to write to a read-only filesystem

again. Has anyone managed to make a work around for this?

Any fsscript or overlay or extra config files are welcome!

----------

## gctaylor

Hi,

I've been unable to get this LiveCD to boot after working on it for a couple of weeks now.  Here's as far as I get:

```

RAMDISK: ext2 filesystem found at block 0

RAMDISK: Loading 8192KiB [1 disk] into ram disk... done.

EXT2-fs warming mounting unchecked fs, running e2fsck is recommended

VFS: Mounted root (ext2 filesystem).

Freeing unused kernel memory: 204k freed

Kernel panic - not syncing: No init found.  Try passing init= option to kernel.

```

I've read a couple of comments in this thread about others having similar problems but it wasn't clear to me how it was resolved.  

What's the next thing that it should be trying?

Some relevant file attributes that I hope are useful:

```

# ls -l /boot/initrd

 -rw-r--r--  1 root root 8388608 Apr 19 20:14 /boot/initrd

 speedy12 grub # ls -l

 -rw-r--r--  1 root root    200 Apr 19 20:13 grub.conf

 -rw-r--r--  1 root root    200 Apr 20 19:07 menu.lst

 # mount -o loop /boot/initrd /mnt/initrd

 # cd /mnt/initrd/

 initrd # ls -l

total 21

drwxr-xr-x  2 root root  1024 Apr 20 17:54 bin

drwxr-xr-x  2 root root  1024 Apr 19 20:14 cdrom

drwxr-xr-x  2 root root  1024 Apr 20 17:54 dev

drwxr-xr-x  2 root root  1024 Apr 19 20:15 etc

drwxr-xr-x  2 root root  1024 Apr 20 17:54 lib

-rwxr-xr-x  1 root root  1105 Apr 22 16:51 linuxrc

drwx------  2 root root 12288 Apr 19 20:14 lost+found

drwxr-xr-x  2 root root  1024 Apr 19 20:14 new

drwxr-xr-x  2 root root  1024 Apr 19 20:14 proc

```

----------

## Wolven

 *gctaylor wrote:*   

> Hi,
> 
> I've been unable to get this LiveCD to boot after working on it for a couple of weeks now.  Here's as far as I get:
> 
> ```
> ...

 

I think you are missing some files in the /mnt/initrd/lib dir.

Be very careful to include all the files that

```
ldd /bin/XYZ
```

gives you.

I found this step very confusing, but you need to do this for ALL of the files you copy from /etc/bin. And not just for /bin/mount as the example shows.

HTH

----------

## ang

 *gctaylor wrote:*   

> 
> 
> ```
> 
> Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
> ...

 

You need /lib/ld-linux*in /mnt/initrd/lib

try to chroot into the initrd of your livecd to check you got all libs

----------

## gctaylor

I was missing a file in /mnt/initrd/lib.  @#$%!  

Thank-you ang and Wolven for pointing this out!

Once I got past that I was getting an error about not finding /dev/hdX devices.  I took off the option in the kernel .config to automatically mount dev file system at boot and that fixed it.  I saw someone in an earlier post suggested enabling that option.  Hopefully this tidbit will help someone else in the future.

----------

## Kampi

 *drio wrote:*   

> 
> 
> Perhaps this is very dirty bad this is what I did to fix that:
> 
> ```
> ...

 

as dirty as yours, but without 'echo' and the 'M' at the end. (maybe the 'M' is not needed...)

```

RDSIZE=`du -m /proc/kcore | awk '{ print $1 / 4 }' | awk -F. '{print $1}'`

RDSIZE=$[RDSIZE + 1]M

```

----------

## deckernico

Hey guys, i've been building a livecd for a while now, but i got a question, how can you make it eject after your reboot? I'm trying to make a automated install live-cd for my computers, but i can't get it to autoeject during reboot.

I've tried doing it manually,

umount -l /newroot/cdrom 

eject /dev/cdrom

but then it doesn't shutdown cleanly

Then i mirrored all the /bin and /sbin directories onto tmpfs' so i can unmount it all, but that also fails. There's gotta be a easier way.

Thanks!

Any hints/tips/tricks?

----------

## Farkenell

Has anyone here successfuly got mysql running on the livedisc?

I'm not sure how to go about setting up a initial user when I can't connect to the myqsl server in a chrooted environment.....although the disc has rw properties on the /var directory, it complains about unable to connect on /var/run/mysqld/something.socket

Hrmm I was thinking maybe copying an existing database but am not sure what files I'll need to copy over.....I'll try some more stuff when I get back home.....

----------

## deckernico

 *Farkenell wrote:*   

> Has anyone here successfuly got mysql running on the livedisc?
> 
> I'm not sure how to go about setting up a initial user when I can't connect to the myqsl server in a chrooted environment.....although the disc has rw properties on the /var directory, it complains about unable to connect on /var/run/mysqld/something.socket
> 
> Hrmm I was thinking maybe copying an existing database but am not sure what files I'll need to copy over.....I'll try some more stuff when I get back home.....

 

You sure the mysql daemon is running? It sounds like the client can't connect to the backend.

Try running mysqld not as a daemon to see if it can bind to the socket, and don't forget to check the logs in /var/log/ to make sure there's no errors.

----------

## Farkenell

Yeah I'm having trouble getting it started, in the chrooted environment and when the livedisc boots....

atm I'm trying to get some other issues going with my current build.....:/ (stupid thing won't prompt login, I think its cause I was missing the livecd flag halfway through, was hoping I'd get away with it)....I'll try to get a more specific problems with the mysqld problem....

----------

## cdelc040

I'm having trouble getting the image booted.  When I use...

```
default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Gentoo Linux

       root (cd)

       kernel (cd)/boot/vmlinuz video=vesafb:1024x768-32 root=/dev/ram0 rw init=/bin/sh cdroot

       initrd (cd)/boot/initrd
```

...for grub/menu.lst  I get...

```
RAMDISK: ext2 filesystem found at block 0

RAMDISK: Loading 8192KiB [1 disk] into ram disk... done.

VFS: Mounted root (ext2 filesystem).

Freeing unused kernel memory: 212k freed

cdroot:cdroot: No such file or directory

Kernel panic = not syncing: Attempted to kill init!
```

And when I use...

```
default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Gentoo Linux

       root (cd)

       kernel (cd)/boot/vmlinuz video=vesafb:1024x768-32 root=/dev/ram0 rw init=/linuxrc cdroot

       initrd (cd)/boot/initrd
```

...I get...

```
RAMDISK: ext2 filesystem found at block 0

RAMDISK: Loading 892KiB [1 disk] into ram disk... done.

VFS: Mounted root (ext2 filesystem).

Freeing unused kermel memory: 212k freed

INIT: version 2.84 booting

Enter runlevel:
```

When I enter a number (example 5) it then says...

```
INIT: Entering runlevel: 5

INIT: no more processes left in this runlevel
```

I think I saw a very similar problem posted before, but I didn't find an answer.  I would greatly appreciate any suggestions on how to fix this.

----------

## bladdo

Very nice howto  :Cool: 

----------

## RuFI0

Does anybody know how i can make the /home/username directory writeable? I think it's what's causing my KDE from starting. I keep getting errors about "dcopserver not started" and "kde conf not writeable" and at the end when the KDE splash screens comes up, it says that KDE can't start cause it can't write to my home directory. Any ideas how i can get pass this? Thanks in advance

cdelc040: Are u using 2004.3 or 2005.0? I had the same problems using 2005.0 and wasted weeks trying to solve it. Then i changed to 2004.3 and it booted perfectly.

----------

## cdelc040

I'm using 2005.0.  I didn't think it would make a difference.  Do I need to use 2004.3 as my portage profile as well, or should I be able to upgrade that to 2005.0?

----------

## RuFI0

i used 2004.3 for the base but i used the 2005 profile and it worked just fine with no problems

----------

## MixMax

You could use unionfs to make your every directory writable. There is nice instuctions how to do that few pages back.

----------

## RuFI0

Hey MixMax, thanks for the reply but i can't seem to find the page with the unionfs instructions.

----------

## MixMax

You can find it here at the top of the page posted by Illissius.

It's very handy feature to have on a livecd  :Wink: 

----------

## nd_stew

Hey I've been working this awhile...  I get to the linuxrc during the boot, can /bin/sh into

it, initrd looks good, bins, and libs, but looks like I'm missing my squashfs file system type 

on the mount?

mount: /dev/loop0 has wrong device number or fs type squashfs not supported

./initrd/dev:

total 0

crw-r--r-- 1 root root 5, 1 May 10 06:16 console

brw-r--r-- 1 root root 3, 0 May 10 06:16 hda

brw-r--r-- 1 root root 3, 64 May 10 06:16 hdb

brw-r--r-- 1 root root 22, 0 May 10 06:16 hdc

brw-r--r-- 1 root root 22, 64 May 10 06:16 hdd

brw-r--r-- 1 root root 7, 0 May 10 06:16 loop0

crw-r--r-- 1 root root 1, 3 May 10 06:16 null

crw-r--r-- 1 root root 4, 0 May 10 06:16 tty

The only variance to the HowTo I see is that I'm doing a stage3 with 2005.0.

loop0 looked good to me so I figured squash must not be in the kernel correctly.

I saw a reference that > 2.0 of squashfs doesn't work on 2004.3, so I've tried both

squashfs2.1-r2.tar.bz2 and squashfs2.0.tar.gz with no luck.

I enable squash, initrd, etc. in the menuconfig, either patch looks like it goes 

in and compiles clean with the kernel.  I can mount source.img before and 

after the chroot, except on the livecd with a squash mount, hopefully it's 

something obvious?

cs

----------

## gieltje

I am working on an automount script, that first checks what partitions are available and create directorys with the same name (got that);

for x in $(cat /proc/partitions | awk '{print $4}' | awk 'NR > 2');

do

  mkdir ${x}

done

So now I have the directory's with the names of the available partitions, now comes the tricky part. I need to determine what type the partitions are, because I want to mount al the ntfs systems with -t captive-ntfs not with the kernel support.

sfdisk -l gives the partition types, and HPFS/NTFS for ntfs at the end. But I can not find a way to harnas it into a shell script.

Can anyone help me?

----------

## nd_stew

 *nd_stew wrote:*   

> 
> 
> The only variance to the HowTo I see is that I'm doing a stage3 with 2005.0.
> 
> loop0 looked good to me so I figured squash must not be in the kernel correctly.
> ...

 

Yep, looks like kernel, /proc/filesystems doesn't have squashfs on my livecd.  I'm compiling against 

vanilla-sources (2.6.11-2) whereas the latest squash is 2.6.9.  Anyone else come across this?  

2005.0 doesn't come with development-sources, does have gentoo-sources at 2.6.11-r3.

What source is recommended for 2005.0 and squash's 2.6.9?

cs

----------

## Bonkie

Its working fine here (many thanks for showing us the way to do this stuff  :Very Happy: ), but I have a question that I dont fully understand.

Im currently trying unionfs, shown by a user in a couple of posts earlier, but I was wondering this; Why make tarballs of directories like /var and /etc, when you dont exclude them from your squashed image ????  And since Im not going to create mounts for each of those directories, should I still create the tarballs and unpack them at boot ?? I dont think so (dont see any reason to), but then again, I didn't come up with this whole scheme so I wanted to check first  :Smile: 

 *veezi wrote:*   

> 
> 
> ```
> # Mount root and create read-write directories
> 
> ...

 

----------

## Illissius

 *Bonkie wrote:*   

> Its working fine here (many thanks for showing us the way to do this stuff ), but I have a question that I dont fully understand.
> 
> Im currently trying unionfs, shown by a user in a couple of posts earlier, but I was wondering this; Why make tarballs of directories like /var and /etc, when you dont exclude them from your squashed image ????  And since Im not going to create mounts for each of those directories, should I still create the tarballs and unpack them at boot ?? I dont think so (dont see any reason to), but then again, I didn't come up with this whole scheme so I wanted to check first 
> 
>  *veezi wrote:*   
> ...

 

Correct me if I'm wrong, but I believe I did exclude the tarballs, if you'll look at what I posted... but it's been a while since I've looked at it myself (never got around to figuring out how to properly make multisession CDs, which is the next thing I want to do with it), so could be wrong  :Wink: .

----------

## MixMax

Bonkie:

When using unionfs you can forget the tarballs all together.

But if you'r still using the older style you need the tarballs to populate the tempfs so that they can contain writable files. Your right they are ingluded twice in the older style. I changed the build script a while back so that after makeing the tarballs it moves the content of the folders to a temp folder (outside of the image folder) and then greates the squasfs image. and at the end moves the content back. I'm sure this isn't the best way but that freed a lot of valuable space on the cd.

But like sayed b4 I highly recomend moving to unionfs  :Smile: 

----------

## nd_stew

 *nd_stew wrote:*   

> 
> 
> Yep, looks like kernel, /proc/filesystems doesn't have squashfs on my livecd.  I'm compiling against 
> 
> vanilla-sources (2.6.11-2) whereas the latest squash is 2.6.9.  Anyone else come across this?  
> ...

 

FYI - straight gentoo-sources did it!  2005.0 (no patches).

----------

## Bonkie

MixMax >> Yes I understand; Never tried excluding them from the squashimage, thought there was a reason why the author didn't do so himself  :Smile: 

About the livecd, I'm getting a strange error and I don't understand why. When I test-run the iso using qemu, it boots up fine, but when I burn the iso and try to boot from that it stops with a sh(ell) bash ??? It doesn't give any errors but none of the filesystems get mounted  :Confused:  Yes, the kernel includes squashfs and everything else is what it should be (i think, why else would qemu test not show any errors then ?) ...

```
RDSIZE=`du -m /proc/kcore | awk '{ print $1 / 4 }' | awk -F. '{ print $1 }'`M

# load unionfs module

modprobe unionfs

mount -t squashfs -o loop /cdrom/source.img /new

mount -t tmpfs -o size=$RDSIZE none /new/ramdisk

mount -t unionfs -o dirs=/new/ramdisk=rw:/new=ro none /new

```

[Edit] Oops, never mind, after reading the linuxrc script I saw it exits when it doesn't find a CDROM, so I check and turns out I had forgotten to create hdb node in /dev so it could not find the cdrom on my pc  :Embarassed: 

----------

## gieltje

is anyone else here trying to try to use the initrd image from the orriginal gentoo livecd?

I got it working and booting but the complete file system remains mounted ro, and it gives some error's about not beiing able to unmount init...... (so eventualy the whole boot borks because everything is read only).

Can anyone else help me? (I can give more specific errors).

----------

## ph3ar

many thanx to the creator of this how to  :Smile: 

I've some errors/problems!

In the mke2fs /dev/loop1

//mke2fs 1.35 (28-Feb-2004)

i can see this nice initialiation screen but nothing happens!(for a big amount of time)

Hm... before that i tried to load the loop module with 

```
modprobe -f --set-version 2.6.11.gentoo-r8 loop
```

, cause i had some problems while in chroot environment with differents kernels... (i 've a previous kernel 2.6.11.gentoo-r6 in my system)

-----many thanx to the creator of this how to  :Smile: 

----------

## ph3ar

Hah

I just realised that the module loop has to be loaded in my system and not in the chroot environment!

That's all about mke2fs.

Let's continue... with the live cd.

 :Very Happy: 

----------

## Farkenell

ok cool  :Smile:  I got mysql goin works great....

had to change the permissions of /var/run to mysql and writeable....

also had to make sure that the ./build script didn't delete it :/ (#rm -Rf /var/run)

now it seems my mkxf86 script doesn't seem to wanna work right...:/ it makes a xorg.conf with a seiral mouse (I'm using usb) and the driver for the video card is set to "" (have to set these manually for these to work....) I never had to do this before.....

----------

## travail101

has this how-to been updated with any information that may have been brought to light in the 16 pages of replies? or by chance, has this how-to been added to the gentoo wiki? or something? i just want to make sure i'm using all the latest greatest ways of putting a livecd together  :Wink:   without having to read all 16 pages =P

----------

## gieltje

http://gentoo-wiki.com/HOWTO_build_a_LiveCD_from_scratch

----------

## ph3ar

Anyone know the values that had to be working out in the kernel config.

Thus, Default number of ram disk 

```
CONFIG_BLK_DEV_RAM_COUNT
```

and Default RAM disk size (kbytes) 

```
CONFIG_BLK_DEV_RAM_SIZE
```

 .

for me are the 1st 12 and 8192 the following.

I figure this out cause i'm having the same as posted problem 

```
Kernel Panic - not syncing: No init found. Try passing init= option to kernel.
```

//Everything is working perfectly it has nothing to do with this issues... I just rechecked all my configs and worked.

//Possibly this kernel panic msg would be occured from the livecd use flag. So i remerged the packages and the baselayout with this use flag.

Anyway thanks veezi for this how-to.Last edited by ph3ar on Tue Jun 07, 2005 9:23 am; edited 1 time in total

----------

## kabage

Your Kung Fu is STRONG!

Thank you veezi for the awesome 

work!  

I will find the answers to below

questions but If you have a quick

answer, would appreciate it. 

1. /etc/inittab I changed the 

default run level to 5 but seems 

to ignore me.  How come?

2. I had to adjust default gateway 

in route.  Is their a config I can

set the livecd to for that?

[EDIT] removed my second nic now autodetection sets it up on the fly!

3. Autologin for agetty.  Thought it

was just -n but that didn't work.

Anyone have the trick? Or just use mingetty? 

[EDIT] I used mingetty works 

Info: If someone is wondering I did

this in pure amd64 with dmraid, and

it detects my sata-promise raid0 

partitions just fine.  So will be my

new build/recovery disk. Awesome!

[EDIT]  I curse you now!  I cant stop makeing cd's!

----------

## Thunder2002

Hi,

very nice howto, one of the best i ever seen. 

No my problem: when i boot the livecd i got this:

 *Quote:*   

> 
> 
> /linuxrc: line 41: dev/console: Read-only file system
> 
> Kernel panic - not syncing: Attemped to kill init!
> ...

 

I found some answers here but nothing matched. I also tried to set dev/console in the initrd part +rw, also the hole initrd image in /boot but nothing happens, every time the above error appears and i dont know what to do now anymore  :Sad: 

Does someone have an idea or something else?

----------

## shaumux

Hi

Great Tutorial

but i was wondering that if it was possible to use the genkernel with this

bcause i wanted to have automatic hardware detection.

If possible can u tell me how , plz

Also can u plz tell me if that is it okay to use stage3 instead of stage2 because iam getting some compile errors with stage2

Thnks

----------

## brenden

This is a great how-to, but for whatever reason I can't make this stuff work correctly.

My initrd gets loaded by the kernel, but it can't find anything for some reason.  init=/bin/sh doesn't work either.  The files are there, including linuxrc, but it just won't work.  When I mount the initrd manually and do chroot /mnt/initrd, it gives me

```
chroot: cannot run command `/bin/sh': No such file or directory
```

However,

```
# pwd

/mnt/initrd/bin

# ls

cat  chroot  mkdir  mount  pivot_root  raid0run  sh  tar  umount
```

as you can see I have everything there.

Some help would be much appreciated.

UPDATE:

I solved it by adding a symlink at /mnt/initrd/lib64 that points to /mnt/initrd/lib.

I guess this was an amd64 issue.Last edited by brenden on Sat Jun 18, 2005 7:41 pm; edited 1 time in total

----------

## platojones

Do an 'ldd /bin/sh' and make sure all of those libraries are in /mnt/initrd/lib.

----------

## hanni_ali

I've created the LiveCD fine it boots and is fully functional however I can't get KDE to work. Running off the HDD (./work), startx works fine but on creating the Live CD I get the error message 

```
Could not start kdeinit. Check your installation.
```

in a pop up xmessage box

I can't work out what to do to fix this any help would be much appreciated.

I'm very tired now so off to bed.

Hanni

----------

## loonix

you could check if either your /tmp folder has full read write access and as well that the permissions for the user folders are set properly i.e. folder ownership.

hope this works

AR

----------

## bardebarde

 *Thunder2002 wrote:*   

> Hi,
> 
> very nice howto, one of the best i ever seen. 
> 
> No my problem: when i boot the livecd i got this:
> ...

 

This is exactly the same problem that appears on my screen. Everything else went fine. So WHERE is the error? Already tried to change permissions for the initrd device nodes... but that was no success. Still got the line 41 error! That damn thing....  :Sad: 

----------

## bardebarde

Okay, I managed to boot a little step further now... 

Now a minimalistic shell, titled "sh-3.00" welcomes me. But where are all the commands and programs I installed in the previous steps?

If I hit the tab button, there's only about 40 commands I can choose. And I won't find /etc/profile....

Looks like the script inside the initrd is buggy, even I copied it off this thread!

I am new to this stuff, please help me, I wanna learn how to configure this livecd to get everything to work, from sound to X. Thanks for your time!Last edited by bardebarde on Wed Jun 29, 2005 10:54 pm; edited 1 time in total

----------

## Thunder2002

Hmm i can't help you atm but maybe you can tell me how you managed the problem i have too? Maybe i will get the same problem and find an anwser with a bit luck  :Smile: 

----------

## bardebarde

 *Thunder2002 wrote:*   

> Hmm i can't help you atm but maybe you can tell me how you managed the problem i have too? Maybe i will get the same problem and find an anwser with a bit luck 

 

I managed to eliminate the problem by just reconfiguring the kernel. In filesystems/pseudofs/devfs I added the option to create all device nodes at bootup time and voilà - that problem was gone. But the problem with not beeing able to boot the init is a big one for me atm.

----------

## bardebarde

Ok, I almost got it. I almost can boot through the initrc file , just the last 3 lines will bring the error....

exec chroot . /bin/sh <<- EOF >dev-console 2>&1

exec /sbin/init ${CMDLINE}

EOF

Because the machine says, that /dev/console is read-only, it will not let me run /sbin/init.

By the way : I looked for /dev/console but it even isn't present!

If I let the script run through it will bring the kernel panic at exactly this position!

Otherwise, if I write it by hand, the shell just complains about the "read-only thingy" and lets me go on. No /sbin/init functionality, either.

There's no /dev/initctl that is needed by init.  :Sad: 

What's the problem? I know, there are some of you, who successfully made their livecd. Please help me! Thanks.

----------

## Thunder2002

Hmm,

i completly rebuild the livecd on my new notebook and now it runs perfectly. Very strange because i also rebuild it on the other pc after this where i tried before but it doesn't work. Is there maybe any unrecognized requirment?

----------

## bardebarde

I am still stuck at the end of initrc. Everything is mounted in the right way. But what is astounding is the fact that, when I  do pivot_root . newroot and then look into /dev, there are all kind of devices, but NO console, null etc.

UPDATE:

Ok, now I finally managed it to start up Gentoo on my LiveCD iso via qemu.

My Solution to achieve thiswas as follows:

1)I created another /dev folder in the read-write enabled tpmfs space 

2)I created the devices like in the tutorial now interactively  :Smile: 

3) And mounted it via mount -o bind new_dev /dev.

Voila! It booted, but booting was slow and 3or 4 points in the init weren't green ,but red, so they failed.

This includes the network card upbringing. But I will see what matters and try to fix that. Finally, there's fun again  :Smile: 

----------

## kri5th

First i would thank veezi for write this! 

I have already read all post relatively this task.

This is my linuxrc:

 *Quote:*   

> 
> 
> ...
> 
> # Mount root and create read-write directories
> ...

 

I add user without any problem inside chroot and i have create a home directory with correct permission

and owenership.

When i boot the cd i don't see in mount directory /mnt/ and /home/user but the other directories (/etc, /var, /root, /tmp)

works fine. What's wrong? Any suggestion?

P.S I use autologin for this user and when the cd boot the autologin works fine. The current working directory is /home/user but i haven't permission to write in this dir.(if i type ls -la i don't see . and .. dir)

Thanks for help

Ciao[/quote]

----------

## gieltje

 *kri5th wrote:*   

> First i would thank veezi for write this! 
> 
> I have already read all post relatively this task.
> 
> This is my linuxrc:
> ...

 [/quote]

I have updated this to the genkernel init scripts, these are very simular to the 2005.0 livecd.

This works MUCH better I must say, boots almost everything, looks way more proffesional etc. It might be a bit of a trick to get it working but it is certainly worth it!

----------

## padhead

For me the new version doesn't work, i made the initrd with genkernel, and then came the error that linuxrc wasn't found. shouldn't genkernel make the linuxrc in the new version? and today came out a new version of genkernel, 3.2.0.

----------

## kri5th

Thank you gieltje for the quick response. I'll take a look at your wiki in the next week.

----------

## padhead

i installed genkernel 3.2.0 and now i get this:

genkernel all --no-bootsplash --no-clean

/usr/bin/genkernel: line 26: /usr/share/genkernel/gen_bootloader.sh: Datei oder Verzeichnis nicht gefunden

* ERROR: Could not read /usr/share/genkernel/gen_bootloader.sh

* -- Grepping log... --

  SCSI generic support (CHR_DEV_SG) [Y/n/m/?] y

  *

  * Some SCSI devices (e.g. CD jukebox) support multiple LUNs

  *

  Probe all LUNs on each SCSI device (SCSI_MULTI_LUN) [N/y/?] n

  Verbose SCSI error reporting (kernel size +=12K) (SCSI_CONSTANTS) [N/y/?] n

--

  CC [M]  drivers/usb/core/sysfs.o

  CC [M]  drivers/usb/core/hcd-pci.o

  CC [M]  drivers/usb/core/devio.o

  CC [M]  drivers/scsi/aha1542.o

In Datei, eingefügt von drivers/scsi/aha1542.c:43:

include/linux/mca-legacy.h:12:2: Warnung: #warning "MCA legacy - please move your driver to the new sysfs api"

--

* Do NOT report kernel bugs as genkernel bugs unless your bug

* is about the default genkernel configuration...

*

* Make sure you have the latest genkernel before reporting bugs.

* ERROR: Could not read /usr/share/genkernel/gen_bootloader.sh

--

* Report any genkernel bugs to bugs.gentoo.org and

* assign your bug to genkernel@gentoo.org. Please include

* as much information as you can in your bug report; attaching

* /var/log/genkernel.log so that your issue can be dealt with effectively.

*

* Please do *not* report compilation failures as genkernel bugs!

*

* ERROR: Could not read /usr/share/genkernel/gen_bootloader.sh

--

* Report any genkernel bugs to bugs.gentoo.org and

* assign your bug to genkernel@gentoo.org. Please include

* as much information as you can in your bug report; attaching

* /var/log/genkernel.log so that your issue can be dealt with effectively.

*

* Please do *not* report compilation failures as genkernel bugs!

*

* ERROR: Could not read /usr/share/genkernel/gen_bootloader.sh

* -- End log... --

* Please consult /var/log/genkernel.log for more information and any

* errors that were reported above.

* Report any genkernel bugs to bugs.gentoo.org and

* assign your bug to genkernel@gentoo.org. Please include

* as much information as you can in your bug report; attaching

* /var/log/genkernel.log so that your issue can be dealt with effectively.

*

* Please do *not* report compilation failures as genkernel bugs!

----------

## daybyter

Use genkernel 3.2.1 and _this_ problem should be solved...

----------

## padhead

i now installed genkernel 3.2.1 and the installation of the kernel was ok, but when i start the iso in vmware there is a problem with the initrd that genkernel generated. the whole programs /bin/tar, /bin/sh ... are not recognized and are not found. what can i do? the deprecated method went good for me

----------

## BigBeer

Well I made my livecd and it is great. 

The only problem I am having is on shutdown or reboot.

I get many erros about not being able to unmount any of the tmpfs filessystems and I have to press Ctrl-D to continue the shutdown/reboot process.

The only thing I have changed is making /dev rw in addition to 'defaults' in fstab.

Here is my fstab:

```

/dev/loop0              /               squashfs        ro,defaults             0 0

none                    /proc           proc            defaults                0 0

none                    /dev/shm        tmpfs           rw,defaults                0 0

//ntinstall/install     /z              smbfs           username=unattended,password=**** 0 0

```

Here is my linuxrc:

```

# Mount root and create read-write directories

mount -t squashfs -o loop /cdrom/files/source.img /new > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/var > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/etc > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/tmp > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/root > /dev/null 2>&1

cd /new/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /new/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /new/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/c > /dev/null 2>&1

```

My appoligies if something like this has already been answered in the thread.

--BigBeer

----------

## kri5th

Hi,

finally i resolve my problem with this script into the /etc/init.d directory inside chroot enviroment

 *Quote:*   

> 
> 
> filename: mnt-dir
> 
> #!/sbin/runscript
> ...

 

then i add them to default runlevel (rc-update add mnt-dir default)

my build script look like this

 *Quote:*   

> 
> 
> #!/bin/bash
> 
> rm -rf target
> ...

 

This works fine for me...

----------

## TheJackal

Hi everyone!

I'm having some serious problems with creating a LiveCD with the instructions from the Gentoo WiKi/This thread.... :Sad: 

I'm using the 2.4.x gentoo-sources as some 3rd part kernel modules will only work with the 2.4 Kernel. I've followed ALL the steps to create the LiveCD and I've used "genkernel" to create the initrd image but when I try to boot from the ISO image, it loads the kernel and then spits out this error when trying to run the "linuxrc" script :

http://www.navero.co.uk/misc/livecd_error1.jpg

I've also tried to use "init=/bin/sh" for debugging purposes but I get this error :

http://www.navero.co.uk/misc/livecd_error2.jpg

----------

## padhead

yes, i have the same problems using a 2.6.12-gentoo-r4 kernel. it seems that the initrd is not valid. and i can not mount to check what is in the initrd, it gaves me always an error that it doesn't recognize the filesystem. i tried to mount it with mount -o loop initrd /mnt/initrd. can anyone help?

----------

## Riklaunim

get slax livecd-tools http://www.linux-live.org/, use a 2.6.12.2 kernel and you can create your iso with one command  :Smile:  I've tested it and it made arch and suse livecd from normal daily used installs  :Smile:  link: http://bbs.archlinux.org/viewtopic.php?t=13949

----------

## caruso

Hey everyone!

First of all, thanx for great how to. Second, i had problem  :Very Happy:  with udev: 

/bin/bash: udev: No such file or directory. What's wrong? I had set init=/bin/bash, when it's set to linuxrc it doesn't work too.

[solved] but i have an another problem:

now, booting is ok but i gen only clean bash  :Confused:  when i want run manually /sbin/init 3 it's complain about not existing initctl...

[solved]

----------

## gieltje

 *TheJackal wrote:*   

> Hi everyone!
> 
> I'm having some serious problems with creating a LiveCD with the instructions from the Gentoo WiKi/This thread....
> 
> I'm using the 2.4.x gentoo-sources as some 3rd part kernel modules will only work with the 2.4 Kernel. I've followed ALL the steps to create the LiveCD and I've used "genkernel" to create the initrd image but when I try to boot from the ISO image, it loads the kernel and then spits out this error when trying to run the "linuxrc" script :
> ...

 

First of all use one guide or the other, my guide is more dedicated to genkernel. I believe your error has something to do with an faulty grub configuration or livecd.squashfs is in the wrong place. (I just updated my build scripts again, minor modifications though). And you are probably using an old genkernel (I had the unable to create stuff to in 3.2.8 it is fixed in 3.2.10).

See http://gentoo-wiki.com/HOWTO_build_a_LiveCD_from_scratch#Installing_Gentoo and the building part.

----------

## bkunlimited

i tried to follow this guide and i have a problem when chrooting into livecd/source directory:

```
btn1xd source # chroot . /bin/bash --login

chroot: cannot run command `/bin/bash': Permission denied

```

does anyone have an idea what the problem could be?

FYI:

```
Portage 2.0.51.22-r2 (default-linux/x86/2005.0, gcc-3.3.5-20050130, glibc-2.3.5-r0, 2.6.12-gentoo-r4 i686)

=================================================================

System uname: 2.6.12-gentoo-r4 i686 Intel(R) Pentium(R) 4 CPU 3.40GHz

Gentoo Base System version 1.6.13

dev-lang/python:     2.3.5

sys-apps/sandbox:    1.2.10

sys-devel/autoconf:  2.13, 2.59-r6

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.5

sys-devel/binutils:  2.15.92.0.2-r10

sys-devel/libtool:   1.5.18-r1

virtual/os-headers:  2.6.11-r2

ACCEPT_KEYWORDS="x86"

AUTOCLEAN="yes"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O3 -march=pentium4 -fomit-frame-pointer -pipe"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"

CONFIG_PROTECT_MASK="/etc/gconf /etc/splash /etc/terminfo /etc/env.d"

CXXFLAGS="-O3 -march=pentium4 -fomit-frame-pointer -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="autoconfig distlocks sandbox sfperms strict"

GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/Linux/distributions/gentoo"

LINGUAS="de"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.de.gentoo.org/gentoo-portage"

USE="x86 X a52 aac alsa apache2 apm avi berkdb bitmap-fonts cdr crypt cups curl directfb divx divx4linux dts dvd dvdread emboss encode esd fam fame firefox foomaticdb fortran gif gpm gtk gtk2 imagemagick imlib ipv6 java jpeg junit kde libg++ libwww mad mikmod mjpeg mmx mmx2 motif mp3 mpeg mysql ncurses nls nptl nvidia ogg oggvorbis opengl oss pam pdflib perl php png python qt quicktime readline samba sdl spell sse sse2 ssl tcpd tetex theora tiff truetype truetype-fonts type1-fonts usb userlocales vorbis win32codecs xine xml2 xmms xv xvid zlib linguas_de userland_GNU kernel_linux elibc_glibc"

Unset:  ASFLAGS, CTARGET, LANG, LC_ALL, LDFLAGS, PORTDIR_OVERLAY

```

EDIT: btw, i tried it on a second gentoo machine and it works there... emerge info of that machine is:

```
Portage 2.0.51.22-r1 (default-linux/x86/2005.0, gcc-3.4.4, glibc-2.3.5-r0, 2.6.11-gentoo-r5 i686)

=================================================================

System uname: 2.6.11-gentoo-r5 i686 Intel(R) Pentium(R) 4 CPU 2.40GHz

Gentoo Base System version 1.6.12

dev-lang/python:     2.3.4-r1, 2.4.1-r1

sys-apps/sandbox:    1.2.10

sys-devel/autoconf:  2.13, 2.59-r7

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.5

sys-devel/binutils:  2.16.1

sys-devel/libtool:   1.5.18-r1

virtual/os-headers:  2.6.11-r2

ACCEPT_KEYWORDS="x86"

AUTOCLEAN="yes"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O3 -march=pentium4 -pipe -fomit-frame-pointer"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"

CONFIG_PROTECT_MASK="/etc/gconf /etc/splash /etc/terminfo /etc/env.d"

CXXFLAGS="-O3 -march=pentium4 -pipe -fomit-frame-pointer"

DISTDIR="/usr/portage/distfiles"

FEATURES="autoconfig distlocks sandbox sfperms strict"

GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/Linux/distributions/gentoo"

LC_ALL="de_DE@euro"

MAKEOPTS="-j2"

PKGDIR="/usr/portage/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/local/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="x86 X a52 aac alsa apache2 apm avi berkdb bitmap-fonts cdr crypt cups curl directfb divx divx4linux dvd dvdread emboss encode esd fam fame firefox flac foomaticdb fortran gdbm gif gpm gtk2 imagemagick imlib ipv6 java jpeg junit kde libg++ libwww mad mikmod mjpeg mmx mmx2 motif mozilla mp3 mpeg mysql ncurses nls ogg oggvorbis opengl oss pam pdflib perl php png postgres python qt quicktime readline samba sdl spell sqlite sse sse2 ssl svga tcltk tcpd tetex theora tiff truetype truetype-fonts type1-fonts usb vhosts vorbis win32codecs xine xml xml2 xmms xv xvid zlib userland_GNU kernel_linux elibc_glibc"

Unset:  ASFLAGS, CTARGET, LANG, LDFLAGS, LINGUAS

```

----------

## caruso

 *bkunlimited wrote:*   

> i tried to follow this guide and i have a problem when chrooting into livecd/source directory:
> 
> ```
> btn1xd source # chroot . /bin/bash --login
> 
> ...

 

Yes. You have mounted partition with "user" or "noexec". Try mount -l. Check your /etc/fstab.

----------

## bkunlimited

thanks a lot! it was mounted with 'user'. now it works

----------

## padhead

i now installed genkernel 3.3.3 and gentoo-sources-2.6.12-r6, but i always get a problem with the initrd. 

now the error message is 

.: 8: Can't open /etc/startup.conf

Kernel panic- not syncing: Attempted to kill init!

does anyone have an idea how to solve that? How can i mount the initrd, because i can't mount it with -o loop. 

Thanks for helping

----------

## caruso

First of all check if file exist then check permission to this file. Configure your kernel to include loop service and next recompile it. I'm too noob but it may help you...

----------

## padhead

i checked all my installations and i have never seen a file like startup.conf. what do i need it for? i think this was generated by genkernel, but i don't know why. any idea?

----------

## padhead

finally with genkernel 3.3.5 i could create the livecd. thanks for help.

----------

## rseku

I followed excactly what was said since begining of this discussion.

However in my case nothing works.

Basicaly when I reboot I go to grub shell.

then I type exactly what was written in grub.conf and it starts up.

Strange is it!

The boot process is :

first info stage2 loading ....

go to shell

when I type manually kernel /boot/vmlinuz-2.4.30 root=/dev/ram0 rw init=/linuxrc cdroot

and                           initrd  /boot/initrd

the system kicks me out to shell after starting linuxrc ( what I fugure out from messages;ramdisk loads, root system detects as ext2; and shell)

when I type manually like in linuxrc everything start up

when I put init=/bin/sh

the system cannot start the shell because of cdroot parameter (already dicussed but not solved

on these groups)

What could be wrong?

Is there way to debug?

maybe it's because I use cd-rw

----------

## gieltje

 *rseku wrote:*   

> I followed excactly what was said since begining of this discussion.
> 
> However in my case nothing works.
> 
> Basicaly when I reboot I go to grub shell.
> ...

 

it is not the cd-rw, remove the menu.lst symlink and rename grub.conf to menu.lst and see.....

----------

## padhead

one suggestion: i had problems with xkb because i wanted that mkxf86config makes the config, but that then i can change the keyboard language from us to another language. so i had to do this:

mount -t tmpfs tmpfs /usr/X11R6/lib/X11/xkb/compiled

and now everything works. i did it in my fstab and now it mounts on startup.

----------

## jkomar

I have one I've been trying to figure out for several days. I have been using the genkernel method from the wiki. When booting my livecd, I get kernel output which seems OK. I then get:

```

>>loading modules

...sata, usb, ieee1394, etc loads OK. (I have abridged this as it's too much to write down)

>> Activating udev

>> Making tmpfs for /newroot

>> Attempting to mount CD:-/dev/cdroms/cdrom0

>> CD medium found on /dev/cdroms/cdrom0

>> Determining root device...

>> Determining loop type...

!! Invalid loop location: /livecd.squashfs

!! Please export LOOP with a valid location, or reboot and pass a proper loop=...

!! kernel command line!
```

Booting halts and I get a Busy Box ash prompt:

```
/bin/ash: can't access tty; job control turned off

/newroot #
```

If I type "exit" at the ash prompt, booting continues:

```

>> Mounting squashfs filesystem

>> Copying read-write image contents to tmpfs

>> No cdupdate.sh script found, skipping...

>> Booting (initramfs)...

Init version 2.86 booting
```

I am assuming that where the booting stops is where the root is supposed to pivot. In any case I can't seem to figure out why booting stops at this point or what I need to do to fix it.

Thanks,

Jason

----------

## padhead

did you check if you have a right grub commandline?

----------

## jkomar

 *padhead wrote:*   

> did you check if you have a right grub commandline?

 

I have triple-checked my menu.lst file and it matches the one on the wiki (with the exception of the kernel name and the initrd name being changed to match mine).

Thanks,

Jason

----------

## Apocalypse_Now

Know to excuse to my poor man ingles. I have followed all the passages without difficulty. I run the script /build, appears the message that it indicates to run /before-build and after which prompt is executed, been and nothing but. Wait for all the night, thinking that it had been time to arm iso, but never was created. Now I ask, can be that this happens, because i make the distro in the /home/usuario directory, like root? I clarify that in script, it changes the necessary thing so that works.

Thank

Sepan disculpar mi pobre ingles. He seguido todos los pasos sin dificultad. Corro el script ./build, aparece el mensaje que indica correr el ./before-build y luego de que se ejecuta, queda el prompt y nada mas.

Espere toda la noche, pensando que llevaba tiempo armar la iso, pero nunca se creó.

Ahora pregunto, ¿puede ser que esto ocurra, porque arme la distro en el directorio /home/usuario, como root?

Aclaro que en el script, cambie lo necesario para que funcione.

Gracias

PD: Si alguien habla español, se lo agradeceré.

----------

## hanni_ali

I have created livecd's using this method and they are relatively successful

However I cannot get one to automount flash devices and successfully mount fdd in user mode (not as root) by successfully i mean the folder mnt is not accessible even if you can mount the device

Hanni

----------

## Hyp

Hi,

I created a livecd and it's almost working.

If I boot, I get the error message

```
mount: Mounting /dev/ram0 on /newroot failed invalid argument
```

My /boot/grub/menu.lst

```
default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Gentoo Linux mit Optionen

root (cd)

kernel (cd)/boot/kernel-genkernel-x86-2.6.12-gentoo-r9 root=/dev/ram0 rw init=/linuxrc looptype=squashfs loop=/livecd.squashfs udev nodevfs cdroot

initrd (cd)/boot/initramfs-genkernel-x86-2.6.12-gentoo-r9

```

Can anybody help me ?

Hyp

EDIT: I found a solution: I think I forgot to activate the support for my cdrom in the kernelconfig. Now it is working, but I do not know which option it was. I activated a lot ... nevermind.

GREAT HOWTO !!

----------

## cellularmitosis

Thanks for the howto!

I am having a problem removing gcc from my livecd's.  The problem is that python is linked to libstdc++ in /usr/lib/gcc-lib, rather than /usr/lib:

```

# ldd /usr/bin/python

        libstdc++.so.5 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/libstdc++.so.5 (0xb7da8000)

        libgcc_s.so.1 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/libgcc_s.so.1 (0xb7d7d000)

```

Thus, when you remove gcc, python no longer works.  I won't be doing any compiling from my livecd, so I don't need gcc.

Any ideas?

----------

## cellularmitosis

ahh, my mistake.  the left hand side of ldd output shows which libraries a binary is linked to, and the right hand side shows how they resolve on your individual system.

thus, I can just copy the libs like so:

```

echo saving gcc-libs

GCC_LIB_PATH=`ldd /usr/bin/python | grep '=>' | awk '{print $3}' | grep /usr/lib/gcc-lib | tail -n1 | perl -pe 's/\/[^\/]*$//'`

cp -a ${GCC_LIB_PATH}/lib* /lib/

```

and python will still work after removing gcc.

----------

## westboy21

Looks like it's my turn to add to this massive discussion.  I'm having a few problems with mkisofs.  Here is what I get after running the build script, or running each part of the build script manually.

# mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 4 -hide -c boot.catalog -o /root/livecd.iso target/

Warning: Creating ISO-9660:1999 (version 2) filesystem.

Warning: ISO-9660 filenames longer than 31 may cause buffer overflows in the OS.

mkisofs: No such file or directory. Invalid node - boot.catalog

I'm done banging my head on the wall, but I might start up again.  I spent 4 hours last night trying to figure out why the "cp" step in the build script kept hanging.  I mean all it's doing is copying, but 3 hours later, it was stuck with no hard drive activity.  I rebooted and I was good to go.

Any takers on my issues?

----------

## saturas

hi, i want to ask an interesting question. is it possible to create a livecd that is using my curent configurations? a stage 3 cd  with all that i compiled already (something like a backup)?

----------

## westboy21

Yeah ... search this thread.  I vaguely remember there being a link out there to some tools that you can use on any distribution to make a livecd based on your install.

----------

## phreak_coder

 *harry.tx wrote:*   

> Hey everyone!
> 
> First of all, thanx for great how to. Second, i had problem  with udev: 
> 
> /bin/bash: udev: No such file or directory. What's wrong? I had set init=/bin/bash, when it's set to linuxrc it doesn't work too.
> ...

 

Hey 

i have the exact same problem how did you fix this? or anyone else?

apologies if this has been answerd already it's a long post  :Smile: 

And many thanks for the excellent tutorial

----------

## BeteNoire

 *gieltje wrote:*   

> I have made a gentoo wiki of it;
> 
> http://gentoo-wiki.com/HOWTO_build_a_LiveCD_from_scratch
> 
> I have added my own build script and other nice things. (and a fix for the grub bug)..
> ...

 

There's an error in the scripts. I run build and it stops on "echo "Execute ./before-build now, but first MAKE SURE it has correctly chrooted to the livecd ${TARGET_SOURCE} directory". So, I run ./before-build. It executes and nothing else happens. 

Shouldn't they two be the one script? Shouldn't build execute before-build and then before-build go back to executing build?

If it is to be real howto, please fix it. Or people like me, not familiar with making livecds, will waste their precious time thinking what is wrong...

----------

## Vouksh

because it chroots you into the livecd target directory, and the script can't interact with the chrooted environment.

----------

## BeteNoire

Uhm... so what should I do? Exit chroot and restart "build"? But how to make it run from the point it ended?

----------

## loux.thefuture

Hello,

in the howto build a liveCD from scratch, i think you forget to delete the line mkdir newroot

because it's just use in the deprecated function to build initrd ?

Great job !

Loux

PS : i'm creating a little script to build a livecd with your howto, i will publish it

----------

## loux.thefuture

Hello,

i'm trying to follow the steps of the howto but during the boot stage, i have the following error :

Booting (initramfs)......

/bin/sh: error while loading shared libraries: cannot make segment writable for relocation: Permission denied

the script that i use to build the livecd and the config of the kernel are in my server :

http://loux.homelinux.org/~loux/livecd/

(i use a lot of sudo because i don't want running my script whith sudo to not execute action i don't want !)

thanks

loux

----------

## Lucio

Hi everybody;

Very usefull howto and lot of comments.

However I didn't find the solution to my pb.

My system loops for ever... every seems to work fine; but at the end of the linuxrc, back to grub....

When i play with /bin/sh instead of linuxrc, i reach the end of the process:

```

# pivot_root . newroot

> Ok (at least no error)

# exec chroot . /bin/sh

> Ok (at least no error)

exec /sbin/init ${CMDLINE} where ${CMDLINE}="root=/dev/ram0 rw init=/linuxrc cdroot"

> No good: Usage: init 012345....

```

Any idea?

Many thanks in advance.

Lucio

----------

## Lepaca Kliffoth

Instead of "exec /sbin/init ${CMDLINE}" use only "exec /sbin/init".

----------

## metalfan

if the cd doesnt even start to boot, the error has to be somewhere in the build script or while it is running right?

burned the cd with this command, is that okay ?

```

cdrecord dev=ATAPI:0,1,0 speed=1 driveropts=burnproof -v -eject -dao livecd.iso

```

greets

metalfan

----------

## Lepaca Kliffoth

That's ok, I'd be more concerned with the mkisofs command you used. Does grub run normally?

----------

## Lucio

Hi, thks for the quick response.

Yes grub boots fine and allows me to boot my "installed gentoo", windows or the "live cd".

And with the linuxrc from the howto, it loops for ever.

I will try to modify the last line and will remove the $CMDLINE parameter.

I kepp you informed.

Lucio

----------

## Lepaca Kliffoth

 *Lucio wrote:*   

> Hi, thks for the quick response.
> 
> Yes grub boots fine and allows me to boot my "installed gentoo", windows or the "live cd".
> 
> And with the linuxrc from the howto, it loops for ever.
> ...

 

Sorry I should have quoted properly. The question about grub was for metalfan.

----------

## BeteNoire

I'm wondering why doesn't anybody answer my question? Was it so "lame"?

----------

## Lepaca Kliffoth

 *BeteNoire wrote:*   

> I'm wondering why doesn't anybody answer my question? Was it so "lame"?

 

Maybe nobody knows?

----------

## BeteNoire

So... how most people here are able to make their livecds following this howto? I am not and stuck with no info about what to do.

----------

## loux.thefuture

Hello,

for 'lame' : i found that on web -> gentoo -> on-line database->lame -> mp3 encoder !

i don't know if it is a good idea to unmerge so packages before making the squash file in the howto,

for example linux-headers, gcc, automake, autoconf ... ?

Loux

----------

## Lucio

Hi,

 *Quote:*   

> 
> 
> Instead of "exec /sbin/init ${CMDLINE}" use only "exec /sbin/init".
> 
> 

 

I've tried, but there is no difference. It loops for ever...

Any idea....

Lucio

----------

## metalfan

[EDIT] my fault, crap deleted [/EDIT]

greets

metalfan

----------

## thoffmeyer

I've been looking for a post like this, thanks   :Razz: 

----------

## LD

Great howto.

Does anyone know of ways to save off a config file to something like a USB stick in a way similar to KNoppix?

----------

## Lepaca Kliffoth

Sorry for the late answers, I hope you 2 guys are still reading this.

 *Lucio wrote:*   

> Hi everybody;
> 
> Very usefull howto and lot of comments.
> 
> However I didn't find the solution to my pb.
> ...

 

When I answered you the first time I had misunderstood, sorry. I didn't get that you were issuing the commands by hand under an sh shell. Basically, you can't start init like that. You have to do exactly the same things the linuxrc does, which is exec chroot /bin/sh ... EOF. Look it up in this guide. If you need some more insight on the linusrc script, you can read my own guide which spends some more time explaining things (shameless plug  :Razz: ).

 *metalfan wrote:*   

> Lepaca Kliffoth: the cd isnt detected as bootcd, tried several drives. the computer just spins the cd up and then down again and boots from drive. knoppix dvds can boot on this machine...
> 
> greets
> 
> metalfan

 

Your BIOS probably has some trouble booting a CD with GRUB on it. It happened to me too a couple of times in the last few days. What I did was moving to ISOLINUX, which works always (barring some VERY buggy bioses). If you need assistance in switching from grub to isolinux, you can read it in my guide (another shameless plug).

----------

## pablo_supertux

wow, a great documentation, I've hust built my first livecd, but I got a kernel panic.

I get 

```

Unable to identify CD-ROM format

Unable to identify CD-ROM format

/linuxrc: linue 34: cd: /new/var:  No such file or directory

/linuxrc: linue 35: cd: /new/etc:  No such file or directory

/linuxrc: linue 34: cd: /new/root:  No such file or directory

pivot_root: No such file or directory

/linuxrc: linue 41: dev/console:  No such file or directory

Kernel panic - not syncing: Attemted to kill init!

```

I am creating an install livecd, well livedvd. I have 20 computer and they have the same hardware, so I decided to install one and create a stage-4 (tar.bz2 file) and pack it on a cd/dvd. This file is almost 3 GB large. I don't know exactly where to put this file, on livecd/source/etc wouldn't be a great idea. Should I put ths file on livecd/target/files so that I get this file from the mounted dvd?

Thank a lot for this great documentation.

----------

## loux.thefuture

Hello,

i'm trying to build a livecd without gcc, to do that i unmerge it before creating the squashfs file,

but when doing it i remove libstdc++.so.6, my question is :

How can i remove gcc from my livecd while keeping libstdc++.so.6 and other librairies ?

bye

loux

----------

## Lepaca Kliffoth

You shouldn't be doing that if you don't know exactly what you're doing. The only good method is to make a package of gcc and manually delete all the executables and stuff you don't need. Of course unmerging it will cripple your system because you need the libraries installed by the gcc package.

----------

## loux.thefuture

Hello,

i understand that unmerging gcc could cause me a lot of trouble due to libstdc++ library

but there is a package libstdc++-v3 to replace gcc-3.3.4

so can we create such a package for replacing gcc-3.4.4 ?

Loux

----------

## pablo_supertux

 *pablo_supertux wrote:*   

> wow, a great documentation, I've hust built my first livecd, but I got a kernel panic.
> 
> I get 
> 
> ```
> ...

 

I am such an idiot, I forgot to enable squashfs   :Laughing:   :Embarassed:  everything works fine, now.

----------

## Lepaca Kliffoth

 *loux.thefuture wrote:*   

> Hello,
> 
> i understand that unmerging gcc could cause me a lot of trouble due to libstdc++ library
> 
> but there is a package libstdc++-v3 to replace gcc-3.3.4
> ...

 

There's no such package so you'll have to do it all by hand.

----------

## lxg

Hi, 

I built a LiveCD following th instructions at http://gentoo-wiki.com/HOWTO_build_a_LiveCD_from_scratch -- it seems to work well, except at 

```
>> Copying read-write image contents to tmpfs 
```

the system keeps hanging for about 5-10 minutes. After that, the booting goes on properly and everything seems to be fine.

I built the initrd using genkernel 3.3.10. I identified the section of the genkernel linuxrc script to do that "copying read-write" action, but I can't figure out what in detail causes the long hanging. I think I have quite an up-to-date machine (P IV 2400 w/ 768MB RAM).

/usr/share/genkernel/generic/linuxrc (ll. 570-613):

```

if [ ! "${USE_UNIONFS_NORMAL}" -eq '1' ]

        then

                good_msg "Copying read-write image contents to tmpfs"

                # Copy over stuff that should be writable

                (cd ${NEW_ROOT}/${FS_LOCATION}; cp -a ${ROOT_TREES} ${NEW_ROOT})

                # Now we do the links.

                for x in ${ROOT_LINKS}

                do

                        if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]

                        then

                                ln -s "`readlink ${NEW_ROOT}/${FS_LOCATION}/${x}`" "${x}" 2>/dev/null

                        else

                                # List all subdirectories of x

                                for directory in `find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null`

                                do

                                        ## Strip the prefix of the FS_LOCATION

                                        directory=${directory#${NEW_ROOT}/${FS_LOCATION}/}

                                        ## Skip this directory if we already linked a parent directory

                                        if [ "${curent_parrent}" != '' ]; then

                                                var=`echo "${directory}" | grep "^${curent_parrent}"`

                                                if [ "${var}" != '' ]; then

                                                        continue

                                                fi

                                        fi

                                        ## Test if the directory exists already

                                        if [ -e "/${NEW_ROOT}/${directory}" ]

                                        then

                                                # It does exist, link all the individual files

                                                for file in `ls /${NEW_ROOT}/${FS_LOCATION}/${directory}`

                                                do

                                                if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then

                                                                ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null

                                                        fi

                                                done

                                        else

                                                # It does not exist, make a link to the livecd

                                                ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null

                                                current_parent=${directory}

                                        fi

                                done

                        fi

                done

```

I have to add that I'm emulating the iso image with qemu, but I gave it 360 megs of RAM, and more important: Knoppix and other LiveCD images run fine. So I think it's not in the qemu.

Does somebody have an idea why that "copying read-write image contents to tmpfs" takes forever? Possibly also a solution how to shorten it?

----------

## Lepaca Kliffoth

 *lx0 wrote:*   

> Does somebody have an idea why that "copying read-write image contents to tmpfs" takes forever? Possibly also a solution how to shorten it?

 

Does it take as much when you run it from CD (I mean, without qemu)?

----------

## lxg

 *Lepaca Kliffoth wrote:*   

>  *lx0 wrote:*   Does somebody have an idea why that "copying read-write image contents to tmpfs" takes forever? Possibly also a solution how to shorten it? 
> 
> Does it take as much when you run it from CD (I mean, without qemu)?

 

After having had wasted some blank CDs on other probs, I had been switching to qemu. It seemed to work fine with other Live-Distros. Also, it appeared to be the same if I burned a real CD or emulated the image with qemu. 

However, I just gave it another try with the real burning. Now the "Copying ..." process still takes about 20 seconds (btw, on quite a fast machine), but by far not as long as with qemu. So possibly there was my mistake in assuming that qemu worked 100% perfect.

Still I wonder why Knoppix booted pretty perfectly with qemu while our LiveCD wouldn't.

----------

## Lepaca Kliffoth

Qemu is NOT perfect.

What about burning to some rewritable media -_-'

----------

## lxg

 *Lepaca Kliffoth wrote:*   

> Qemu is NOT perfect.

 

Well, obviously not.  :Wink:  But after having tried it with Knoppix, I thought there wouldn't be anymore serious problems.

 *Lepaca Kliffoth wrote:*   

> What about burning to some rewritable media -_-'

 

Yes, I know  -- but that would require me to go to that thing called "real world"...

Seriously, I use CDs so seldom that I still live from the pile I got myself quite a year ago. Same with RWs... I just don't need them (normally  :Wink: ).

----------

## lxg

I just tested the Gentoo 2005.1-r1-minimal installation CD, it also works fine with qemu, especially when it comes to "Copying read-write image contents to tmpfs". Seems they use a different linuxrc script.

I'll see if I find out some more, but I better don't stuff it into this thread but I'll post it at http://gentoo-wiki.com/Talk:HOWTO_build_a_LiveCD_from_scratch

----------

## xanas3712

Can anyone explain exactly what this does?

 *Quote:*   

> 
> 
> tar cvpf ../../target/files/etc.tar * .[[:alnum:]]* 
> 
> 

 

I know that cvpf is just to create an archive with files in that directory (etc) but what does the .[[:alnum:]]* do exactly?  I can't find any syntax like that elsewhere to explain ...

----------

## Lepaca Kliffoth

It's a regular expression, it means "any letter or number"

----------

## xanas3712

Ok, but what does it cover that the pure wildcard * does not?

I basically followed this guide and am pretty close to having everything working now (x is the only thing lacking as I'm not sure how to log into kdm yet lol)..

I combined it with the wiki guide (which I used before and the genkernel initrd didn't do things right.. there was no tmpfs for var/ tmp/ etc.  ) so that created a few issues.  But anyway I just used * since I didn't know what that was for.

Also, is there a way with tar to exclude path from the archive or to extract without path data?  I am guessing not since this script requires changing directory into the path to actually archive but I figured it was worth asking anyway.

----------

## Lepaca Kliffoth

 *xanas3712 wrote:*   

> Ok, but what does it cover that the pure wildcard * does not?

 

I think it's needed to match filenames starting with a dot or something like that, I don't remember. I suggest you use unionfs and drop the ramdisk mechanism altogether.

 *xanas3712 wrote:*   

> x is the only thing lacking as I'm not sure how to log into kdm yet lol...

 

Exit from your current DE, chroot inside the "livecd" mounting what's needed (dev, sys, proc...) and start KDE then configure everything. If you don't want to run as root create a normal user and use that user to log in kdm.

 *xanas3712 wrote:*   

> Also, is there a way with tar to exclude path from the archive or to extract without path data?  I am guessing not since this script requires changing directory into the path to actually archive but I figured it was worth asking anyway.

 

```
man tar
```

Man is a great app and Google is at least as great. Check out the --exclude option. "Excluding path from the archive" doesn't make much sense. If you want to specify the target directory under wich you want to extract the archive you do that with the -C or --directory option.

----------

## xanas3712

I did check the man page/ --help output on tar before asking that (as well as checking google.)

It's not clear how to do this however, which is why I asked.

I'm not sure I was clear myself, so here is what I'm wanting to know if you can do (you can do it with some other zip programs like winrar in windows).

say you start compressing from ...

/home

and you are compressing

/home/thisuser

/home/thisuser/stuffhere

/home/thatuser

/home/anotheruser

under that.

What I wanted to know is, is there a way to exclude the path, just extracting the files themselves into the directory without recreating the path.

Why would you do this?

Well, in the example (the script here), I had originally just 

tar cvpf /root/livecd/source/etc.tar /root/livecd/source/etc/*

Instead of just cd /root/livecd/source/etc/ and then running the command the other way.

Ok, since I did that it created an archive with the files I wanted but with this path, so when it was extracting it was creating that whole path within the etc directory, so it was doing...

tar xpf /new/etc.tar 

and of course it created

/new/etc/root/livecd/source/etc/ <-- this path

I wanted to know if it could just extract the files without creating that path. so that it would put those files in that path directly in

/new/etc instead

Again, I'm aware of the -C, and --exclude options, but they are not for this AFAIK.  I don't think anything is, so I'm sure the answer is no.  I was curious though if there was a good roundabout way of accomplishing the same thing.

BTW, I use google all the time, as well as the forum search.  I don't know if you were intentionally condescending or not, but I see that answer far too often.  Google only works because people have asked and others have answered.  I understand not wanting to waste time but if that's the case isn't it faster/easier just not to answer at all?   Man pages, helpful though they may be are not always explicit or clear either, and many learn from examples not always provided by such pages.

----------

## Lepaca Kliffoth

What you want to exclude is only the base path. Your post made me believe you wanted to extract the single files without paths, meaning that all the files end up in the same directory -- which of course makes no sense for etc and var. I apologize for misunderstanding.

To answer your question, what you have there is basically a non-issue. We're talking about a script here, just 'cd dir && tar <args> && cd ..' and you have solved the problem. If you want you can get rid of the tar mess using unionfs but if you want to abide by veezi's guide you should use his scripts as they are.

About the google and man thing I said that because I'm a dick but I'm also the only one answering you here so you can't complain  :Laughing:   :Laughing:   :Laughing:  Joke, joke.

----------

## xanas3712

Well, the problem is that I used the wiki scripts and then I came here.  I've pretty much fixed those issues though.  Everything is working fine.

Thanks for the help btw, you are right that you were the only one who answered.

I'll look into unionfs thing.  This has been an interesting enough project for learning basic bash scripting if nothing else.  I'm trying to get to the point where this cd will run on any one of the 3 systems I have here with 3d acceleration (so I'm going to have to figure out how to write a script to detect nvidia/ati and modprobe the appropriate driver module along with changing xorg.conf)..  Once I've done that I'm going to try to write an installer script so that I can install gentoo from the dvd/cd for some other people that I've been working on converting to linux  :Smile: 

I could always set them up with an easier to use distro but this is fun and good practice anyway.

----------

## scriptX

```
gentoo boot # touch /boot/initrd

gentoo boot # dd if=/dev/zero of=/boot/initrd bs=1024k count=8

8+0 records in

8+0 records out

gentoo boot # losetup /dev/loop0 /boot/initrd

/dev/loop0: No such device or address

gentoo boot # ls -al /dev | grep loop0

brw-rw----   1 root disk     7,   0 Oct 19 11:12 loop0

gentoo boot # 

```

----------

## Lepaca Kliffoth

 *scriptX wrote:*   

> 
> 
> ```
> gentoo boot # touch /boot/initrd
> 
> ...

 

Have you tried with /dev/loop/0? Are you sure you have loop device support in your kernel?

----------

## scriptX

I actually didn't have it compiled in... I did compile it just last night, haven't had a chance to try again. Hopefully it'll work now...

----------

## scriptX

The problem was that I didn't have it compiled in, now I do and have finished the tutorial. A new problem arises:

```
UDF-fs: No partition found (1)

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)
```

This is under

```
qemu -cdrom livecd.iso
```

if it makes an difference.

[EDIT]

Meh, I didn't have initrd support compiled in... I'll retry...... brb

[EDIT]

Well, I got farther. /linuxrc is failing at line 41

```

/linxurc:41:

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

QEMU:

pivot_root: No such file or directory

/linuxrc: line 41: cannot create temp file for here document: Read-only file system

Kernel panic - not syncing: Attempted to kill init!

```

Methinks it's pivot_root not being found... I just fixed it (I think), we'll see if that helps.

[EDIT]

Now I get:

```
/linuxrc: line 40: pivot_root: command not found

/linuxrc: line 41: cannot create temp file for here document: Read-only file system

Kernel panic - not syncing: Attempted to kill init!
```

In the previous post, I moved pivot_root to /sbin (it was in /bin). I'll try.... using absolute paths -.-

----------

## hanni_ali

If your still getting it check you have all the options in the kernel reccommended it sounds like something's missing or maybe an issue with your menu.lst in grub.

----------

## Lepaca Kliffoth

As sh says, you're missing the pivot_root executable. Either you forgot to copy it under /bin or it's in a directory that isn't included in the PATH env variable.

Try mounting the initrd, chrooting into it (chroot /mnt/initrd /bin/sh) and then calling /bin/pivot_root. If it exists and works, check the PATH variable set inside the linuxrc script.

----------

## scriptX

I used

```
genkernel initrd
```

and all is fine.

http://gentoo-wiki.com/HOWTO_build_a_LiveCD_from_scratch#INITRD_image

----------

## scriptX

```
gentoo ~ # cd livecd

gentoo livecd # ./enter.sh

gentoo / # ifconfig

bash: ifconfig: command not found

gentoo / # 

```

What's the deal?

----------

## Lepaca Kliffoth

I don't know what that enter.sh is but have you recreated the environment variables running "env-update && source /etc/profile"? Try running it. Have you tried running /sbin/ifconfig instead of just ifconfig?

----------

## scriptX

```
gentoo / # ls /sbin | grep ifconfig

gentoo / # /sbin/ifconfig

bash: /sbin/ifconfig: No such file or directory

gentoo / # env-update && source /etc/profile

>>> Regenerating /etc/ld.so.cache...

gentoo / # /sbin/ifconfig

bash: /sbin/ifconfig: No such file or directory

gentoo / # ifconfig

bash: ifconfig: command not found

gentoo / # 
```

enter.sh:

```
#!/bin/bash

mount -o bind /proc source/proc

mount -o bind /sys source/sys

mount -o bind /dev source/dev

mount -o bind /dev/pts source/dev/pts

mount -o bind /usr/portage/distfiles source/usr/portage/distfiles

chroot source/ /bin/bash --login

umount source/proc

umount source/sys

umount source/dev/pts

umount source/dev

umount source/usr/portage/distfiles

```

[EDIT]

I guess I could just copy it over...

----------

## Lepaca Kliffoth

As the first command you ran shows, there is no ifconfig under /sbin. I don't know what the hell you're doing but ifconfig is in the base system in Gentoo so something has gone VERY wrong...

----------

## hanni_ali

I have a question I've been using this sort of thing for creating livecd's for about a year now but I cannot get automounting to work once the livecd boots into kde

any suggestions

----------

## Lepaca Kliffoth

You'll find several threads about automounting with KDE. You need hal (dbus too of course) and pmount. It works flawlessly for me.

----------

## hanni_ali

On a LiveCD?

I want kdemedia manager to mount ANY removable device plugged into the system but mainly just usbflash drives

they are detected they can be mounted manually but not automatically

I have all those

dbus, hal, kde 3.4.3, pmount...

I'd also tried using ivman but I've removed that now

And hours and hours of effort how come it won't work

I've tried udev rules as well

plus automounting as root using kdemedia manager is ita ny different?

----------

## Lepaca Kliffoth

Sorry but you don't make any sense and this is not the place to ask anyway. Please refer to a thread about automounting under KDE and ask there. Only thing I can tell you is that I configured KDE as I would have configured it on a nromal installation and it works from the LiveCD as it doeas from the hard disk. If you have any problem regarding the making of a livecd or the guide itself I'll help you as much as I can.

----------

## fidel

I just don't get the right device for the cd rom probed. When I boot the livecd I created it somehow always tries to determine a cdrom on my harddrive /dev/hda*. I got 9 partitions, mostly reiserfs. In the boot process it assumes to find a cdrom device on /dev/hda9. I even kicked hda and hdb from my linuxrc script, still, the same! I still probes my harddrive... I disabled the harddrive in the bios, still, it determines my cdrom on /dev/hda9... 

I spent hours and hours and hours trying to get a working livecd (need it for installing on a raid with a promise TX2300, I seem to need kernel-2.6.15 or newer...)

I found your smooth guide hours and hours after already trying to suceed with another guide:

http://gentoo-wiki.com/HOWTO_build_a_LiveCD_from_scratch

On that guide, the script linuxrc is missing totally! It is mentioned in the boot kernel command, but.. 

Therefore I needed one, found one here and tried to adapt the needed things. My linuxrc ended up like this:

```

#!/bin/sh

export PATH=/bin

mount -t proc none /proc

CMDLINE=`cat /proc/cmdline`

umount /proc

CDROM=""

for x in hdc hdd cdroms/cdrom0 cdroms/cdrom1 cdroms/cdrom2 cdroms/cdrom3

do

  mount -t iso9660 -r /dev/${x} /mnt/cdrom > /dev/null 2>&1

  if [ "$?" = "0" ]

  then

    CDROM="${x}"

    break

  fi

done

if [ "${CDROM}" == "" ]

then

  exec /bin/sh

  exit

fi

mount -t squashfs -o loop /cdrom/livecd.squashfs /new > /dev/null 2>&1

mount -t tmpfs -o size=8m none /new/var > /dev/null 2>&1

mount -t tmpfs -o size=4m none /new/etc > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/tmp > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/root > /dev/null 2>&1

cd /new/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /new/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /new/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

cd /new

pivot_root . newroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}

EOF
```

Whatever I try, no luck!   :Crying or Very sad:   :Crying or Very sad:   :Crying or Very sad: 

What could I do to get that livecd to work?.. I am totally stuck..

Thanks for any help!!!!

Greets

fidel

----------

## Lepaca Kliffoth

(I think veezi's not around anymore)

After you replaced genkernel's initrd with the one you posted where does it fail? What's the error message? The linuxrc from this guide won't try to mount hda9 so it must be something else. You can try my own guide too if you want but you'll have to modify many things.

----------

## fidel

The cd boots and finds the kernel, that's all fine. Afterwards the linuxrc starts and tries to find the appropriate cdrom. There it fails! It just goes for any hd* devices and tries to mount them. It finally finds the /dev/hda9 and starts mounting it.. There the error appears, as it can't find "livecd.squashfs" and exits, I get the error I should append a correct "loop=" line.

The point is, I don't understand why my hda gets probed, I removed that one from the linuxrc. I wouldn't care if I only got the option of being able to mount /dev/hdc, since mostly I connect the cdroms and dvds on the master of the second IDE...

Since I followed the other guide, where there cannot be found any linuxrc at all, I am not sure anymore, if its my linuxrc that gets executed at all... I could imagine that the genkernel initrd tries to probe the cdrom device.. Just don't know anything anymore...   :Crying or Very sad: 

Maybe someone knows how to achieve using my livecd. Otherwise I most probably will start all over and try your guide!.. Just a bit tired of "trying"  :Wink: 

But thanks anyway!

greets!

fidel

----------

## Lepaca Kliffoth

Is what you're using an initrd or an initramfs? I suggest you go the initrd way. You could try rebuilding the initrd from scratch, it takes only a little time. Refer to the relevant part of this guide or section number 5 of my guide if you wish to try that. Once you have an initrd just modify the bootloader's configuratin so that it loads it.

I'm saying this because although what you write is confused it seems to me that your problem is that your linuxrc isn't being executed at all. There is no other explanation since it keeps doing things it cannot do.

----------

## fidel

It really was an initramfs and NOT an initrd!.. Noob me didn't know that not only the name of the file differs!   :Embarassed: 

I'm no building the cd again, trying to succeed with an initrd, I was a bit scared of the complexity of building an initrd, therefore I liked to use genkernel just needing to type genkernel initrd.. Stupid thing it still creates an initramfs!... I still don't know the difference of it though, will keep on reading!

Thanks once again! I'll see if it works, otherwise I really start all over again...

By the way, do I need livecd-tools installed? According to

http://de.gentoo-wiki.com/Eigene_LiveCD_bauen_ohne_catalyst

grub only understands the cdroot parameter having livecd-tools installed...

greets!

fidel

[edit]

Now my cd boots, loads the kernel and leaves me at a sh-prompt.. ok, I will start all over and use your guide!

[/edit]

----------

## Lepaca Kliffoth

I think livecd-tools are needed only for genkernel's initramfs. I'm not sure though. When I still used grub I had no problems without that package, it booted the CD just fine (now I use isolinux).

----------

## sixtymhz

What is the roots passwd on the livecd?? Or how can I set it so I can use emeger and such?

Thanks.

----------

## fidel

The root password on the livecd is not set, you can set a password using

```
# passwd
```

Strange that this question appears at all, since when you boot from the livecd you are automatically logged in as root!...

If you boot your own livecd though, the root password is most probably the same as in your installation you use for the livecd...

greets

fidel

----------

## Lepaca Kliffoth

 *fidel wrote:*   

> If you boot your own livecd though, the root password is most probably the same as in your installation you use for the livecd...

 

No, unless you copy things from the host system /etc to the /etc of the livecd. Normally the root password is unset and you can't login no matter what so the "good way" is to set the passwords with "passwd root", "passwd user1", "passwd user2" and so on from inside the chroot.

----------

## fidel

Sorry!

... and sorry for asking again! I am getting closer, just another stupid newbie question: where do I have to put the linuxrc script? Does this go into livecd/source/linuxrc or livecd/source/boot/linuxrc or livecd/source/mnt/initrd/linuxrc...??

----------

## Lepaca Kliffoth

Sorry for what??

Anyway, short: linuxrc goes inside the initrd.

Long: linuxrc is a script called by the kernel; instead of calling /sbin/init it calls linuxrc, which is a behaviour you trigger with the "init=/linuxrc" parameter you put in the kernel commandline, specified inside the bootloader's configuration, "kernel (cd)/boot/vmlinuz init=/linuxrc root=/dev/ram0" for grub. Since the kernel doesn't mount the root fs straight away you can't just keep linuxrc somewhere inside the root fs. The kernel mounts the initrd -- "initrd (cd)/boot/initrd" in grub's configuration -- and then tries to execute linuxrc. That's why the linuxrc script must be inside the initrd. Don't put it under /bin; it must be directly under / unless you change "init=/linuxrc" to something else. You have to mount the initrd with "mount -o loop initrd /somewhere" and then "mv linuxrc /somewhere/". Make sure linuxrc has the exec flag enabled: "chmod +x /somewhere/linuxrc". That's all.

----------

## fidel

Thanks! 

I get a kernel panic, linuxrc not found. I already copied (in the chroot) the linuxrc file (executable!) to /boot/linuxrc /linuxrc and have the same content in /mnt/initrd/linuxrc

My /boot/grub/menu.lst:

```

default 0

timeout 5

splashimage=(cd)/boot/grub/splash.xpm.gz

title=Gentoo Linux - 2.6.15-r1

root (cd)

kernel (cd)/boot/kernel-2.6.15-r1 vga=0x317 video=vesafb,mtrr,ywrap root=/dev/ram0 rw init=/linuxrc cdroot dodmraid

initrd (cd)/boot/initrd

title=Memtest86+

root (cd)

kernel (cd)/boot/memtest86plus/memtest.bin

```

My corresponding folders:

```
# ls -lh /boot

insgesamt 12M

lrwxrwxrwx  1 root root    1 14. Feb 20:59 boot -> .

-rw-r--r--  1 root root  37K 15. Feb 09:30 config-2.6.15-r1

drwxr-xr-x  2 root root  544 15. Feb 09:55 grub

-rw-r--r--  1 root root 8.0M 15. Feb 14:00 initrd

-rw-r--r--  1 root root 2.5M 15. Feb 09:29 kernel-2.6.15-r1

-rwxr-xr-x  1 root root 1.1K 15. Feb 13:11 linuxrc

drwxr-xr-x  2 root root   80 15. Feb 09:56 memtest86plus

-rw-r--r--  1 root root 857K 15. Feb 09:29 System.map-2.6.15-r1

# ls -lh /mnt/initrd

insgesamt 21K

drwxr-xr-x  2 root root 1.0K 15. Feb 14:00 bin

drwxr-xr-x  2 root root 1.0K 15. Feb 14:00 cdrom

drwxr-xr-x  2 root root 1.0K 15. Feb 14:00 dev

drwxr-xr-x  2 root root 1.0K 15. Feb 14:00 etc

drwxr-xr-x  2 root root 1.0K 15. Feb 14:00 lib

-rwxr-xr-x  1 root root 1.1K 15. Feb 14:00 linuxrc

drwx------  2 root root  12K 15. Feb 14:00 lost+found

drwxr-xr-x  2 root root 1.0K 15. Feb 14:00 new

drwxr-xr-x  2 root root 1.0K 15. Feb 14:00 proc

# ls -lh /

insgesamt 22K

drwxr-xr-x    2 root root 3.7K 15. Feb 09:52 bin

drwxr-xr-x    4 root root  304 15. Feb 13:12 boot

drwxr-xr-x   19 root root  14K 15. Feb 13:47 dev

drwxr-xr-x   36 root root 2.6K 15. Feb 14:00 etc

drwxr-xr-x    2 root root   72 19. Okt 18:12 home

drwxr-xr-x    8 root root 3.9K 15. Feb 12:23 lib

-rwxr-xr-x    1 root root 1.1K 15. Feb 12:35 linuxrc

-rwxr-xr-x    1 root root 1.1K 15. Feb 13:24 mkinitrd

drwxr-xr-x    5 root root  144 15. Feb 12:04 mnt

drwxr-xr-x    2 root root   72 19. Okt 18:12 opt

dr-xr-xr-x  112 root root    0 15. Feb 2006  proc

drwx------    2 root root  128 15. Feb 10:53 root

drwxr-xr-x    2 root root 4.0K 15. Feb 13:11 sbin

drwxr-xr-x    2 root root   72 19. Okt 18:12 sys

drwxrwxrwt    2 root root   72 15. Feb 13:10 tmp

drwxr-xr-x   12 root root  352 14. Feb 22:10 usr

drwxr-xr-x   10 root root  336 15. Feb 12:24 var
```

I don't get why my linuxrc cannot be found...   :Sad: 

----------

## fidel

 :Embarassed:   :Embarassed:   :Embarassed:   Sorry! I had an empty line at the beginning of my linuxrc script!...   :Embarassed:   :Embarassed:   :Embarassed: 

Now the linuxrc gets found, still I get some errors, the cdrom format cannot be found, somehow I must have missed the pivot_root (cannot be found either..) and creating tmpfs fails (read only filesystem)...

Trying to fix that....

thanks a lot!

[edit]

It just won't work! I've been trying to get a running livecd for a week now, trying two different guides... But I hate to give up!.. Still I am getting errors that the cdrom format cannot be identified and that there is no possibility of creating anything tmpfs, read only...

Please help!...

I wrote a little script for creating the initrd:

```
##

rm /boot/initrd

touch /boot/initrd

dd if=/dev/zero of=/boot/initrd bs=1024k count=8

losetup /dev/loop0 /boot/initrd

mke2fs /dev/loop0

mkdir /mnt/initrd

mount /dev/loop0 /mnt/initrd

cd /mnt/initrd

mkdir etc dev lib bin sbin proc new cdrom

touch linuxrc

chmod +x linuxrc

cp /linuxrc ./

touch etc/mtab

touch etc/fstab

# bin fuellen

cp /bin/sh bin

cp /bin/cat bin

cp /bin/mount bin

cp /bin/umount bin

cp /bin/mkdir bin

cp /bin/chroot bin

cp /bin/tar bin

cp /sbin/pivot_root bin

cp /sbin/init sbin

cp /lib/libblkid.so.1 lib

cp /lib/libuuid.so.1 lib

cp /lib/libc.so.6 lib

cp /lib/ld-linux.so.2 lib

cp /lib/librt.so.1 lib

cp /lib/libpthread.so.0 lib

cp /lib/libdl.so.2 lib

mknod /mnt/initrd/dev/console c 5 1

mknod /mnt/initrd/dev/null c 1 3

mknod /mnt/initrd/dev/hda b 3 0

mknod /mnt/initrd/dev/hdb b 3 64

mknod /mnt/initrd/dev/hdc b 22 0

mknod /mnt/initrd/dev/hdd b 22 64

mknod /mnt/initrd/dev/tty c 4 0

mknod /mnt/initrd/dev/loop0 b 7 0

```

The script for creating the livecd is about the same as in the guide:

```
#!/bin/bash

rm -rf target

mkdir target

cp -a source/boot target/

mkdir target/files

rm -rf source/var/tmp/*

rm -rf source/var/run/*

rm -rf source/var/lock/*

rm -rf source/tmp/*

rm -f source/etc/mtab

touch source/etc/mtab

cd source/etc/

tar cvpf ../../target/files/etc.tar *

cd ../var/

tar cvpf ../../target/files/var.tar *

cd ../root/

tar cvpf ../../target/files/root.tar *

cd ../../

mksquashfs source/ target/files/source.img

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 4 -hide boot.catalog -o ./livecd.iso target
```

My linuxrc:

```
#!/bin/sh

export PATH=/bin

# Get kernel CMDLINE

mount -t proc none /proc

CMDLINE=`cat /proc/cmdline`

umount /proc

# Mount CD device

CDROM=""

for x in hda hdb hdc hdd

do

  mount -t iso9660 -r /dev/${x} /cdrom > /dev/null 2>&1

  if [ "$?" = "0" ]

  then

    CDROM="${x}"

    break

  fi

done

# CD not found

if [ "${CDROM}" == "" ]

then

  exec /bin/sh

  exit

fi

# Mount root and create read-write directories

mount -t squashfs -o loop /cdrom/files/source.img /new > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/var > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/etc > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/tmp > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/root > /dev/null 2>&1

cd /new/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /new/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /new/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

# Pivot root and start real init

cd /new

pivot_root . newroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}

EOF

```

Just don't see what's wrong here!.. 

[/edit]

----------

## Lepaca Kliffoth

Please check again if you built the iso9660 filesystem (the fs used for cd and dvd) INSIDE the kernel. Not built as a module. You also need squashfs support INSIDE the kernel. The error you describe sounds like your kernel doesn't know those filesystems, which is the case when you build them as modules. You're doing fine, don't worry, this kind of things always happen the first couple of times.

edit: about the pivot_root, just put it in the intird under /bin if for some reason it isn't there already and check again that all the libraries it needs are under /lib inside the initrd.

edit2: oh and in the script you wrote that builds the initrd, take away the line that copies the "init" executable. You don't want it inside the intird.

----------

## fidel

Thanks a lot! The thing is, I really have the iso9660 fs and squashfs and the appropriate ide driver etc. compiled into the kernel!... The script that creates the initrd really does copy the pivot_root from /sbin/ to /mnt/initrd/bin/. Really strange to me! I don't know if that might be an issue at all, I am merging the system on an amd64 host and it should result in a livecd for a pentium4 or some i686 system....

```
# linux32 chroot /mnt/dick/livecd/source /bin/bash --login

# env-update && source /etc/profile

>>> Regenerating /etc/ld.so.cache...

# emerge --info

Portage 2.0.54 (default-linux/x86/2005.1, gcc-3.4.4, glibc-2.3.5-r2, 2.6.15-gentoo-r5 i686)

=================================================================

System uname: 2.6.15-gentoo-r5 i686 AMD Athlon(tm) 64 Processor 3200+

Gentoo Base System version 1.6.14

dev-lang/python:     2.3.5-r2, 2.4.2

sys-apps/sandbox:    1.2.12

sys-devel/autoconf:  2.13, 2.59-r6

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1

sys-devel/binutils:  2.16.1

sys-devel/libtool:   1.5.22

virtual/os-headers:  2.6.11-r2

ACCEPT_KEYWORDS="x86"

AUTOCLEAN="yes"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O2 -march=i686 -pipe -fomit-frame-pointer"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/lib/X11/xkb /usr/lib64/mozilla/defaults/pref /usr/share/config /var/qmail/control"

CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"

CXXFLAGS="-O2 -march=i686 -pipe -fomit-frame-pointer"

DISTDIR="/usr/portage/distfiles"

FEATURES="autoconfig distlocks sandbox sfperms strict"

GENTOO_MIRRORS="http://mirror.switch.ch/ftp/mirror/gentoo/"

LANG="de_CH"

LC_ALL="de_CH.UTF-8"

LINGUAS="de"

PKGDIR="/usr/portage/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="x86 X alsa apm arts avi berkdb bitmap-fonts bzip2 cdrom cdrw crypt cups dvd eds emboss encode expat foomaticdb fortran gdbm gif gpm gstreamer gtk gtk2 imlib ipv6 jpeg libg++ libwww livecd mad mikmod motif mp3 mpeg ncurses nls ogg oggvorbis opengl oss pam pcre pdflib perl png python quicktime readline sdl slang spell ssl tcpd truetype truetype-fonts type1-fonts udev unicode usb userlocales utf8 vorbis xml2 xmms xv zlib linguas_de userland_GNU kernel_linux elibc_glibc"

Unset:  ASFLAGS, CTARGET, LDFLAGS, MAKEOPTS, PORTDIR_OVERLAY

```

When I finally try to boot from the cd, grub starts fine and the kernel gets loaded. After that though, right after the filling of the ramdisk, the following appears:

```

RAMDISK: ext2 filesystem found at block 0

RAMDISK: Loading 8192KiB[1 disk] into ramdisk... done

EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended

VFS: Mounted root (ext2 filesystem)

Freeing unused kernel memory: 284k freed

pivot_root: No such file or directory

/linuxrc: line 41 cannot create temp file for here document: Read-only filesystem

Kernel panic - not syncing: Attempted to kill init
```

The line 41 of the linuxrc:

```
exec chroot . /bin/sh <<- EOF >dev/console 2>&1

```

... I am stuck!

----------

## Lepaca Kliffoth

I'm quite sure there is no /newroot inside your initrd. Create a "/newroot" directory inside the initrd and try again.

edit: more indepth: look at the "pivot_root" command inside the linurc: "pivot_root . /newroot". As you see during bootup the pivot_root command doesn't find a file; since "." always exists, the directory "newroot" must be the missing file. I noticed just now that the script you use to make the initrd doesn't create it.

----------

## vinky

fidel: make sure your initrd is smaller than what is supported  by the kernel. I had a similar prob until I recreated the initrc and saw that it was 8.4MB and the kernel supported 8.0MB(something wrong with dd not understanding my will (bs=1024k count=8 should create a file of 8MB right?))

the newroot dir is created by tar when unpacking your squashfile and should be automatically created in /new

----------

## Lepaca Kliffoth

 *vinky wrote:*   

> fidel: make sure your initrd is smaller than what is supported  by the kernel. I had a similar prob until I recreated the initrc and saw that it was 8.4MB and the kernel supported 8.0MB(something wrong with dd not understanding my will (bs=1024k count=8 should create a file of 8MB right?))
> 
> the newroot dir is created by tar when unpacking your squashfile and should be automatically created in /new

 

Are you sure? First of all his kernel seem to load and mount the initrd without any problems:

```
RAMDISK: Loading 8192KiB[1 disk] into ramdisk... done 

 EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended 
```

Thanks for pointing out the fact that newroot is inside the squashfs image and not in the initrd, my fault. However tar doesn't unpack the squashfs file -- it's not unpacked at all -- and it certainly doesn't create any newroot dir. So /newroot isn't missing from the initrd, as you  pointed out it's not needed there, but it's still missing from the squashfs archive and he must create it by hand.

fidel: Instead of creating the newroot dir inside the initrd, create it inside the root of the livecd. Sorry for my mistake.

----------

## vinky

 *Lepaca Kliffoth wrote:*   

>   *vinky wrote:*    skrev:
> 
> fidel: make sure your initrd is smaller than what is supported by the kernel. I had a similar prob until I recreated the initrc and saw that it was 8.4MB and the kernel supported 8.0MB(something wrong with dd not understanding my will (bs=1024k count=8 should create a file of 8MB right?))
> 
> the newroot dir is created by tar when unpacking your squashfile and should be automatically created in /new 
> ...

 

Not sure but it helped me

----------

## vinky

I have done as the guide says and installed grub and made a grub.conf under boot/grub but when I boot I get a grub-commandline and manualy have to write:

root (cd)

configfile (cd)/boot/grub/grub.conf to get a normal bootwindows,

any ideas?

----------

## Lepaca Kliffoth

You just have to make sure you wrote correctly menu.lst under /boot/grub/ as the guide says. Once it was grub.conf, now it seems to have changed to menu.lst.

----------

## fidel

Thanks a lot!!!! Dumb me! It really was that the command pivot_root in my file used a non-existant directory! It now boots!!!   :Laughing:   :Laughing:   :Laughing: 

Great!!!

There is just another problem though, first of all depscan.sh is missing functions.sh in /etc/init.d.... Hmmm! In my running Gentoo System functions.sh is a link to..:

```
$ ll /etc/init.d | grep func

lrwxrwxrwx  1 root root   23 16. Feb 00:51 functions.sh -> ../../sbin/functions.sh
```

Therefore I assume I need to change that! I will try it removing the link and copying the file from /sbin to /etc/init.d!...

Results will follow!...  :Wink: 

Another problem, I just by now don't know yet if it occurs because of the above error, is that I really have to login, I don't automatically get logged in...

But, results will follow!

Thanks a lot!!!!! Your patience, your help and your awesome guide really rocks! Great!!!

----------

## Lepaca Kliffoth

 *fidel wrote:*   

> Thanks a lot!!!! Dumb me! It really was that the command pivot_root in my file used a non-existant directory! It now boots!!!    
> 
> Great!!!
> 
> There is just another problem though, first of all depscan.sh is missing functions.sh in /etc/init.d.... Hmmm! In my running Gentoo System functions.sh is a link to..:
> ...

 

The depscan thing is called when init tries to cache service dependencies. I'm not sure that it will work but try running "rc" from the chroot. Don't move functions.sh!

(oh and this is not my guide, it's veezi's!)

----------

## fidel

Alright, still got the same problem, running rc kills my running environment. Got something to do with running a unicode system, after running rc in the chroot environment I can't use my system anymore, had to reboot (no keyboard anymore).

I still got the same error "Could not get SVCDIR!", "Error running /sbin/depscan.sh", some errors showing that ebegin, eerror and eend couldn't be found and another complaint that I got a read only filesystem, not able to create anything in the according directory...

I still don't get logged in as root, I get a prompt to log in.

I am a lot further now, the kernel gets loaded and the cdrom gets mounted and the system starts.... grr, I'd like to get the rest as well!..   :Crying or Very sad: 

----------

## Lepaca Kliffoth

I figured it wouldn't work but I didn't think it would make your system unusable and need a reboot O_O Sorry, I thought it was harmless.

About the problem I'm a bit clueless. It's a long time since I last made a non-unionfs livecd and I don't remember ever getting that problem. Have you tried identifying which of the many services cause the problem? Maybe if I know which service it is I can help you.

----------

## fidel

Don't really know how to figure that out.. I guess that in /sbin/depscan.sh the thing

```
f [[ ! -d ${svcdir} ]] ; then

        if ! mkdir -p -m 0755 "${svcdir}" 2>/dev/null ;
```

can't be done, I also get errors of having an unwriteable filesystem... might be wrong though, just guessing!..

----------

## fidel

I got a bit further. After I installed livecd-tools I get logged in as root, the cd works so far. Still, running depscan I get the error that {SVCDIR} cannot be gotten. It seems as well that autoconfig (from livecd-tools) doesn't get started, I assume that's because of the error of not being able to get svcdir. I unfortunately don't even know, what depscan really does and what svcdir stands for... do I miss a directory? Can anybody give me a suggestion how to find out about that error?... (It's the last thing my livecd needs!...)

Thanks!

[edit]

Weird! functions.sh still doesn't get found!... 

[/edit]

----------

## fidel

Hate to give up, but now time has come to surrender....  :Crying or Very sad: 

Is there anyone who can provide me with a livecd with a kernel >=2.6.15 and sys-fs/raidtools installed?...

could give a ftp place....

----------

## slycordinator

So in the original post, why bind-mount just /usr/portage/distfiles? Why not bind-mount the entire /usr/portage?

Bind-mounting distfiles is so you don't have to download them again. Well, bind-mounting the whole tree clearly avoids having to unpack a snapshot and what-not.

----------

## marciv

Hello,

first: sorry for my bad english...

I have a problem with my Live-cd, when i boot my CD initrd stops with this message:

```
 

...

Freeing unused kernel memory: 216k freed

Starte Initrd...

/linuxrc: line 37: dev/console: Read-only file system

Kernel panic - not syncing: Attempted to kill init!

```

Can some one help me?

My linuxrc script is exactly the same as this in the tutorial...

[edit]

Now i have tested the livecd with a genkernel an its initrd,

but i dont get it work. There comes this:

```

...

>>Activating udev

>>Making tmpfs for /newroot

...

>>Attempting to mount CD: - /dev/hdc

...

>>No bootable medium found. waiting for new devices...

...

>>Attempting to mount CD: - /dev/hdc

...

!! Could not find CD to boot, something else needed!

>>Determining root device...

!! The root block device is unspecified or not detected 

Please specify a device to boot, or "shell" for a shell...

boot() ::_

```

[/edit]

----------

## marciv

So, i have tried this, with the initramfs-genkernel:

```

boot() :: /dev/hdc  # hdc is definitely my cdrom drive

>>Mounting root...

mkdir: Cannot create directory '/newroot/tmp` : Read-only file system

mknod: //newroot-dev-console: No such file or directory

mknod: //newroot/dev/tty1: No such file or directory

>>Booting (initramfs)...umount: /sys: Invalid argument

*: Failed to umount the initrd /sys!

..

chroot: cannot execute /bin/sh : No such file or directory

Kernel panic - not syncing: Attemted to kill init!

```

On sonday i tried it with my own initrd, it was the first time i made the iso of the cd.

With this CD i can boot with init=/bin/sh into the initrd and start the whole cd by hand.

It doesnt start automaticly because, i have written "mount -t squashfs -o loop /cdrom/files/livecd.img" in the linuxrc script, 

but my .img was  "/cdrom/livecd.squashfs"

Yesterday i corrected the linuxrc and maked a new iso now there is the error in my first post. I dont know why...

----------

## slycordinator

 *Lepaca Kliffoth wrote:*   

> You just have to make sure you wrote correctly menu.lst under /boot/grub/ as the guide says. Once it was grub.conf, now it seems to have changed to menu.lst.

 

```
# ls -l /boot/grub/menu.lst

lrwxrwxrwx 1 root root 9 Apr  3 19:28 /boot/grub/menu.lst -> grub.conf
```

menu.lst is a symlink to grub.conf

----------

## scriptX

The ISO9660 or whatever it is filesystem doesn't like symlinks

----------

## Thegreatone

Hi guys! 

I have built the livecd using your help but got some problem with database:

I need to load at boot, both postgresql and mysql..

should i change something during the creation process?

Thanks

Luca

----------

## Thegreatone

I have follow the guide on the wiki for building from sreatch but on boot got this error:

http://img230.imageshack.us/my.php?image=liveerror19ac.png

Thx

Luca

----------

## vinky

check that you have right command in linuxrc when it comes to the mounting

----------

## Thegreatone

thank your for your answer!

I am following this, but i don't understand how ceck what you told me

http://gentoo-wiki.com/HOWTO_build_a_LiveCD_from_scratch#Installing_Gentoo

Luca

----------

## vinky

that one is a bit different from the one I used( the one on the first page of this thread)

your guide uses genkernel and that makes the initrd where the linuxrc is automatically

check this part of the guide.

http://gentoo-wiki.com/HOWTO_build_a_LiveCD_from_scratch#Checking.2Fediting_the_Initramfs

----------

## Thegreatone

This is my initrd:

```
# Default to the udev device manager

USE_UDEV_NORMAL=1

# Insert ctrl character

# ctrl-V then esc will print ^[

# ctrl-V then ctrl-shift-m will print ^M

BACK_UP="\033[1K\033[0G"

NORMAL="\033[0m"

WARN="\033[33;1m"

BAD="\033[31;1m"

BOLD="\033[1m"

GOOD="\033[32;1m"

# From KNOPPIX LINUXRC

# Reset fb color mode

RESET="]R"

# ANSI COLORS

# Erase to end of line

CRE="

[K"

# Clear and reset Screen

CLEAR="c"

# Normal color

NORMAL="[0;39m"

# RED: Failure or error message

RED="[1;31m"

# GREEN: Success message

GREEN="[1;32m"

# YELLOW: Descriptions

YELLOW="[1;33m"

# BLUE: System mesages

BLUE="[1;34m"

# MAGENTA: Found devices or drivers

MAGENTA="[1;35m"

# CYAN: Questions

CYAN="[1;36m"

# BOLD WHITE: Hint

WHITE="[1;37m"

# Clear screen with colormode reset

# echo "$CLEAR$RESET"

# echo "$CLEAR"

# Just go to the top of the screen

# echo -n "[H[J"

KV="`uname -r`"

KMAJOR=`echo $KV | cut -f1 -d.`

KMINOR=`echo $KV | cut -f2 -d.`

KVER="${KMAJOR}.${KMINOR}"

MISCOPTS='idebug detect'

if [ "${KMAJOR}" -eq 2 -a "${KMINOR}" -ge '6' ]

then

   KV_2_6_OR_GREATER="yes"

fi

QUIET=1

ROOT_LINKS='bin sbin lib lib32 lib64 boot usr opt'

ROOT_TREES='etc root home var'

INSMOD='insmod'

if [ "${KMINOR}" -gt '4' ]

then

   KSUFF='.ko'

else

   KSUFF='.o'

fi

REAL_ROOT=''

CDROOT=0

CDROOT_DEV=''

NEW_ROOT="/newroot"

CONSOLE="/dev/console"

# Only sections that are in by default or those that

# are not module groups need to be defined here...

HWOPTS='usb firewire keymap cache evms2 sata lvm2 dmraid slowusb'

MY_HWOPTS='usb firewire sata dmraid'

HWOPTS="$HWOPTS ataraid dmraid evms2 firewire lvm2 pcmcia sata scsi usb "

 070701003FFBAE000081ED0000000000000000000000014447DBB700003921000000030000000400000000000000000000001300000000etc/initrd.scripts    #!/bin/ash

. /etc/initrd.defaults

backup() {

   echo -ne "\033[0G\033[0K"

}

strlen() {

   if [ -z "$1" ]

   then

      echo "usage: strlen <variable_name>"

      die

   fi

   eval echo "\${#${1}}"

}

parse_opt() {

   case "$1" in

      *\=*)

         local key_name="`echo "$1" | cut -f1 -d=`"

         local key_len=`strlen key_name`

         local value_start=$((key_len+2))

         echo "$1" | cut -c ${value_start}-

      ;;

   esac

}

modules_load() {

   for module in $*

   do

      echo ${module} >> /etc/modules/extra_load

   done

   modules_scan extra_load

}

modules_scan() {

   local MODS

   [ -d /etc/modules/${1} ] || touch /etc/modules/${1}

   MODS=`cat /etc/modules/${1}`

   for x in ${MODS}

   do

      MLOAD=`echo ${MLIST} | sed -e "s/.*${x}.*/${x}/"`

      if [ "${MLIST}" = "${x}" ] # Only module to no-load

      then

         echo -e "${BOLD}   ::${NORMAL} Skipping ${x}..."

      elif [ "${MLOAD}" = "${MLIST}" ] # == No change == No specified no-load

      then

         [ -n "${DEBUG}" ] && echo -ne "${BOLD}   ::${NORMAL} Checking for ${x}..."

         # find -name does not work since the return status is always zero

         if find /lib/modules | grep "${x}${KSUFF}" >/dev/null 2>&1

         then

            echo -ne "${BOLD}   ::${NORMAL} Scanning for ${x}..."

            modprobe ${x} -n

            backup

            echo -ne "${NORMAL}"

         fi

      else

         echo -e "${BOLD}   ::${NORMAL} Skipping ${x}..."

      fi

   done

}

findcdmount() {

   if [ "$#" -gt "0" ]

   then

      for x in $*

      do

         # Check for a block device to mount

         if [ -b "${x}" ]

         then

            good_msg "Attempting to mount CD:- ${x}"

            mount -r ${x} ${NEW_ROOT}/mnt/cdrom > /dev/null 2>&1

            if [ "$?" = '0' ]

            then

               # Check for a LiveCD

               if [ -e ${NEW_ROOT}/mnt/cdrom/livecd ]

               then

                  REAL_ROOT="${x}"

                  break

               else

                  umount ${NEW_ROOT}/mnt/cdrom

               fi

            fi

         fi

      done

      if [ "${REAL_ROOT}" != '' ]

      then

         good_msg "CD medium found on ${x}"

      fi

   fi

}

cache_cd_contents() {

   # Check loop file exists and cache to ramdisk if DO_cache is enabled

   if [ "${LOOPTYPE}" != "noloop" ] && [ "${LOOPTYPE}" != "sgimips" ]

   then

      check_loop

      if [ "${DO_cache}" ]

      then

         good_msg "Copying loop file for caching..."

         cp -a ${NEW_ROOT}/mnt/cdrom/${LOOP} ${NEW_ROOT}/mnt/${LOOP}

         if [ $? -ne 0 ]

         then

            bad_msg "Failed to cache the loop file! Lack of space?"

            rm -rf ${NEW_ROOT}/mnt/livecd.* 2>/dev/null

            rm -rf ${NEW_ROOT}/mnt/zisofs 2>/dev/null

         else

            LOOPEXT='../'

         fi

      fi

   fi

}

mount_sysfs() {

   if [ "${KV_2_6_OR_GREATER}" ]

   then

      # Udev is semi-broken on non /sys sysfs mount points.

      mount -t sysfs /sys /sys >/dev/null 2>&1

      ret=$?

   

      # sysfs mount failed .. udev wont work fall back to devfs if available

      [ "$ret" -eq '0' ] || USE_UDEV_NORMAL=0

   fi

}

# Insert a directory tree $2 to an union specified by $1

# Top-level read-write branch is specified by it's index 0

# $1 = union absolute path (starting with /)

# $2 = path to data directory

#

union_insert_dir() {

   /sbin/unionctl $1 --add --after 0 --mode ro $2

   if [ $? = '0' ]

   then

      good_msg "Addition of $2 to $1 successful"

   fi

}

findnfsmount() {

   if [ "${IP}" != '' ]

   then

      if [ "${NFSROOT}" = '' ]

      then

         # Obtain NFSIP   

         OPTIONS=`busybox dmesg | grep rootserver | sed -e "s/,/ /g"`

         for OPTION in $OPTIONS

         do

            if [ `echo $OPTION | sed -e "s/=/ /g" | cut -d " " -f 1` = 'rootserver' ]

            then

               NFSIP=`echo $OPTION | sed -e "s/=/ /g" | cut -d " " -f 2`

            fi 

         done

         

         # Obtain NFSPATH

         OPTIONS=`busybox dmesg | grep rootpath | sed -e "s/,/ /g"`   

         for OPTION in $OPTIONS

         do

            if [ `echo $OPTION | sed -e "s/=/ /g" | cut -d " " -f 1` = 'rootpath' ]

            then

               NFSPATH=`echo $OPTION | sed -e "s/=/ /g" | cut -d " " -f 2`

             fi

         done

         # Setup NFSROOT

         if [ "${NFSIP}" != '' ] && [ "$NFSPATH" != '' ]

         then

            NFSROOT="${NFSIP}:${NFSPATH}"

         else

            bad_msg "The DHCP Server did not send a valid root-path."

            bad_msg "Please check your DHCP setup, or provide a nfsroot=<...> parameter."

         fi

      fi

      if [ "${NFSROOT}" != '' ]

      then

         if [ "${CDROOT}" != '0' ]

         then

            good_msg "Attempting to mount NFS CD image on ${NFSROOT}"

            mount -t nfs -o ro,nolock,rsize=1024,wsize=1024 ${NFSROOT} ${NEW_ROOT}/mnt/cdrom

            if [ "$?" = '0' ]

            then

               REAL_ROOT="/dev/nfs"

            else

               bad_msg "NFS Mounting failed. Is the path corrent ?"

            fi

         else   

            good_msg "Attemping to mount NFS root on ${NFSROOT}"

            mount -t nfs -o ro,nolock,rsize=1024,wsize=1024 ${NFSROOT} ${NEW_ROOT}

            if [ "$?" = '0' ]

            then

               REAL_ROOT="/dev/nfs"

            else

               bad_msg "NFS Mounting failed. Is the path correct ?"

            fi

            # FIXME: Need to start portmap and the other rpc daemons in order to

            # FIXME: remount rw.

         fi

      fi

   fi

}

kill_devfsd() {

   killall devfsd > /dev/null 2>&1

}

check_loop() {

   if [ "${LOOP}" = '' -o ! -e "mnt/cdrom/${LOOP}" ]

   then

   

      bad_msg "Invalid loop location: ${LOOP}"

      bad_msg 'Please export LOOP with a valid location, or reboot and pass a proper loop=...'

      bad_msg 'kernel command line!'

   

      run_shell

   fi

}

run_shell() {

   /bin/ash

}

runUdev() {

   mount -t tmpfs -o size=100k udev /dev

   mkdir /dev/pts

   mkdir /dev/shm

   echo /sbin/udevsend > /proc/sys/kernel/hotplug 

   /sbin/udevstart

   ln -snf /proc/self/fd /dev/fd

   ln -snf /proc/self/fd/0 /dev/stdin

   ln -snf /proc/self/fd/1 /dev/stdout

   ln -snf /proc/self/fd/2 /dev/stderr

   ln -snf /proc/kcore /dev/core

}

test_success() {

   error_string=$1

   error_string="${error_string:-run command}"

   # If last command failed send error message and fall back to a shell   

   if [ "$?" != '0' ]

   then

      splash 'verbose'

      bad_msg 'Failed to $1; failing back to the shell...'

      run_shell

   fi

}

good_msg() {

   msg_string=$1

   msg_string="${msg_string:-...}"

   echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}"

}

bad_msg() {

   msg_string=$1

   msg_string="${msg_string:-...}"

   echo -e "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}"

} 

warn_msg() {

   msg_string=$1

   msg_string="${msg_string:-...}"

   echo -e "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}"

} 

bind_mount_dev() {

   # bind-mount /dev/ so that loop devices can be found

   mount -o bind ${NEW_ROOT}/dev /dev

}

start_dev_mgr() {

   # Check udev is available...

   if [ "${KV_2_6_OR_GREATER}" -a ! "${USE_UDEV_NORMAL}" -eq '0' -a -x /sbin/udev ]

   then

      USE_UDEV_NORMAL=1

   else

      USE_UDEV_NORMAL=0

   fi

   if [ "${USE_UDEV_NORMAL}" -eq '1' ]

   then

      cd /sys

      [ "${DO_slowusb}" ] && sleep 10

      kill_devfsd

      good_msg 'Activating udev'

      runUdev

      [ "${DO_slowusb}" ] && sleep 20

      cd /

   else

      if [ ! -e /dev/.devfsd ]

      then

         good_msg 'Activating devfs'

         mount -t devfs devfs /dev

         devfsd /dev -np

      fi

   fi

}

bootstrapCD() {

   # Locate the cdrom device with our media on it.

   [ -n "${CDROOT_DEV}" ] && DEVICES="$DEVICES ${CDROOT_DEV}" # Device specified on the command line

   DEVICES="$DEVICES /dev/cdroms/*" # CDROM DEVICES

   DEVICES="$DEVICES /dev/ide/cd/*" # CDROM DEVICES

   DEVICES="$DEVICES /dev/sr*" # UML DEVICES

   DEVICES="$DEVICES /dev/sd*" # USB Keychain

   DEVICES="$DEVICES /dev/hd*" # IDE devices

   DEVICES="$DEVICES /dev/ubd* /dev/ubd/*" # UML DEVICES

   DEVICES="$DEVICES /dev/iseries/vcd*" # iSeries Devices

   findcdmount $DEVICES

}

cmdline_hwopts() {

   # Scan CMDLINE for any "doscsi" or "noscsi"-type arguments

   

   local FOUND

   local TMP_HWOPTS

   for x in $HWOPTS

   do

      for y in $CMDLINE

      do

         if [ "${y}" = "do${x}" ]

         then

            MY_HWOPTS="${MY_HWOPTS} $x"

         elif [ "${y}" = "no${x}" ]

         then

            MY_HWOPTS="`echo ${MY_HWOPTS} | sed -e \"s/${x}//g\" -`"

         fi

      done

   done

   

   # Shouldnt need to sort this as the following loop should figure out the

   # duplicates and strip them out

   #MY_HWOPTS=`echo ${MY_HWOPTS}|  sort`

   

   for x in ${MY_HWOPTS}

   do

      FOUND=0

      for y in ${TMP_HWOPTS}

      do

         if [ "${y}" = "${x}" ]

         then 

            FOUND=1

         fi

      done

      if [ ! "${FOUND}" = '1' ]

      then

         TMP_HWOPTS="${TMP_HWOPTS} ${x}"

      fi

   done

   MY_HWOPTS=${TMP_HWOPTS}

}

load_modules() {

   # Load modules listed in MY_HWOPTS if /lib/modules exists

   

   if [ -d '/lib/modules' ]

   then

      good_msg 'Loading modules'

      # Load appropriate kernel modules

      for modules in $MY_HWOPTS

      do

         modules_scan $modules

         eval DO_`echo $modules | sed 's/-//'`=1

      done

   else

      good_msg 'Skipping module load; no modules in the initrd!'

   fi

}

detect_sbp2_devices() {

   # http://www.linux1394.org/sbp2.php

   

   # /proc

   # /proc/scsi/sbp2/0, /proc/scsi/sbp2/1, etc.

   #

   # You may manually add/remove SBP-2 devices via the procfs with:

   # add-single-device <h> <b> <t> <l> or remove-single-device <h> <b> <t> <l>,

   # where:

   #

   # <h> = host (starting at zero for first SCSI adapter)

   # <b> = bus (normally zero)

   # <t> = target (starting at zero for first SBP-2 device)

   # <l> - lun (normally zero) 

   # e.g. To manually add/detect a new SBP-2 device

   # echo "scsi add-single-device 0 0 0 0" > /proc/scsi/scsi

   # e.g. To manually remove a SBP-2 device after it's been unplugged

   # echo "scsi remove-single-device 0 0 0 0" > /proc/scsi/scsi

   # e.g. To check to see which SBP-2/SCSI devices are currently registered

   # cat /proc/scsi/scsi 

   [ -e /proc/scsi/scsi ] && echo 'scsi add-single-device 0 0 0 0' > /proc/scsi/scsi

}

setup_keymap() {

   if [ "${DO_keymap}" ]

   then

      if [ ! -e /dev/vc/0 -a ! -e /dev/tty0 ]

      then

         DEVBIND=1

         mount -o bind ${NEW_ROOT}/dev /dev

      fi

      [ ! -e /dev/tty0 ] && ln -s /dev/tty1 /dev/tty0

      chooseKeymap

      [ "${DEVBIND}" -eq '1' ] && umount /dev

      

      if [ -e /etc/sysconfig/keyboard -a "${CDROOT}" -eq '1' ]

      then

         mkdir -p ${NEW_ROOT}/etc/sysconfig/

         cp /etc/sysconfig/keyboard ${NEW_ROOT}/etc/sysconfig/keyboard

      fi

   fi

}

chooseKeymap() {

   good_msg "Loading keymaps"

   cat /lib/keymaps/keymapList

   read -t 10 -p '<< Load keymap (Enter for default): ' keymap

   if [ -e /lib/keymaps/${keymap}.map ]

   then

      good_msg "Loading the ''${keymap}'' keymap"

      loadkmap < /lib/keymaps/${keymap}.map

      xkeymap=${keymap}

      echo ${keymap} | egrep -e "[0-9]+" >/dev/null 2>&1

      if [ "$?" -eq '0'  ]

      then

         xkeymap=`tail -n 7 /lib/keymaps/keymapList | grep ${keymap} | sed -r "s/.*\s+${keymap}\s+([a-z-]+).*/\1/g" | egrep -v 1`

      fi

      mkdir -p /etc/sysconfig

      echo "XKEYBOARD=${xkeymap}" > /etc/sysconfig/keyboard

   elif [ "$keymap" = '' ]

   then

      echo

      good_msg "Keeping default keymap"

   else

      bad_msg "Sorry, but keymap ''${keymap}'' is invalid!"

      chooseKeymap

   fi

}

startVolumes() {

   #good_msg 'Checking if volumes need to be started...'

   

   if [ "${USE_DMRAID_NORMAL}" -eq '1' ]

   then

      if [ -e '/sbin/dmraid' ]

      then

         good_msg "Activating Device-Mapper RAID(s)"

         if [ '${DMRAID_OPTS}' = '' ]

         then

            /sbin/dmraid -ay

         else

            /sbin/dmraid -ay ${DMRAID_OPTS}

         fi

      fi

   fi

   if [ "${USE_LVM2_NORMAL}" -eq '1' ]

   then

      if [ -e '/bin/vgscan' -a -e '/bin/vgchange' ]

      then

         for dev in ${RAID_DEVICES}

         do

            setup_md_device "${dev}"

         done

         good_msg "Scanning for Volume Groups"

         /bin/vgscan --ignorelockingfailure --mknodes 2>/dev/null

         good_msg "Activating Volume Groups"

         /bin/vgchange -ay --ignorelockingfailure 2>/dev/null

         # Disable EVMS since lvm2 is activated and they dont work together.

         if [ "${USE_EVMS2_NORMAL}" -eq '1' ]

         then

            bad_msg "Disabling EVMS Support because LVM2 started"

            bad_msg "Do not add dolvm2 to the cmdline if this is not what you want"

            bad_msg "LVM2 and EVMS do not work well together"

            USE_EVMS2_NORMAL=0

         fi

      else

         bad_msg "vgscan or vgchange not found: skipping LVM2 volume group activation!"

      fi

   fi

   if [ "${USE_EVMS2_NORMAL}" -eq '1' ]

   then

      if [ -e '/sbin/evms_activate' ]

      then

         good_msg "Activating EVMS"

         evms_activate

      fi

   fi

}

sdelay() {

   # Sleep a specific number of seconds if SDELAY is set otherwise only sleep

   # 1 second

   if [ -n "${SDELAY}" ]

   then

      sleep ${SDELAY}

   else

      sleep 1

   fi

}

quiet_kmsg() {

   # if QUIET is set make the kernel less chatty

   [ -n "$QUIET" ] && echo '0' > /proc/sys/kernel/printk

}

verbose_kmsg() {

   # if QUIET is set make the kernel less chatty

   [ -n "$QUIET" ] && echo '6' > /proc/sys/kernel/printk

}

cdupdate() {

   if [ "${CDROOT}" -eq '1' ]

   then

      if [ -x /${NEW_ROOT}/mnt/cdrom/cdupdate.sh ]

      then

         good_msg "Running cdupdate.sh"

         ${NEW_ROOT}/mnt/cdrom/cdupdate.sh

         if [ "$?" != '0' ]

         then

            splash 'verbose'

            bad_msg "Executing cdupdate.sh failed!"

            run_shell

         fi

      else

         good_msg 'No cdupdate.sh script found, skipping...'

      fi

   fi

}

setup_md_device() {

   local device

   [ -z "$1" ] && device="${REAL_ROOT}" || device="$1"

   [ -z "${device}" ] && return # LiveCD

   if [ `echo ${device}|sed -e 's#\(/dev/md\)[[:digit:]]\+#\1#'` = "/dev/md" ]

   then

      good_msg 'Detected real_root as a md device. Setting up the device node...'

      MD_NUMBER=`echo ${device}|sed -e 's#/dev/md\([[:digit:]]\+\)#\1#'`

      if [ ! -e /dev/md${MD_NUMBER} ]

      then

         mknod /dev/md${MD_NUMBER} b 9 ${MD_NUMBER} >/dev/null 2>&1

         [ "$?" -ne 0 ] && bad_msg "Creation of /dev/md${MD_NUMBER} failed..."

      fi

      mdstart ${MDPART} /dev/md${MD_NUMBER}

   fi

}

rundebugshell() {

   if [ -n "$DEBUG" ]

   then

      good_msg 'Starting debug shell as requested by "debug" option.'

      good_msg 'Type "exit" to continue with normal bootup.'

      [ -x /bin/sh ] && /bin/sh || /bin/ash

   fi

}

setup_unionfs() {

   if [ "${USE_UNIONFS_NORMAL}" -eq '1' ]

   then

      # Directory used for rw changes in union mount filesystem

      UNION=/union

      MEMORY=/memory

      if [ -z "$UID" ]

      then

         CHANGES=$MEMORY/unionfs_changes/default

      else

         CHANGES=$MEMORY/unionfs_changes/$UID

      fi

      mkdir -p ${MEMORY}

      mkdir -p ${UNION}

      good_msg "Loading unionfs module"

      modprobe unionfs > /dev/null 2>&1

      if [ -n "${UNIONFS}" ]

      then

         CHANGESDEV=${UNIONFS}

         good_msg "mounting $CHANGESDEV to $MEMORY for unionfs support"

         mount -t auto $CHANGESDEV $MEMORY

         # mount tmpfs only in the case when changes= boot parameter was

         # empty or we were not able to mount the storage device

         ret=$?

         if [ "${ret}" -ne 0 ]

         then

            bad_msg "mount of $CHANGESDEV failed falling back to ramdisk based unionfs"

            mount -t tmpfs tmpfs $MEMORY

         fi

         if [ "${CDROOT}" -eq '1' -a ! -f ${MEMORY}/livecd.unionfs  ]

         then

            umount $MEMORY

            bad_msg "failed to find livecd.unionfs file on $CHANGESDEV"

            bad_msg "create a livecd.unionfs file on this device if you wish to use it for unionfs"

            bad_msg "falling back to ramdisk based unionfs for safety"

            mount -t tmpfs tmpfs $MEMORY

         fi

      else 

         good_msg "Mounting ramdisk to $MEMORY for unionfs support..."

         mount -t tmpfs tmpfs $MEMORY 

      fi 

      mkdir -p $CHANGES 

      mount -t unionfs -o dirs=$CHANGES=rw unionfs ${UNION}

      ret=$?

      if [ "${ret}" -ne 0 ]

      then 

         die "Can't setup union ${UNION} in  directory!"

      fi

   else

      USE_UNIONFS_NORMAL=0

   fi

}
```

----------

## scriptX

```

haktik livecds # qemu -cdrom gentoo-live.iso

```

QEMU:

 *Quote:*   

> 
> 
> >> Copying read-write image contents to tmpfs
> 
> cp: etc: No such file or directory
> ...

 

```

haktik / # ls /bin | grep sh

bash

bashlogin

rbash

sh

```

I used the `genkernel initrd` method, if that's got anything to do with it...

----------

## marciv

Hi, please can someone help me...

I have now a new error,

my livecd stops at the end of the linuxrc script!

```

mount: /dev/hdb is not a valid block device

LiveCD found in /dev/hdc

NET: Registered protocol family 1

umount: /initrd: device is busy

umount: /initrd: device is busy

```

After : 

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}

EOF 

it hangs without an error...

[Edit]

When i try to start /sbin/init manually i get this message:

```

init: timeout opening/writing control channel /dev/initctl

```

Ha! now my livecd works.

Without the nvidia drivers but it works...

[edit]

How do i get the nvidia drivers to work?

The nvidia-settings program says "The OpenGL extension 'GLX' is not suported by the X server"...blah blah

and glxinfo says: "error while loading shared libraries: libnvidia-tls.so.1: cannot handle TLS data"

I tested the CD on another PC with ati-drivers and it works, but why not the nvidia-driver?

[/edit]

----------

## scriptX

 *scriptX wrote:*   

> 
> 
> ```
> 
> haktik livecds # qemu -cdrom gentoo-live.iso
> ...

 

BBBBBUUUUUUMMMMMMPPPPPPPP kthnxbye

----------

## Sunthief

Hey just wanted to say thanks for all your hard work!!  

Now I have a little bit of a modified project.  I am using the Lived layout to make some routers on 512MB flash Cards.  Everything seems to be working up to a point.  Here's my grub config:

```
default 0 

timeout 5 

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title=Gentoo Linux 

        root (hd0,0)

        kernel /boot/vmlinuz root=/dev/ram0 rw init=/linuxrc 

        initrd /boot/initrd 

```

I had to manually install Grub on the Memory card and it's an IDE card interface so its located at /dev/hda1.

I get the boot screen and initrd seems to work fine but I keep getting this error when it attempts to run the "/linuxrc" init script.  

```

Failed to execute /linixrc. Attempting defaults...

Kernel Panic - not syncing: No init found.  Try passing init= option to kernal.
```

here is my linuxrc file:

```
#!/bin/sh

export PATH=/bin

# Get kernel CMDLINE

mount -t proc none /proc

CMDLINE=`cat /proc/cmdline`

umount /proc

echo "Mounting Image"

mount -t ext2 -r /dev/hda1 /cdrom > /dev/null 2>&1                                                      

echo "Mount root and create read-write directories"

mount -t squashfs -o loop /cdrom/files/source.img /new > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/var > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/etc > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/tmp > /dev/null 2>&1

mount -t tmpfs -o size=32m none /new/root > /dev/null 2>&1

cd /new/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /new/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /new/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

echo "Pivot root and start real init"

cd /new

pivot_root . newroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}

EOF

```

Now if I change the init= option to /bin/sh, I can go into my initrd just fine, I can even go through the steps of the linuxrc file manually and get the sucker to start booting. I can also run the /linuxrc file with the ./linuxrc at the terminal, but it wont start booting.  i suspect it has something to do with the CMDLINE variable not being correct (/bin/sh instead of /linuxrc) My questions are:

-Why can't it execute /linuxrc script, when I can execute it manually?

-How accurate is the error message, is it possible it's executing the linuxrc script and just failing somewhere in there?

-Got any ideas to help out my project?

----------

## marciv

Yes! I get it.

Now i have nvidia and ati drivers, reiser4, skas3 and a UML Slackware on my Live cd

Thx Veezi and Lepaca for the howto's.

----------

## Sunthief

OK well I changed my linuxrc file a bunch and now I finally got it to boot.  It looks like if the linuxrc doesn't run correctly you get that very generic error during booting.  Hope maybe it will help someone else know where to look in the future.

----------

## KingOfSka

i followed the same guide from the wiki, step by step, but when i try to boot the livecd, the cdrom medium is found at /dev/iseries/vcd* , which is not true, so the booting process couldn't continue... any suggestion ?

----------

## jayblanc54

Hy, 

It's gonna be the 6 image that I'm creating (genkernel and squashfs time, it's long) and I'm crazy ; it's not working.

Resume : 

1. Installation Gentoo OK 

2. Chroot OK

3. emerge system and tools OK

4. emerge gnome-light OK

5. configuring system OK

6. configuring kernel OK

7. clean OK

8. bootloader OK

9. final clean and build OK

Testing iso with vmplayer CRASH : 

::Scanning for dm-mirror...dm-mirror loaded

>> Activating udev (green, i guess it's ok)

>> Making tmpfs for /newroot (green)

>> No bootable medium found. Waiting for new devices (yellow)

!! Could not find CD to boot, something else needed !

>> Determining root device (green)

!! The root block device is unspecified or not detected.

Please specify a device to boot, or "shell" for a shell...

I don't understand where I made a mistake. I search the web for explanation, read this thread but without having answear. I'm trying to use unionfs instead of tmpfs but I don't think problem come from here.

my question if anybody could help me : 

1. At what time of boot process this error occures ? (kernel loading, root filesystem switching, ...) As I'm not a geek of booting process, I can't figure out what's happening and where to search...

2. I read the note : Writeable /home directories with genkernel and unionfs in the How to TALK and i don't kow how to create the livecd.unionfs ?? Actually I used mksquashfs with a file named livecd.unionfs but I'm not sure. I read the exemple of Union-fs site and it doesn't seem to work like that but I don't find how to create an image of a directory (is mounting a directory with unionfs and adding branch to it is the way to create the livecd image ?)

3. What is exactly the difference between /dev/loop0 in etc/fstab and the /dev/ram0 in grub config ?

you and your help is really welcome  :Smile: 

----------

## scriptX

 *jayblanc54 wrote:*   

> 
> 
> ::Scanning for dm-mirror...dm-mirror loaded
> 
> >> Activating udev (green, i guess it's ok)
> ...

 

I had this exact problem, it turns out that I didn't compile some options into the kernel (they were modules). I changed a few options so I don't know which ones they were exactly, but I think it was that I didn't compile the ISO9660 filesystem into the kernel (Filesystems -> CD-ROM/DVD Filesystems -> ISO9660 -> "ISO 9660 CDROM file system support"). If that doesn't fix it, go through and look for options that regard a CD/DVD or CD/DVD drive, etc.

EDIT: Oh.... rather old post :p

----------

## JasonB87

Alright I've built my livecd and am testing it out on vmware. Grub launches and loads the initrd and then I run into this error

No filesystem could Mount root, tried: ext3 ext2 squashfs msdos vfat iso9660 ntfs

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)

Here is my linuxrc script:

```
#!/bin/sh

export PATH=/bin

# Get kernel CMDLINE

mount -t proc none /proc

CMDLINE='cat /proc/cmdline'

umount /proc

# Mount option

# mount -t iso9660 -r /dev/hdc /cdrom > /dev/null 2>&1

# Mount CD device

CDROM=""

for x in hda hdb hdc hdd

do

  mount -t iso9660 -r /dev/${x} /cdrom > /dev/null 2>&1

  if [ "$?" = "0" ]

  then

    CDROM="${x}"

    break

  fi

done

# CD not found

if [ "${CDROM}" == "" ]

then

  exec /bin/sh

  exit

fi

# Mount root and create read-write directories

mount -t squashfs -o loop /cdrom/files/livecd.squashfs /newroot > /dev/null 2>&1

mount -t tmpfs -o size=32m none /newroot/var > /dev/null 2>&1

mount -t tmpfs -o size=32m none /newroot/etc > /dev/null 2>&1

mount -t tmpfs -o size=32m none /newroot/tmp > /dev/null 2>&1

mount -t tmpfs -o size=32m none /newroot/root > /dev/null 2>&1

cd /newroot/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /newroot/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /newroot/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

# Pivot root and start real init

cd /newroot

pivot_root . newroot

exec chroot /newroot /bin/sh <<- EOF >dev/console 2>&1

exec /sbin/init ${CMDLINE}

EOF

```

My other question is do i leave /dev/loop0 mount at /mnt/initrd?

Any clues to what i'm doing wrong?

----------

## mbar

Sorry for crossposting  :Smile:  The following is taken from Talk page, I have the same problem:

 *Quote:*   

>  Problems with Symbolic Links
> 
> After "Copying read-write image ...", when, I think, the linuxrc script starts to run, it starts giving me a LOT of errors in the form : "ln: creating symbolic link `/var/lib/init.d/softscripts.new/clock` to `/etc/init.d/clock`: No such file or directory". The same goes to all the files in init.d, such as hostname, domainname, net.lo etc... Does anyone have a clue as to what is the problem? I tried to switch to init=/bin/sh instead of the linuxrc and it still boots like this. I followed the instructions on the site exactly as it is written and I fail to see where the problem is. can anyone please help?
> 
>     * [mapelo] I have the same problem, and all files and directories in tmpfs (etc,var,...) are NOT write access, only read access. 

 

Is there any way to solve it?

www.technoportal.pl/photo/live.jpg

----------

## mbar

ok, I solved it by adding livecd-tools to my livecd source

----------

## rickvernam

followed the how-to as closely as I could.  I get a kernel panic when trying to execute /linuxrc

(fyi: I'm typing this out from qemu...)

```
RAMDISK: ext2 filesystem found at block 0

RAMDISK: Loading 8192KiB [1 disk] into ram disk... done.

input: ImExPS/2 Generic Explorer Mouse as /class/input/input1

VFS: Mounted root (ext2 filesystem).

Freeing unused kernel memory: 112k freed

Failed to execute /linuxrc.  Attempting defaults...

Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
```

linuxrc is copied identically from the OPs how-to...

(all file system references below are while chrooted in...)

```

mutt / # stat /mnt/initrd/linuxrc

  File: `/mnt/initrd/linuxrc'

  Size: 972             Blocks: 2          IO Block: 4096   regular file

Device: 702h/1794d      Inode: 18          Links: 1

Access: (0777/-rwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)

```

If I press 'e' while in grub menu and edit the kernel's init parameter to '/bin/sh' I get the same error as above, but instead of not being able to execute /linuxrc, it says it is unable to execute /bin/sh ... however

```
mutt / # stat /mnt/initrd/bin/sh

  File: `/mnt/initrd/bin/sh'

  Size: 648400          Blocks: 1276       IO Block: 4096   regular file

Device: 702h/1794d      Inode: 19          Links: 1

Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
```

/boot/grub/grub.conf

```

default 0

timeout 25

title=Live CD

 root (cd)

 kernel (cd)/boot/vmlinuz video=vesafb-tng:mtrr,ywrap,1024x768@60 root=/dev/ram0 rw init=/linuxrc cdroot

 initrd (cd)/boot/initrd

```

Kernel Config:

In Drivers/Block devices

```
<*> Loopback device support

<*> Ram disk support

(1)      Default number of RAM disks

(49152) Default RAM disk size (kbytes)

[*]  Inital RAM filesystem and RAM disk (initramfs/initrd) suport
```

In File systems

```
<*> Second extended fs support

<*> ROM file system support
```

In File systems/CD-ROM Filesystems

```
<*> ISO 9660 CDROM file system support

[*]    Microsoft Joliet CDROM extensions

[*]    Transparent decompression extension
```

In File systems/Miscellaneous filesysems (I have tried both with and without the options for memory-constrained systems)

```
<*> SquashFS 3.0 - Squashed file system support

[*]    Additional options for memory-constrained systems

(3)        Number of fragments cached (NEW)

[*]        Use Vmalloc rather than Kmalloc
```

----------

## rickvernam

 *rickvernam wrote:*   

> followed the how-to as closely as I could.  I get a kernel panic when trying to execute /linuxrc
> 
> (fyi: I'm typing this out from qemu...)
> 
> ```
> ...

 

After being stumped for a week, I finally figured it out.

but first, a bit of background.

I had, as instructions said, copied /bin/sh /bin/cat ...etc to the initrd fs.

Also, I did ldd /bin/sh, copied the resulting stuff from lib... and the same for everything in bin.

The idea was to copy ALL of bin and ALL of lib into the initrd.  While I had to omit some of the clearly unneeded things from bin, it all fit in a 7MB initrd.

And most importantly, it works!!

So, clearly the problem was that I was not careful enough when copying the lib stuff specified by ldd.

What a waste of a perfectly good week.  sheesh.

----------

## psychocandy

[quote="veezi"]

```
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size \

4 -boot-info-table -iso-level 4 -hide boot.catalog -o ~/livecd.iso target/

```

OK. So -b is to produce a bootable El Torito CD....

I think its -B for sparc but where do I get the boot image from ???

----------

## bobber205

It would be nice to have a tutorial that explains how to make a livecd from windows xp. All the ones I can find already assume you have at least some kind of linux distro installed or usually gentoo already.

----------

## mrosack

 *rickvernam wrote:*   

> 
> 
> After being stumped for a week, I finally figured it out.
> 
> but first, a bit of background.
> ...

 

I had EXACTLY they same problem you did, but I found a different fix without copying everything into bin/lib.  This might be obvious, but it took me a day to figure it out - if you have a 64 bit system, copy everything into /lib64 and create a symlink /lib pointing to /lib64.  Most of my binaries were linked to the lib64 directory, so it couldn't find them on boot because I just had a /lib directory in my initrd.

----------

## sch

Hi, I try to run Xorg+KDE on my livecd, but i get this error: (no space Ieft on device)

```
x Activating (possibIe) swap [ oX ]

 x Setting up dM-crypt Mappings ... [ oX ]

 x Setting systeM cIocX using the hardware cIocX [LocaI Ti Me] [ oX ]

 x Configuring XerneI paraMeters [ oX ]

 x Updating environMent [ oX ]

 x CIeaning /var/IocX, /var/run [ oX ]

 x Updating inittab .. [ oX ]

 /sbin/rc: Iine 512: echo: write error: Ho space Ieft on device

 x Caching service dependencies ...

 gawX: /Iib/rcscripts/awX/gendepends.awX:537: (FILEHAME=- FHR=158) fataI: print t

 o ''/var/Iib/init.d/treecache.XIYtUF8'' faiIed (no space Ieft on device)

 x FaiIed to cache service dependencies [ !! ]

 x Caching service dependencies ...

 gawX: /Iib/rcscripts/awX/gendepends.awX:537: (FILEHAME=- FHR=158) fataI: print t

 o ''/var/Iib/init.d/treecache.XbPve2u'' faiIed (no space Ieft on device)

 x FaiIed to cache service dependencies [ !! ]

 x Error running '/sbin/depscan.sh'!

 x PIease correct any probIeMs above.

 /sbin/rc: Iine 565: echo: write error: Ho space Ieft on device

 x Caching service dependencies ...

 gawX: /Iib/rcscripts/awX/gendepends.awX:537: (FILEHAME=- FHR=158) fataI: print t

 o ''/var/Iib/init.d/treecache.XiLbXcU'' faiIed (no space Ieft on device)

 x FaiIed to cache service dependencies [ !! ]

x Caching service dependencies ...

 gawX: /Iib/rcscripts/awX/gendepends.awX:537: (FILEHAME=- FHR=158) fataI: print t

 o ''/var/Iib/init.d/treecache.XbPve2u'' faiIed (no space Ieft on device)

 x FaiIed to cache service dependencies [ !! ]

 x Error running '/sbin/depscan.sh'!

 x PIease correct any probIeMs above.

 /sbin/rc: Iine 565: echo: write error: Ho space Ieft on device

 x Caching service dependencies ...

 gawX: /Iib/rcscripts/awX/gendepends.awX:537: (FILEHAME=- FHR=158) fataI: print t

 o ''/var/Iib/init.d/treecache.XiLbXcU'' faiIed (no space Ieft on device)

 x FaiIed to cache service dependencies [ !! ]

 x Error running '/sbin/depscan.sh'!

 x PIease correct any probIeMs above.

 IHIT: Entering runIeveI: 3

 x Caching service dependencies ...

 gawX: /Iib/rcscripts/awX/gendepends.awX:537: (FILEHAME=- FHR=158) fataI: print t

 o ''/var/Iib/init.d/treecache.X5iFaOp'' faiIed (no space Ieft on device)

 x FaiIed to cache service dependencies [ !! ]

 x Error running '/sbin/depscan.sh'!

 x PIease correct any probIeMs above.

 (none) root #

```

I use 

```
rc-update add mkxf86config default
```

and 

```
rc-update add autoconfig default
```

But, when i write hwsetup & mkxf86cinfig, startx works. 

startkde write error: no space Ieft on device

What do i wrong, or what i should do?

Thanks! Sorry, my english isn`t very good..  :Embarassed: 

----------

## Shamus397

Remove mkxf86config from default. Autoconfig will run it automatically.

NOTE TO SELF (for future reference):

Add noresume to the kernel argument list to prevent spurious

```
ls: : No such file or directory
```

messages from showing up during boot.

----------

## bob doe

My turn to bump an old topic.

Seeing as this guide is older than written word itself, I've had to modify it a lot to get it working for me.

Anyways, Im having a problem mounting the CD-ROM drive as part of linuxrc's script:

```
* Executing linuxrc

* Mounting /proc

* Unmounting /proc

* Mounting optical device

mount: /dev/hda is not a valid block device

mount: /dev/hdb is not a valid block device

mount: /dev/hdc is not a valid block device

mount: /dev/hdd is not a valid block device

*** NO optical device found, dropping a shell ***

sh-3.2# _
```

Im really not sure why Im getting these errors.  My kernel (2.6.24-gentoo-r4) is (as far as I know) setup properly with the right items built in, rather than modules.  My linuxrc file looks like this:

```
#!/bin/sh

export PATH=/bin

# Get kernel CMDLINE

echo " * Mounting /proc"

mount -t proc none /proc

CMDLINE=`cat /proc/cmdline`

echo " * Unmounting /proc"

umount /proc

# Mount CD device

echo " * Mounting optical device"

CDROM=""

for x in hda hdb hdc hdd cdrom

do

  mount -t iso9660 -r /dev/${x} /cdrom

  if [ "$?" = "0" ]

  then

    CDROM="${x}"

    break

  fi

done

# CD no found

if [ "${CDROM}" == "" ]

then

  echo " *** NO optical device found, dropping a shell ***"

  exec /bin/sh

  exit

fi

# Mount root and create read-write directories

echo " * Mounting root file system"

mount -t squashfs -o loop /cdrom/files/source.img /new > /dev/null 2>&1

echo " * Mounting /var"

mount -t tmpfs -o size=32m none /new/var > /dev/null 2>&1

echo " * Mounting /etc"

mount -t tmpfs -o size=32m none /new/etc > /dev/null 2>&1

echo " * Mounting /tmp"

mount -t tmpfs -o size=32m none /new/tmp > /dev/null 2>&1

echo " * Mounting /root"

mount -t tmpfs -o size=32m none /new/root > /dev/null 2>&1

echo " * Filling directories"

cd /new/var && tar xpf /cdrom/files/var.tar > /dev/null 2>&1

cd /new/etc && tar xpf /cdrom/files/etc.tar > /dev/null 2>&1

cd /new/root && tar xpf /cdrom/files/root.tar > /dev/null 2>&1

# Pivot root and start real init

echo " * Attempting pivot"

cd /new

pivot_root . newroot

exec chroot . /bin/sh <<- EOF >dev/console 2>&1

echo " * Starting init"

exec /sbin/init ${CMDLINE}

EOF
```

Anyone with advice - feel free to help  :Smile: 

----------

## Jupiter1TX

I also am having a problem with linuxrc

```

mounting squashfs file system

mount:mounting /dev/loop0 on /newroot/mnt/livecd failed:invalid argument

failed to $1; falling back to the shell

```

----------

## bob doe

post your linuxrc and init files (btw, if you use an initramfs you dont need linuxrc afaik)

----------

