LinuxQuestions.org
Review your favorite Linux distribution.
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 09-06-2011, 10:11 PM   #1
Devyn
Member
 
Registered: Oct 2004
Posts: 98

Rep: Reputation: 15
LVM Question


I've three partitions on /dev/sda: sda1, sda2 sda3. There is FREE space between sda2 and sda3 and sda3 ends on the last sector. sda2 and sda3 have the same number of sectors allocated and so are the exact same size.

/dev/sda2 is already part of the VG VolGroup. However, what puzzles me is that if I do "lvm vgextend /dev/sda3" and check with "lvm pvdisplay", the PV Size for /dev/sda3 is listed as 754.07GiB whereas the PV for /dev/sda2 is listed as 187GiB. I expected /dev/sda3 to be listed as 187GiB. Did the system include the FREE space as well in the vgextend? I'm not able to derive 754.07GiB.

If it included the free space as well, if I did:

"lvm pvmove /dev/sda2 /dev/sda3"

will it move the PV (VG's and LV's) to the start of the FREE region or to the start of /dev/sda3? I expect to the start of the partition /dev/sda3 though I have a doubt based on the actual size repoted for VolGroup on /dev/sda3

Thank You,
 
Old 09-07-2011, 07:56 PM   #2
Devyn
Member
 
Registered: Oct 2004
Posts: 98

Original Poster
Rep: Reputation: 15
Anyone? Is more details needed?
 
Old 09-07-2011, 11:46 PM   #3
tommylovell
Member
 
Registered: Nov 2005
Distribution: Raspbian, Debian, Ubuntu
Posts: 380

Rep: Reputation: 103Reputation: 103
Quote:
sda2 and sda3 have the same number of sectors allocated and so are the exact same size.
You didn't mention, but have they always been the same size? Was /dev/sda3 resized at any point or has it always been 187GiB?
If your answers are 'yes', 'no' and 'its always been 187GiB', I'd say something is amiss.

Quote:
I expected /dev/sda3 to be listed as 187GiB.
I would expect the same. If that's the size of the partition, I would expect the physical volume to be that size (rounded down slightly if required to be a multiple of the PE size).

Quote:
Did the system include the FREE space as well in the vgextend?
I hope not. I've never seen that happen. LVM2 (I hope you are LVM2, and not LVM1) is pretty bullet proof, but like any piece of code, it has had bugs...

Quote:
Originally Posted by Devyn View Post
Anyone? Is more details needed?
Yes. It would help if you posted the output of 'fdisk -l /dev/sda'.

And please post the output of 'pvdisplay', 'vgdisplay' and 'lvdisplay', too. ('pvdisplay --maps' would be even better than just 'pvdisplay'.)

Last edited by tommylovell; 09-07-2011 at 11:48 PM.
 
Old 09-09-2011, 01:53 AM   #4
Devyn
Member
 
Registered: Oct 2004
Posts: 98

Original Poster
Rep: Reputation: 15
More details below:

Code:
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup
  PV Size               187.00 GiB / not usable 1.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              47871
  Free PE               0
  Allocated PE          47871
  PV UUID               AR2cbu-Zlxw-8nR0-423o-20pa-3g3l-Te3gcI
   
  --- Volume group ---
  VG Name               VolGroup
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  41
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               187.00 GiB
  PE Size               4.00 MiB
  Total PE              47871
  Alloc PE / Size       47871 / 187.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               l6D50I-m8tf-2iPJ-ef1R-O9kf-kH2v-7SslkB
   
  --- Logical volume ---
  LV Name                /dev/VolGroup/lv_root
  VG Name                VolGroup
  LV UUID                b3XsIw-JC3l-cIEU-njSP-1NbY-kPaO-gvMJda
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                32.00 GiB
  Current LE             8192
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Name                /dev/VolGroup/lv_swap
  VG Name                VolGroup
  LV UUID                KBdB2L-j1ZS-8iA6-Uilh-43G1-NKxX-eE06FW
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                4.00 GiB
  Current LE             1024
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Name                /dev/VolGroup/LogVol02
  VG Name                VolGroup
  LV UUID                beOzB5-znIO-SD44-bkgr-aT9F-gb6N-9Ayyia
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                151.00 GiB
  Current LE             38655
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
   
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup
  PV Size               187.00 GiB / not usable 1.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              47871
  Free PE               0
  Allocated PE          47871
  PV UUID               AR2cbu-Zlxw-8nR0-423o-20pa-3g3l-Te3gcI
   
  --- Physical Segments ---
  Physical extent 0 to 8191:
    Logical volume      /dev/VolGroup/lv_root
    Logical extents     0 to 8191
  Physical extent 8192 to 9215:
    Logical volume      /dev/VolGroup/lv_swap
    Logical extents     0 to 1023
  Physical extent 9216 to 47870:
    Logical volume      /dev/VolGroup/LogVol02
    Logical extents     0 to 38654
   
