LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-25-2011, 06:40 PM   #1
XRayden
LQ Newbie
 
Registered: Sep 2011
Location: Quebec, Qc, Canada
Distribution: CentOS
Posts: 10

Rep: Reputation: Disabled
LVM2 resize problems


I post this in the newbie section because I now feels like a total noob on this.

I got a little internal server with a lamp+svn for webdev and bind to permit the use of domains name inside our organisation..

It was time to upgrade the HDD because it was too small (80G)
and we took a 1To HDD from another system to upgrade the small server.

i've never upgraded a linux in this maner, but as for any other os normaly you clone, than expand the partition.

Problem is, our little Centos 5.6 (basic, basic install) created a /Boot and a LVM2 partition (I presume it contain the swap and main)

I could not, in 3 days work, extend the partition...

GParted is useless, any liveCD we have (Ubuntu, fedora, centos6!) wont work properly withg LVM2....

how... how???? I'm still pounding my head on the floor for this... the system works... but with 80 Go out of 1To of the drive!!!!!!

if you search "grow lvm2 centos" on google it's useless... there is about 30 differents ppl in the first page saying about 30 different way to do this...

NONE OF WITCH say how to grow YOUR OWN LVM2 when in use (because no LiveCD work with this) and as for the doc on centos site, they say :
- dont grow your partition when mounted (hard to do with our own)
- please use LVM partition manager (WITCH IS NOT ON THE LIVE CD!!!!!)


I even tried installing a new centos on another hard drive, loading the new drive as slave... you know what it did? NOTHING... it said that there is already a VolGroup01 LVM2 and cannot load or touch the other... and how many manual explain the process of this ? none in the first 35 pages of the google search i've done...

sorry if I sound frustrated... but I am a little!

I want my HDD witch run fine, to extend it's LVM2 partition to the rest of the disk...

and BTW, lvextend -L +900G /dev/VolGroup00 say I can't...

but... maybe I do not understand how it work, but any website that does only explains it in the scientific method!
 
Old 09-25-2011, 07:09 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi there,

Welcome to LQ!!!

Here is the brief idea how LVM works:

1. You create a physical volume. A physical volume can be a device or a partition.
2. You create LV group.
3. Create logical volumes in LV group.

In your case as I can understand you want to add the physical volume or device to this existing group. Once done you want to increase your existing lv over to new device. This can be done: Running e2fsck and then lvresize.

If could let us know the output of the following commands then it will be easier for us to guide you on this:

1. df -h
2. fdisk -l
3. pvdisplay
4. vgdisplay
5. ldvdisplay
 
Old 09-25-2011, 08:01 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,139

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
Another LVM resize question. No help in the "Similar threads" below ?.
As I suggested in the other thread, there is a good howto on tldp.org.

If you can fit both disks in the box, that would be best - simply add the new disk to LVM, and grow your filesystem(s). It's what LVM was designed to do. In your case you'll need to delete that image you put on the new disk first. Because of the issue you've already noted - same named entities. Can occur outside of LVM as well, but you really have to try hard. With standard Redhat (CentOS) installs, happens all the time.

To work on LVM, it's usually easiest to use the appropriate install disk in rescue mode. That way you'll get the LVM toolset and entity names (like lv's) known. here is the Redhat doco - note that it is linked from the CentOS site.
From there you should be able to do all you need.
 
1 members found this post helpful.
Old 09-26-2011, 07:56 AM   #4
XRayden
LQ Newbie
 
Registered: Sep 2011
Location: Quebec, Qc, Canada
Distribution: CentOS
Posts: 10

Original Poster
Rep: Reputation: Disabled
I think I maybe out of my league here or something is wrong

when running pvdisplay i get :


--- Physical volume ---
PV Name /dev/hda2
VG Name VolGroup00
PV Size 27.85 GB / not usable 9.65 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 891
Free PE 0
Allocated PE 891
PV UUID MjfZwr-45KZ-u9mz-lMel-lP2L-FU9a-4X3XOB

/dev/hda is a 320 G HDD, how to get the PV to see the rest of this hard drive so I can just lvextend -L290G /dev/VolGroup00/LogVol00 ?
because it will always say there is no more space....
 
Old 09-26-2011, 10:54 PM   #5
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Quote:
--- Physical volume ---
PV Name /dev/hda2
VG Name VolGroup00
PV Size 27.85 GB / not usable 9.65 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 891
Free PE 0
Allocated PE 891
PV UUID MjfZwr-45KZ-u9mz-lMel-lP2L-FU9a-4X3XOB
From the above output I can see that PV /dev/hda2 is added to VG VolGroup00. As you said that /dev/hda is a 320G HDD. As I am not aware about the partition table on /dev/hda I would be able to suggest much.

However, the procedure will be to:

1. Create a new partition lets say of 50G on your device.
2. Using pvcreate make that partition available as physical volume.
3. Using vgextend add that pv to this VG (VolGroup00)
4. Run e2fsck on this lv.
5. Using lvresize extend your lv.

Remember you have make the PV first available to VolGroup00 using vgextend and then only you will be able extend the size of lv.

Last edited by T3RM1NVT0R; 09-27-2011 at 02:08 AM.
 
Old 09-27-2011, 02:03 AM   #6
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Smile

Well if you have 320GB of HD space in /dev/hda then you can easily extend your logical volume size.

Just use this command:

#lvresize -L 290GB /dev/VolGrp00/LogVol00

check your file system if you can see the changed size of you new logical volume

#df -h

If you don't see any changes then

#resize2fs -f -p /dev/VolGrp00/LogVol00

then check

#df -h

BEST OF LUCK :-)
 
