LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-21-2006, 10:43 AM   #1
daveschile
LQ Newbie
 
Registered: Jan 2004
Posts: 17

Rep: Reputation: 0
LVM - help replacing a drive,


Hi,

This is a simple question, but I really don't want to lose any data, so I'd really appreciate it if someone could give me a quick rundown on how this is done. I've searched around and read the LVM Howto but Im still not comfortable with this specific scenario:

I have a simple implementation of LVM that creates logical volume from /dev/hda3 and /dev/hdc1. /dev/hda is a 250G drive that holds the filesystem on /dev/hda1, but only /dev/hda3 is part of the volume group. /dev/hdc1 is a 100G drive with only one partition and its part of the volume group.

I want to replace /dev/hdc1 with a 250G drive I just bought. Right now the whole logical volume is 334G. All of that is allocated and none is free as far as physical extens go. However, I only have 119G of data on the whole logical volume. Is there any way to tell where physically that data resides? I cannot do a pvmove (as I understand it) because I have no free extens on /dev/hda3. Is it better to make extens available somehow on /dev/hda3 and do a pvmove? or should I install the new drive somewhere else, like /dev/hdb, then add it to the volume group and do a pvmove? If that's the case, then will it screw up the volume group when I move the new drive into its permanent location at /dev/hdc?

I know that's a lotta questions, but I really need some clarification. If' anyone can help I'll be very thankfull.

Dave Schile
 
Old 02-21-2006, 10:57 AM   #2
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,491

Rep: Reputation: 50
Quote:

Right now the whole logical volume is 334G. All of that is allocated and none is free as far as physical extens go. However, I only have 119G of data on the whole logical volume.
are you sure you created the volume group and lvol correctly?
it seems to my mind that you aren't getting the full capacity. did you run lvextend & extendfs (or whatever it's called), when you added /dev/hdc1 to the volume group (presumably vg00 and lvol1)? does that make sense?

i would have done:

pvcreate on /dev/hdc1
vgextend to add /dev/hdc to vg00
lvextend to increase the size of the logical volume
extendfs to grow the file system to the full size of the lvol

hope i'm making sense!

i realised i was reading this wrong. lol

however, you still need to do vgextend,lvextend and extendfs when you add a new physical volume.....
 
Old 02-21-2006, 11:03 AM   #3
daveschile
LQ Newbie
 
Registered: Jan 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Statinet,

Yeah, I'm pretty sure I set it up right. The size is right as /dev/hda3 is about 220G. That drive is 250G, but I use about 20G for filesystem and swap.

Thanks for your reply. All I wanna do is swap one of the physical volumes for a larger one without losing any data.

Dave Schile
 
Old 02-21-2006, 11:16 AM   #4
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,491

Rep: Reputation: 50
have u actually added the new disk to the volume group??

i've never actually done anything like that i have to admit - only ever added more disks in.

but i'm interested by your post:

take a look at this:

http://www.tldp.org/HOWTO/LVM-HOWTO/removeadisk.html


not sure its the exact answer, because if you removed the disk. /dev/hdc would get reassigned to this bigger disk that you added to the volume group, if you see what i mean....
 
Old 02-21-2006, 11:25 AM   #5
daveschile
LQ Newbie
 
Registered: Jan 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Yes,
I've read that. I'm just not sure how things will go when I move the new drive into it's normal location. The drive has to reside at /dev/hdc. I can use /dev/hdb temporarily for the pvmove, but once everything's off the old drive I want the new one to take it's place at /dev/hdc1 Is this okay? Will it screw up the metadata?

Dave Schile
 
Old 02-21-2006, 11:27 AM   #6
satinet
Senior Member
 
Registered: Feb 2004
Location: England
Distribution: Slackware 14.2
Posts: 1,491

Rep: Reputation: 50
yes, i think it would.... as you would have added /dev/hdb1 to the volume group. only for it to suddenly reappear as /dev/hdc1....



i'll ask around...
 
Old 02-21-2006, 12:16 PM   #7
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
Originally Posted by daveschile
Is there any way to tell where physically that data resides?
Run pvdisplay. If your PV on /dev/hdc1 comes back with a line saying "Allocated PE 0" then these is nothing stored on this PV and you can safely reduce your LV and remove the PV (knock on wood!) But if pvdisplay comes back with something greater than zero for Allocated PE, then you need to mess with pvmove.

