[Libguestfs] virt-resize

Richard W.M. Jones rjones at redhat.com
Mon Jun 25 12:23:52 UTC 2012


[Please keep replies on the list so that others can benefit
from the answers]

On Mon, Jun 25, 2012 at 07:13:49AM -0500, Dan The Man wrote:
> Hmmm well I beleive the only way I can think to do it is enlarge the lv
> in linux as usual , then have to boot into freebsd , modify the
> partition table for rest of sectors and use the growfs command, even
> that is problematic seeing the partition cannot be mounted
> regardless. Might be worth reading source code to growfs.c in
> freebsd source tree or just trying a zfs root install to see if it
> happens automatically.
> 
> I did have a question after playing more with linux virtualization
> maybe you could shed some light on, I was wondering how to mount
> lv's inside guests.
> 
> cappy:~# ls /dev/mapper
> control  virtual-centos  virtual-centos_new  virtual-freebsd
> virtual-freebsd_new  virtual-windows7  virtual-windows8
> cappy:~# virsh start centos
> Domain centos started
> 
> cappy:~# kpartx -av /dev/virtual/centos
> add map virtual-centos1 (253:6): 0 512000 linear /dev/virtual/centos 2048
> add map virtual-centos2 (253:7): 0 20457472 linear
> /dev/virtual/centos 514048
> cappy:~# ls /dev/mapper
> control  virtual-centos  virtual-centos1  virtual-centos2
> virtual-centos_new  virtual-freebsd  virtual-freebsd_new
> virtual-windows7 virtual-windows8
> cappy:~# virt-filesystems --long --parts --blkdevs -h -a
> /dev/virtual/centos
> Name       Type       Size  Parent
> /dev/sda1  partition  250M  /dev/sda
> /dev/sda2  partition  9.8G  /dev/sda
> /dev/sda   device     10G   -
> cappy:~# virt-filesystems -lh -a /dev/virtual/centos
> Name               Type        VFS   Label  Size
> /dev/sda1          filesystem  ext4  -      250M
> /dev/virtual/root  filesystem  ext4  -      7.8G
> cappy:~# mount /dev/mapper/virtual-centos1 /centos
> 
> OK but now how do I mount that /dev/virtual/root since its a lvm on
> /dev/sda2 ?

With libguestfs you'd use guestmount to do this:

  guestmount -a /dev/virtual/centos -m /dev/virtual/root /tmp/mnt

There's no need to use kpartx.

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




More information about the Libguestfs mailing list