linux文件系统ext4扩容,文件系统为EXT4的LVM如何在线扩容及缩减?

a4c26d1e5885305701be709a3d33442f.png

Figure A shows a file system mounted on /db01.

Currently it is at 95% usage. If more space is requested, then the

options are to either add another file system or to grow the

existing file system. Suppose the request is for 1GB to be added to

the file system. The first step is to run vgdisplay on the volume

group to determine how many physical extents are free and what the

size of the physical extents is.

Figure B is the output from running vgdisplay

with no options. The number of free extents is given in the second

last line of output. In this case there are 3310 free physical

extents. The PE size is also listed and is set at 4MB. The PE size

is set when the volume group is created.

Figure B

a4c26d1e5885305701be709a3d33442f.png

Figure C is the extra output from running

vgdisplay -v. It shows that the logical volume db01 is using 256

extents. Growing db01 to 2GB would take another 256 extents: well

within the number of free extents.

Figure C

a4c26d1e5885305701be709a3d33442f.png

The process of growing a file system consists of two parts. The

first part is to grow the logical volume, whilst the second part is

to grow the file system. It is possible to grow a logical volume

online; however, earlier file system types were not able to be

resized online. Growing the file system required the file system to

be un-mounted. This example uses ext4 file systems which can be

resized when mounted.

The command used to extend a logical volume is called lvextend.

There are a few options that can be used with this command. The

main ones used are -L, where the size can be specified in

Megabytes, Gigabytes, Terabytes, Petabytes or Exabytes and -l,

where the size can be specified in extents. Using a ‘+’ sign in

front of the extents or size means that the logical volume is to be

grown by the specified size or by the specified number of extents.

Omitting the ‘+’ means grow the logical volume to the specified

size.

For example, typing in

lvextend -L +1024M /dev/vg01/db01

means grow the logical volume another 1024 Megabytes.

Typing in

lvextend -L 2048M /dev/vg01/db01

will extend the logical volume size up to 2048 Megabytes. For the

purpose of this example, the two commands shown produce the same

result: the logical volume is grown to 2048 Megabytes in size.

Figure D shows the command string used in this

example. The -v option is for verbose output.

Figure D

a4c26d1e5885305701be709a3d33442f.png

The extension of the logical volume can be verified by running

lvdisplay as shown in Figure E

Figure E

a4c26d1e5885305701be709a3d33442f.png

The logical volume is now 2GB. The next step is to use fsadm to

grow the file system online. For this example, fsadm is run with

the options shown in Figure F. Note that if the size is omitted,

fsadm will grow the file system up to the same amount occupied by

the logical volume. Again, the -v option is for verbose and can be

omitted.

Figure F

a4c26d1e5885305701be709a3d33442f.png

After running fsadm, run a df -kl on the file system; it will

have grown to the new size, as can be seen in Figure

G.

Figure G

In summary, LVM and fsadm can be used to grow ext4 file systems

without incurring an outage. For Linux, this is a substantial

feature, as it allows highly critical applications to keep running

even when the underlying file system is being expanded.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值