how to copy an ubuntu system disk containing a logical volume.

how to copy an ubuntu system disk containing a logical volume.

shimi linux-il at shimi.net
Sun Nov 18 23:55:51 IST 2018


On Sun, Nov 18, 2018 at 8:14 PM Geoffrey Mendelson <
geoffreymendelson at gmail.com> wrote:

> The lvm volume is something I dont understand.
>

Essentially LVM creates an abstraction layer between the actual block
device and your filesystems. Usually, your filesystems are written directly
on the block device.

With LVM, instead you get multiple layers that allows you flexibility (at
the cost of some performance degradation, there IS some translation going
on there....) in such a way that you can make many small block
devices/partitions for just about everything, so nothing will surprise you
taking too much disk, and then gradually grow those that you wish, on the
fly, without even unmounting your filesystem (assume your filesystem
supports online resizing; most modern ones do).

Additionally it allows you to concatenate multiple disks into one large
store pool (similar to the concept of RAID0)

The way it works is like this:

You create  PVs on actual block devices. From one PV or more ('pvs' to see
all PVs), you create a VG (Volume Group) ('vgs' to see all VGs'). So you
can create a VG that spans two PVs from two disks. The VG is like a regular
block device - you can 'partition' it, and those partitions are called LVs
- Logical Volumes ('lvs' to see all LVs). They behave in a similar manner
to your /dev/sda1 for that matter, just that you can always enlarge them
with the 'lvresize' command, as long there's free space in your VG.

You don't really need a tool to copy them. It's fairly simple - you create
partition on all the available disk space, change the partition type to
Linux LVM, use pvcreate on it, then use vgcreate to create a VG on the PV,
and then lvcreate to create volumes/partitions on the VG, after which you
mkfs them as you normally would mkfs /dev/sda1 - just with
/dev/mapper/vgname-logvolname instead... the one place where you might be
bothered is if your root directory itself is over LVM. In that case, the
kernel will not directly be able to use it with a root= boot parameter,
rather then you'll need to use initramfs that will be capable of
enumerating all the LVM hierarchy, and then things like UUIDs/Labels become
available and you can use them in your root= parameter. I am assuming your
existing system already does that if that's your current setup, so you can
copy from there and just modify the GRUB config to your new details.

Having said all the above - you can get all that, and more, and especially
snapshots which were mentioned before, which... suck... I've no better
word, in LVM, better, in.... ZFS (https://en.wikipedia.org/wiki/ZFS). But
it's even more complicated ;-)

HTH,

-- Shimi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20181118/3744d38b/attachment.html>


More information about the Linux-il mailing list