[PATCH 1/3] febootstrap/helper/init: make sure /proc is mounted into chroot.
--- helper/init.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/helper/init.c b/helper/init.c index 0ca3135..2b5dacf 100644 --- a/helper/init.c +++ b/helper/init.c @@ -163,8 +163,10 @@ main () chdir ("/"); - /* Run /init from ext2 filesystem. */ + mount_proc (); print_uptime (); + + /* Run /init from ext2 filesystem. */ execl ("/init", "init", NULL); perror ("execl: /init"); -- 1.7.5.3
--- helper/init.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/helper/init.c b/helper/init.c index 2b5dacf..50ed19e 100644 --- a/helper/init.c +++ b/helper/init.c @@ -40,6 +40,23 @@ extern long init_module (void *, unsigned long, const char *); +/* translation taken from module-init-tools/insmod.c */ +static const char *moderror(int err) +{ + switch (err) { + case ENOEXEC: + return "Invalid module format"; + case ENOENT: + return "Unknown symbol in module"; + case ESRCH: + return "Module has wrong symbol version"; + case EINVAL: + return "Invalid parameters"; + default: + return strerror(err); + } +} + /* Leave this enabled for now. When we get more confident in the boot * process we can turn this off or make it configurable. */ @@ -212,7 +229,7 @@ insmod (const char *filename) close (fd); if (init_module (buf, st.st_size, "") != 0) { - fprintf (stderr, "insmod: init_module: %s: %m\n", filename); + fprintf (stderr, "insmod: init_module: %s: %s\n", filename, moderror (errno)); /* However ignore the error because this can just happen because * of a missing device. */ -- 1.7.5.3
On Sun, Jun 05, 2011 at 01:02:49AM +0200, Hilko Bengen wrote:
--- helper/init.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/helper/init.c b/helper/init.c index 2b5dacf..50ed19e 100644 --- a/helper/init.c +++ b/helper/init.c @@ -40,6 +40,23 @@
extern long init_module (void *, unsigned long, const char *);
+/* translation taken from module-init-tools/insmod.c */ +static const char *moderror(int err) +{ + switch (err) { + case ENOEXEC: + return "Invalid module format"; + case ENOENT: + return "Unknown symbol in module"; + case ESRCH: + return "Module has wrong symbol version"; + case EINVAL: + return "Invalid parameters"; + default: + return strerror(err); + } +} + /* Leave this enabled for now. When we get more confident in the boot * process we can turn this off or make it configurable. */ @@ -212,7 +229,7 @@ insmod (const char *filename) close (fd);
if (init_module (buf, st.st_size, "") != 0) { - fprintf (stderr, "insmod: init_module: %s: %m\n", filename); + fprintf (stderr, "insmod: init_module: %s: %s\n", filename, moderror (errno)); /* However ignore the error because this can just happen because * of a missing device. */ -- 1.7.5.3
Thanks, applied. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
The previous implementation had two problems: (I) Not all needed kernel modules were copied to the initrd. (II) If a kernel module depended on more than one other module, only the first dependency was considered for the load order. Using 2.6.39-1-amd64 (Debian/unstable) ext2.ko was not loaded and therefore the root FS could not be mounted. The use of tsort(1) has been replaced with a set of functions that build a DAG in memory and use that to calculate the list of modules to be copied into the initrd and the order in which to laod them. --- helper/ext2initrd.c | 222 ++++++++++++++++++++++++++------------------------- 1 files changed, 113 insertions(+), 109 deletions(-) diff --git a/helper/ext2initrd.c b/helper/ext2initrd.c index 17af3bd..19ac8b3 100644 --- a/helper/ext2initrd.c +++ b/helper/ext2initrd.c @@ -27,6 +27,7 @@ #include <dirent.h> #include <errno.h> #include <assert.h> +#include <fnmatch.h> #include "error.h" #include "full-write.h" @@ -38,7 +39,10 @@ static void read_module_deps (const char *modpath); static void free_module_deps (void); -static const char *get_module_dep (const char *); +static void add_module_dep (const char *name, const char *dep); +static struct module * add_module (const char *name); +static struct module * find_module (const char *name); +static void print_module_load_order (FILE *f, FILE *pp, struct module *m); /* The init binary. */ extern char _binary_init_start, _binary_init_end, _binary_init_size; @@ -65,6 +69,20 @@ static const char *kmods[] = { NULL }; +/* Module dependencies. */ +struct module { + struct module *next; + struct moddep *deps; + char *name; + int visited; +}; +struct module *modules = NULL; + +struct moddep { + struct moddep *next; + struct module *dep; +}; + void ext2_make_initrd (const char *modpath, const char *initrd) { @@ -72,85 +90,39 @@ ext2_make_initrd (const char *modpath, const char *initrd) if (mkdtemp (dir) == NULL) error (EXIT_FAILURE, errno, "mkdtemp"); - char *cmd; - int r; - - /* Copy kernel modules into tmpdir. */ - size_t n = strlen (modpath) + strlen (dir) + 64; - size_t i; - for (i = 0; kmods[i] != NULL; ++i) - n += strlen (kmods[i]) + 16; - cmd = malloc (n); - /* "cd /" here is for virt-v2v. It's cwd might not be accessible by - * the current user (because it sometimes sets its own uid) and the - * "find" command works by changing directory then changing back to - * the cwd. This results in a warning: - * - * find: failed to restore initial working directory: Permission denied - * - * Note this only works because "modpath" and temporary "dir" are - * currently guaranteed to be absolute paths, hence assertion. - */ - assert (modpath[0] == '/'); - sprintf (cmd, "cd / ; find '%s' ", modpath); - for (i = 0; kmods[i] != NULL; ++i) { - if (i > 0) strcat (cmd, "-o "); - strcat (cmd, "-name '"); - strcat (cmd, kmods[i]); - strcat (cmd, "' "); - } - strcat (cmd, "| xargs cp -t "); - strcat (cmd, dir); - if (verbose >= 2) fprintf (stderr, "%s\n", cmd); - r = system (cmd); - if (r == -1 || WEXITSTATUS (r) != 0) - error (EXIT_FAILURE, 0, "ext2_make_initrd: copy kmods failed"); - free (cmd); - - /* The above command effectively gives us the final list of modules. - * Calculate dependencies from modpath/modules.dep and write that - * into the output. - */ read_module_deps (modpath); - - cmd = xasprintf ("tsort > %s/modules", dir); - if (verbose >= 2) fprintf (stderr, "%s\n", cmd); - FILE *pp = popen (cmd, "w"); - if (pp == NULL) - error (EXIT_FAILURE, errno, "tsort: failed to create modules list"); - - DIR *dr = opendir (dir); - if (dr == NULL) - error (EXIT_FAILURE, errno, "opendir: %s", dir); - - struct dirent *d; - while ((errno = 0, d = readdir (dr)) != NULL) { - size_t n = strlen (d->d_name); - if (n >= 3 && - d->d_name[n-3] == '.' && - d->d_name[n-2] == 'k' && - d->d_name[n-1] == 'o') { - const char *dep = get_module_dep (d->d_name); - if (dep) - /* Reversed so that tsort will print the final list in the - * order that it has to be loaded. - */ - fprintf (pp, "%s %s\n", dep, d->d_name); + add_module (""); + for (int i = 0; kmods[i] != NULL; ++i) { + for (struct module *m = modules; m; m = m->next) { + char *n = strrchr (m->name, '/'); + if (n) + n += 1; else - /* No dependencies, just make it depend on itself so that - * tsort prints it. - */ - fprintf (pp, "%s %s\n", d->d_name, d->d_name); + n = m->name; + if (fnmatch (kmods[i], n, FNM_PATHNAME) == 0) { + if (verbose >= 2) + fprintf (stderr, "Adding top-level dependency %s (%s)\n", m->name, kmods[i]); + add_module_dep ("", m->name); + } } } - if (errno) - error (EXIT_FAILURE, errno, "readdir: %s", dir); - - if (closedir (dr) == -1) - error (EXIT_FAILURE, errno, "closedir: %s", dir); + + char *cmd = xasprintf ("cd %s; xargs cp -t %s", modpath, dir); + char *outfile = xasprintf ("%s/modules", dir); + if (verbose >= 2) fprintf (stderr, "writing to %s\n", cmd); + + FILE *f = fopen (outfile, "w"); + if (f == NULL) + error (EXIT_FAILURE, errno, "failed to create modules list (%s)", outfile); + FILE *pp = popen (cmd, "w"); + if (pp == NULL) + error (EXIT_FAILURE, errno, "failed to create pipe (%s)", cmd); - if (pclose (pp) == -1) - error (EXIT_FAILURE, errno, "pclose: %s", cmd); + /* The "pseudo" module depends on all modules matched by the contents of kmods */ + struct module *pseudo = find_module (""); + print_module_load_order (pp, f, pseudo); + fclose (pp); + pclose (f); free (cmd); free_module_deps (); @@ -161,7 +133,7 @@ ext2_make_initrd (const char *modpath, const char *initrd) if (fd == -1) error (EXIT_FAILURE, errno, "open: %s", init); - n = (size_t) &_binary_init_size; + size_t n = (size_t) &_binary_init_size; if (full_write (fd, &_binary_init_start, n) != n) error (EXIT_FAILURE, errno, "write: %s", init); @@ -175,7 +147,7 @@ ext2_make_initrd (const char *modpath, const char *initrd) " | cpio --quiet -o -H newc) > '%s'", dir, initrd); if (verbose >= 2) fprintf (stderr, "%s\n", cmd); - r = system (cmd); + int r = system (cmd); if (r == -1 || WEXITSTATUS (r) != 0) error (EXIT_FAILURE, 0, "ext2_make_initrd: cpio failed"); free (cmd); @@ -187,21 +159,11 @@ ext2_make_initrd (const char *modpath, const char *initrd) free (cmd); } -/* Module dependencies. */ -struct moddep { - struct moddep *next; - char *name; - char *dep; -}; -struct moddep *moddeps = NULL; - -static void add_module_dep (const char *name, const char *dep); - static void free_module_deps (void) { /* Short-lived program, don't bother to free it. */ - moddeps = NULL; + modules = NULL; } /* Read modules.dep into internal structure. */ @@ -225,15 +187,9 @@ read_module_deps (const char *modpath) char *name = strtok (line, ": "); if (!name) continue; - /* Only want the module basename, but keep the ".ko" extension. */ - char *p = strrchr (name, '/'); - if (p) name = p+1; - + add_module (name); char *dep; while ((dep = strtok (NULL, " ")) != NULL) { - p = strrchr (dep, '/'); - if (p) dep = p+1; - add_module_dep (name, dep); } } @@ -242,25 +198,73 @@ read_module_deps (const char *modpath) fclose (fp); } -/* Module 'name' requires 'dep' to be loaded first. */ -static void -add_module_dep (const char *name, const char *dep) +static struct module * +add_module (const char *name) { - struct moddep *m = xmalloc (sizeof *m); - m->next = moddeps; - moddeps = m; + struct module *m = find_module (name); + if (m) + return m; + m = xmalloc (sizeof *m); m->name = xstrdup (name); - m->dep = xstrdup (dep); + m->deps = NULL; + m->next = modules; + m->visited = 0; + modules = m; + return m; } -static const char * -get_module_dep (const char *name) +static struct module * +find_module (const char *name) { - struct moddep *m; + struct module *m; + for (m = modules; m; m = m->next) { + if (strcmp (name, m->name) == 0) + break; + } + return m; +} - for (m = moddeps; m; m = m->next) - if (strcmp (m->name, name) == 0) - return m->dep; +/* Module 'name' requires 'dep' to be loaded first. */ +static void +add_module_dep (const char *name, const char *dep) +{ + if (verbose >= 2) fprintf (stderr, "add_module_dep %s: %s\n", name, dep); + struct module *m1 = add_module (name); + struct module *m2 = add_module (dep); + struct moddep *d; + for (d = m1->deps; d; d = d->next) { + if (d->dep == m2) + return; + } + d = xmalloc (sizeof *d); + d->next = m1->deps; + d->dep = m2; + m1->deps = d; + return; +} - return NULL; +/* DFS on the dependency graph */ +static void +print_module_load_order (FILE *pipe, FILE *list, struct module *m) +{ + if (m->visited) + return; + + for (struct moddep *d = m->deps; d; d = d->next) + print_module_load_order (pipe, list, d->dep); + + if (m->name[0] == 0) + return; + + char *basename = strrchr (m->name, '/'); + if (basename) + ++basename; + else + basename = m->name; + + fputs (m->name, pipe); + fputc ('\n', pipe); + fputs (basename, list); + fputc ('\n', list); + m->visited = 1; } -- 1.7.5.3
On Sun, Jun 05, 2011 at 01:02:50AM +0200, Hilko Bengen wrote:
The previous implementation had two problems: (I) Not all needed kernel modules were copied to the initrd. (II) If a kernel module depended on more than one other module, only the first dependency was considered for the load order. Using 2.6.39-1-amd64 (Debian/unstable) ext2.ko was not loaded and therefore the root FS could not be mounted.
The use of tsort(1) has been replaced with a set of functions that build a DAG in memory and use that to calculate the list of modules to be copied into the initrd and the order in which to laod them.
Thanks, applied. 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
On Sun, Jun 05, 2011 at 01:02:48AM +0200, Hilko Bengen wrote:
--- helper/init.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/helper/init.c b/helper/init.c index 0ca3135..2b5dacf 100644 --- a/helper/init.c +++ b/helper/init.c @@ -163,8 +163,10 @@ main ()
chdir ("/");
- /* Run /init from ext2 filesystem. */ + mount_proc (); print_uptime (); + + /* Run /init from ext2 filesystem. */ execl ("/init", "init", NULL); perror ("execl: /init");
Is the point here to mount /proc before printing the uptime (which is obviously going to fail)? Do you think it's better to mount /proc in the init script? We could remove the call to print_uptime() here instead. libguestfs already mounts /proc in the init script: http://git.annexia.org/?p=libguestfs.git;a=blob;f=appliance/init;hb=HEAD Perhaps we could do it earlier, but still in /init. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
* Richard W.M. Jones:
Is the point here to mount /proc before printing the uptime (which is obviously going to fail)?
Yeah, I just noticed that the second call to print_uptime() failed and fixed that -- not thinking about why the uptime was printed at all.
Do you think it's better to mount /proc in the init script?
Good question. The init script that Debian's initramfs-tools put into the initrd do mount /proc and a number of other filesystems, so I think makes sense to do something similar in the init script that is installed by febootstrap -- at least on Debian systems. This is the initialization code from initramfs-tools version 0.98.8 from squeeze (stable): ,---- | [ -d /dev ] || mkdir -m 0755 /dev | [ -d /root ] || mkdir -m 0700 /root | [ -d /sys ] || mkdir /sys | [ -d /proc ] || mkdir /proc | [ -d /tmp ] || mkdir /tmp | mkdir -p /var/lock | mount -t sysfs -o nodev,noexec,nosuid none /sys | mount -t proc -o nodev,noexec,nosuid none /proc | | # Note that this only becomes /dev on the real filesystem if udev's scripts | # are used; which they will be, but it's worth pointing out | tmpfs_size="10M" | if [ -e /etc/udev/udev.conf ]; then | . /etc/udev/udev.conf | fi | if ! mount -t devtmpfs -o mode=0755 none /dev; then | echo "W: devtmpfs not available, falling back to tmpfs for /dev" | mount -t tmpfs -o size=$tmpfs_size,mode=0755 udev /dev | [ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1 | [ -e /dev/null ] || mknod /dev/null c 1 3 | fi | mkdir /dev/pts | mount -t devpts -o noexec,nosuid,gid=5,mode=0620 none /dev/pts || true | > /dev/.initramfs-tools | mkdir /dev/.initramfs `---- After that, the command line parameters are parsed, some package-provided scripts are sourced, and finally the root filesystem is mounted. Just before the init script on the root fs is called, existing mounts are moved: ,---- | mount -n -o move /sys ${rootmnt}/sys | mount -n -o move /proc ${rootmnt}/proc `---- (I wonder why /dev isn't moved, though.) The most notable change introduced in initramfs-tools 0.99 (current unstable) is that init also puts a tmpfs under /run which is later moved into the root filesystem: ,---- | mount -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run `---- I haven't looked at how RedHat and Fedora systems behave before mounting the root fs but having all the mounts set up by the init that lives in the initrd does make sense to me.
libguestfs already mounts /proc in the init script:
http://git.annexia.org/?p=libguestfs.git;a=blob;f=appliance/init;hb=HEAD
This is the init script that is execl()'d by febootstrap's init, correct? -Hilko
On Mon, Jun 06, 2011 at 04:44:58PM +0200, Hilko Bengen wrote:
libguestfs already mounts /proc in the init script:
http://git.annexia.org/?p=libguestfs.git;a=blob;f=appliance/init;hb=HEAD
This is the init script that is execl()'d by febootstrap's init, correct?
Yup. I would prefer either that we push all this stuff into libguestfs's init script, or (better) that we fix the Debian packages themselves so that any directories, device files etc that they need are listed in the packages already and not in separate scripts. (Fedora is just as culpable about this). 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
* Richard W.M. Jones:
I would prefer either that we push all this stuff into libguestfs's init script, or (better) that we fix the Debian packages themselves so that any directories, device files etc that they need are listed in the packages already and not in separate scripts. (Fedora is just as culpable about this).
Since not many people seem to be involved and interested in hacking on initrd systems, I think that fixing this in the distributions won't exactly be a short-term effort. A few short looks at dracut and mkinitcpio (Arch Linux) show that their /init scripts perform essentially the same filesystem mount operations as the /init script from Debian's initramfs-tools described earlier. (I am not surprised.) It should be easy to implement this in a few mount(2) calls as part of febootstrap's /init. One could even use #ifdefs to cope with slightly different behavior across distributions. I think febootstrap would be more useful when used for other purposes than building a libguestfs appliance. And there is one less possibly distribution-specific detail that needs to be coded into libguestfs. -Hilko
On Tue, Jun 07, 2011 at 01:29:16AM +0200, Hilko Bengen wrote:
* Richard W.M. Jones:
I would prefer either that we push all this stuff into libguestfs's init script, or (better) that we fix the Debian packages themselves so that any directories, device files etc that they need are listed in the packages already and not in separate scripts. (Fedora is just as culpable about this).
Since not many people seem to be involved and interested in hacking on initrd systems, I think that fixing this in the distributions won't exactly be a short-term effort.
A few short looks at dracut and mkinitcpio (Arch Linux) show that their /init scripts perform essentially the same filesystem mount operations as the /init script from Debian's initramfs-tools described earlier. (I am not surprised.)
In Fedora, the same code is duplicated (with small differences/errors) in at least 3 places: anaconda, mock, the live CD scripts. Plus libguestfs if you want to count that. However this is definitely a bug in Fedora, even if the maintainers won't fix it.
It should be easy to implement this in a few mount(2) calls as part of febootstrap's /init. One could even use #ifdefs to cope with slightly different behavior across distributions.
The problem is that we'll end up with complex conditional C code, when really this is better and easier done in the shell script. The code will also be different for every distro.
I think febootstrap would be more useful when used for other purposes than building a libguestfs appliance. And there is one less possibly distribution-specific detail that needs to be coded into libguestfs.
Agreed. However I still don't think fixing this in febootstrap is the right thing to do. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
* Richard W.M. Jones:
It should be easy to implement this in a few mount(2) calls as part of febootstrap's /init. One could even use #ifdefs to cope with slightly different behavior across distributions.
The problem is that we'll end up with complex conditional C code, when really this is better and easier done in the shell script. The code will also be different for every distro.
Is a small size the only reason why you have written febootstrap's /init in C with as few external dependencies as possible? Would you accept a patch that would make it possible to use the distribution's initrd creation tools (initramfs-tools, dracut, mkinitcpio) with febootstrap? -Hilko
On Tue, Jun 07, 2011 at 06:04:42PM +0200, Hilko Bengen wrote:
* Richard W.M. Jones:
It should be easy to implement this in a few mount(2) calls as part of febootstrap's /init. One could even use #ifdefs to cope with slightly different behavior across distributions.
The problem is that we'll end up with complex conditional C code, when really this is better and easier done in the shell script. The code will also be different for every distro.
Is a small size the only reason why you have written febootstrap's /init in C with as few external dependencies as possible?
Would you accept a patch that would make it possible to use the distribution's initrd creation tools (initramfs-tools, dracut, mkinitcpio) with febootstrap?
Yes, with a few privisos. I hope you don't think these are too onerous, but from a libguestfs point of view they are vital: - It would have to work with Fedora (dracut) and Debian - It would need to not slow down boot at all. ie. 'time guestfish -a /dev/null run' should not be affected - It shouldn't make the boot any more risky/buggy than it is currently. A low bar because our boot is already quite buggy, but let's not make things worse ... Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
On Tue, Jun 07, 2011 at 06:57:12PM +0100, Richard W.M. Jones wrote:
On Tue, Jun 07, 2011 at 06:04:42PM +0200, Hilko Bengen wrote:
* Richard W.M. Jones:
It should be easy to implement this in a few mount(2) calls as part of febootstrap's /init. One could even use #ifdefs to cope with slightly different behavior across distributions.
The problem is that we'll end up with complex conditional C code, when really this is better and easier done in the shell script. The code will also be different for every distro.
Is a small size the only reason why you have written febootstrap's /init in C with as few external dependencies as possible?
Would you accept a patch that would make it possible to use the distribution's initrd creation tools (initramfs-tools, dracut, mkinitcpio) with febootstrap?
Yes, with a few privisos. I hope you don't think these are too onerous, but from a libguestfs point of view they are vital:
- It would have to work with Fedora (dracut) and Debian
- It would need to not slow down boot at all. ie. 'time guestfish -a /dev/null run' should not be affected
- It shouldn't make the boot any more risky/buggy than it is currently. A low bar because our boot is already quite buggy, but let's not make things worse ...
Your recent insmod patch was great because it improved on all three of these factors. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
On Tue, Jun 07, 2011 at 06:57:12PM +0100, Richard W.M. Jones wrote:
On Tue, Jun 07, 2011 at 06:04:42PM +0200, Hilko Bengen wrote:
* Richard W.M. Jones:
It should be easy to implement this in a few mount(2) calls as part of febootstrap's /init. One could even use #ifdefs to cope with slightly different behavior across distributions.
The problem is that we'll end up with complex conditional C code, when really this is better and easier done in the shell script. The code will also be different for every distro.
Is a small size the only reason why you have written febootstrap's /init in C with as few external dependencies as possible?
Would you accept a patch that would make it possible to use the distribution's initrd creation tools (initramfs-tools, dracut, mkinitcpio) with febootstrap?
Yes, with a few privisos. I hope you don't think these are too onerous, but from a libguestfs point of view they are vital:
- It would have to work with Fedora (dracut) and Debian
- It would need to not slow down boot at all. ie. 'time guestfish -a /dev/null run' should not be affected
- It shouldn't make the boot any more risky/buggy than it is currently. A low bar because our boot is already quite buggy, but let's not make things worse ...
I forgot an important one: - Mustn't require root. dracut basically requires root for everything. We used to use fakeroot/fakechroot in febootstrap 2.x, and it was a world of pain. 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
* Richard W.M. Jones:
I forgot an important one:
- Mustn't require root.
This was on my list, of course. But never mind, I am already less enthusiastic about the idea. What initramfs-tools puts into the initrd is tied to what is installed on the host system. One would need to maintain a list of what essentials need to be included in the initrd and clean out everything else.
dracut basically requires root for everything.
Does it? I didn't run into _that_ problem. There is a dracut package in Debian/unstable, but it hasn't been kept up-to-date and it wouldn't build an initrd for me because it didn't find some files installed in the system. There seems to be more that needs to be straightened out first. For the moment, I lean towards using febootstrap from your git repository plus the attached patch to helper/init.c and uploading that to Debian. When somebody comes up with a solution for using dracut, initramfs-tools or whatever for building febootstrap's initrd, the binary /init can still be replaced. I'll certainly keep this in mind as a goal, but right now I'd rather put efforts to libguestfs packages.
We used to use fakeroot/fakechroot in febootstrap 2.x, and it was a world of pain.
What kinds of pain? fakeroot is used to build Debian packages all the time. -Hilko
participants (2)
-
Hilko Bengen -
Richard W.M. Jones