Visit Our UNIX and Linux User Community


add lvm space from a regular partition

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat add lvm space from a regular partition
# 1  
Old 10-19-2009
add lvm space from a regular partition

Hi,

I have red hat enterprise 4. I would like to add more space on my lvm from the first partition that is not lvm type.

Here's the config
Code:
[root@local ~]# fdisk -l

Disk /dev/sda: 73.4 GB, 73406611456 bytes
255 heads, 63 sectors/track, 8924 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        1033     8193150   82  Linux swap
/dev/sda3            1034        2053     8193150   83  Linux
/dev/sda4            2054        8924    55191307+   5  Extended
/dev/sda5            2054        2563     4096543+  83  Linux
/dev/sda6            2564        3073     4096543+  83  Linux

Disk /dev/sdb: 73.4 GB, 73406611456 bytes
128 heads, 32 sectors/track, 35003 cylinders
Units = cylinders of 4096 * 512 = 2097152 bytes

I want to delete /dev/sda6 and add it to /dev/sdb (lvm). Is that possible? If yes, can you give me the instructions.

Thanks for any comment you may add.

Last edited by pludi; 10-19-2009 at 05:35 PM.. Reason: code tags, please
# 2  
Old 10-19-2009
Of course it's possible. Move away anything residing on /dev/sda6, unmount it, change the partition type to Linux LVM (8e). pvcreate, vgextend, and you're done.

Last edited by pludi; 10-28-2009 at 08:44 AM..
# 3  
Old 10-19-2009
Sorry about that

let me test

sample code:

Code:
ls -la
rm -fr

end testing

thanks again!
# 4  
Old 10-20-2009
Quote:
Originally Posted by itik
Hi,

I have red hat enterprise 4. I would like to add more space on my lvm from the first partition that is not lvm type.

Here's the config
Code:
[root@local ~]# fdisk -l

Disk /dev/sda: 73.4 GB, 73406611456 bytes
255 heads, 63 sectors/track, 8924 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        1033     8193150   82  Linux swap
/dev/sda3            1034        2053     8193150   83  Linux
/dev/sda4            2054        8924    55191307+   5  Extended
/dev/sda5            2054        2563     4096543+  83  Linux
/dev/sda6            2564        3073     4096543+  83  Linux

Disk /dev/sdb: 73.4 GB, 73406611456 bytes
128 heads, 32 sectors/track, 35003 cylinders
Units = cylinders of 4096 * 512 = 2097152 bytes

I want to delete /dev/sda6 and add it to /dev/sdb (lvm). Is that possible? If yes, can you give me the instructions.

Thanks for any comment you may add.
You need using Logical Volume when you use LVM to store your data.
# 5  
Old 10-20-2009
Yes it is possible. The commands you need are

- fdisk (or parted) to change the partition type of /dev/sda6 to 8e (logical partition)
- pvcreate /dev/sda6 to create a new physical volume
- vgextend to add the physical partition to an existing volume group
- lventend to increase the logical volume
- resize2fs to increase the size of the filesystem
# 6  
Old 10-20-2009
I did extend the uservg but the size is not what I expected, look on my code or execution

Code:
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          25      200781   83  Linux
/dev/sda2              26         662     5116702+  83  Linux
/dev/sda3             663        1044     3068415   83  Linux
/dev/sda4            1045        2610    12578895    5  Extended
/dev/sda5            1045        1426     3068383+  83  Linux
/dev/sda6            1427        1808     3068383+  83  Linux
/dev/sda7            1809        1935     1020096   82  Linux swap

Command (m for help): n
First cylinder (1936-2610, default 1936):
Using default value 1936
Last cylinder or +size or +sizeM or +sizeK (1936-2610, default 2610): +2000M

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

Command (m for help): p

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          25      200781   83  Linux
/dev/sda2              26         662     5116702+  83  Linux
/dev/sda3             663        1044     3068415   83  Linux
/dev/sda4            1045        2610    12578895    5  Extended
/dev/sda5            1045        1426     3068383+  83  Linux
/dev/sda6            1427        1808     3068383+  83  Linux
/dev/sda7            1809        1935     1020096   82  Linux swap
/dev/sda8            1936        2179     1959898+  8e  Linux LVM

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@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               uservg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  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               20.00 GB
  PE Size               4.00 MB
  Total PE              5119
  Alloc PE / Size       1280 / 5.00 GB
  Free  PE / Size       3839 / 15.00 GB
  VG UUID               RC3a86-rTJr-lTTC-7jrz-yiH0-B47h-nYKoLB
****15G ====>  uservg

[root@localhost ~]# mkfs.ext3 /dev/sda8
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
123648 inodes, 246991 blocks
12349 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=255852544
8 block groups
32768 blocks per group, 32768 fragments per group
15456 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@localhost ~]# pvcreate /dev/sda8
  Physical volume "/dev/sda8" successfully created

[root@localhost ~]# vgextend uservg /dev/sda8
  /dev/cdrom: open failed: No medium found
  Volume group "uservg" successfully extended

[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               uservg
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               20.94 GB
  PE Size               4.00 MB
  Total PE              5360
  Alloc PE / Size       1280 / 5.00 GB
  Free  PE / Size       4080 / 15.94 GB
  VG UUID               RC3a86-rTJr-lTTC-7jrz-yiH0-B47h-nYKoLB
***not even 1G????????????????????

It only added half of it. Is that suppose to be like that? Thanks.

---------- Post updated at 02:28 PM ---------- Previous update was at 02:16 PM ----------

My mistake, it's really just

Code:
/dev/sda8               972404     17632    905376   2% /second
[root@localhost /]#

When I created to a regular linux partition, no space.. MY BAD!

Last edited by itik; 10-20-2009 at 03:22 PM..
# 7  
Old 10-22-2009
Two comments:

1. You can use the partprobe utility after fdisk to update the kernel partition information.

2. You do not need to create a filesystem before using pvcreate.

Previous Thread | Next Thread
Test Your Knowledge in Computers #324
Difficulty: Medium
The IBM PC used an Intel 8008 microprocessor clocked at 4.77 MHz and 8 kilobytes of memory.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Safe way to shrink lvm vg_*-lv_swap partition and reclaim freed space on Linux?

Hello, # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 1024M 0 rom sda 8:0 0 38.2G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 ... (2 Replies)
Discussion started by: centosadmin
2 Replies

2. Red Hat

Converting Standart partition to LVM

is possible to convert standard partition ext4 to LVM with preserving data? is yes then how? OS is Linux 5 / 6 (1 Reply)
Discussion started by: manoj.solaris
1 Replies

3. Red Hat

LVM based partition

Hi , Background : I am installing the KVM based RHEL OS VM on one of the HP pro-line physical server. Issue: While doing custom layout partition, i want to create partition lvm based , for example :lv_root. But problem is that, whenever i am creating the partition, its showing /sda1... (2 Replies)
Discussion started by: Nats
2 Replies

4. Red Hat

Shrink LVM partition & create new Linux Primary partition

Hello All, I have a Red Hat Linux 5.9 Server installed with one hard disk & 2 Partitions created on it as follows, /boot - Linux Partition & another is LVM - One VG & under that 5-6 Logical volumes(var,opt,home etc). Here my requirement is to take out 1GB of space from LVM ( Any logical... (5 Replies)
Discussion started by: gr8_usk
5 Replies

5. Red Hat

Linux partition with LVM

Hi, I need a suggesstion i have 2 disk if i installed OS / root partition by making Lvm in one disk and data in other disk also with the lvm, means 2 different lvms. Is making LVM partition for OS disk will the performacne will be good? Can i make 2 different lvm one is for OS and other for... (1 Reply)
Discussion started by: Rahulne25
1 Replies

6. Red Hat

Removing encrypted lvm partition

Hi guys, let me start by saying I appreciate your assistance always. I was practicing how to encrypt partitions in my server. I encrypted an lvm partition using luks and when I tried to remove the partition using lvremove, I get this message Logical volume vg10/lvol1 is used by another... (2 Replies)
Discussion started by: cjashu
2 Replies

7. Linux

Creating /boot partition for LVM VG

Hi, I have a server booted into sysresccd (mini-linux OS) with 1 40 GB disk attached I am trying to create a volume group and restore another server into the new one However, when I try to create a partition for /boot it seems that my VG in LVM is not recognized anymore These are the... (2 Replies)
Discussion started by: galuzan
2 Replies

8. UNIX for Dummies Questions & Answers

How to convert non LVM root partition to LVM?

Hi Guys, I m using redhat 6, I have installed root partition as non-LVM . Is there any way i can convert it to LVM? (1 Reply)
Discussion started by: pinga123
1 Replies

9. Red Hat

Increase root partition in LVM

I have a RHEL6 guest running on vmware esx server and the root disk size is 30G and i increased the disk size and create another partition /dev/sda3 but i do not know how to increase the size of the VG and then intrun LV .. can anyone help me on this . fdisk -l /dev/sda Disk /dev/sda:... (1 Reply)
Discussion started by: fugitive
1 Replies

10. UNIX for Dummies Questions & Answers

Need to add aditional space on an exsisting Linux Partition..

Hi, I need to add more space to an exsisting /u partition by adding an additional physical drive, so that the additional space is added in continuation to the exsisting /u diskspace. Is it possible...if yes....how do I go about it. Thanks, Amit (1 Reply)
Discussion started by: amitsayshii
1 Replies

Featured Tech Videos