Model: ATA WDC WD15EADS-32R (scsi)
Disk /dev/sda: 2930277168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start        End          Size         Type     File system  Flags
 1      63s          409662s      409600s      primary  ext4         boot
 2      409663s      392570943s   392161281s   primary               lvm
        392570944s   2538115886s  2145544943s           Free Space
 3      2538115887s  2930277167s  392161281s   primary               lvm

Disk /dev/sda: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008528d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26       24437   196080640+  8e  Linux LVM
/dev/sda3          157991      182402   196080640+  8e  Linux LVM
VolGroup used to take up the entire physical drive /dev/sda. I resized all the LV's, VG's and ext4 (resize2fs) filesystems on them to 187G in total from 1.5TB in total. To test, ran fsck I booted up to the new setup and everything booted fine from /dev/sda1 and /dev/sda2. I've added /dev/sda3 after that so I can copy everything from /dev/sda2 over to it. Even though the partitions are identical in sector size, when I run lvm pvcreate /dev/sda3 then lvm vgextend /dev/sda3, instead of a size of 187G *2, I get 754G with change, which I don't feel is right.

The reason why I want data and LV's/VG's to move from sda2 to sda3 is to free up space for a new OS install on sda1 and sda2 and still retain the old data in sda3 to mount later on when the new OS setup is complete. I'm running LVM2 from the recovery console of the Scientific Linux distro (which is same as the RHEL 6.1 distro other then some additions by the scientific community.).

Trying to make sense of this.

Thanks,

Last edited by Devyn; 09-09-2011 at 01:54 AM.
 
Old 09-09-2011, 12:51 PM   #5
tommylovell
Member
 
Registered: Nov 2005
Distribution: Raspbian, Debian, Ubuntu
Posts: 380

Rep: Reputation: 103Reputation: 103
Quote:
when I run lvm pvcreate /dev/sda3 then lvm vgextend /dev/sda3, instead of a size of 187G *2, I get 754G with change, which I don't feel is right.
I would agree with you.

The sizes that LVM reports come from the metadata that is written near the beginning of each volume that you've pvcreated. (By default, the metadata is written to every volume in that volume group.)

I would start from scratch with that new PV on /dev/sda3 (although it sounds like you did just that). Do a 'pvremove /dev/sda3', then 'pvcreate /dev/sda3' and 'vgextend VolGroup /dev/sda3' again. I'd be curious what a 'pvs' and 'vgs' would say after that. If a 'pvdisplay /dev/sda3' shows "Total PE" is more than 47871, then there must be a bug and I wouldn't use it or trust it.

Looking at your displays, I'm a little puzzled by where the 745G comes from. The free space is around 1T, not 754G...
 
Old 09-09-2011, 06:50 PM   #6
Devyn
Member
 
Registered: Oct 2004
Posts: 98

Original Poster
Rep: Reputation: 15
Did just that:

lvm pvremove /dev/sda3
lvm pvcreate /dev/sda3
lvm vgextend VolGroup /dev/sda3

then the following:

lvm pvdisplay
lvm vgdisplay
lvm lvdisplay
lvm pvs
lvm vgs


