Skip to contentSkip to conversation

I need to convert my root file system to LVM (adding a 2nd disk as well).

linux-lvm Rupert Heesom 2 participants 6 messages Apr 24, 2001 – Apr 26, 2001

lore
Share & tools
lore
#0 lore raw

My current partition config is -

Device Boot Start End Blocks Id System

/dev/sda1   *         1         3     24066   83  Linux
/dev/sda2             4      1116   8940172+   5  Extended
/dev/sda5             4      1099   8803588+  83  Linux
/dev/sda6          1100      1116    136521   82  Linux swap

/dev/sda1 has /boot in it
/dev/sda5 has / in it.

I will be adding a 2nd disk onto the PC (/dev/sdb).

From what I read in the LVM-HOWTO, converting the root file system needs < 1/2 the disk to be full. Mine is > 1/2 full (~70%). Apparantly one can convert the file system to LVM by

1) creating an LVM partition on the 2nd disk, then
2) copying the root files to the LVM partition, then
3) adding the original file system to LVM.

I'm not sure I want to do all that copying, etc. Is it possible to -
1) Convert 2nd disk to LVM
2) extend the LV to the 1st disk.

Signature · 2 lines
regs
rupert
#1 lore raw
Quoted 17 lines · Rupert Heesom

My current partition config is -

Device Boot Start End Blocks Id System

/dev/sda1   *         1         3     24066   83  Linux
/dev/sda2             4      1116   8940172+   5  Extended
/dev/sda5             4      1099   8803588+  83  Linux
/dev/sda6          1100      1116    136521   82  Linux swap

/dev/sda1 has /boot in it
/dev/sda5 has / in it.

I will be adding a 2nd disk onto the PC (/dev/sdb).

Quoted 1 line

From what I read in the LVM-HOWTO, converting the root file system

needs < 1/2 the disk to be full. Mine is > 1/2 full (~70%). Apparantly one can convert the file system to LVM by

Quoted 7 lines

1) creating an LVM partition on the 2nd disk, then
2) copying the root files to the LVM partition, then
3) adding the original file system to LVM.

I'm not sure I want to do all that copying, etc. Is it possible to -
1) Convert 2nd disk to LVM
2) extend the LV to the 1st disk.

Yes you should be able to do that. Follow the instructions in the HOWTO (without shrinking the main disk obviously!) substituting hdb1 for hda4.

When you've got it working you can then make a PV on sda5 and pvmove hdb1 back onto it if you want to keep root on the SCSI disk.

If you're not very familiar with LVM I recommend you have a play with it on the new disk before attempting to convert the root filesystem though.

patrick

#2 lore raw
Quoted 10 lines · Patrick Caulfield

On Tue, Apr 24, 2001 at 11:39:02AM -0400, Rupert Heesom wrote:

Yes you should be able to do that. Follow the instructions in the HOWTO (without shrinking the main disk obviously!) substituting hdb1 for hda4.

When you've got it working you can then make a PV on sda5 and pvmove hdb1 back onto it if you want to keep root on the SCSI disk.

If you're not very familiar with LVM I recommend you have a play with it on the new disk before attempting to convert the root filesystem though.

Thanks, Patrick. Yes, I think I'll have a play with it on the 2nd
disk. I'm not very familiar at all with LVM.

Signature · 2 lines
regs
rupert
#3 lore raw
In reply to Patrick Caulfield
Quoted 3 lines · Patrick Caulfield

On Tue, Apr 24, 2001 at 11:39:02AM -0400, Rupert Heesom wrote:
If you're not very familiar with LVM I recommend you have a play with it on the new disk before attempting to convert the root filesystem though.

I'm playing around with LVM on my 2nd spare disk (/dev/sdb).

The partitions are that disk now are -
/dev/sdb1, /dev/sdb2

I've created Vol Grp "vg" (/dev/vg), and Log Vol "lvol1" (/dev/vg/lvol1).

I'm now trying to take one of the partitions out of the LV. I'm hoping that I can run a command something like lvreduce /dev/sdb2 lvol1 (reduce lvol1 by taking /dev/sdb2 out of the vol), but the only way I can see of
reducing lvol1 is by specifying the Mbs to reduce the LV by. If I do
this (specify the size of /dev/sdb2), how do I know that the LV will give it's space back to /dev/sdb2?
It could easily give space back to /dev/sdb1 as well.

The part in the HOWTO about removing an old disk should help, but it doesn't. It talks about vgextending to add the new disk into the VG, then vgreducing to take the old disk out of the VG.
When I try to "vgreduce vg /dev/sdb2", I'm told that /dev/sdb2 is still active.
How do I de-activate /dev/sdb2?

I think I'm getting the idea of all this slowly, but am still pretty confused overall!!

As I see it, this is the general idea of the software layers handling the disks -

LVM:   LV
LVM:   VG
Disk:   PV

LV: Volume space within a VG which is used by users (usually 1 LV per VG for nice big volumes).

VG:  Group of PVs.
PV:   partitions on disk (1 or more to a disk)
Signature · 2 lines
regs
rupert
#4 lore raw
Quoted 28 lines · Rupert Heesom
Quoted 3 lines · Patrick Caulfield

On Tue, Apr 24, 2001 at 11:39:02AM -0400, Rupert Heesom wrote:
If you're not very familiar with LVM I recommend you have a play with it on the new disk before attempting to convert the root filesystem though.

I'm playing around with LVM on my 2nd spare disk (/dev/sdb).

The partitions are that disk now are -
/dev/sdb1, /dev/sdb2

I've created Vol Grp "vg" (/dev/vg), and Log Vol "lvol1" (/dev/vg/lvol1).

I'm now trying to take one of the partitions out of the LV. I'm hoping that I can run a command something like lvreduce /dev/sdb2 lvol1 (reduce lvol1 by taking /dev/sdb2 out of the vol), but the only way I can see of
reducing lvol1 is by specifying the Mbs to reduce the LV by. If I do
this (specify the size of /dev/sdb2), how do I know that the LV will give it's space back to /dev/sdb2?
It could easily give space back to /dev/sdb1 as well.

The part in the HOWTO about removing an old disk should help, but it doesn't. It talks about vgextending to add the new disk into the VG, then vgreducing to take the old disk out of the VG.
When I try to "vgreduce vg /dev/sdb2", I'm told that /dev/sdb2 is still active.
How do I de-activate /dev/sdb2?

Quoted 2 lines

I think I'm getting the idea of all this slowly, but am still pretty confused overall!!

What you need to do is lvreduce the volume to the size of the PV /dev/sdb1 (which will be slightly smaller than the actual partition), then use pvmove to move the used extents from sdb2 to sdb2. *then* you can vgreduce vg /dev/sdb2.

That might sound a little over-complicated but it's really the more common case in "real world" situations to be LV focussed rather than PV focussed. (I think!)

patrick

#5 lore raw
Quoted 9 lines · Patrick Caulfield
Quoted 2 lines · Rupert Heesom
Quoted 1 line · Patrick Caulfield

On Tue, Apr 24, 2001 at 11:39:02AM -0400, Rupert Heesom wrote:

What you need to do is lvreduce the volume to the size of the PV /dev/sdb1 (which will be slightly smaller than the actual partition), then use pvmove to move the used extents from sdb2 to sdb2. *then* you can vgreduce vg /dev/sdb2.

That might sound a little over-complicated but it's really the more common case in "real world" situations to be LV focussed rather than PV focussed. (I think!)

Thanks, Patrick. I'll try that.

Signature · 2 lines
regs
rupert