Skip to contentSkip to conversation

Newbie of LVM

linux-lvm Way Loss 6 participants 10 messages Dec 9, 2005 – Dec 12, 2005

lore
Share & tools
lore

Way Loss

author
#0 lore raw

Hi all,

I am very new to LVM. Here is the detail of my
current fs.

Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              9.4G  2.5G  6.5G  28% /
/dev/md2              9.4G  7.6G  1.4G  85% /home
/dev/md3              9.4G  6.6G  2.4G  74% /var
/dev/md4              958M   18M  892M   2% /tmp
/dev/md5              153G  119G   27G  82% /www

My md5 is almost full and I wanna use LVM to merge
my md5 with a new partition from a new hdd. I wanna ask if this possible for LVM to merge 2 partition together while one of them have data on it? I can't suffer any data loss and want to make sure that LVM works perfectly to what I want.
Thanks all.

Best Regards,
Sing

_______________________________________
�x��ӍϢ - Yahoo! Messenger ������]���ϾW����������Կ�������ӍϢ�o�㣬�����ϾW�r���������������κ��fԒ������ʧ��
http://messenger.yahoo.com.hk

#1 lore raw

U should confirm this before going ahead,

I believe that's what LVM is good for, or else why use it in the first place?

{
Logical volume management is traditionally associated with large installations containing many disks but it is equally suited to small systems with a single disk or maybe two.
} <- this is from Why would I want
it?<http://tldp.org/HOWTO/LVM-HOWTO/whywouldiwantit.html>

and this will take U home -> Benefits of Logical Volume Management on a Small System <http://tldp.org/HOWTO/LVM-HOWTO/benefitsoflvmsmall.html>

HTH
--
Anil Kumar Shrama

#2 lore raw
In reply to Way Loss
Quoted 11 lines · Way Loss

Hi all,

I am very new to LVM. Here is the detail of my
current fs.

Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              9.4G  2.5G  6.5G  28% /
/dev/md2              9.4G  7.6G  1.4G  85% /home
/dev/md3              9.4G  6.6G  2.4G  74% /var
/dev/md4              958M   18M  892M   2% /tmp
/dev/md5              153G  119G   27G  82% /www
Quoted 7 lines

My md5 is almost full and I wanna use LVM to merge
my md5 with a new partition from a new hdd. I wanna ask if this possible for LVM to merge 2 partition together while one of them have data on it? I can't suffer any data loss and want to make sure that LVM works perfectly to what I want.
Thanks all.

You're out of luck. You can't take an existing partition and keep the data yet switch it over to LVM. It's like RAID that way: you need to set up the lower level stuff *before* you format the disk/partition with your filesystem and start putting data on it.

To do what you want is possible, provided that you created an LVM from the beginning that had md5 as a PhysicalVolume, then created your filesystem on the Logical Volume. But it seems clear from your fstab that you didn't do that.

Sorry,
--Matt

#3 lore raw
Quoted 5 lines

You're out of luck. You can't take an existing partition and keep the data yet switch it over to LVM. It's like RAID that way: you need to set up the lower level stuff *before* you format the disk/partition with your filesystem and start putting data on it.

But couldn't he set up his new drive with LVM copy the data from the old drive to it, provided it's large enough and then add the old drive to the group?

#4 lore raw
Quoted 10 lines · Jeff Cousino
Quoted 5 lines

You're out of luck. You can't take an existing partition and keep the data yet switch it over to LVM. It's like RAID that way: you need to set up the lower level stuff *before* you format the disk/partition with your filesystem and start putting data on it.

But couldn't he set up his new drive with LVM copy the data from the old drive to it, provided it's large enough and then add the old drive to the group?

Right, I was writing a followup to this effect before I got your response.

--Matt

#5 lore raw
In reply to Jeff Cousino
Quoted 3 lines · Jeff Cousino

But couldn't he set up his new drive with LVM copy the data from the old drive to it, provided it's large enough and then add the old drive to the group?

As long as he can get the downtime to do it, sure. At that point the device '/dev/md5' can be added as a PV and the volume grown.

However - to do that he'd need to unmount the existing volume, ideally for the time it took to do the copy (although there are ways around that).

And also, the answer to the initial question is still no, since that's just a different way to do it.

If the new storage device is big enough (and the solution wanted is not a RAID that requires the existing disk space to build) then the following would be a way to do it:

