linux 磁盘空间扩容,Linux下新添加磁盘启用未使用的硬盘空间扩容LVM

SSH登陆后,查看现有分区、挂载及swap情况:可以看到大概8G的硬盘空间分布情况

1.df -hal

2.free -m

复制代码

[root@XenSystem ~]# df -hal

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

5.7G 1.1G 4.4G 20% /

proc 0 0 0 - /proc

sysfs 0 0 0 - /sys

devpts 0 0 0 - /dev/pts

/dev/xvda1 99M 27M 67M 29% /boot

tmpfs 257M 0 257M 0% /dev/shm

none 0 0 0 - /proc/sys/fs/binfmt_misc

sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs

[root@XenSystem~]# free -m

total

used       free

shared    buffers     cached

Mem:           512

506          5

0

447          9

-/+ buffers/cache:         49

463

Swap:         2079

0       2079

查看硬盘设备列表:

1.fdisk -l

复制代码

Disk /dev/xvdb: 23.6 GB, 23622320128 bytes

255 heads, 63 sectors/track, 2871 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/xvdb doesn't contain a valid partition table

Disk /dev/xvda: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start

End      Blocks

Id  System

/dev/xvda1   *

1          13

104391   83  Linux

/dev/xvda2

14        1044

8281507+  8e  Linux LVM

re硬盘/dev/xvdb尚未划分使用,接下来我们为dev/xvdb分区

1.fdisk

/dev/xvdb

复制代码

[root@XenSystem ~]# fdisk /dev/xvdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF

disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

The number of cylinders for this disk is set to 2871.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by

w(rite)#输入n,新建分区Command (m for help):n#输入P,主分区Command action

e   extended

p   primary partition (1-4)p#目前是xvdb第一个分区输入1Partition number (1-4):1#敲回车,默认就行了First cylinder (1-2871, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-2871, default 2871):

Using default value 2871#这里输入t,指定分区的格式为8e (LVM)Command (m for help):tSelected partition 1

Hex code (type L to list codes):8eChanged system type of partition 1 to 8e

(Linux LVM)#这里输入w,保存退出Command (m for help):wThe partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

重启使其生效

1.reboot

复制代码

重启后,再次运行fdisk -l,可看到我们划分的xvdb1已经生效了

[root@XenSystem]# fdisk -l

Disk /dev/xvdb: 23.6 GB, 23622320128 bytes

255 heads, 63 sectors/track, 2871 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/xvdb1 1 2871 23061276 8e Linux LVM

Disk /dev/xvda: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/xvda1 * 1 13 104391 83 Linux

/dev/xvda2 14 1044 8281507+ 8e Linux LVM

执行vgs查看卷组情况,可以看到只有一个卷组VolGroup00(此名称因系统而异)

1.vgs

复制代码

[root@XenSystem ~]# vgs

VG #PV #LV #SN Attr VSize VFree

VolGroup00 2 2 0 wz--n- 49.84G 0

创建物理卷,并将物理卷加入到组VolGroup00(此名称因系统而异)

1.pvcreate

/dev/xvdb1

2.vgextend

VolGroup00 /dev/xvdb1

复制代码

[root@XenSystem~]# pvcreate /dev/xvdb1

Physical volume "/dev/xvdb1" successfully created

[root@XenSystem~]# vgextend VolGroup00 /dev/xvdb1

Volume group "VolGroup00" successfully extended

执行vgdisplay查看卷组空间情况

1.vgdisplay

复制代码

[root@XenSystem~]# vgdisplay

--- 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

29.84 GB

PE Size

32.00 MB

Total PE

955

Alloc PE / Size       252 / 7.88 GB

Free  PE / Size       703 /21.97GB

VG UUID

jWlke0-R01B-RqBP-Qp1X-xxi0-ltOI-FompAt

可以看到大概有21.97G的空间可以扩充使用,我们将卷组下的卷LogVol00扩容21.96G

1.lvresize -L

+21.96G /dev/VolGroup00/LogVol00

2.resize2fs

/dev/VolGroup00/LogVol00

复制代码

[root@XenSystem~]# lvresize -L +21.96G /dev/VolGroup00/LogVol00

Rounding up size to full physical extent 21.97 GB

Extending logical volume LogVol00 to 27.81 GB

Logical volume LogVol00 successfully resized

[root@XenSystem~]# resize2fs /dev/VolGroup00/LogVol00

resize2fs 1.39 (29-May-2006)

Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing

require d

Performing an on-line resize of /dev/VolGroup00/LogVol00 to 7290880 (4k)

blocks.

The filesystem on /dev/VolGroup00/LogVol00 is now 7290880 blocks long.

运行完成后,我们可以持到相应的空间已经扩展出来可以使用了

[root@XenSystem~]# df -hal

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

27G 1.1G 25G 5% /

proc 0 0 0 - /proc

sysfs 0 0 0 - /sys

devpts 0 0 0 - /dev/pts

/dev/xvda1 99M 27M 67M 29% /boot

tmpfs 257M 0 257M 0% /dev/shm

none 0 0 0 - /proc/sys/fs/binfmt_misc

sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Go语言(也称为Golang)是由Google开发的一种静态强类型、编译型的编程语言。它旨在成为一门简单、高效、安全和并发的编程语言,特别适用于构建高性能的服务器和分布式系统。以下是Go语言的一些主要特点和优势: 简洁性:Go语言的语法简单直观,易于学习和使用。它避免了复杂的语法特性,如继承、重载等,转而采用组合和接口来实现代码的复用和扩展。 高性能:Go语言具有出色的性能,可以媲美C和C++。它使用静态类型系统和编译型语言的优势,能够生成高效的机器码。 并发性:Go语言内置了对并发的支持,通过轻量级的goroutine和channel机制,可以轻松实现并发编程。这使得Go语言在构建高性能的服务器和分布式系统时具有天然的优势。 安全性:Go语言具有强大的类型系统和内存管理机制,能够减少运行时错误和内存泄漏等问题。它还支持编译时检查,可以在编译阶段就发现潜在的问题。 标准库:Go语言的标准库非常丰富,包含了大量的实用功能和工具,如网络编程、文件操作、加密解密等。这使得开发者可以更加专注于业务逻辑的实现,而无需花费太多时间在底层功能的实现上。 跨平台:Go语言支持多种操作系统和平台,包括Windows、Linux、macOS等。它使用统一的构建系统(如Go Modules),可以轻松地跨平台编译和运行代码。 开源和社区支持:Go语言是开源的,具有庞大的社区支持和丰富的资源。开发者可以通过社区获取帮助、分享经验和学习资料。 总之,Go语言是一种简单、高效、安全、并发的编程语言,特别适用于构建高性能的服务器和分布式系统。如果你正在寻找一种易于学习和使用的编程语言,并且需要处理大量的并发请求和数据,那么Go语言可能是一个不错的选择。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值