Re: [Libguestfs] Suggestions on building VM disks from scratch
by Richard W.M. Jones
> Then I created my blank 'disk' file and tried to
> run virt-rescue on it. It crashed out with an
> error from febootstrap.
First of all, debug this properly:
(1) What is the full error message?
(2) What is the complete, unedited output of 'libguestfs-test-tool'?
(3) What version of libguestfs & febootstrap are using and where did
you get them from?
You can post the details on our mailing list libguestfs(a)redhat.com
(no need to subscribe if you don't want to).
> After finding nothing terribly
> useful or current on this in searching, I tried
> guestfish instead. After some fiddling I got it
> to attach my blank disk. However I cannot find a
> reasonable way to partition it with the part-add which
> seems to want me to count sectors. All I want is
> a 9G linux and a 2G swap.
Assuming the filesystem was in /tmp/root.tar.gz, the following code
will do this:
guestfish <<EOF
sparse /tmp/test.img 11G
run
part-init /dev/sda mbr
# 9GB sda1
part-add /dev/sda p 64 $(( 9*1024*1024*2 ))
# remainder in sda2
part-add /dev/sda p $(( 9*1024*1024*2 + 1 )) -64
mkfs ext4 /dev/sda1
mkswap /dev/sda2
mount /dev/sda1 /
tgz-in /tmp/root.tar.gz /
EOF
Example:
$ sh test.sh
$ virt-df -a test.img -h
Filesystem Size Used Available Use%
test.img:/dev/sda1 9.0G 276M 8.3G 4%
$ ll -h test.img
-rw-rw-r--. 1 rjones rjones 11G Apr 4 09:39 test.img
Whether this would actually boot is another question: you may also
need to add some grub commands to set up the bootloader, *or* (better
and easier IMHO) set up libvirt so that it boots from an external
kernel + initrd.
> It also lacks access to rsync.
It's not the first time that someone has asked for rsync, and it
wouldn't be too hard to add. However note that rsync really gives you
no benefit when you're creating a filesystem from scratch, because
there's no original to rsync against. If you are updating a
filesystem image then rsync makes sense.
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
12 years, 7 months
[PATCH] fuse: Add missing #include to guestmount.c
by Matthew Booth
Fix compilation failure on F17
---
fuse/guestmount.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fuse/guestmount.c b/fuse/guestmount.c
index 7c5e0af..379346f 100644
--- a/fuse/guestmount.c
+++ b/fuse/guestmount.c
@@ -28,6 +28,7 @@
#include <unistd.h>
#include <getopt.h>
#include <signal.h>
+#include <locale.h>
/* We're still using some of FUSE to handle command line options. */
#include <fuse.h>
--
1.7.9.3
12 years, 7 months
febootstrap 3.x use cases.
by Carwyn Edwards
I'm confused! What use cases is the new febootstrap primarily intended
for? I'm mainly trying to figure out if I'm trying to put a square peg
into a round hole.
What I'm looking into is using linux containers (LXC) either using
libvirt or lxc-tools) to create jails for a web hosting type
environment. I can see that in the long run btrfs has some nice
features to help with this too.
Is febootstrap really intended for this kind of use case?
I can see two mechanisms that might work for what I'm trying to do:
* Figure out how to create application containers around
apache/whateverwebserver with a docroot and virtually no other
filesystem. The down side to this is that it needs a lot of stuff
added to the jail to make it work.
* Use something like febootstrap or btrfs to create minimal
filesystem roots for each hosted environment. This seems simpler if a
little overkill.
I'll probably ask over at the lxc lists and take a look at OpenVZ too.
I'm mainly interested in finding out more about the intended use of
febootstrap here.
Thanks,
Carwyn
12 years, 7 months
[PATCH RFC] sysprep:add logging feature
by Wanlong Gao
Hi Rich,
What I felt at using virt-sysprep is that all things are done in silent and
there is no log what's done. Please consider to add logging feature what was done
at virt-sysprep. For example,
deleted /var/log/utmp
deleted /etc/.....
modified /etc/sysconfing/network...
...
What do you think?
Thanks,
Wanlong Gao
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
sysprep/sysprep_operation_cron_spool.ml | 2 ++
sysprep/sysprep_operation_dhcp_client_state.ml | 2 ++
sysprep/sysprep_operation_dhcp_server_state.ml | 2 ++
sysprep/sysprep_operation_hostname.ml | 2 ++
4 files changed, 8 insertions(+)
diff --git a/sysprep/sysprep_operation_cron_spool.ml b/sysprep/sysprep_operation_cron_spool.ml
index e67688b..cec18e0 100644
--- a/sysprep/sysprep_operation_cron_spool.ml
+++ b/sysprep/sysprep_operation_cron_spool.ml
@@ -16,12 +16,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
+open Printf
open Sysprep_operation
module G = Guestfs
let cron_spool_perform g root =
Array.iter g#rm_rf (g#glob_expand "/var/spool/cron/*");
+ eprintf "Deleted /var/spool/cron/*\n";
[]
let cron_spool_op = {
diff --git a/sysprep/sysprep_operation_dhcp_client_state.ml b/sysprep/sysprep_operation_dhcp_client_state.ml
index e3e87cb..18415c5 100644
--- a/sysprep/sysprep_operation_dhcp_client_state.ml
+++ b/sysprep/sysprep_operation_dhcp_client_state.ml
@@ -16,6 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
+open Printf
open Sysprep_operation
module G = Guestfs
@@ -27,6 +28,7 @@ let dhcp_client_state_perform g root =
fun glob -> Array.iter g#rm_rf (g#glob_expand glob)
) [ "/var/lib/dhclient/*"; "/var/lib/dhcp/*" (* RHEL 3 *) ]
);
+ eprintf "Deleted /var/lib/dhclient/* /var/lib/dhcp/*\n";
[]
let dhcp_client_state_op = {
diff --git a/sysprep/sysprep_operation_dhcp_server_state.ml b/sysprep/sysprep_operation_dhcp_server_state.ml
index c5251ce..87cb2ed 100644
--- a/sysprep/sysprep_operation_dhcp_server_state.ml
+++ b/sysprep/sysprep_operation_dhcp_server_state.ml
@@ -16,12 +16,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
+open Printf
open Sysprep_operation
module G = Guestfs
let dhcp_server_state_perform g root =
Array.iter g#rm_rf (g#glob_expand "/var/lib/dhcpd/*");
+ eprintf "Deleted /var/lib/dhcpd/*\n";
[]
let dhcp_server_state_op = {
diff --git a/sysprep/sysprep_operation_hostname.ml b/sysprep/sysprep_operation_hostname.ml
index 1472a1c..6caf8d7 100644
--- a/sysprep/sysprep_operation_hostname.ml
+++ b/sysprep/sysprep_operation_hostname.ml
@@ -42,10 +42,12 @@ let hostname_perform g root =
String.concat "\n" lines ^
sprintf "\nHOSTNAME=%s\n" !hostname in
g#write filename file;
+ eprintf "Modified HOSTNAME to %s\n" !hostname;
[ `Created_files ]
| "linux", ("debian"|"ubuntu") ->
g#write "/etc/hostname" !hostname;
+ eprintf "Modified HOSTNAME to %s\n" !hostname;
[ `Created_files ]
| _ -> []
--
1.7.10.rc3
12 years, 7 months
[PATCH (incomplete)] Rewrite virt-sysprep in OCaml.
by Richard W.M. Jones
This patch is incomplete but it illustrates the idea. virt-sysprep is
rewritten as a modular tool in OCaml.
Only the 'utmp' and 'hostname' operations are implemented at the
moment.
Rich.
12 years, 7 months