1. Create the PV/VG on the new disk (since it doesn't look as though LVM is in use at all on that machine, if it is then do as appropriate)
2. Create the new volume, and mount it under /mnt or something.
3. use rsync to get the two volumes (existing & new) in sync. The command I use is:

	rsync --delete-after -av /www /mnt
4. Arrange a downtime of at least 15 minutes, and during that move the
mount points around (after stopping all applications that use /www):
	rsync --delete-after -av /www /mnt # bring the copy up to date
	umount /mnt
	umount /www
	mount <LVM device> /www

5. Restart all the applications

Things to note about this are that not only does it require a lot of disk space, but it also will be quite slow (especially if there are lots of little files on /www). If you start work well before you can arrange the downtime (last time I did this I had everything in place and had to wait 2 weeks for the window to do the rotation) then you can keep running the rsync to keep the two copies closer together and therefore keep the downtime to a minimum.

A shorter term solution would be to migrate some of the data off /www and use symlinks. That would still require a brief downtime to move around the data - but it doesn't require the big hit. (e.g. mount the new partition as /www2 and then move /www/site1 to /www2/site1 and then create a symlink /www/site1 to /www2/site1 - couple of other things to be aware of, but that's the principle).

#6 lore raw
In reply to Matthew Gillen
Quoted 27 lines · Matthew Gillen
Quoted 11 lines · Way Loss

Hi all,

I am very new to LVM. Here is the detail of my
current fs.

Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              9.4G  2.5G  6.5G  28% /
/dev/md2              9.4G  7.6G  1.4G  85% /home
/dev/md3              9.4G  6.6G  2.4G  74% /var
/dev/md4              958M   18M  892M   2% /tmp
/dev/md5              153G  119G   27G  82% /www
Quoted 7 lines

My md5 is almost full and I wanna use LVM to merge
my md5 with a new partition from a new hdd. I wanna ask if this possible for LVM to merge 2 partition together while one of them have data on it? I can't suffer any data loss and want to make sure that LVM works perfectly to what I want.
Thanks all.

You're out of luck. You can't take an existing partition and keep the data yet switch it over to LVM. It's like RAID that way: you need to set up the lower level stuff *before* you format the disk/partition with your filesystem and start putting data on it.

Quoted 4 lines

To do what you want is possible, provided that you created an LVM from the beginning that had md5 as a PhysicalVolume, then created your filesystem on the Logical Volume. But it seems clear from your fstab that you didn't do that.

Well, you're not totally out of luck, assuming the other disk is as big or bigger than /dev/md5:
You could create an LVM with the new disk, create your filesystem, copy the contents of md5 to the new LVM filesystem (via tar/cpio or something that will preserve symlinks etc), then add md5 to the LVM setup (thereby destroying the data on md5) and resize your filesystem. --Matt

#7 lore raw
In reply to Matthew Gillen

Yes, it is possible and this is the way LVM is supposed to work else who will touch it?
U will need to copy your data at least once,
I mean, to merge, U must have your data on LVM - so get it there !!

Since U will have a shining brand new HDD, and your taste says it will be bigger than previous one - has to be, else drop the idea or data!

So brief steps would be (Details, please work out precisely before proceeding or ask)

0. Read LVM things before hand - they will come very handy because U are now embracing LVM.

1. plug New HDD in the box, and get it going.
2. Get LVM on new disk going. PV, PE, VG, LV, etc all done.
3. Copy (please note - copy it is - not move - not shift) copy data to new disc to LVM partition created on new disk.

4. Reboot and "confirm" that new data is available (Do not skip this step).

5. "ReConfirm" by all means that your data is safe sound and reachable on new disc. Like use it again and again and earn confidence with it. Check data presence through your software etc etc etc etc.

6. I do not wish to use capitals but "do not delete your old data on md5" "do not delete your old data on md5".
6.1 Keep it as backup for few days till U become comfortable with your data in new location.

### Important ### U C, U have a new disc, may be, twice the size of old
disc.... just wait before U delete old data.

7. Then onwards it will be like house keeping. I mean merging of partitions starts now . And for that u will have to reformat (or wait for FC8, it may be sooner) your old partition. Read LVM thoroughly, it is good only with caution.

I again remind that U are playing with data, keep backup.

Quoted 12 lines
Quoted 8 lines

My md5 is almost full and I wanna use LVM to merge
my md5 with a new partition from a new hdd. I wanna ask if this possible for LVM to merge 2 partition together while one of them have data on it? I can't suffer any data loss and want to make sure that LVM works perfectly to what I want.
Thanks all.

--
Anil Kumar Shrama

#8 lore raw

This list moves fast....4 hits before a send button hit.... brief is a word..

--
Anil Kumar Shrama

#9 lore raw
In reply to Matthew Gillen
Quoted 11 lines · Matthew Gillen
Quoted 8 lines · Way Loss

/dev/md5 153G 119G 27G 82% /www

My md5 is almost full and I wanna use LVM to merge
my md5 with a new partition from a new hdd. I wanna ask if this possible for LVM to merge 2 partition together while one of them have data on it? I can't suffer any data loss and want to make sure that LVM works perfectly to what I want.

Quoted 2 lines

You're out of luck. You can't take an existing partition and keep the data yet switch it over to LVM.

See also:
https://www.redhat.com/archives/linux-lvm/2005-October/msg00110.html

Alasdair

Signature · 1 line
[email protected]