LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 04-24-2005, 08:40 PM   #1
donv2
Member
 
Registered: Nov 2004
Location: Upper right corner of USA
Distribution: Ubuntu/Mint, unSLUng (NSLU2), Arch/PlugApps (Dockstar)
Posts: 50

Rep: Reputation: 15
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

Last edited by donv2; 08-15-2005 at 11:29 PM.
 
Old 04-26-2005, 07:57 AM   #2
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
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/

Last edited by JZL240I-U; 04-27-2005 at 04:14 AM.
 
Old 04-27-2005, 01:31 AM   #3
donv2
Member
 
Registered: Nov 2004
Location: Upper right corner of USA
Distribution: Ubuntu/Mint, unSLUng (NSLU2), Arch/PlugApps (Dockstar)
Posts: 50

Original Poster
Rep: Reputation: 15
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...?

Last edited by donv2; 04-27-2005 at 04:37 PM.
 
Old 04-27-2005, 04:23 AM   #4
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
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...

Last edited by JZL240I-U; 04-27-2005 at 04:25 AM.
 
  


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
resize existing partition w/o losing data rebelscum Slackware 8 07-21-2005 05:44 PM
resize LVM partition bkesting Linux - General 3 06-17-2005 09:28 AM
existing LVM partition won't mount anymore dehuszar Linux - Software 1 09-10-2004 01:26 PM
Resize existing windows ntfs partition in mandrake Stoic Mandriva 8 10-17-2003 11:18 AM
How to add new partition before Linux partition in an existing Linux box? ashutosh Linux - Software 3 04-23-2002 03:26 AM

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

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