LVM 分区扩容

本贴最后更新于 2182 天前,其中的信息可能已经时异事殊

一.当前分区

``` [root@Linkdood ~]# df -Ph Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_linkdood-LogVol00 48G 3.6G 42G 8% / tmpfs 16G 80K 16G 1% /dev/shm /dev/sda1 190M 41M 140M 23% /boot /dev/mapper/vg_linkdood-LogVol01 92G 60M 87G 1% /data ```

二.创建分区

1.新增磁盘

``` [root@Linkdood ~]# fdisk -l ... Disk /dev/sdb: 1099.5 GB, 1099511627776 bytes 255 heads, 63 sectors/track, 133674 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 ``` ****手动刷新磁盘**** ``` [root@Linkdood ~]# ls /sys/class/scsi_host/ host0 host1 host2

[root@Linkdood ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@Linkdood ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@Linkdood ~]# echo "- - -" > /sys/class/scsi_host/host2/scan

### 2.创建分区
<font size=4>

[root@Linkdood ~]# fdisk /dev/sdb

Command (m for help): 'n'
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): '1'
First cylinder (1-133674, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-133674, default 133674):
Using default value 133674

Command (m for help): 'w'
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

</font>

### 3.查看新分区
<font size=4>

[root@Linkdood ~]# fdisk -l|grep /dev/sdb
Disk /dev/sdb: 1099.5 GB, 1099511627776 bytes
/dev/sdb1 1 133674 1073736373+ 83 Linux

</font>


## 三.LVM拓展
### 1.创建PV
<font size=4>

'创建 PV'
[root@Linkdood ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created

'查询 PV'
[root@Linkdood ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name vg_linkdood
PV Size 141.80 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 36301
Free PE 0
Allocated PE 36301
PV UUID m9B3Mg-96It-sxLG-CM2v-NXFD-1iCL-pPEfAd

"/dev/sdb1" is a new physical volume of "1023.99 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 1023.99 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID v7X8gF-PQAJ-aNxw-6csx-s0Vd-BYDY-mU3iCc

</font>

### 2.扩展VG
<font size=4>

'查询 VG'
[root@Linkdood ~]# vgdisplay
--- Volume group ---
VG Name vg_linkdood
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size '141.80 GiB'
PE Size 4.00 MiB
Total PE 36301
Alloc PE / Size 36301 / 141.80 GiB
Free PE / Size 0 / 0
VG UUID 3XCgTR-3nX1-ZUbt-sM86-rop2-Rg2n-yAPtfy

'扩展 VG'
[root@Linkdood ~]# vgextend vg_linkdood /dev/sdb1
Volume group "vg_linkdood" successfully extended

'查询 VG'
[root@Linkdood ~]# vgdisplay
--- Volume group ---
VG Name vg_linkdood
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 '1.14 TiB'
PE Size 4.00 MiB
Total PE 298443
Alloc PE / Size 36301 / 141.80 GiB
Free PE / Size 262142 / 1023.99 GiB
VG UUID 3XCgTR-3nX1-ZUbt-sM86-rop2-Rg2n-yAPtfy

</font>

### 3.LV扩容
<font size=4>

'查询 LV'
[root@Linkdood ~]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_linkdood/LogVol01
LV Name LogVol01
VG Name vg_linkdood
LV UUID kZzmkt-rmzD-GgI9-Xu1I-KlUs-unPc-pCRfBu
LV Write Access read/write
LV Creation host, time Linkdood, 2017-12-12 10:04:26 +0800
LV Status available

open 1

LV Size '92.97 GiB'
Current LE 23801
Segments 1
Allocation inherit
Read ahead sectors auto

  • currently set to 256
    Block device 253:1

--- Logical volume ---
LV Path /dev/vg_linkdood/LogVol00
LV Name LogVol00
VG Name vg_linkdood
LV UUID PNu3LK-UwqQ-bb7Y-NM5m-iyBP-X16E-Xbpafb
LV Write Access read/write
LV Creation host, time Linkdood, 2017-12-12 10:04:40 +0800
LV Status available

open 1

LV Size 48.83 GiB
Current LE 12500
Segments 1
Allocation inherit
Read ahead sectors auto

  • currently set to 256
    Block device 253:0

'LV 扩容'
[root@Linkdood ~]# lvextend -L +1023.99G /dev/mapper/vg_linkdood-LogVol01
Rounding size to boundary between physical extents: 1023.99 GiB.
Size of logical volume vg_linkdood/LogVol01 changed from 92.97 GiB (23801 extents) to 1.09 TiB (285943 extents).
Logical volume LogVol01 successfully resized.

'LV 刷新'
[root@Linkdood ~]# resize2fs /dev/mapper/vg_linkdood-LogVol01
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_linkdood-LogVol01 is mounted on /data; on-line resizing required
old desc_blocks = 6, new_desc_blocks = 70
Performing an on-line resize of /dev/mapper/vg_linkdood-LogVol01 to 292805632 (4k) blocks.
The filesystem on /dev/mapper/vg_linkdood-LogVol01 is now 292805632 blocks long.

</font>

## 四.分区查看
<font size=4>

[root@Linkdood ~]# df -Ph
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_linkdood-LogVol00 48G 3.6G 42G 8% /
tmpfs 16G 80K 16G 1% /dev/shm
/dev/sda1 190M 41M 140M 23% /boot
/dev/mapper/vg_linkdood-LogVol01 1.1T 71M 1.1T 1% /data

</font>
  • Linux

    Linux 是一套免费使用和自由传播的类 Unix 操作系统,是一个基于 POSIX 和 Unix 的多用户、多任务、支持多线程和多 CPU 的操作系统。它能运行主要的 Unix 工具软件、应用程序和网络协议,并支持 32 位和 64 位硬件。Linux 继承了 Unix 以网络为核心的设计思想,是一个性能稳定的多用户网络操作系统。

    943 引用 • 943 回帖

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...