linux扩根空间lvm,linux VM LVM扩充空间(单盘加空间上限)

[root@gjzq-sh-mb ~]# fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes

64 heads, 32 sectors/track, 51200 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00028dae

Device

Boot Start End Blocks Id System

/dev/sda1 * 2 201 204800 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 202 40960 41737216 8e Linux LVM

Partition 2 does not end on cylinder boundary.

/dev/sda3 40961 51200 10485760 8e Linux LVM

Disk /dev/mapper/VolGroup-lv_swap: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 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

Disk /dev/mapper/VolGroup-lv_root: 49.2 GB, 49174020096

bytes

255 heads, 63 sectors/track, 5978 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@gjzq-sh-mb ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

45G 4.9G 38G 12% /

tmpfs 1.9G 0 1.9G 0%

/dev/shm

/dev/sda1 190M 39M 141M 22% /boot

[root@gjzq-sh-mb ~]# free -m

total used free shared buffers cached

Mem: 3832 306 3525 0 68 78

-/+

buffers/cache: 159 3673

Swap: 4095 0 4095

Vcenter里将单块磁盘的空间从50G增加到65G

下面开始扩展磁盘分区

Reboot

[root@gjzq-sh-mb ~]# fdisk -l

Disk /dev/sda: 69.8 GB, 69793218560 bytes

64 heads, 32 sectors/track, 66560 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00028dae

Device

Boot Start End Blocks Id System

/dev/sda1 * 2 201 204800 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 202 40960 41737216 8e Linux LVM

Partition 2 does not end on cylinder boundary.

/dev/sda3 40961 51200 10485760 8e Linux LVM

Disk /dev/mapper/VolGroup-lv_swap: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 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

Disk /dev/mapper/VolGroup-lv_root: 49.2 GB, 49174020096

bytes

255 heads, 63 sectors/track, 5978 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@gjzq-sh-mb ~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly

recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help): m

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility

flag

d delete a partition

l list known partition

types

m print this menu

n add a new partition

o create a new empty DOS

partition table

p print the partition table

q quit without saving

changes

s create a new empty Sun

disklabel

t change a partition's system

id

u change display/entry

units

v verify the partition

table

w write table to disk and

exit

x extra functionality (experts

only)

Command (m for help): n

e extended

p primary partition (1-4)

p

Selected partition 4

First cylinder (1-66560, default 1): 51201

Last cylinder, +cylinders or +size{K,M,G} (51201-66560, default

66560):

Using default value 66560

Command (m for help): w

The partition table has been altered!

[root@gjzq-sh-mb ~]# fdisk -l

Disk /dev/sda: 69.8 GB, 69793218560 bytes

64 heads, 32 sectors/track, 66560 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00028dae

Device

Boot Start End Blocks Id System

/dev/sda1 * 2 201 204800 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 202 40960 41737216 8e Linux LVM

Partition 2 does not end on cylinder boundary.

/dev/sda3 40961 51200 10485760 8e Linux LVM

/dev/sda4 51201 66560 15728640 83 Linux

Disk /dev/mapper/VolGroup-lv_swap: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 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

Disk /dev/mapper/VolGroup-lv_root: 49.2 GB, 49174020096

bytes

255 heads, 63 sectors/track, 5978 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@gjzq-sh-mb ~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly

recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help): m

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility

flag

d delete a partition

l list known partition

types

m print this menu

n add a new partition

o create a new empty DOS

partition table

p print the partition table

q quit without saving

changes

s create a new empty Sun

disklabel

t change a partition's system

id

u change display/entry

units

v verify the partition

table

w

write table to disk and

exit

x extra functionality (experts

only)

Command (m for help): t

Partition number (1-4): 4

Hex code (type L to list codes): 8e

Changed system type of partition 4 to 8e (Linux LVM)

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16:

Device or resource busy.

The kernel still uses the old table. The new table will be used

at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

[root@gjzq-sh-mb ~]# fdisk -l

Disk /dev/sda: 69.8 GB, 69793218560 bytes

64 heads, 32 sectors/track, 66560 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00028dae

Device

Boot Start End Blocks Id System

/dev/sda1 * 2 201 204800 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 202 40960 41737216 8e Linux LVM

Partition 2 does not end on cylinder boundary.

/dev/sda3 40961 51200 10485760 8e Linux LVM

/dev/sda4 51201 66560 15728640 8e Linux LVM

Disk /dev/mapper/VolGroup-lv_swap: 4294 MB, 4294967296 bytes

255 heads, 63 sectors/track, 522 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

Disk /dev/mapper/VolGroup-lv_root: 49.2 GB, 49174020096

bytes

255 heads, 63 sectors/track, 5978 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

Reboot

添加新LVM到已有的LVM组,实现扩容

[root@gjzq-sh-mb ~]# lvm

lvm> pvcreate /dev/sda4

Physical volume "/dev/sda4" successfully

created

lvm> vgdisplay

--- Volume group ---

VG

Name VolGroup

System

ID

Format lvm2

Metadata

Areas 2

Metadata Sequence No 5

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

PE

Size 4.00 MiB

Total

PE 12748

Alloc PE /

Size 12748 / 49.80 GiB

Free PE /

Size 0 / 0

VG

UUID AvedJh-iwnf-Ln6C-MEq3-0Udc-dGbn-DieZU4

lvm> vgextend VolGroup /dev/sda4

Volume group "VolGroup" successfully extended

lvm> pvdisplay

--- Physical volume ---

PV