Code:
# cat /root/extended.txt 
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup
  PV Size               187.00 GiB / not usable 1.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              47871
  Free PE               0
  Allocated PE          47871
  PV UUID               AR2cbu-Zlxw-8nR0-423o-20pa-3g3l-Te3gcI
   
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               VolGroup
  PV Size               754.07 GiB / not usable 2.37 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              193042
  Free PE               193042
  Allocated PE          0
  PV UUID               x0O0xW-TAXH-Vrz2-g299-pJm6-Mj5g-srkOBH
   
  --- Volume group ---
  VG Name               VolGroup
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  42
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               941.07 GiB
  PE Size               4.00 MiB
  Total PE              240913
  Alloc PE / Size       47871 / 187.00 GiB
  Free  PE / Size       193042 / 754.07 GiB
  VG UUID               l6D50I-m8tf-2iPJ-ef1R-O9kf-kH2v-7SslkB
   
  --- Logical volume ---
  LV Name                /dev/VolGroup/lv_root
  VG Name                VolGroup
  LV UUID                b3XsIw-JC3l-cIEU-njSP-1NbY-kPaO-gvMJda
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                32.00 GiB
  Current LE             8192
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Name                /dev/VolGroup/lv_swap
  VG Name                VolGroup
  LV UUID                KBdB2L-j1ZS-8iA6-Uilh-43G1-NKxX-eE06FW
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                4.00 GiB
  Current LE             1024
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Name                /dev/VolGroup/LogVol02
  VG Name                VolGroup
  LV UUID                beOzB5-znIO-SD44-bkgr-aT9F-gb6N-9Ayyia
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                151.00 GiB
  Current LE             38655
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
   
  PV         VG       Fmt  Attr PSize   PFree  
  /dev/sda2  VolGroup lvm2 a-   187.00g      0 
  /dev/sda3  VolGroup lvm2 a-   754.07g 754.07g
  VG       #PV #LV #SN Attr   VSize   VFree  
  VolGroup   2   3   0 wz--n- 941.07g 754.07g

Aside from the LVM in SL, I've a number of other options here. I've PXE booted SL 6.1 (Which is an RHEL clone) to get to this recovery console from where I'm running the commands. The partitioning was originally done with the LVM from F12 if I recall correctly, but nothing earlier. But the VolGroup that was created by the F12 LVM is already resized successfully per the details I posted above. I've a number of other distro's I can boot through PXE, all configured, including F14. I might try the other distro's with a more recent/stable LVM.

Would definitely welcome any suggestions or recommendations in regards to which distro currently, has the most stable / recent LVM version and I'll boot that over PXE. That is, if the LVM with SL is considered erronous.

Thanks,
 
Old 09-09-2011, 11:41 PM   #7
tommylovell
Member
 
Registered: Nov 2005
Distribution: Raspbian, Debian, Ubuntu
Posts: 380

Rep: Reputation: 103Reputation: 103
Well, this is really perplexing. I have no idea how it could get into the state it is in now.

But, I WOULD NOT USE IT AS IT IS NOW!!!! A 'pvmove' would probably succeed if all of the PE's assigned were phyically on the partition, but you are really tempting fate if you did. You have, as they say, an accident waiting to happen.

What I would suggest would be to remove it from the VG
Code:
vgreduce /dev/sda3
Then
Code:
pvresize -v --setphysicalvolumesize 187G /dev/sda3
Doing it with --test first would allow you to see if 187G is the right value to use to get 47871 extents exactly,
like,
Code:
pvresize --test -v --setphysicalvolumesize 187G /dev/sda3
Once the number of PE's is correct in that PV, then you can reextend your VG.

I would strongly advise you to get a good backup of your data before you proceed if it is of any importance to you.

I can't help with a suggestion on a distro. I've been using RHEL and Fedora for a few years now with no problems migrating from release to release; but I've also used LVM on Ubuntu without incident.

Last edited by tommylovell; 09-09-2011 at 11:46 PM.
 
  


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
LVM question TheR_ Linux - Server 1 02-03-2010 01:33 PM
LVM question sang_froid Linux - General 2 03-10-2009 10:25 AM
LVM question tom.bokman@mcwa.com Linux - Server 3 02-20-2008 02:19 PM
Question about LVM Torr Linux - General 1 05-28-2006 07:36 AM
question about LVM an2ny_18 Linux - Software 3 03-12-2006 04:35 AM

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

All times are GMT -5. The time now is 08:50 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