1 members found this post helpful.
Old 09-27-2011, 02:24 AM   #7
Chenchu
Member
 
Registered: Nov 2009
Location: Mars
Distribution: CentOS
Posts: 50

Rep: Reputation: 20
/dev/hda is your HD, /dev/hda2 is a PARTITION. it makes sense that this partition will be smaller than the size of the whole HD.

post here the output of; fdisk -cul

now when you plug in a new drive, see if you recognize it with fdisk -cul
if you do, do the following:
Code:
fdisk /dev/your-new-hd
Command (m for help): n           # to create a new partition
Command action
   e   extended
   p   primary partition (1-4)
e
Selected partition 4
First cylinder (653-1044, default 653): 
Using default value 653
Last cylinder or +size or +sizeM or +sizeK (653-1044, default 1044): 
Using default value 1044

Command (m for help): t                        # to change the PARTITION TYPE
Partition number (1-6): 4
Hex code (type L to list codes): 8e            # 8e is the code of LVM
Changed system type of partition 5 to 8e (Linux LVM)

Command (m for help): w                        # write your changes
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
now you prepered the disk to be working as LVM
next, you need to set the lvm:
Code:
pvcreate /dev/your-hd
vgextend vg-group /dev/your-hd
lvcreate -L SIZEG/M/B -n NAME-OF-LV VG-NAME
now you are done prepering your LVM. from here, you need to build a fstable (mkfs, mke2fs..) and then you'll have a ready partition to use with your exisitng LVM.
 
Old 10-08-2011, 12:50 PM   #8
XRayden
LQ Newbie
 
Registered: Sep 2011
Location: Quebec, Qc, Canada
Distribution: CentOS
Posts: 10

Original Poster
Rep: Reputation: Disabled
The more I try, i feel stupider!

I worked with Centos for the last 4 years and never got that kind of problems...

And BTW, i do not want to extend the lvm to the new hd

i want to transfert the install to the new hd and take the old 40G hd to his death (it sound like a screeching buzzsaw)

I already DD'ed to the 320G, and UNFORTUNETLY we has to work with it for the past week, so backing down now is not an option.

i tried: creating new PV and extended : failed

I deleted all and reduced the lv back

tried Chenchu's solution
blocked at the change of partition type (said i cannot change extended to primary and vice-versa) but already made it in extended (type e) ?

here more infos... if you have any ideas...

df -h
Code:
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       27G  3.1G   22G  13% /
/dev/hda1              99M   19M   76M  20% /boot
tmpfs                 252M     0  252M   0% /dev/shm
fdisk -l
Code:
Disk /dev/hda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        3649    29206170   8e  Linux LVM
pvdisplay
Code:
  --- Physical volume ---
  PV Name               /dev/hda2
  VG Name               VolGroup00
  PV Size               27.85 GB / not usable 9.65 MB
  Allocatable           yes
  PE Size (KByte)       32768
  Total PE              891
  Free PE               32
  Allocated PE          859
  PV UUID               MjfZwr-45KZ-u9mz-lMel-lP2L-FU9a-4X3XOB
vgdisplay
Code:
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               27.84 GB
  PE Size               32.00 MB
  Total PE              891
  Alloc PE / Size       859 / 26.84 GB
  Free  PE / Size       32 / 1.00 GB
  VG UUID               dOKvUM-vv4v-V2OQ-omKn-Zqtl-WX4u-Tj3OfD
lvdisplay

Code:
--- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                DPIXRN-411Z-O9pW-Ov1I-gJtw-98vp-c0XZiw
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                26.84 GB
  Current LE             859
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
 
Old 10-08-2011, 11:42 PM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,139

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
Quote:
Originally Posted by XRayden View Post
i tried: creating new PV and extended : failed
Explain - in (extreme) detail.

What part of the suggestion in post #5 didn't work ?. In detail ...
 
Old 10-09-2011, 07:22 PM   #10
XRayden
LQ Newbie
 
Registered: Sep 2011
Location: Quebec, Qc, Canada
Distribution: CentOS
Posts: 10

Original Poster
Rep: Reputation: Disabled
Ok, let's retry

at first, I fdisk a new partition
Code:
[root@serveur ~]# fdisk /dev/hda

The number of cylinders for this disk is set to 38913.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (3650-38913, default 3650):
Using default value 3650
Last cylinder or +size or +sizeM or +sizeK (3650-38913, default 38913):
Using default value 38913

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@serveur ~]# reboot
and reboot

now fdisk -l give
Code:
Disk /dev/hda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        3649    29206170   8e  Linux LVM
/dev/hda3            3650       38913   283258080   83  Linux
now with pvcreate
Code:
pvcreate /dev/hda3
  Physical volume "/dev/hda3" successfully created
Code:
[root@serveur ~]# vgextend /dev/VolGroup00 /dev/hda3
  Volume group "VolGroup00" successfully extended
now i must load the linux debug from cd to be outside the install, BRB
 
Old 10-09-2011, 07:57 PM   #11
XRayden
LQ Newbie
 
Registered: Sep 2011
Location: Quebec, Qc, Canada
Distribution: CentOS
Posts: 10

Original Poster
Rep: Reputation: Disabled
when running
"e2fsck /dev/hda3"
got the "can't find the superblock" error
 
Old 10-09-2011, 10:52 PM   #12
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Well as far as I understand the problem

Quote:
first of all change the type of the partition to 8e (linux LVM)
you created a partition hda3 successfully but you have not assigned inode no. to the partition

After creating the partition you should have run this command

Code:
#mke2fs  -j /dev/hda3

This will assign the inode no. and will mark the entry in superblock

This is the reason when you are trying to do fsck it shows a superblock error.

and I don't have much idea on LVM but you will have to run this command after deleting the physical volume you created so that changes can take affect

Last edited by deep27ak; 10-10-2011 at 12:46 AM.
 
1 members found this post helpful.
Old 10-09-2011, 11:37 PM   #13
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

You do not have to run e2fsck on physical partition but on lvm which is /dev/VolGrp00/LogVol00.

The reason you get that error message because there is no file system defined for /dev/hda3. It is just a partition without any file system.

This is how you have to proceed:

Code:
mkfs.ext3 /dev/hda3
/* Wait!!! This command will depend on the file system in use on your existing lv. If you are using ext4 on your existing lv then run mkfs.ext4 /dev/hda3 instead */

Once done with the above command run e2fsck on your existing LVM which is /dev/VolGrp00/LogVol00

then run,

resize2fs in order to expand your existing lv to this newly created partition.

I hope this helps.

Note: It is always advisable to have good backup without performing any file system changes
 
Old 10-10-2011, 12:43 AM   #14
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,139

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
Nope, nope, nope ...
That just doesn't make sense to mkfs on the new pv, so I decided to test (as I'm not a user of LVM in general).

Do the pvcreate, then add it to the vg (vgextend), then resize the lv (lvextend).
Then simply resize2fs (for ext[234]) the lv name - that will cause the filesystem on that lv to grow to the full extent of the lv. Use parms for particular size if that is what you want (but why ?).
 
1 members found this post helpful.
Old 10-10-2011, 10:21 AM   #15
XRayden
LQ Newbie
 
Registered: Sep 2011
Location: Quebec, Qc, Canada
Distribution: CentOS
Posts: 10

Original Poster
Rep: Reputation: Disabled
ok,

i've change the partition type to 8e
done.

i've resize the lv (lvextend -L +271.12G /dev/VolGroup00/LogVol00)

reseize successfully

now executing resize2fs /dev/VolGroup00/LogVol00 and it seams to be working )))
 
  


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
LXer: What is the procedure to resize an LVM2 logical volume and the ext2 or ext3 fil LXer Syndicated Linux News 0 07-17-2008 03:50 AM
Problems setting up lvm2 drive on ubuntu tomazN Linux - Hardware 0 10-13-2006 09:06 AM
lvm2-resize partiton linuxmandrake Linux - General 1 09-19-2005 12:22 AM
How to resize /usr with resize2fs and LVM2 shadow5277 Red Hat 2 08-15-2005 01:20 AM
Problems compiling LVM2 A.C. Red Hat 0 02-13-2004 11:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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