Name /dev/sda2

VG

Name VolGroup

PV

Size 39.80 GiB / not usable 3.00 MiB

Allocatable yes (but full)

PE

Size 4.00 MiB

Total

PE 10189

Free

PE 0

Allocated

PE 10189

PV

UUID gIK9kn-BFCx-FHUK-t0wx-th3F-Qepp-cY65b0

--- Physical volume ---

PV

Name /dev/sda3

VG

Name VolGroup

PV

Size 10.00 GiB / not usable 4.00 MiB

Allocatable yes (but full)

PE

Size 4.00 MiB

Total

PE 2559

Free

PE 0

Allocated

PE 2559

PV

UUID NIUQVc-jnBp-4aLT-Yd5x-d3ll-q1Rs-Ta4kHd

--- Physical volume ---

PV

Name /dev/sda4

VG

Name VolGroup

PV

Size 15.00 GiB / not usable 4.00 MiB

Allocatable yes

PE

Size 4.00 MiB

Total

PE 3839

Free

PE 3839

Allocated

PE 0

PV

UUID KBK6ZX-3XCM-4wF3-toZx-jo6f-UldR-qofe27

lvm> lvdisplay

--- Logical volume ---

LV

Path /dev/VolGroup/lv_swap

LV

Name lv_swap

VG

Name VolGroup

LV

UUID mkwmPK-A3bG-hFpP-bApY-K3lx-p2Z6-54GOzK

LV Write

Access read/write

LV Creation host, time gjzq-sh-mb, 2017-08-08

08:22:58 +0800

LV

Status available

#

open 1

LV

Size 4.00 GiB

Current

LE 1024

Segments 1

Allocation inherit

Read ahead

sectors auto

- currently set

to 256

Block

device 253:0

--- Logical volume ---

LV

Path /dev/VolGroup/lv_root

LV

Name lv_root

VG

Name VolGroup

LV

UUID UR3IJj-PuhD-pgHz-ZzVZ-e0G4-r3oW-eqyXX8

LV Write

Access read/write

LV Creation host, time gjzq-sh-mb, 2017-08-08

08:23:00 +0800

LV

Status available

#

open 1

LV

Size 45.80 GiB

Current

LE 11724

Segments 2

Allocation inherit

Read ahead

sectors auto

- currently set

to 256

Block

device 253:1

lvm> lvextend -l +3839 /dev/VolGroup/lv_root

Size of logical volume VolGroup/lv_root

changed from 45.80 GiB (11724 extents) to 60.79 GiB (15563

extents).

Logical volume lv_root successfully

resized.

lvm> lvdisplay

--- Logical volume ---

LV

Path /dev/VolGroup/lv_swap

LV

Name lv_swap

VG

Name VolGroup

LV

UUID mkwmPK-A3bG-hFpP-bApY-K3lx-p2Z6-54GOzK

LV Write

Access read/write

LV Creation host, time gjzq-sh-mb, 2017-08-08

08:22:58 +0800

LV

Status available

#

open 1

LV

Size 4.00 GiB

Current

LE 1024

Segments 1

Allocation inherit

Read ahead

sectors auto

- currently set

to 256

Block

device 253:0

--- Logical volume ---

LV

Path /dev/VolGroup/lv_root

LV

Name lv_root

VG

Name VolGroup

LV

UUID UR3IJj-PuhD-pgHz-ZzVZ-e0G4-r3oW-eqyXX8

LV Write

Access read/write

LV Creation host, time gjzq-sh-mb, 2017-08-08

08:23:00 +0800

LV

Status available

#

open 1

LV

Size 60.79 GiB

Current

LE 15563

Segments 3

Allocation inherit

Read ahead

sectors auto

- currently set

to 256

Block

device 253:1

[root@gjzq-sh-mb ~]# resize2fs /dev/VolGroup/lv_root

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line

resizing required

old desc_blocks = 3, new_desc_blocks = 4

Performing an on-line resize of /dev/VolGroup/lv_root to

15936512 (4k) blocks.

The filesystem on /dev/VolGroup/lv_root is now 15936512 blocks

long.

[root@gjzq-sh-mb ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

60G 4.9G 52G 9% /

tmpfs 1.9G 0 1.9G 0%

/dev/shm

/dev/sda1 190M 39M 141M 22% /boot

若不是xfs我们可以用resize2fs,这里报错了

[root@Mysql01-213-66 ~]# resize2fs -f

/dev/mapper/vg_mysql0121366-LogVol01

resize2fs 1.41.12 (17-May-2010)

resize2fs: Bad magic number in super-block while trying to open

/dev/mapper/vg_mysql0121366-LogVol01

Couldn‘t find valid filesystem superblock.

[root@Mysql01-213-66 ~]# xfs_growfs

/dev/mapper/vg_mysql0121366-LogVol01

[root@gjzq-sh-mb ~]# xfs_growfs

/dev/mapper/VolGroup-lv_root

meta-data=/dev/mapper/VolGroup-lv_root

isize=256 agcount=16, agsize=646400 blks

= sectsz=512 attr=2,

projid32bit=1

= crc=0 finobt=0

data = bsize=4096 blocks=10342400,

imaxpct=25

= sunit=64 swidth=64 blks

naming =version

2 bsize=4096 ascii-ci=0

ftype=0

log =internal bsize=4096 blocks=5056,

version=2

= sectsz=512 sunit=64 blks,

lazy-count=1

realtime

=none extsz=4096 blocks=0,

rtextents=0

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值