LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Resize existing and add another partition with LVM (http://www.linuxquestions.org/questions/linux-newbie-8/resize-existing-and-add-another-partition-with-lvm-316813/)

donv2 04-24-2005 08:40 PM

Resize existing and add another partition with LVM
 
Hi, I have a situation where I'd like to take a new 120GB disk that has a ~3GB FC3 install on it (transferred from an old disk using g4u) and add storage space to match the total capacity of the drive. The drives info for the system is currently showing as:

Code:

[root@localhost ~]# df -k
Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      3193084  2929852    101032  97% /
/dev/hda1                97570    15494    77038  17% /boot
none                    127972        0    127972  0% /dev/shm
[root@localhost ~]#

Code:

[root@localhost ~]# fdisk -l

Disk /dev/hda: 120.0 GB, 120034123776 bytes
128 heads, 63 sectors/track, 29072 cylinders
Units = cylinders of 8064 * 512 = 4128768 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/hda1  *          1          25      100768+  83  Linux
/dev/hda2              26        969    3806208  8e  Linux LVM
[root@localhost ~]#

<image file for HWBrowser image was here before, URL since removed>

I'd like to expand the storage so that it will have 2 ~55 GB areas (partitions? vol groups?). The first of these would be for normal use by the users/system (extended from the current ~3GB) and the second would be to store periodic 'backups' of the first using 'partimage' or similar.

OK, what I see from df -k seems to be different than what I see if I use 'fdisk -l' or the HW browser. I understand that LVMs are groups of partitions. Is this essentially saying that there is an hda2 partition and that is solely what the LVM (same thing as /dev/mapper/VolGroup00-LogVol00 ?) contains?

If so, how do I expand the hda2 partition to 55GB and add a similarly sized hda3 for backups within the current structure, so that the end result uses effectively the whole disk?

I've spent quite a bit of time with the LVM How-To, etc. but I'm still puzzled for how to do this. I'd appreciate any help to complete this task.

Thanks!
Don

JZL240I-U 04-26-2005 07:57 AM

I'm not quite sure I understand what you want. I guess you might do this:

1. Create those two partitions (2*55 GB or whatever you want) creating one as LVM the other "normal", i.e. Linux.

2. Format them (whatever file type you use).

3. Create a new logical volume in your original Volume group.

4. Resize your logical volumes as needed...

This gives you leeway to enlarge your root (/) as needed. For Backup a single normal partition will do, since it is not anticipated that you can enlarge it. If you want to exchange space between root and Backup, though, you'd better create two logical volumes in the same volume group.

In case you don't know them:

http://www.sistina.com/products_lvm.htm
http://www.suse.de/de/whitepapers/lvm/index.html
http://tldp.org/HOWTO/LVM-HOWTO/

donv2 04-27-2005 01:31 AM

Hi, thanks for the response!

You've pretty much got what I was trying to do. Using your advice and what I could learn from your linked sources (plus http://www.linuxhomenetworking.com/l...m#_Toc92547584), I've done a lot since.

I got a bit carried away with the LVM thing in that I've gone and created a second Volume Group "VolGroup01" with Logical Volume "LogVol01" for use as the back-up area when, as you say, it could have just been a normal partition or I could have just added it as another logical volume to the VolGroup00. Oh well, that part seems to be working OK, anyway.

All I have left to do is finish enlarging the original Volume Group (VolGroup00). I'm now confused/stuck on how to finish this. I think my issues are:

- I need to unmount VolGroup00/LogVol00 before resizing it, to include the file system space added from the PV "/dev/hda3" which is now part of LV "LogVol00". I've done all the below so far in a normal terminal window (nothing affected any files in use). Where VolGroup00 contains the filesystem root "/" (which is always in use?), how do I do the required unmount, resize2fs and mount? Can I just exit to single user mode and do it there?

- I believe the commands I will need to run are:
Code:

umount /dev/VolGroup00/LogVol00/dev/VolGroup00/LogVol00
resize2fs /dev/VolGroup00/LogVol00
mount /dev/VolGroup00/LogVol00 /

Does this look correct?

A run down of what I've done already is below.

Thanks!
Don

Actions taken since last post:
Created two new partitions /dev/hda3 & /dev/hda4 using QTparted. Created as ext3, later changed to type LVM using fdisk. Picking up from there:

First, figure out where we are:
Code:

[root@localhost ~]# fdisk -l

Disk /dev/hda: 120.0 GB, 120034123776 bytes
128 heads, 63 sectors/track, 29072 cylinders
Units = cylinders of 8064 * 512 = 4128768 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/hda1  *          1          25      100768+  83  Linux
/dev/hda2              26        969    3806208  8e  Linux LVM
/dev/hda3            970      14458    54387648  8e  Linux LVM
/dev/hda4          14459      29072    58923648  8e  Linux LVM

Next, create new physical volumes, new volume group, and associated new logical volume:
Code:

[root@localhost ~]# pvcreate /dev/hda3
  Physical volume "/dev/hda3" successfully created
[root@localhost ~]# pvcreate /dev/hda4
  Physical volume "/dev/hda4" successfully created
[root@localhost ~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup00" using metadata type lvm2
[root@localhost ~]# vgdisplay VolGroup00
  --- 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              3.62 GB
  PE Size              32.00 MB
  Total PE              116
  Alloc PE / Size      115 / 3.59 GB
  Free  PE / Size      1 / 32.00 MB
  VG UUID              3D0xJe-q1Bv-JGwN-B41j-10sG-hiOa-DEDQb4

[root@localhost ~]# vgcreate VolGroup01 /dev/hda4
  Volume group "VolGroup01" successfully created
[root@localhost ~]# vgdisplay VolGroup01
  --- Volume group ---
  VG Name              VolGroup01
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                0
  Open LV              0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size              56.19 GB
  PE Size              4.00 MB
  Total PE              14385
  Alloc PE / Size      0 / 0
  Free  PE / Size      14385 / 56.19 GB
  VG UUID              tybcVI-5RZZ-7x7l-2vCZ-ixt0-SD0i-QmSljO

[root@localhost ~]# lvcreate -l 14385 VolGroup01 -n LogVol01
  Logical volume "LogVol01" created
[root@localhost ~]# vgdisplay VolGroup00
  --- 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              3.62 GB
  PE Size              32.00 MB
  Total PE              116
  Alloc PE / Size      115 / 3.59 GB
  Free  PE / Size      1 / 32.00 MB
  VG UUID              3D0xJe-q1Bv-JGwN-B41j-10sG-hiOa-DEDQb4

Extend VolGroup00 to include new physical volume, verify:
Code:

[root@localhost ~]# vgextend VolGroup00 /dev/hda3
  Volume group "VolGroup00" successfully extended
[root@localhost ~]# vgdisplay VolGroup00
  --- Volume group ---
  VG Name              VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                2
  Open LV              2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size              55.47 GB
  PE Size              32.00 MB
  Total PE              1775
  Alloc PE / Size      115 / 3.59 GB
  Free  PE / Size      1660 / 51.88 GB
  VG UUID              3D0xJe-q1Bv-JGwN-B41j-10sG-hiOa-DEDQb4

Finish up with the new VG/LV via formatting it:
Code:

[root@localhost ~]# mkfs -t ext3 /dev/VolGroup01/LogVol01
mke2fs 1.36 (05-Feb-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
7372800 inodes, 14730240 blocks
736512 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=16777216
450 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

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

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

Need to be able to access VolGroup01 through a named mount point, so why not use "/backup" as the name, as it is intended to support backups of the rest of the machine...
Code:

[root@localhost ~]# mkdir /backup
[root@localhost ~]# vi /etc/fstab

used vi to add the following line to fstab:
Code:

/dev/VolGroup01/LogVol01 /backup                ext3    defaults        1 2
and finishing from there, confirming where things are left...
Code:

[root@localhost ~]# mount -a
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      3.1G  2.8G  136M  96% /
/dev/hda1              96M  16M  76M  17% /boot
none                  125M    0  125M  0% /dev/shm
/dev/mapper/VolGroup01-LogVol01
                      56G  85M  53G  1% /backup
[root@localhost ~]# ls /backup
lost+found

[root@localhost ~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup01" using metadata type lvm2
  Found volume group "VolGroup00" using metadata type lvm2

Now all is done except for completing the original resizing of VolGroup00-LogVol00...?

JZL240I-U 04-27-2005 04:23 AM

Looks allright to me. I have to admit, though, that I used LVM only via YAST in my SuSE, which makes it pretty easy, but circumnavigates questions like umounting root ;).

Why don't you try
Code:


umount -a

  and to verify

mount

and see what happens? Alternatively use a live CD and do it from there...


All times are GMT -5. The time now is 07:08 AM.