[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: lvm and replacing disk



On Thu, Sep 28, 2006 at 10:37:20AM +0200, Turbo Fredriksson wrote:
> >>>>> "Andy" == Andy Smith <andy@lug.org.uk> writes:
> 
>     Andy> Yes.  I'll assue that your first disk is /dev/sda and your
>     Andy> second one is /dev/sdb.
> 
> My current 400Gb is sda (SATA), the 80Gb (that will eventually be
> removed) is hdb and my (soon to arrive - I hope :) will then be
> sdb (also SATA).

Okay, so sda, hdb and sdb.  I'll assume the first partition of each
is your PV, so sda1, hdb1, sdb1.

>     Andy> If your current logical volumes are small enough to all fit
>     Andy> on /dev/sda then all you need to do is:
> 
> sda does NOT have enough space on it. It's already full (hence the 80Gb
> disk). So according to the HOWTO, you just add the new disk to the
> group/volume, move hdb to sdb (with pvmove), then remove hdb using
> (vg,lv)reduce.

- Install sdb

- vgextend vg00 /dev/sdb1

Adds sdb1 to the volume group vg00

- pvmove -v /dev/hdb1

This moves all extents off hdb1 and onto PVs on sda1 and sdb1

- vgreduce -v vg00 /dev/hdb1

Removes hdb1 from the volume group.

>     Andy> you'll need to resize2fs to shrink filesystems
> 
> This part was what I didn't quite understand. Granted, i'm not sure
> how a filesystem actually works (never needed to know :).

You don't need to shrink any filesystems or work on the level of
filesystems at all, if you can have all 3 drives in the machine at
once until pvmove/vgreduce is done.

> Maybe a picture will try to explain how I think/thought it worked.
> 
> 
> Before the move:
> +-------------------------+----------------+-------------------------+
> | sda fs (~380Gb)         | hdb fs (~74Gb) | sdb fs (~380Gb) (empty) |
> +-------------------------+----------------+-------------------------+

I do not think LVM will store its extents linearly so while at the
moment the extents on sda1 may be exhausted and the extents on hdb1
may be partly exhausted, the extents that make up any given file are
likely spread across both sda1 and hdb1.

> After the move:
> +-------------------------+----------------+-------------------------+
> | sda fs (~380Gb)         |                | sdb fs + hdb fs         |
> +-------------------------+----------------+-------------------------+
> 
> Now, if I remove the middle disk, there will be a hole in the middle,
> so I (or resize2fs ?) needs to 'move' the content at the end (sdb+hdb
> data) to directly AFTER the data of sda...

pvmove does this by moving LVM's extents.  This is below filesystem
level.

> +-------------------------+-------------------------+----------------+
> | sda fs (~380Gb)         | sdb fs + hdb fs         | fs hole+nodev  |
> +-------------------------+-------------------------+----------------+
> 
> In this situation, the fs hole can now be safely removed/shrinked/reduced
> by resize2fs...

Do not need to run resizefs.

> Note that at the time sdb arrives, both sda and hdb will be 100% full
> with data...

Hope you have backups.  3 disks = 3 times as likely to lose all your
data.  In your position I would be using the two 400G disks in a
RAID1 then LVM on top of that.

Cheers,
Andy

Attachment: signature.asc
Description: Digital signature


Reply to: