building a supermin appliance with febootstrap...
Rich, So, I tried to build the simple supermin app. from your blog. I can confirm that I did get to the shell when I invoked qemu-kvm. I used the standard qemu-kvm cmdline (but appended a serial console). This boots fine. ######################################################## [root@moon appliance-test]# qemu-kvm -kernel kernel -append "console=tty0 console=ttyS0,115200" -initrd initrd -hda root -nographic . . . insmod: error inserting 'ideapad-laptop.ko': -1 Unknown symbol in module insmod: wait: File exists febootstrap: insmod sym53c8xx.ko febootstrap: picked /sys/block/sda/dev as root device febootstrap: creating /dev/root as block special 8:0 febootstrap: mounting new root on /root febootstrap: chroot /proc/uptime: No such file or directory Welcome to my world bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell bash-4.2# [ 1.103034] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input2 [ 1.334183] Refined TSC clocksource calibration: 1995.006 MHz. bash-4.2# ######################################################## But when I try to 'exit', I notice a kernel panic. And it just seems to hung there, no more budging. I had to do 'ctl a + x' to get out of the serial console. Is this expected? ######################################################## bash-4.2# exit exit [ 153.520309] Kernel panic - not syncing: Attempted to kill init! [ 153.523584] Pid: 1, comm: init Not tainted 2.6.40-4.fc15.x86_64 #1 [ 153.526990] Call Trace: [ 153.529039] [<ffffffff814ae2cd>] panic+0x91/0x19c [ 153.531914] [<ffffffff810580a2>] do_exit+0xb9/0x77b [ 153.534798] [<ffffffff810589e9>] do_group_exit+0x7a/0xa2 [ 153.537835] [<ffffffff81058a28>] sys_exit_group+0x17/0x17 [ 153.540924] [<ffffffff814bd7c2>] system_call_fastpath+0x16/0x1b ######################################################## -- /kashyap
* Kashyap Chamarthy:
So, I tried to build the simple supermin app. from your blog. I can confirm that I did get to the shell when I invoked qemu-kvm.
I used the standard qemu-kvm cmdline (but appended a serial console). This boots fine. [...]
But when I try to 'exit', I notice a kernel panic. And it just seems to hung there, no more budging. I had to do 'ctl a + x' to get out of the serial console. Is this expected?
This is normal behavior. The demo system as described by Rich has no regular init process. The shell has been started via exec, so it is PID 1. PID 1 has a special role on Unix and Linux, the first processs that is started by the kernel is normally /sbin/init which is responsible for bringing up the rest of the system. Something must have gone horribly wrong with the system if this process exits. And this is what the kernel panic message you posted is all about:
bash-4.2# exit exit [ 153.520309] Kernel panic - not syncing: Attempted to kill init! [ 153.523584] Pid: 1, comm: init Not tainted 2.6.40-4.fc15.x86_64 #1
-Hilko
On Wed, Aug 17, 2011 at 11:34:54AM +0530, Kashyap Chamarthy wrote:
But when I try to 'exit', I notice a kernel panic. And it just seems to hung there, no more budging. I had to do 'ctl a + x' to get out of the serial console. Is this expected?
As Hilko says, this is normal behaviour when the init process dies: http://lxr.linux.no/#linux+v3.0.2/kernel/exit.c#L728 In libguestfs, our "init process" is the guestfsd daemon. We configure the kernel to reboot instead of panicking by adding the kernel command line option "panic=1". If you use a real init or systemd then this won't be an issue because init will issue a reboot system call instead of exiting. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
On Wed, Aug 17, 2011 at 10:24:10AM +0100, Richard W.M. Jones wrote:
In libguestfs, our "init process" is the guestfsd daemon. We configure the kernel to reboot instead of panicking by adding the kernel command line option "panic=1".
I should say, we configure the kernel to reboot (panic=1), and qemu to shutdown on reboot (qemu-kvm -no-reboot). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
On 08/17/2011 03:00 PM, Richard W.M. Jones wrote:
On Wed, Aug 17, 2011 at 10:24:10AM +0100, Richard W.M. Jones wrote:
In libguestfs, our "init process" is the guestfsd daemon. We configure the kernel to reboot instead of panicking by adding the kernel command line option "panic=1".
I should say, we configure the kernel to reboot (panic=1), and qemu to shutdown on reboot (qemu-kvm -no-reboot).
Rich.
Ok, so , If I have to build appliance which has a bunch of %post, %preun, %postun, %pre operations in it's RPM SPEC file, I need to pull all of those into a custom init script(like the one for libguestfs[1]), so that the guest kernel can detect this(run it as PID 1) and sanely bring up the rest of the system ? And then I need to invoke 'febootstrap-supermin-helper' like below to build the appliance. # febootstrap-supermin-helper -f ext2 supermin.d x86_64 kernel initrd appliance. Where appliance is the file system. As of now, other file systems like ext3/ext4(maybe btrfs in future) are not yet available ? Question: After I build and boot the appliance, how about networking inside it? Any pointers to that? Thank Rich and Hilko. I need to wrap my head a little bit more around this and try a few more things. Ref: [1] http://git.annexia.org/?p=libguestfs.git;a=blob;f=appliance/init;hb=HEAD -- /kashyap
On Wed, Aug 17, 2011 at 04:50:17PM +0530, Kashyap Chamarthy wrote:
Ok, so , If I have to build appliance which has a bunch of %post, %preun, %postun, %pre operations in it's RPM SPEC file, I need to pull all of those into a custom init script(like the one for libguestfs[1]), so that the guest kernel can detect this(run it as PID 1) and sanely bring up the rest of the system ?
Yes, you're gonna need an /init file anyway. Another unfortunate thing about Fedora is that the base RPMs like "filesystem-*.rpm" don't contain all the base files. If you look at the source for mock, anaconda and so on, you'll see some code to create the base system. For example: https://fedorahosted.org/mock/browser/py/mock/backend.py#L385 Naturally this duplicated code is slightly different in each program where it appears. So your /init file should probably create some basic filesystem and device nodes as in the mock example above, then include any bits from the %pre/%post scripts that look important, and then jump to whichever init system you want (eg. /sbin/init which in newer Fedora is a link to systemd).
And then I need to invoke 'febootstrap-supermin-helper' like below to build the appliance.
# febootstrap-supermin-helper -f ext2 supermin.d x86_64 kernel initrd appliance.
Where appliance is the file system. As of now, other file systems like ext3/ext4(maybe btrfs in future) are not yet available ?
It would be very simple to modify febootstrap to support ext3 and/or ext4. (btrfs would definitely NOT be a simple change). In libguestfs the appliance is added read-only with a disposable overlay on top. Thus journals (a data integrity feature) don't make any sense for us. http://git.annexia.org/?p=libguestfs.git;a=blob;f=src/launch.c;h=e58add54362...
Question: After I build and boot the appliance, how about networking inside it? Any pointers to that?
You just need to pass the right parameters to qemu. Assuming you are using a real init system, the network will be brought up automatically inside the guest when it detects the virtual hardware. http://git.annexia.org/?p=libguestfs.git;a=blob;f=src/launch.c;h=e58add54362... Note also that you can overlay any extra files (eg. config files, programs) that you need in the appliance by dropping cpio files into the supermin.d directory. Again, take a look at how libguestfs does it: http://git.annexia.org/?p=libguestfs.git;a=tree;f=appliance;hb=HEAD Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
On 08/17/2011 05:32 PM, Richard W.M. Jones wrote:
On Wed, Aug 17, 2011 at 04:50:17PM +0530, Kashyap Chamarthy wrote:
Ok, so , If I have to build appliance which has a bunch of %post, %preun, %postun, %pre operations in it's RPM SPEC file, I need to pull all of those into a custom init script(like the one for libguestfs[1]), so that the guest kernel can detect this(run it as PID 1) and sanely bring up the rest of the system ?
Yes, you're gonna need an /init file anyway.
Another unfortunate thing about Fedora is that the base RPMs like "filesystem-*.rpm" don't contain all the base files. If you look at the source for mock, anaconda and so on, you'll see some code to create the base system. For example:
https://fedorahosted.org/mock/browser/py/mock/backend.py#L385
Naturally this duplicated code is slightly different in each program where it appears.
So your /init file should probably create some basic filesystem and device nodes as in the mock example above, then include any bits from the %pre/%post scripts that look important, and then jump to whichever init system you want (eg. /sbin/init which in newer Fedora is a link to systemd).
Thanks Rich, for this great detail. I haven't played much with mock, apart from building a couple of packages(I understand that everything is done in 'chroot'). I need to take a closer look at mock source and play around more a little bit.
And then I need to invoke 'febootstrap-supermin-helper' like below to build the appliance.
# febootstrap-supermin-helper -f ext2 supermin.d x86_64 kernel initrd appliance.
Where appliance is the file system. As of now, other file systems like ext3/ext4(maybe btrfs in future) are not yet available ?
It would be very simple to modify febootstrap to support ext3 and/or ext4. (btrfs would definitely NOT be a simple change). In libguestfs the appliance is added read-only with a disposable overlay on top. Thus journals (a data integrity feature) don't make any sense for us.
If it's trivial to add newest ext* fs, that's nice. For projects we'd like to build appliances, there will be decent I/O ( maybe the newest available journaling FS may help..)
http://git.annexia.org/?p=libguestfs.git;a=blob;f=src/launch.c;h=e58add54362...
Question: After I build and boot the appliance, how about networking inside it? Any pointers to that?
You just need to pass the right parameters to qemu. Assuming you are using a real init system, the network will be brought up automatically inside the guest when it detects the virtual hardware.
Ah, that makes sense, so using all the regular networking parameters to qemu would do the trick
http://git.annexia.org/?p=libguestfs.git;a=blob;f=src/launch.c;h=e58add54362... Note also that you can overlay any extra files (eg. config files, programs) that you need in the appliance by dropping cpio files into the supermin.d directory. Again, take a look at how libguestfs does it:
http://git.annexia.org/?p=libguestfs.git;a=tree;f=appliance;hb=HEAD
Thanks again for all the detail.
Rich.
-- /kashyap
On Wed, Aug 17, 2011 at 07:13:19PM +0530, Kashyap Chamarthy wrote:
On 08/17/2011 05:32 PM, Richard W.M. Jones wrote:
It would be very simple to modify febootstrap to support ext3 and/or ext4. (btrfs would definitely NOT be a simple change). In libguestfs the appliance is added read-only with a disposable overlay on top. Thus journals (a data integrity feature) don't make any sense for us.
If it's trivial to add newest ext* fs, that's nice. For projects we'd like to build appliances, there will be decent I/O ( maybe the newest available journaling FS may help..)
I'm a bit busy now, but patches welcome. Basically it involves changing the command line argument processing a bit, and passing the '-t {ext2,ext3,ext4}' flag through to mke2fs. And testing that it still works. See the febootstrap.git helper/ subdirectory, particularly 'main.c' and 'ext2.c'. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
participants (3)
-
Hilko Bengen -
Kashyap Chamarthy -
Richard W.M. Jones