Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian User (http://www.linux-archive.org/debian-user/)
-   -   creating a logical volume with a disk with existing data (http://www.linux-archive.org/debian-user/433344-creating-logical-volume-disk-existing-data.html)

Chris Purves 09-29-2010 03:19 PM

creating a logical volume with a disk with existing data
 
I have a 500 GB disk that is full and I would like to use it and a new 1 TB disk to create a 1.5 TB logical volume. Is it possible to do this without destroying the data on the 500 GB disk?

The manpage for pvcreate gives a warning that running pvcreate on a whole disk will erase the partition table (and therefore the data), but doesn't say what the effect is when running on an existing partition.

I haven't used lvm2 before, and although it seems straightforward to create logical volumes with empty disks, I couldn't find any info for disks with existing data.

Thanks.

--
Chris Purves

"Whence come I and whither go I? That is the great unfathomable question, the same for every one of us. Science has no answer to it." - Max Planck


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 201009291119.12949.chris@northfolk.ca">http://lists.debian.org/201009291119.12949.chris@northfolk.ca

Mark Allums 09-29-2010 03:46 PM

creating a logical volume with a disk with existing data
 
On 9/29/2010 10:19 AM, Chris Purves wrote:

I have a 500 GB disk that is full and I would like to use it and a new 1 TB disk to create a 1.5 TB logical volume. Is it possible to do this without destroying the data on the 500 GB disk?

The manpage for pvcreate gives a warning that running pvcreate on a whole disk will erase the partition table (and therefore the data), but doesn't say what the effect is when running on an existing partition.

I haven't used lvm2 before, and although it seems straightforward to create logical volumes with empty disks, I couldn't find any info for disks with existing data.

Thanks.



It's not clear to me reading your post: Is the existing data on LVM?
If so, then moving it is easy. If not, then it's a little too late to
use LVM to move the data.


However, you should definitely use LVM for your new setup.

If not on LVM, it is easiest to move the data with the partition *not*
mounted as / (root). If you have another computer running Linux, you
can just temporarily move both drives over there and do it. If you only
have the one, then you might want to use a live CD. Boot from it, then
do the work.


But *do* definitely use LVM on the new drive, and next time, you will be
ahead of the game.


Some people would use rsync, and some might use chroot shenanigans, but
I think it's safer to mount the partition read-only and then copy the
files.



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4CA35F3D.4060202@allums.com">http://lists.debian.org/4CA35F3D.4060202@allums.com

Chris Purves 09-29-2010 04:00 PM

creating a logical volume with a disk with existing data
 
On September 29, 2010 11:46:05 am Mark Allums wrote:
> On 9/29/2010 10:19 AM, Chris Purves wrote:
> > I have a 500 GB disk that is full and I would like to use it and a new 1 TB disk to create a 1.5 TB logical volume. Is it possible to do this without destroying the data on the 500 GB disk?
> >
> > The manpage for pvcreate gives a warning that running pvcreate on a whole disk will erase the partition table (and therefore the data), but doesn't say what the effect is when running on an existing partition.
> >
> > I haven't used lvm2 before, and although it seems straightforward to create logical volumes with empty disks, I couldn't find any info for disks with existing data.
>
> It's not clear to me reading your post: Is the existing data on LVM?
> If so, then moving it is easy. If not, then it's a little too late to
> use LVM to move the data.
>
> However, you should definitely use LVM for your new setup.
>
> If not on LVM, it is easiest to move the data with the partition *not*
> mounted as / (root). If you have another computer running Linux, you
> can just temporarily move both drives over there and do it. If you only
> have the one, then you might want to use a live CD. Boot from it, then
> do the work.
>
> But *do* definitely use LVM on the new drive, and next time, you will be
> ahead of the game.
>
> Some people would use rsync, and some might use chroot shenanigans, but
> I think it's safer to mount the partition read-only and then copy the
> files.
>

The existing data is not on LVM, but I should clarify: The 500 GB disk is used for file storage and is not mounted as root. I can unmount it without affecting the system. It occurs to me after reading your post that I could create the logical volume using the 1 TB drive, copy the data from the 500 GB drive to the logical volume, then extend the logical volume to include the 500 GB drive, giving me the 1.5 TB storage volume that I was looking for.

It's still not clear to me though, if I can create the logical volume using the 500 GB drive without losing the data and saving the time it takes to copy the data over.

--
Chris Purves

"I've seen the look of a fat man having dinner." - Frank Sinatra


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 201009291200.49337.chris@northfolk.ca">http://lists.debian.org/201009291200.49337.chris@northfolk.ca

Mark Allums 09-29-2010 04:11 PM

creating a logical volume with a disk with existing data
 
On 9/29/2010 11:00 AM, Chris Purves wrote:

On September 29, 2010 11:46:05 am Mark Allums wrote:

On 9/29/2010 10:19 AM, Chris Purves wrote:

I have a 500 GB disk that is full and I would like to use it and a new 1 TB disk to create a 1.5 TB logical volume. Is it possible to do this without destroying the data on the 500 GB disk?

The manpage for pvcreate gives a warning that running pvcreate on a whole disk will erase the partition table (and therefore the data), but doesn't say what the effect is when running on an existing partition.

I haven't used lvm2 before, and although it seems straightforward to create logical volumes with empty disks, I couldn't find any info for disks with existing data.


It's not clear to me reading your post: Is the existing data on LVM?
If so, then moving it is easy. If not, then it's a little too late to
use LVM to move the data.

However, you should definitely use LVM for your new setup.

If not on LVM, it is easiest to move the data with the partition *not*
mounted as / (root). If you have another computer running Linux, you
can just temporarily move both drives over there and do it. If you only
have the one, then you might want to use a live CD. Boot from it, then
do the work.

But *do* definitely use LVM on the new drive, and next time, you will be
ahead of the game.

Some people would use rsync, and some might use chroot shenanigans, but
I think it's safer to mount the partition read-only and then copy the
files.



The existing data is not on LVM, but I should clarify: The 500 GB disk is used for file storage and is not mounted as root. I can unmount it without affecting the system. It occurs to me after reading your post that I could create the logical volume using the 1 TB drive, copy the data from the 500 GB drive to the logical volume, then extend the logical volume to include the 500 GB drive, giving me the 1.5 TB storage volume that I was looking for.

It's still not clear to me though, if I can create the logical volume using the 500 GB drive without losing the data and saving the time it takes to copy the data over.



I would have to give that some thought. I think that using LVM has to
be done on a whole drive before anything else (don't do this---don't use
it on an unpartitioned drive, you are just asking for trouble) or on a
partition at the time of partitioning. If you put LVM on a partition,
you are preparing it for further operations. So, you would be
overwriting some of the metadata and losing whatever data is on it data
on it.


So, yeah, you have to copy it first, and then add it to the volume group
as an extent to the (1 TB) volume.




--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4CA36546.8020207@allums.com">http://lists.debian.org/4CA36546.8020207@allums.com

Mark Allums 09-29-2010 04:14 PM

creating a logical volume with a disk with existing data
 
On 9/29/2010 11:11 AM, Mark Allums wrote:

If you put LVM on a partition,
you are preparing it for further operations. So, you would be
overwriting some of the metadata and losing whatever data is on it data
on it.


I mean, losing the data that is already on the existing partition.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4CA365FE.6090409@allums.com">http://lists.debian.org/4CA365FE.6090409@allums.com

Chris Purves 09-29-2010 04:17 PM

creating a logical volume with a disk with existing data
 
On September 29, 2010 12:11:50 pm Mark Allums wrote:
> On 9/29/2010 11:00 AM, Chris Purves wrote:
> > On September 29, 2010 11:46:05 am Mark Allums wrote:
> >> On 9/29/2010 10:19 AM, Chris Purves wrote:
> >>> I have a 500 GB disk that is full and I would like to use it and a new 1 TB disk to create a 1.5 TB logical volume. Is it possible to do this without destroying the data on the 500 GB disk?
> >>>
> >>> The manpage for pvcreate gives a warning that running pvcreate on a whole disk will erase the partition table (and therefore the data), but doesn't say what the effect is when running on an existing partition.
> >>>
> >>> I haven't used lvm2 before, and although it seems straightforward to create logical volumes with empty disks, I couldn't find any info for disks with existing data.
> >>
> >> It's not clear to me reading your post: Is the existing data on LVM?
> >> If so, then moving it is easy. If not, then it's a little too late to
> >> use LVM to move the data.
> >>
> >> However, you should definitely use LVM for your new setup.
> >>
> >> If not on LVM, it is easiest to move the data with the partition *not*
> >> mounted as / (root). If you have another computer running Linux, you
> >> can just temporarily move both drives over there and do it. If you only
> >> have the one, then you might want to use a live CD. Boot from it, then
> >> do the work.
> >>
> >> But *do* definitely use LVM on the new drive, and next time, you will be
> >> ahead of the game.
> >>
> >> Some people would use rsync, and some might use chroot shenanigans, but
> >> I think it's safer to mount the partition read-only and then copy the
> >> files.
> >>
> >
> > The existing data is not on LVM, but I should clarify: The 500 GB disk is used for file storage and is not mounted as root. I can unmount it without affecting the system. It occurs to me after reading your post that I could create the logical volume using the 1 TB drive, copy the data from the 500 GB drive to the logical volume, then extend the logical volume to include the 500 GB drive, giving me the 1.5 TB storage volume that I was looking for.
> >
> > It's still not clear to me though, if I can create the logical volume using the 500 GB drive without losing the data and saving the time it takes to copy the data over.
> >
>
> I would have to give that some thought. I think that using LVM has to
> be done on a whole drive before anything else (don't do this---don't use
> it on an unpartitioned drive, you are just asking for trouble) or on a
> partition at the time of partitioning. If you put LVM on a partition,
> you are preparing it for further operations. So, you would be
> overwriting some of the metadata and losing whatever data is on it data
> on it.
>
> So, yeah, you have to copy it first, and then add it to the volume group
> as an extent to the (1 TB) volume.
>

That makes sense. Thanks for your help.

--
Chris Purves

"Just look at the world around you; tell me why is there so much need. Because of greed." - Damien Dempsey


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 201009291217.46324.chris@northfolk.ca">http://lists.debian.org/201009291217.46324.chris@northfolk.ca

"Jesús M. Navarro" 09-29-2010 07:11 PM

creating a logical volume with a disk with existing data
 
Hi, Mark:

On Wednesday 29 September 2010 18:11:50 Mark Allums wrote:
[...]

> I would have to give that some thought. I think that using LVM has to
> be done on a whole drive before anything else (don't do this---don't use
> it on an unpartitioned drive, you are just asking for trouble) or on a
> partition at the time of partitioning.

Like...?

I've been using whole unpartitioned hard disks for LVM physical volumes for
ages without any problem, so what are the troubles you found with that?

Cheers.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 201009292111.13433.jesus.navarro@undominio.net">ht tp://lists.debian.org/201009292111.13433.jesus.navarro@undominio.net

Mark Allums 09-29-2010 08:08 PM

creating a logical volume with a disk with existing data
 
On 9/29/2010 2:11 PM, Jesús M. Navarro wrote:

Hi, Mark:

On Wednesday 29 September 2010 18:11:50 Mark Allums wrote:
[...]


I would have to give that some thought. I think that using LVM has to
be done on a whole drive before anything else (don't do this---don't use
it on an unpartitioned drive, you are just asking for trouble) or on a
partition at the time of partitioning.


Like...?

I've been using whole unpartitioned hard disks for LVM physical volumes for
ages without any problem, so what are the troubles you found with that?

Cheers.



I ran into some frustrations with various disk utilities, including
gparted. Granted, gparted is not a requirement, there are other
programs that are more LVM-friendly, and are better programs, anyway.
That's what I get for not using the command line.


Also, if an LVM-on-an-unpartitioned-disk resides in a dual-boot machine
with Windows, that disk is likely to get hosed by Windows.


I had some volume-group/logical-volume management issues as well, but it
was more a matter of how easy it was to accomplish something than it was
a matter of not being able to do that something at all. I can't recall
the specific details, I don't need do whatever it was very often.


Using DOS partitions isn't absolutely necessary, and for server roles
and large systems, they may just get in the way, but I find them
convenient.


OP sounded like a small desktop system, but perhaps we shouldn't make
the call to put or not to put volume groups on physical volumes
(unpartitioned drive) for OP until we we know more about his
requirements. If I am giving that sort of advice, I should explain, or
find out more.





--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4CA39CD7.1040607@allums.com">http://lists.debian.org/4CA39CD7.1040607@allums.com

Nuno Magalhăes 09-29-2010 09:53 PM

creating a logical volume with a disk with existing data
 
Hi,

I followed [1] two days ago and it suited me. I had a non-LVM 160GB
disk with / and /home (ext3), plus a blank 1TB. What i did was
partition the whole 1TB as a "Linux LVM" partition, then set up the vg
and a -home (ext4) partition.

Then i mounted the LVM -home as /mount/tmp and copied my non-LVM /home
from the 160GB to the 1TB. I don't think it's feasible to turn a
non-LVM partition into an LVM one, you'd definitely lose data, so you
do need to copy.

So right now i have my old 160GB as it was, plus an LVM 1TB with a
-home partition (i wanna make sure it copied everything right before i
change fstab). The plan is to dump the partitions in the 160GB (which
include a rarely-if-ever used 15GB for XP (thanks to virtualbox)) and
to a fresh reinstall, using the installer's lvm-manager to set up both
drives. Hopefully it'll recognise one already has LVM, so i can add
everything to the same volume group.

Then i'll be able to set / as LVM (and /boot out of it apparently), as
well as other partitions for multimedia, vbox disks and maybe
something for public access like /var/www

Question 0: won't extending an existing lvm partition fragment it?

Question 1: is it feasable under linux (and an Asus m2npv-vm) to use
RAID as well? I was considering RAIDing 160GB since the drives are of
different sizes, maybe RAID 0 or 1, but i'm not sure such complexity
is worth it and even though the mb supports it, i think it's more sw
than hw-raid. But this is highjaking already.

Question 2: In order to add the 160GB drive, do i also format is as an
160GB "Linux LVM" partition and add that to the volume group? Will i
then have two drives under /dev/mapper? Is the split still there or
could i expand the existing LVM partition onto the 160GB and create
logical vlumes for / and what not in it?

HTH and TIA and some other acronym,
Nuno

[1] http://www.linux.com/learn/tutorials/306352-weekend-project-migrate-from-direct-partitions-to-lvm-volumes


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: AANLkTimtSMR6AwgYgtbW-NuOT=8rhgaGLYk12axh41SU@mail.gmail.com">http://lists.debian.org/AANLkTimtSMR6AwgYgtbW-NuOT=8rhgaGLYk12axh41SU@mail.gmail.com

Mark Allums 09-29-2010 10:51 PM

creating a logical volume with a disk with existing data
 
On 9/29/2010 4:53 PM, Nuno Magalhăes wrote:

Hi,

I followed [1] two days ago and it suited me. I had a non-LVM 160GB
disk with / and /home (ext3), plus a blank 1TB. What i did was
partition the whole 1TB as a "Linux LVM" partition, then set up the vg
and a -home (ext4) partition.

Then i mounted the LVM -home as /mount/tmp and copied my non-LVM /home
from the 160GB to the 1TB. I don't think it's feasible to turn a
non-LVM partition into an LVM one, you'd definitely lose data, so you
do need to copy.

So right now i have my old 160GB as it was, plus an LVM 1TB with a
-home partition (i wanna make sure it copied everything right before i
change fstab). The plan is to dump the partitions in the 160GB (which
include a rarely-if-ever used 15GB for XP (thanks to virtualbox)) and
to a fresh reinstall, using the installer's lvm-manager to set up both
drives. Hopefully it'll recognise one already has LVM, so i can add
everything to the same volume group.

Then i'll be able to set / as LVM (and /boot out of it apparently), as
well as other partitions for multimedia, vbox disks and maybe
something for public access like /var/www

Question 0: won't extending an existing lvm partition fragment it?

Question 1: is it feasable under linux (and an Asus m2npv-vm) to use
RAID as well? I was considering RAIDing 160GB since the drives are of
different sizes, maybe RAID 0 or 1, but i'm not sure such complexity
is worth it and even though the mb supports it, i think it's more sw
than hw-raid. But this is highjaking already.


RAID is definitely feasible under Linux. You would be using software
RAID, but Linux has very good software RAID. No need to use the mb
RAID. Use Linux RAID. (mdraid)


You can create partitions of equal size on each disk. The RAID would be
across partitions. So, the unequal sizes of the disks would not matter.
You can create and use additional partitions on the larger drive,
separate from the RAIDed one. Thus, you would have the use of the whole
drive capacity. However, the rest of the drive wouldn't be protected.
It's even possible to have bizarre combinations spanning partitions on
several disks.


After creating the setup you want, use LVM on top of the RAID.



Question 2: In order to add the 160GB drive, do i also format is as an
160GB "Linux LVM" partition and add that to the volume group? Will i
then have two drives under /dev/mapper? Is the split still there or
could i expand the existing LVM partition onto the 160GB and create
logical vlumes for / and what not in it?

HTH and TIA and some other acronym,
Nuno

[1] http://www.linux.com/learn/tutorials/306352-weekend-project-migrate-from-direct-partitions-to-lvm-volumes




I'm not sure what you're asking. You probably want to set up the RAID
first, and then put LVM on that. You will see different views of your
setup in different places. As far as the Linux file system goes (what
you see when you type "mount" on the command line), it will only see
whatever separate individual logical volumes you create (that are
mounted). There can be both LVM and non-LVM volumes visible as block
devices at the same time.


If you put everything under LVM, you will see two "drives" if you have
two logical volumes.


You can add new physical volumes and expand a logical volume at any time.



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4CA3C2DD.1090005@allums.com">http://lists.debian.org/4CA3C2DD.1090005@allums.com


All times are GMT. The time now is 11:16 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.