[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: LVM: combining two logical volumes, how?

In <[🔎] 4DDE7E85.50304@heard.name>, Ken Heard wrote:
>In a box with Squeeze I have one volume group (VG1) with only one (at
>the moment) physical volume (/dev/md1).  Two of the six current logical
>volumes (LV) in VG1 are are /dev/VG1/root (/) and /dev/VG1/usr.  I want
>to (1) enlarge /dev/VG1/root, (2) transfer the contents of /dev/VG1/usr
>to it, and (3) remove /dev/VG1/usr.
>Enlarging /dev/VG1/root is easy (I think) using the lvextend command,
>and so is removing /dev/VG1/usr using the lvremove command.  What I
>cannot find is any command or information to do the second step,
>transfer the entire contents of one LV to another.  Is it possible to do
>what I want to do?

You would do that via cp, rsync, etc.

Something like this could work:
mount -o bind / /mnt
# view of the / file systems without any other mounts under /mnt
mount -o remount,ro /usr # Make sure no one is writing to the /usr file system
rsync -HaAxX --progress --stats /usr/. /mnt/usr
# Copy the data, including hard links, acls, and extended attributes
umount /mnt # Remove the view
sync;sync;sync # Precaution
umount /usr
# Fully unmount /usr, exposing the copy created on the / file system

Why doesn't LVM do this?  Because, you might not put file systems on LVs and 
it doesn't understand the dozen different file systems you might have on the 
two LVs, even if they are both file systems.

LVM operates at the LE / PE (block) level, it doesn't really understand 
anything besides that.  vgmerge exists because that can be handled at the 
block level basically by rewriting all the metadata on one VG.  We can know 
that is the correct operation because only LVM itself reads / writes that 
metadata.  lvmerge could certainly be done at the block level, but then the 
file systems or device mapper devices or whatever you put on top of your LVs 
could be confused.
Boyd Stephen Smith Jr.                   ,= ,-_-. =.
bss@iguanasuicide.net                   ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy         `-'(. .)`-'
http://iguanasuicide.net/                    \_/

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply to: