Chinaunix首页 | 论坛 | 博客

qsh

  • 博客访问: 4036845
  • 博文数量: 1015
  • 博客积分: 15904
  • 博客等级: 上将
  • 技术积分: 8572
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-04 19:16
文章分类

全部博文(1015)

文章存档

2019年(1)

2017年(1)

2016年(19)

2015年(27)

2014年(30)

2013年(95)

2012年(199)

2011年(72)

2010年(109)

2009年(166)

2008年(296)

分类: LINUX

2013-06-11 22:26:30


Increase the size of an LVM logical volume

Content

Tested on

Debian (Etch, Lenny, Squeeze)
Fedora (14)
Ubuntu (Hardy, Intrepid, Jaunty, Karmic, Lucid, Maverick, Natty)

Objective

To increase the size of an existing LVM logical volume

Background

Be aware that extending a logical volume does not by itself let you to store more files in a filesystem located on that volume. If that is your aim then you will need to:

  1. increase the size of the underlying block device (the logical volume), then
  2. increase the size of the filesystem to fill the block device.

These instructions cover the first step only. The method for the second step will depend on the type of filesystem (and in some cases there will be no practicable method). See below for further information.

Scenario

Suppose that /dev/vg0/foo is a logical volume of size 80GB. You wish to increase its size by 40GB to 120GB.

Method

A logical volume can be extended using the lvextend command. You can specify either the amount by which you want to increase the size of the volume:

lvextend --size +40G /dev/vg0/foo

or the final size that you want to achieve:

lvextend --size 120G /dev/vg0/foo

If successful you should see a response of the form:

  Extending logical volume foo to 8.00 GB
  Logical volume foo successfully resized

Testing

Verify the new size of the logical volume using the lvdisplay command:

lvdisplay /dev/vg0/foo

This should give a response of the form:

 --- Logical volume ---
  LV Name                /dev/vg0/foo
  VG Name                vg0
  LV UUID                w2q9ZN-hKnN-CLGf-6Z5g-e1QZ-DCKX-1DYZvR
  LV Write Access        read/write
  LV Status              available
  # open                 0  LV Size                120.00 GB  Current LE             30720
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:85 

You should not at this stage expect to see any increase in the amount of usable space within whatever filesystem located on the logical volume, for example, as reported by the df command: it is only the size of the underlying block device that has been changed.

Next steps

If the logical volume contains a filesystem then you will probably now want to extend it to fill the newly available space. Filesystems that can be extended include ext2, ext3, ext4, jfs, reiserfs and xfs. See:

  • .

Some filesystems cannot be extended, either because their design makes this impracticable or because the necessary software has not been written. In that case your only option is to move the files somewhere else, then recreate the filesystem, then move the files back.

Troubleshooting

See .

Alternatives

lvresize

An alternative to lvextend is to use the lvresize command:

lvresize --size +40G /dev/vg0/foo

or:

lvresize --size 120G /dev/vg0/foo

The difference is that lvextend can only increase the size of a volume, whereas lvresize can increase or reduce it. This makes lvresize more powerful but more dangerous. If you accidentally reduce the size of a volume without first reducing the size of the filesystem contained within it then the filesystem is likely to be damaged irreparably. For scenarios similar to the one described here, lvextend is recommended because mistakes of this type are not then possible.

See also

阅读(1099) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~