Talk:HOWTO build a LiveCD from scratch
From Gentoo Linux Wiki
[edit] Read only filesystem
When I boot the image I get a bunch of errors such as:
mount: none already mounted or /dev/pts busy * Some local filesystems failed to mount ... rm cannot remove directory '/var/lib/init.d/coldplugged': Read-only filesystem rm cannot remove directory '/var/lib/init.d/daemons': Read-only filesystem rm cannot remove directory '/var/lib/init.d/exclusive': Read-only filesystem ...This continues...
- be sure to emerge livecd-tools. (evildick - 12-29-2006)
[edit] No space left on device
I created a 690MB LiveCD followed every step correctly I have 512mb of ram P4 2GHZ how come when its like 4 seconds after saying "Copying read-write image" it shows up with No space left on device, yet I am able to boot Ubuntu and other bigger distros like Sabayon (gentoo basde 2GB DVD) without any problems?
- Have you done the cleanup? A thing 23:01, 26 January 2007 (UTC)
[edit] Less RAM Need
Is it possible to make a 690MB LiveCD built using this guide require LESS than 300MB of Ram?
- What file system etc are you using? my livecd is 535MB and boots with 16mb ram --GieltjE 15:45, 4 September 2007 (UTC)
[edit] Install Script
Is it possible to write a script wich install the live-cd on hdd ?
- Take a look at the USB script. It should be able to be modified to fit your needs.
[edit] Genkernel: From scratch?
If the focus of this article is truly on building a LiveCD "from scratch", I don't think genkernel should be used. Automating the process of building the initrd/initramfs is not in line with the topic of the article.
I realize that a stage-based install is not quite "from scratch" either, but this aspect of system building (bootstrapping, system tools installation, etc) is amply documented elsewhere (e.g., Linux From Scratch). Creating an initramfs is not currently well documented (even over at LFS), although a number of people have managed to figure it out somehow.
So, what do I propose? I think the currently "deprecated" section about creating the initrd should become "non-deprecated" and reinserted into the main article. In it's current position (a "deprecated" section at the bottom of the article), it is not likely to be used/updated as much by visitors to the wiki. Ultimately, since initramfs is supposed to replace initrd, hopefully someone who understands the process (not me, unfortunately, at least at the moment...) will be able to write up how to do it and eventually replace the initrd section with an initramfs one.
Thoughts?
-- Mark
- I agree with Mark on this one, genkernel isn't "from scratch". Perhaps a link could be provided to genkernel for those who really want to use it, but not a section.
- I know genkernel is not completly from scratch, but there still is a very high level of mod-possible and own configs. But the part it is about are the initrd scripts. These are WAY WAY more advanced then the deprecated part (e.g. scsi boot etc). I do not have much time to explain, I need to go and work now. But genkernel is the best solution.
- Ken: I would also have to agree with going back to the initrd instead of genkernel. I have been using the embedded gentoo to make a very small livecd, and I find genkernel to not work very well in that situation. It would be great if someone with knowledge about initrd/initramfs would update the 'deprecated' section with anything to help us tweak that or make it easier.
- Keep the Genkernel portion. It is very helpful. If "From Scratch" is the problem, then move the genkernel version to a new article.
[edit] initrd without genkernel
I don't know a lot about initrd but i can give you some hints how to create a basic initrd by showing how i create mine for some diskless servers. This is NOT an HOWTO but only one see my example and try to understand
- Create a dir like ramfs/bin, copy the busybox bin to that directory and make symlinks from busybox to all the things possible.
My first time i do it with a "for", but exists ways to populate the dir with busybox symlinks using portage.
- you should create the nodes console and null in the dev/
- link etc/mtab to proc/mounts
- create the usual dirs of a /, you should have this: bin dev etc proc sbin sys tmp var
- make your init script(that will named name init and will be in the root of the initrd), you could put your init script all here but i think its smarter that the init inside the initrd only do the basics ( like fetching the other script or in the case of livecd do nothing) and call another script(outside the initrd), because is much easier to edit the other script outside the gzip(in this case your aux script must be in gzip to). this is mine (again for the diskless servers):
#!/bin/sh echo "Executing init" echo "Mounting proc" mount -n -t proc proc /proc 2>/dev/null echo "Remounting / rw" mount -n / -o remount,rw 2>/dev/null HOSTNAME=`cat /proc/sys/kernel/hostname` echo "Hostname: $HOSTNAME" BOOTSERVER=`grep bootserver /proc/net/pnp | cut -d" " -f2` echo "Bootserver: $BOOTSERVER" tftp -g -l linuxrc-aufs.real -r linuxrc-aufs.real $BOOTSERVER chmod 777 ./linuxrc-aufs.real echo "Exec real init" exec ./linuxrc-aufs.real
ps: the use of exec in last line is crucial, if not the process with pid 0 dies and you get a kernel panic
- and then create the linuxrc-aufs.real i will paste here mine for didactic reasons ( you cant learn how to use unionfs without genkernel )
#!/bin/sh #################### #DISK #################### #echo "Mounting syfs" #mount -n -t sysfs syfs /sys #echo "Populating dev" #mdev -s #echo "Mounting real_root" #mkdir /union #mount -n /dev/sda1 /union 2>/dev/null #echo "Unmounting sysfs and proc" #umount /proc /sys #echo "Running init" #exec switch_root /union /sbin/init "$@" #################### #DISKLESS #################### echo "Mounting root NFS" mkdir static mount -n -t nfs 192.168.0.254:/home/node-image static/ -o hard,intr,ro,nolock,posix,rsize=32768,wsize=32768,actimeo=600 2>/dev/null echo "Mount dynamic tmpfs" mkdir dynamic mount -n -t tmpfs tmpfs dynamic/ 2>/dev/null chmod 755 dynamic # esta built in kernel #echo "Loading aufs module" #insmod /static/lib/modules/`uname -r`/kernel/fs/aufs/aufs.ko echo "Mounting root aufs filesystem" mkdir union mount -n -t aufs -o dirs=/dynamic=rw:/static=ro aufsroot /union 2>/dev/null chmod 755 /union echo "Moving mount point of fs" mkdir /union/mnt/static mkdir /union/mnt/dynamic mount -n --move /static /union/mnt/static mount -n --move /dynamic /union/mnt/dynamic #echo "Copying files" #cp -af /union/files/* /union/ echo "Removing files" rm /union/etc/init.d/net.eth0 rm /union/etc/runlevels/default/netmount echo "Unmounting proc" umount /proc echo "Running init" exec switch_root /union /sbin/init "$@"
Finally to make the gzip
cd "$1"; find . | cpio -o -H newc > ../initramfs && cd .. && gzip initramfs
I hope that this helps someone and that someone edits this to get this more like a howto and in a decent english. ps: I'm trying to make a rw liveusb so i will look to the initrd from genkernel, i think you should do the same if you want to use a initrd in this case.
-- Dane
[edit] Copying read-write image contents to tmpfs
I try to build the livecd with genkernel but when it boot, it is bloked on "Copying read-write image contents to tmpfs" Someone has a idea about this problem?
- I had that to with a version of genkernel, it has been fixed in 3.2.6 I believe, but updating to the latest is better with this package.
- LX: Well, I'm working with genkernel 3.3.10 and I do get the above message. I don't even know what it could be evoked by. Anybody got an idea?
- LX 17:58, 8 January 2006 (GMT): A little update on that one: I had the same issue again and again. But I saw that the booting continues after I waited long enough. (Yes, I'm blessed with patience...) The booting seems to go on after that pretty ok.
- LX 08:18, 11 January 2006 (GMT): Ok, the problem seemed to be that I emulated with qemu. Burning a real CD, the "Copying read-write image contents to tmpfs" only takes some 20 seconds. This seems to be ok.
- It takes a very long time to do this stage on my old p2 laptop. I've been trying to figure out why, but I can't seem to mount the initrd to really figure it out. And I've mounted initrds before. This one seems to think it's not ext2
[edit] Invalids script
What about referring to the script built by invalid account? Automated script [1] located here. It seems a lot easier to me... but then mine still isn't working. :)
- That is a nice help if you can not get something right, but for me it did more dammage than good. And if you want to do it by an automated system why not use Catalyst? If you can not do this right manualy you wil probably get stuck after manualy editing or updating your cd by some (stupid) error. (believe me I have had loads of those).
[edit] Cleaning the build before building
What about adding -e usr/src usr/portage etc/* var/* root/* tmp/* to the mksquashfs line so the image isn't any bigger than necessary?
There are several places that are good candidates for numbered lists so it's easier to read. Currently item 1 is followed directly by 2, 3, etc, horizontally. It might be easier to read if the items are left aligned with 2 right under 1, etc.
- That might be a good idea, but I am not so sure about leaving etc/* var/* and root/* out, the first two I do not know if they are neceseary for boot, the third because in the root folder I have placed a few little extras for the users.
I have placed a modified build script here, which copies the entire folder, then strippes out some stuff. This kills portage completly but leaves normal compile support (which might come in handy).
But you might want to switch to genkernel, and use the new script here because this is the one I will update once in a while.
[edit] Init process
How do we set the variable ${CDBOOT} used in the initscripts?
-have the package app-misc/livecd-tools installed and pass the "cdroot" parameter to the kernel on bootup.
[edit] Modules error on boot
This is to get rid of the error message when /etc/init.d/modules script is run.
thanks
/etc/init.d/modules
change:
ebegin "Calculating module dependencies"
/sbin/modules-update &>/dev/null
eend $? "Failed to calculate dependencies"
for:
if [ /etc/modules.d -nt /etc/modules.conf ]
then
ebegin "Calculating module dependencies"
/sbin/modules-update &>/dev/null
eend $? "Failed to calculate dependencies"
else
einfo "Module dependencies are up-to-date"
fi
Doing this, modules-update will only run if it´s really needed because you made changes in the system. Be sure to run modules-update in the chrooted area before you run the build script.
(these and other tweaks can be found at Flying with Gentoo .
- recent baselayout changed this script, any ideas how to apply the fix to the current one?
[edit] Shut Down
Does anyone know how to eject the cd after shutdown?
-the eject command and it's dependencies can be added to the initrd package initially made
-then, at the end of the /sbin/rc file in the shutdown section call that command
(The tricky part is to have all of the filesystems unmounted by this point)
- The better solution is to switch to genkernel, this automaticly solves all the shutdown problems. But then I do not know how to edit the initrd it makes, to eject it @halt. I can not simply ungzip and mount this image like the old one.
- To edit the genkernel init script go to /usr/share/genkernel/generic and edit linuxrc. Just rebuild the initrd after that.
- How should it be done? I managed to get `eject` into the initrd, but how can i unmount the cd in the shutdown scripts???
- All I do is the following (giving the possibility to manually eject the cd, ie, unlock the eject button, then unmount everything):
cdctl -oA /mnt/cdrom && umount -al
[edit] Chmods
I notice that all the files/folders in / get the 777 chmod, this permits some programs to work correctly, anyone know how to solve this? (i guess this happens when making the squashfs).
- Again switching to genkernel solves the problem, I do not know how to solve it with the old version.
[edit] Last Login:
The cd sometimes displays the "Last login: somedate sometime", where do I clear this? it is kind of annoying.
- Remove the /usr/bin/lastlog and the /var/log contents that should solve it
[edit] Unable to identify cd format
Has anyone figured this dumb error out? It is because the initrd script try's to mount the hda hdb hdc and hdd and there are no iso9660 formats on those so it gives an error. is the > /dev/null 2>&1 not good enough?
- Again this is because of the old initrd...
[edit] /new and /newroot?
'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).
[edit] /usr/portage
Any reason, you bind-mount /usr/portage/distfiles and not all of /usr/portage? That way, one could do without the portage snapshot.
- That is to not mess up your system.
Bind-mounting /usr/portage seems not to mess anything up. AFAIK, the entirety of /usr/portage is a mirror of the portage tree on the gentoo servers anyhow, so no system-specific derivations should ever occur in there.
The only issue i could see would be if one were using the livecd-chroot and --syncing or emerging outside of the chroot at the same time? Or, if one would find it necessary to break the portage tree to build the livecd (but portage overlay within the chroot should avoid this as well, right?)
- Yes, I have been experimenting with it and you appear correct, I shall edit the main howto.
I've been using this at home for building my CD for weeks with no problems: veracity that it works.
[edit] Writeable /home directories with genkernel and unionfs
How do I get a writeable /home directory? I want some X applications to work and they seem to need write permissions in /home. Illissius posted his scripts here. He doesn't seem to use genkernel (at least this guide doesn't refer to linuxrc anymore). Unionfs support is included in genkernel>=3.2.0. Does it work from fstab?
- I use genkernel and unionfs together, and so I have the unionfs overlay over the whole livecd (what I want). Use genkernel with "--unionfs-dev"; change the build script to produce a "livecd.unionfs" instead of "livecd.squashfs" and give grub (in menu.list) the "unionfs" option
[edit] Cleaner, Smaller, Better?
Is there a way to compress, or decrease the size of the resulting cd even more? Is there a way to remove GCC from the target and still make the source usable for future additions/upgrades?
- yes edit the before-build script to unmerge gcc to, this only unmerges gcc from the copy'd version of the livecd and the source folder remains intact. But I do not know any other things to make the cd smaller without cripling it. My cd is 299mb, with TONS of admin tools and all possible support.
- (evildick 2005-08-10) I was able to get the build down to 111 meg without much trouble. I stripped some modules out of the kernel. I could probably get it smaller but we need Perl for diagnostics (uncompressed it takes up 30 meg). There are only a handful of tools installed.
- (evildick 2005-09-06) Finally able to get the size down to 103, considerable size decrease from changing make.conf, CFLAG from '-03' to '-Os'. This changed the size from 138 meg to 103 meg.
- If you use genkernel, it leaves the unassembled pieces of the initramfs in /usr/share/genkernel/pkg/(ARCH)/cpio. You can delete that directory in the target. This saved me over 2.5 megs compressed on the ISO. You can probably delete the entire /usr/share/genkernel folder, but I have not tested this.
[edit] USB
- (evildick 2005-08-06) Are there small modifications to be able to boot off a USB flash drive?
- I am working on that, but it is not my priority.
- (evildick 2005-08-10) I added a USB build script to to the main article. (actually moved it from here, no sense keeping duplicates)
- (evildick 2005-08-23) Still having issues. Also see this post http://forums.gentoo.org/viewtopic-t-369277-highlight-.html .
[edit] Shouldn't the script be . . .?
- (evildick 2005-08-06) In one of your scripts you have:
| File: Building the LiveCD build located in ~/livecd/ |
#Cut
cd ${TARGET}/files
mount -o bind /sys ${SOURCE}/sys
mount -o bind /dev ${SOURCE}/dev
mount -o bind /proc ${SOURCE}/proc
mount -o bind /usr/portage/distfiles ${SOURCE}/usr/portage/distfiles
echo "Execute ./before-build now, but first MAKE SURE it has correctly chrooted to the livecd ${SOURCE} folder"
chroot ${SOURCE}/ /bin/bash --login
umount ${SOURCE}/sys
umount ${SOURCE}/dev
umount ${SOURCE}/proc
umount ${SOURCE}/usr/portage/distfiles
env-update
source /etc/profile
#Cut
|
Considering your chrooting into the target to clean up and remove unneeded bulk and you want to isolate the source. . . Shouldn't the above portion of the script it be more like this:
| File: Building the LiveCD build located in ~/livecd/ |
##Cut
cd ${TARGET}/files
mount -o bind /sys ${TARGET}/files/source/sys
mount -o bind /dev ${TARGET}/files/source/dev
mount -o bind /proc ${TARGET}/files/source/proc
mount -o bind /usr/portage/distfiles ${TARGET}/files/source/usr/portage/distfiles
echo "Execute ./before-build now, but first MAKE SURE it has correctly chrooted to the livecd ${TARGET} directory."
chroot ${TARGET}/files/source /bin/bash --login
umount ${TARGET}/files/source/sys
umount ${TARGET}/files/source/dev
umount ${TARGET}/files/source/proc
umount ${TARGET}/files/source/usr/portage/distfiles
env-update
source /etc/profile
##Cut
|
(This is great instructions btw, I would not have been successful without tyour help.)
- Thnx for the tip, I just noticed after you posted this. Somebody updated my build script to make it a bit more flexible which in theory was good. But he messed up the source/target bit. I have corrected this now, please UPDATE to the new script NOW to stop you deleting all the .keep files in your source install (which will give some problems with updating, because all your config files will be overwritten without question e.g. etc-update).
Note that the grub config file had real_root=/dev/loop/0, but there should be no second /; it's just /dev/loop0. Corrected on the main page.
[edit] The cd gives weird label and does not boot
If the cd gives a label like this and shows only weird tekst when booting. Remove the "-iso-level 4 -hide boot.catalog" from the build script. Some burning programs do not appear compatable with ISO9660 version 2.
[edit] Adding docache?
Would it be possible to somehow add the 'docache' functionality to the livecd? I would like to be able to unmount/eject the cd in order to insert other media (when restoring a backup, etc)
- I do not know, try it I should say. But please notice this requires the entire cd to be in the ram.
- Yes it works, I tested it with the genkernel. I combined it with eject so I can mount other CDs.
[edit] Problem with modules-update
When running modules-update I get an error but no idea how to fix it
modules-update * Updating /etc/modprobe.conf ... * Warning: could not generate /etc/modprobe.conf!
Any Ideas?
This has to do with running a different kernel in the chroot environment than the one on the host system, if you make sure both are the same kernel, you will no longer get this error. -bender183
LX 18:34, 30 December 2005 (GMT): I also had this. Normally, you could call
modules-update --assume-kernel <your kernel>
But this feature is broken in "generate-modprobe.conf" at the moment (http://bugs.gentoo.org/show_bug.cgi?id=117212)
I helped myself out with the following hack:
cd /lib/modules/ ln -s <target_kernel> <running_kernel>
I also found out that "generate-modprobe.conf" called by modules-update has problems if it encounters an "option" line in a file in /etc/modules.d/ .
The only ( ? ) solution I have right now is to comment out the line that cause the problem.
As example in my case :
| File: /etc/modules.d/nvidia |
#Comment any lines like : option nvidia NVreg_Mobile=2 |
This fixed the bug in my case, but I can not use any options now. -H-E
--
I got around this problem by temporarily copying the livecd source kernel, initramfs, and modules to my base system, adding a lilo entry for the source kernel, and booting into the "livecd" kernel (generated a few errors when booting, for example, nvidia and alsa drivers didn't load properly, but this didn't seem to be an issue). Once booted into the "livecd" kernel, chroot into the source directory and run the depscan and modules-update. In order to avoid having to do this every time, I did this from the source directory rather than the target directory. After modules-update has been successfully run, reboot back into your "normal" system, delete the temporary "livecd" kernel, initramfs, and modules from your "normal" system, and remove the entry from lilo.
---
- Make sure you run the exact same kernel version on your base system as the livecd env, this helped me.
[edit] Mounting Squashfs failed: No such device
I also get the same modules-update error as mentioned above.
Also
At boot time I get:
Mounting Squashfs mount: Mounting /newroot/mnt/cdrom/livecd.squash on /newroot/mnt/livecd failed: No such device
Then the kernel panics. I have built-in Squashfs and loopback support in my kernel (genkernel actually). I followed the directions and used the provided scripts.
Any ideas on what I could be missing?
- Hi, I've the same problem, any ideas?
Many thanks, rosmild
- Solved!! I've compiled squashfs as module. Sorry. rosmild
Compiling squashfs as a module did not work for me, but using the .config file as the base configuration file worked.
- Hi, I tried compiling squashfs as a module and it didn´t work. I don´t understand what
using the .config file as the base configuration file means. Anyone? ran Sorry, solved it by changing a mistake in the menu.lst file from /dev/loop0 as the root device to /dev/ram0 ..
- Can anyone please explain it properly. Wat i need to do.. i have a livecd and i want to change it. i copied the whole thing on my hardisk..
than i get the above error.. if i just make the image without any changes.. please help
- I had the same problem but installing a earlier version of squashfs solved it
emerge --unmerge sys-fs/squashfs-tools emerge =sys-fs/squashfs-tools-2.2_p2
- I get this error..
Invalid Argument. when it tries to mount.. please help.. my livecd i extracted the squash image and copied to my hdb3 ext3 partiton. empty hdd.. put itin a folder called live/livecd made squash image by using mksquashfs /media/hdb3/live/livecd/ livecd.squashfs please help
- I believe that kernel 2.6.15-r1 will only work with squashfs-tools-2.2_p2, not squashfs-tools-3, so emerge the appropriate version before making the squashfs
- Does anyone know how to get the bloody thing running? kernel gentoo-sources-2.6.17-r8 on both, squashfs-tools-3.1_p2
CD can't mount the squashfs. The main system mounts it without a word of complain.
[edit] Captive-NTFS
Has anyone gotten captive-ntfs working on the livecd?
- Yeah, you need to do a modprobe fuse and chmod 755 / (searched long and hard for this nasty problem)
[edit] 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.
[edit] Compliments
- Whomever added the qemu testing section, nice work! I love qemu!
[edit] Hang-up at "Copying read-write image..."
In this article you note that Qemu may product a hang-up at the "Copying read-write image contents to tmpfs" part. What if this happens when you actually burn the ISO and put it in the system?
- Count Zero (29/08/06): Well I have this problem right now using genkernel 3.3.11d, and kernel linux-2.6.16-gentoo-r7, this problem came after update, so I don't know if it is the genkernel or the kernel itself that is the problem.
[edit] Synching vs. Purging and Recreating target. And livecd-tools?
Are there any disadvantages to continually synchronizing the target build directory with rsync and doing the actual ISO building in another directory? I've been doing that and it seems to be working just as well, except much faster.
Also, I ended up having to emerge livecd-tools when I set up my LiveCD, otherwise it was nigh unusable. Is this normal? I don't recall seeing it in the article anywhere. -Spectere 00:25, 20 August 2006 (UTC)
I have looked into this and it seems to provide a good working copy. I have rewritten the build script to allow this. The only drawback is that on the first time copy you could better take a vacation, but after that it is way faster.
[edit] missing device nodes
When booting I get the following error:
>> Determining looptype ... !! Invalid loop location: /livecd.squashfs !! Please export LOOP with a valid location, or reboot and pass a proper loop=... !! kernel command line
29.02.2008 - for me it was this bug -> http://bugs.gentoo.org/show_bug.cgi?id=208477 emerging keyworded genkernel 3.4.10_pre3 and rebuilding initrd, the cd boots fine
Playing around I edited the linuxrc script and figured out (by doing an busybox ls /dev/hd?) that those nodes are missing, so I guess the cd never gets mounted. (BTW: I didn't bootstrap the system, is that vital?)
/EDIT: it seems udev is not working at the moment, so busybox mdev is doing its work. mdev uses /sys information for dev-node creation. However, my /sys dir only contains ram and loop devices.
- Solved, had to tweak my kernel config a little more. However, I don't exactly which option solved it, I'll post when I've found out.
- I get the same error. I also tried some tweaks on my kernel, but nothing solved it. Can someone post a working kernel-config for me? Maybe for gentoo-sources-2.6.17-r8 or similar?
Comment from Maurice Volaski It's not related to the kernel config. It occurs because the init script is actually checking for the presence of a file called "livecd" in the root of the CD. That is the location where boot and livecd.squashfs are located. Create an empty file of that name in the ~/livecd/target directory. End comment
- I'm also having that error, however somehow it only appears in qemu/vmware but not when I test the livecd on a "real" system. Still no idea what could have caused this to happen? --Jens 16:16, 26 September 2006 (UTC)
- True, you will have to put a file called 'livecd' into livecd/target/, but for me there was an additional kernel problem, solved by compiling in all drivers under "PCI IDE chipset support":
Device Drivers --->
ATA/ATAPI/MFM/RLL support --->
[*] PCI IDE chipset support
...
<*> AMD and nVidia IDE support
<*> ATI IXP chipset IDE support
<*> CMD64{3|6|8|9} chipset support
<*> Compaq Triflex IDE support
...
[edit] livecd-tools and LOOP problem
Greg: Before you pull your hair out like I did when using the new portage.
1. Invalid LOOP device: use the kernel config off the 2006.1 cd
2. You will find that the root will not remount as readwrite. If you dig you will find that the /sbin/rc has changed a bit and looks for livecd-functions.sh. This is found in the livecd-tools and resolves the remount problem.
- Where can I get this kernel config?
Just boot the 2006.1 minimal cd and Read The Friendly Manual that is displayed just before you got the shell.
- Point 2 verified for new baselayout, adding to the main HowTo
[edit] Shutdown cleanly
Hello,
I updated my livecd recently and got a new problem. When I shutdown or reboot the system, I get this:
- Umounting loopback filesystems ...
- Failed to unmount filesystems [!!]
INIT: no more processes left in this runlevel
Then it hangs there. Any ideas?
- Same problem over here. I've tried it on few physical machines and qemu, but it still refuses to shutdown/reboot on its own. -- Jan Stępień
Same problem, -- 18/03/2007 gouZ
(27/04/2007) Just about to say it :) In my case it looks, like LiveCD wasn't even chacking what services have been started during bootup i default runlevel...
(13/06/2007) I found the couse - at bugzilla. It was an error in livecd-tools (in /etc/init.d/halt.sh). After emerging livecd-tools to the 1.0.35-r1 system started to shutdown and reboot corectly.
[edit] Boot Splash
I managed to get a bootable LiveCD created today. That was a nice milestone. To add a final touch I wanted to get a pretty boot splash screen so I created an initrd with genkernel using the "--gensplash=..." argument. I followed the directions about changing the kernel arguments and managed to get a splash screen when I booted the new image. Sadly the root directory didn't get setup like it did without the splash screen becasue I was getting read-only file system errors for all of the services. Does anyone know why the "splash" boot argument screws everything up?
- Turned out I needed the livecd-tools emerged.
[edit] Making / rw with unionfs(or something better?)
I'm trying to make a livecd with working portage, so far it works fine (compiling things and so on works) but merging doesn't because / is only ro. How can I make a LiveCD which is completely writeable?
[edit] Introduction
Well, first I'm sorry for my bad english. I suppose that my livecd is in my usb stick and non on a cdrom.
Into the chroot eviroment you have to patch the kernel with aufs support
jigen ~ # cvs -d:pserver:anonymous@aufs.cvs.sourceforge.net:/cvsroot/aufs login (CVS password is empty) jigen ~ # cvs -z3 -d:pserver:anonymous@aufs.cvs.sourceforge.net:/cvsroot/aufs co aufs jigen ~ # cd aufs jigen ~ # make -f local.mk kconfig jigen ~ # cp -a fs/aufs /usr/src/linux/fs/ jigen ~ # cp -a include/linux /usr/src/linux/include/ jigen ~ # echo "obj-\$(CONFIG_AUFS) += aufs/" >> /usr/src/linux/fs/Makefile jigen ~ # nano /usr/src/linux/fs/Kconfig (add 'source "fs/aufs/Kconfig"' in the file)
[edit] Customize init script
You can find my customized init script unionfs-linuxrc
do_realroot() {
verbose "Mounting $REALROOT on $NEWROOT"
# assume that my disk partition hava a label "root"
# this call set REALROOT=/dev/hd-labbeled and LABEL=<your root param>
do_findfs
[ ! -d $TMP ] && mkdir $TMP
mount -t tmpfs tmpfs $TMP
[ ! -d $DISK ] && mkdir $DISK
mount $REALROOT $DISK
# I suppose that the squashfs image is in a hidden folder of my compact flash
# My filesystem is configured:
# /dev/sda1 = ext2 16M
# - boot
# - grub (grub stage and file)
# - vmlinuz
# - initramfs
# /dev/sda2 = xfs 1G (label=disk)
# - .overlay (empty dir used by aufs like a rw branch)
# - .disk
# - disk.squashfs (readonly disk image to be mounted)
[ ! -d $SQUASH ] && mkdir $SQUASH
mount -o loop,ro $DISK/.$LABEL/$LABEL.squashfs $SQUASH
[ ! -d $NEWROOT ] && mkdir $NEWROOT
mount -t aufs -o dirs=$DISK/.overlay=rw:$SQUASH=ro aufs $NEWROOT
return $?
}
do_switch() {
verbose "Switching / to $NEWROOT"
# Better make sure these exist before switching
[ ! -c "$NEWROOT/dev/console" ] && mknod "$NEWROOT/dev/console" c 5 1
[ ! -c "$NEWROOT/dev/null" ] && mknod "$NEWROOT/dev/null" c 1 3
echo > /proc/sys/kernel/hotplug
umount /dev || umount -l /dev
umount /sys || umount -l /sys
umount /proc || umount -l /proc
# This is important !!
mount -o move $TMP $NEWROOT/newroot
exec switch_root $NEWROOT $INIT
}
[edit] build your kernel with genkernel
cd /usr/src/linux genkernel all --no-bootsplash --no-clean --linuxrc=/path/to/your/init --menuconfig
Configure the kernel
File systems --->
...
...
...
<*> Another unionfs
--- These option are generated for ...
[*] Use simplified (fake) nameidata
Maximum number of branches (127) --->
[ ] Aufs as an readonly branch of another aufs
[ ] Delegate the internal branch access the kernel thread
[ ] Make squashfs branch RR (real readonly) by default
[ ] Special handling for FUSE-based filesystem
[*] Debug aufs
[ ] Compatibility with Unionfs (obsolete)
...
...
...
[edit] Change your /etc/fstab
replace this line /dev/loop0 / squashfs ro,defaults 0 0 with aufs / aufs defaults 0 0 # This free you compiled temporany files on reboot tmpfs /var/tmp tmpfs defaults 0 0
[edit] grub.conf / menu.lst
timeout 10 default 0 fallback 1 title=Gentoo kernel /boot/vmlinuz root=phox vga=791 initrd /boot/initramfs title Gentoo NO-FB (NB) kernel /boot/vmlinuz root=phox initrd /boot/initramfs
I tried this but it has no idea what phox is. I followed the directions to the letter.
[edit] Problem Booting
After creating the cd and booting it it stops and says /dev/loop0 is not valid boot device and fail to boot Any had this error or know how to fix this?(03/09/2007)(dd/mm/yy)
Comment Are you sure you have compiled in the "Loopback device support" in kernel? End comment
[edit] How to disable automated login?
What is the correct way to disable the automated login? I'm trying to build a firewall/security LiveCD, with the ease of maintenance that Gentoo provides, but I want to prevent root (or anyone) from automatically logging in.
To prevent root or any other user from being automatically logged in, edit the /sbin/rc file as described in the Auto Login section, but DON'T edit the /etc/inittab. This has been added to the Auto Login section.