I would expect your Allocated PE's to come back zero for /dev/hdc1 unless you used striped mapping rather than linear mapping when you set up the volume (and you should know if you used striping, because it requires additional parameters to lvcreate). This assumption based on your report that the PV on /dev/hda3 is 220Gb and you're only using 119Gb of the LV.

This is all covered very well in the LVM HowTo:

http://www.tldp.org/HOWTO/LVM-HOWTO/index.html
 
Old 02-21-2006, 12:46 PM   #8
daveschile
LQ Newbie
 
Registered: Jan 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Haertig,

Thanks for your reply. I'm not using striped mapping. Just a linear LVM. The thing is that once you extend the LV, you allocate all physical extents to the logical volume. Therefore, It shows zero free. Even though there's no useful data being stored on the extents, they're still allocated to the logical volume. pvdisplay shows that all the extens on both drives are allocated, none free for a total of 234G with a df command on the mounted logical volume, I can see that I'm only using 119G of the 234G

Hope this clarifies.

Dave Schile
 
Old 02-21-2006, 01:27 PM   #9
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Oh yes. You did say that, didn't you:
Quote:
Right now the whole logical volume is 334G.
I don't know how I missed that. I made an incorrect assumption and started off down the wrong path. I do that a lot!

First you will need to reduce your filesystem. Then reduce the LV with lvreduce. Then maybe do some pvmove-ing (here's where you can check if it's needed with pvdisplay!) And finally a vgreduce and a pvremove.

The big "if" in all this is the "reduce your filesystem" part. Some filesystems simply do not support reducing. I don't think XFS or JFS can be reduced, but I may be wrong. EXT2/EXT3 can be reduced (use the resize2fs command). I have personally never attempted to reduce a filesystem, only grow them. So I'm not experienced in the procedure. It would seem that if data were scattered all around the filesystem you'd need to defrag it before reducing it. Maybe resize2fs does this automatically, but I don't know.

I wouldn't want to attempt this personally without having a backup on hand. But with a 334Gb LV, that's going to be one heckuva big backup! Even if only 119Gb of that is used, that's still quite a chunk of data. Maybe you could backup only the really really critical files and then go for the resize2fs and pray!

Wait - you have a new 250Gb harddisk. Backup to THAT! Then do all your reducing and if that works out for you, just reformat the 250Gb backup disk and add it to the VG. If the reducing clobbers things, restore from your 250Gb drive.

[edit]
p.s. - I suppose you could backup everything to that new drive, verify it!, and then trash your two original drives and recreate the LVM from scratch on only the original 250Gb disk. Restore from the 250Gb backup disk (it should easily fit with only 119Gb used). Then reformat and add the 250Gb to the volume group. Personally, I wouldn't add this new disk to the volume group until you need the space. Just leave it sitting there unused. That way you avoid a situation similar to the one you're in right now!
[/edit]

[2nd edit]
Even better: Treat your current disks AS THE BACKUP. Recreate LVM from scratch on your new 250Gb and then restore data from your original disks, freeing them up to do with as you please.
[/2nd edit]

Last edited by haertig; 02-21-2006 at 01:34 PM.
 
Old 02-21-2006, 02:09 PM   #10
daveschile
LQ Newbie
 
Registered: Jan 2004
Posts: 17

Original Poster
Rep: Reputation: 0
Haertig,

Thanks for that. The thing I was concerned about was creating the new Physical Volume in a different place (ide location) then where I plan to keep it permanently. I've learned through the linux-lvm mailing lists that it doesn't matter since LVM keeps track of the drives via the uuid.

I appreciate your backup solutions, but since the disk I plan to keep in the machine (/dev/hda) also contains the root filesystem and boot sectors, and these are not LVM'ed I think I might run into problems with that.

Thanks again.

Dave Schile
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors with software after replacing CD drive opus Mandriva 4 01-04-2006 06:35 PM
Replacing floppy with flash drive for dual boot jogger Linux - General 1 03-22-2005 10:53 AM
replacing scsi hard drive xushi Linux - Hardware 2 11-13-2004 09:58 AM
Replacing old CDR drive -- New burner doesn't work KingofBLASH Slackware 2 03-24-2004 04:32 PM
Replacing Hard Drive Dallam Linux - Software 1 01-01-2002 09:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration