LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Adding a new Space to LVM ? (https://www.linuxquestions.org/questions/linux-newbie-8/adding-a-new-space-to-lvm-775751/)

your_shadow03 12-15-2009 04:27 AM

Adding a new Space to LVM ?
 
I am in verse to add a new Hard Drive to my Linux Box.
All I have a new Hard Disk added and shown below:
Code:

[root@localhost ~]# fdisk -l

Disk /dev/sda: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          13      104391  83  Linux
/dev/sda2              14        391    3036285  8e  Linux LVM

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Code:

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      2.4G  2.1G  125M  95% /
/dev/sda1              99M  9.5M  85M  11% /boot
none                  125M    0  125M  0% /dev/shm

Code:

[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name              VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                2
  Open LV              2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size              2.88 GB
  PE Size              32.00 MB
  Total PE              92
  Alloc PE / Size      92 / 2.88 GB
  Free  PE / Size      0 / 0
  VG UUID              IQj7ho-fYeh-Le0g-RNvf-dVJ7-7W2i-jmICey

[root@localhost ~]#

How Can I add more space to / partition?

evo2 12-15-2009 04:31 AM

I can never remember how to do that, and always end up googling for a tutorial. Here's one that google presented just now.

http://tldp.org/HOWTO/LVM-HOWTO/recipeadddisk.html

Cheers,

Evo2.

your_shadow03 12-15-2009 04:46 AM

Thanks evo2 that was superb docs.
I followed the link and am now stuck at the resizing point.
Ho can I do it online.
Code:

ADDING A NEW SPACE TO LVM
----------------------------------------------------

[root@localhost ~]# fdisk /dev/sdb

Command (m for help): p

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System

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

Command (m for help): p

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1          37      297171  83  Linux

Command (m for help): n
Command action
  e  extended
  p  primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (38-783, default 38): 37
Value out of range.
First cylinder (38-783, default 38):
Using default value 38
Last cylinder or +size or +sizeM or +sizeK (38-783, default 783): +300

Command (m for help): p

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1          37      297171  83  Linux
/dev/sdb2              38        338    2417782+  83  Linux

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# fdisk /dev/sdb

Command (m for help): p

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1          37      297171  83  Linux
/dev/sdb2              38        338    2417782+  83  Linux

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1          37      297171  8e  Linux LVM
/dev/sdb2              38        338    2417782+  83  Linux

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1          37      297171  8e  Linux LVM
/dev/sdb2              38        338    2417782+  8e  Linux LVM

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]#

[root@localhost ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created
[root@localhost ~]# pvcreate /dev/sdb2
  Physical volume "/dev/sdb2" successfully created
[root@localhost ~]# fdisk -l

Disk /dev/sda: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          13      104391  83  Linux
/dev/sda2              14        391    3036285  8e  Linux LVM

Disk /dev/sdb: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1          37      297171  8e  Linux LVM
/dev/sdb2              38        338    2417782+  8e  Linux LVM
[root@localhost ~]# pvdisplay
  --- Physical volume ---
  PV Name              /dev/sda2
  VG Name              VolGroup00
  PV Size              2.90 GB / not usable 21.12 MB
  Allocatable          yes (but full)
  PE Size (KByte)      32768
  Total PE              92
  Free PE              0
  Allocated PE          92
  PV UUID              3SFLy5-8aup-WXuH-EGj0-V2Zz-jqq1-fqHdtM

  "/dev/sdb1" is a new physical volume of "290.21 MB"
  --- NEW Physical volume ---
  PV Name              /dev/sdb1
  VG Name
  PV Size              290.21 MB
  Allocatable          NO
  PE Size (KByte)      0
  Total PE              0
  Free PE              0
  Allocated PE          0
  PV UUID              1lZhYP-tNoD-2wCL-5IQJ-DOe6-yK1E-eH10fR

  "/dev/sdb2" is a new physical volume of "2.31 GB"
  --- NEW Physical volume ---
  PV Name              /dev/sdb2
  VG Name
  PV Size              2.31 GB
  Allocatable          NO
  PE Size (KByte)      0
  Total PE              0
  Free PE              0
  Allocated PE          0
  PV UUID              EtOdWR-JfG2-l3a9-V6eg-haLY-1jO0-myL80M

[root@localhost ~]#

[root@localhost ~]# vgextend VolGroup00-LogVol00 /dev/sdb1
  Volume group "VolGroup00-LogVol00" not found
[root@localhost ~]# vgextend VolGroup00  /dev/sdb1
  Volume group "VolGroup00" successfully extended
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      2.4G  2.1G  125M  95% /
/dev/sda1              99M  9.5M  85M  11% /boot
none                  125M    0  125M  0% /dev/shm
[root@localhost ~]# vgextend VolGroup00  /dev/sdb2
  Volume group "VolGroup00" successfully extended
[root@localhost ~]# pvscan
  PV /dev/sda2  VG VolGroup00  lvm2 [2.88 GB / 0    free]
  PV /dev/sdb1  VG VolGroup00  lvm2 [288.00 MB / 288.00 MB free]
  PV /dev/sdb2  VG VolGroup00  lvm2 [2.28 GB / 2.28 GB free]
  Total: 3 [5.44 GB] / in use: 3 [5.44 GB] / in no VG: 0 [0  ]
[root@localhost ~]#


your_shadow03 12-15-2009 04:58 AM

I did tried with:
Code:

[root@localhost ~]# lvextend -L+300M /dev/VolGroup00/LogVol00
  Rounding up size to full physical extent 320.00 MB
  Extending logical volume LogVol00 to 2.69 GB
  Logical volume LogVol00 successfully resized
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      2.4G  2.1G  125M  95% /
/dev/sda1              99M  9.5M  85M  11% /boot
none                  125M    0  125M  0% /dev/shm
[root@localhost ~]# fdisk -l

Bot no improvement.
Please help with the same.
I read resize2fs is the command but the command says:

Code:

[root@localhost ~]# resize2fs -f /dev/VolGroup00/LogVol00
resize2fs 1.35 (28-Feb-2004)
/dev/VolGroup00/LogVol00 is mounted; can't resize a mounted filesystem!

I cant unmount the / partition Right?
Whats the Issue here?

syg00 12-15-2009 05:03 AM

Do it from a liveCD.

your_shadow03 12-15-2009 05:07 AM

oops !!!

How to do that?
I never used that?
Any tutorials??

EricTRA 12-15-2009 05:10 AM

Quote:

Originally Posted by your_shadow03 (Post 3792102)
oops !!!

How to do that?
I never used that?
Any tutorials??

Hi,

Here's a very easy to follow step by step guide that covers almost everything you need. http://www.howtoforge.com/linux_lvm

Kind regards,

Eric


All times are GMT -5. The time now is 02:41 AM.