Resizing libvirt disks. Sharing dirs from host <-> guest

1. Resize

Source: https://doc.opensuse.org/documentation/leap/virtualization/html/book-virtualization/cha-libvirt-storage.html
Inside the guest system, check the current size of the disk (for example /dev/vda).

fdisk -l /dev/vda
Disk /dev/sda: 160.0 GB, 160041885696 bytes, 312581808 sectors
Units = sectors of 1 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


On the host, resize the logical volume holding the /dev/vda disk of the guest to the required size, for example 200 GB.

lvresize -L 200G /dev/mapper/vg00-home
Extending logical volume home to 200 GiB
Logical volume home successfully resized



On the host, resize the block device related to the disk /dev/mapper/vg00-home of the guest. Note that you can find the DOMAIN_ID with virsh list.

virsh blockresize --path /dev/vg00/home --size 200G DOMAIN_ID
Block device '/dev/vg00/home' is resized



Check that the new disk size is accepted by the guest.

fdisk -l /dev/vda
Disk /dev/sda: 200.0 GB, 200052357120 bytes, 390727260 sectors
Units = sectors of 1
512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes



2. Share directory from host to guest


1. enable shared memory

<memoryBacking>
    <source type='memfd'/>
    <access mode='shared'/>
  </memoryBacking>
 


2. Share the directory

<filesystem type='mount' accessmode='passthrough'>
      <driver type='virtiofs'/>
      <binary xattr='on'>
        <lock posix='on' flock='on'/>
      </binary>
      <source dir='/mnt/shared_files'/>
      <target dir='mount_shared_files'/>
    </filesystem>
 


3. Start/Restart the vm and mount the dir
FSTAB:

mount_shared_files /mnt/host/   virtiofs        ro,defaults     0       0
 


or CLI

mount -t virtiofs mount_shared_files /mnt/host
 

Trackbacks

Trackback specific URI for this entry

This link is not meant to be clicked. It contains the trackback URI for this entry. You can use this URI to send ping- & trackbacks from your own blog to this entry. To copy the link, right click and select "Copy Shortcut" in Internet Explorer or "Copy Link Location" in Mozilla.

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA