LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-15-2013, 09:04 AM   #1
Raiyan
LQ Newbie
 
Registered: Feb 2011
Location: China
Posts: 5

Rep: Reputation: 0
pvmove question


Hello

This is not any server in my office, just a virtual machine in my home that is helping me to go through RHCE certification.

I have 2 disks (excluding sda1 + sda2 for RHEL installation), /dev/sdb and /dev/sdc 8G each, 1 vg and 1 lv.

I have found that I can use pvmove /dev/sdb /dev/sdc cmd only when my lv size is less than 8G.

So, if the size of lv is 16G and I want to move all of my data from sdb to sdc (target is to drop the pv sdb from vg), then I need to reduce the size of lv
to less than 8G.

My question is if my total data volume is 4G, then when reducing the size of the lv is it guaranteed that the data will remain intact? if no, then how this thing is accomplished in real world scenario?

Last edited by Raiyan; 04-15-2013 at 09:38 AM.
 
Old 04-15-2013, 10:08 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by Raiyan View Post
I have 2 disks (excluding sda1 + sda2 for RHEL installation), /dev/sdb and /dev/sdc 8G each, 1 vg and 1 lv.

I have found that I can use pvmove /dev/sdb /dev/sdc cmd only when my lv size is less than 8G.
Yes, because sdc is only 8G: you can't put more that 8G on an 8G disk..

Quote:
So, if the size of lv is 16G and I want to move all of my data from sdb to sdc (target is to drop the pv sdb from vg), then I need to reduce the size of lv
to less than 8G.

My question is if my total data volume is 4G, then when reducing the size of the lv is it guaranteed that the data will remain intact?
There are never any guarantees, but in principle it should work. Presumably you need to resize your file system too (before shrinking the lv). Exactly how to do that will depend on what filesystem you are using.
Quote:
if no, then how this thing is accomplished in real world scenario?
In the real world, people (should) make backups of important data.

Evo2.
 
Old 04-16-2013, 07:37 AM   #3
Raiyan
LQ Newbie
 
Registered: Feb 2011
Location: China
Posts: 5

Original Poster
Rep: Reputation: 0
Not clear about resizing the file system, I have only configured pv, vg and lv here. I have formatted the file system as ext4.

Could you please explain the procedure for ext4 file system? If the lv is 16G, then isn't it that the data in it can be anything upto 16G?

Thanks in advance.

BR//R

Last edited by Raiyan; 04-16-2013 at 07:40 AM.
 
Old 04-16-2013, 09:48 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

Quote:
Not clear about resizing the file system, I have only configured pv, vg and lv here. I have formatted the file system as ext4.
Presumably your current ext4 filesystem uses the full 8G of the lv. If you want to shrink the lv, you'll first need to shrink the filesystem. You can use the resize2fs command for this.

Quote:

Could you please explain the procedure for ext4 file system? If the lv is 16G, then isn't it that the data in it can be anything upto 16G?
Sure, and presumably you ext4 filesystem is now 16G using all of the lv, but the point is that you plan to reduce the lv to only 8G, and therefore your filesystem will have to be shrunk so that it will fit on the smaller lv.

So the steps to remove /dev/sdb would be something like..
Code:
umount /mount/point/
e2fsck -f /dev/vg0/lv0
resize2fs /dev/vg0/lv0 4G
lvreduce -L 4G /dev/vg0/lv0
pvmove -b /dev/sdb /dev/sdc # The -b makes this run in the background
# You can watch the status of the pvmove with:
lvs --all --options +devices
# Once you think the pvmove is finished confirm that the disk is not being used 
pvdisplay /dev/sdb
vgreduce vg0 /dev/sdb
pvremove /dev/sdb
Unmounting the filesystem is only for the fsck operation, since ext4 can be resized while mounted, and the lvm operations don't care if the fs is mounted or not.

There are *many* lvm tutorials that describe this sort of process. Have a search and feel free to post back if you have any more questions.

Evo2.
 
1 members found this post helpful.
  


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
LVMs / pvmove phatrik Linux - Server 3 08-18-2012 01:12 PM
pvmove question BFCsaus Linux - Software 3 04-27-2012 02:31 AM
pvmove speed satishfaction Linux - Server 1 01-30-2011 12:12 PM
LVM (pvmove) problem CyberMonk6 Linux - Software 1 11-30-2009 10:48 PM
Logical Volume Management "pvmove" Question jamida Linux - Software 1 02-23-2008 09:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:33 AM.

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