Radhat linux 6.3根分区在线扩容
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Radhat linux 6.3根分区在线扩容相关的知识,希望对你有一定的参考价值。
需求: 虚拟机需要扩容硬盘容量,通过vCenter编辑资源设置,将原来50G扩容至100G.但是并不是马上可以使用.以下操作:
修改后100G,登陆虚拟机查看如下:
[[email protected]_test etc]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-lv_root
45G 7.0G 36G 17% /
tmpfs 3.9G 88K 3.9G 1% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
[[email protected]_test ~]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x000b6327
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 6528 51915776 8e Linux LVM
Disk /dev/mapper/rootvg-lv_root: 49.0 GB, 48997859328 bytes
255 heads, 63 sectors/track, 5956 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/rootvg-lv_swap: 4160 MB, 4160749568 bytes
255 heads, 63 sectors/track, 505 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
1、操作步骤如下:
fdisk -l //查看分区列表
fdisk /dev/sda //分区,先划分extend分区,再划分逻辑分区.本例划为extand为:/dev/sda3,逻辑分区/dev/sda5
m->n -> e -> w
fdisk /dev/sda
m->n -> l -> w
partx -a /dev/sda //添加指定的分区或读取磁盘并添加所有分区
pvcreate /dev/sda5 //初始化分区
vgextend rootvg /dev/sda5 //将初始化过的分区加入虚拟卷组rootvg中(通过vgdisplay查看)
lvextend -l +100%FREE /dev/mapper/rootvg-lv_root //在线扩容磁盘空间,扩容/dev/mapper/rootvg-lv_root卷空间.
resize2fs /dev/mapper/rootvg-lv_root //重设大小,扩容/dev/mapper/rootvg-lv_root。
具体操作实例如下:
[[email protected]_test ~]# fdisk -l Disk /dev/sda: 107.4 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 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: 0x000b6327 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 6528 51915776 8e Linux LVM Disk /dev/mapper/rootvg-lv_root: 49.0 GB, 48997859328 bytes 255 heads, 63 sectors/track, 5956 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/rootvg-lv_swap: 4160 MB, 4160749568 bytes 255 heads, 63 sectors/track, 505 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
1)分区
[[email protected]_test etc]# 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): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 3
First cylinder (6528-13054, default 6528):
Using default value 6528
Last cylinder, +cylinders or +size{K,M,G} (6528-13054, default 13054):
Using default value 13054
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.
[[email protected]_test etc]# 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): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (6528-13054, default 6528):
Using default value 6528
Last cylinder, +cylinders or +size{K,M,G} (6528-13054, default 13054):
Using default value 13054
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.
分区完成:
[[email protected]_test etc]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x000b6327
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 6528 51915776 8e Linux LVM
/dev/sda3 6528 13054 52427455 5 Extended
/dev/sda5 6528 13054 52427423+ 83 Linux
Disk /dev/mapper/rootvg-lv_root: 49.0 GB, 48997859328 bytes
255 heads, 63 sectors/track, 5956 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/rootvg-lv_swap: 4160 MB, 4160749568 bytes
255 heads, 63 sectors/track, 505 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
2)初始化/dev/sda5,有如下错误提示,partx -a /dev/sda,再次初始化,OK.
[[email protected]_test etc]# pvcreate /dev/sda5
Device /dev/sda5 not found (or ignored by filtering).
[[email protected]_test etc]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
[[email protected]_test etc]# pvcreate /dev/sda5
Writing physical volume data to disk "/dev/sda5"
Physical volume "/dev/sda5" successfully created
查看vg
[[email protected]_test etc]# vgdisply
--- Volume group ---
VG Name rootvg
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 49.51 GiB
PE Size 4.00 MiB
Total PE 12674
Alloc PE / Size 12674 / 49.51 GiB
Free PE / Size 0 / 0
VG UUID 0N5RVO-5Uob-yYm7-HGnp-pg0x-2rPH-aKJpXF
3)将/dev/sda5添加到VGgroup卷组:rootvg中。
[[email protected]_test etc]# vgextend rootvg /dev/sda5
Volume group "rootvg" successfully extended
4)在线扩容磁盘空间,扩容/dev/mapper/rootvg-lv_root卷空间.
[[email protected]_test etc]# lvextend -l +100%FREE /dev/mapper/rootvg-lv_root
Extending logical volume lv_root to 95.63 GiB
Logical volume lv_root successfully resized
[[email protected]_test etc]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name rootvg
PV Size 49.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 12674
Free PE 0
Allocated PE 12674
PV UUID UIP0kz-a3Xo-4X0V-P78o-t1E6-abuc-F0qqr7
--- Physical volume ---
PV Name /dev/sda5
VG Name rootvg
PV Size 50.00 GiB / not usable 2.66 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 12799
Free PE 0
Allocated PE 12799
PV UUID JijY54-GseR-NvPU-FEzv-ZvMi-8CRp-m5AFhP
没有重设大小,
[[email protected]_test etc]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-lv_root
45G 7.0G 36G 17% /
tmpfs 3.9G 88K 3.9G 1% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
5)重设卷大小
[[email protected]_test etc]# resize2fs /dev/mapper/rootvg-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/rootvg-lv_root is mounted on /; on-line resizing required
old desc_blocks = 3, new_desc_blocks = 6
Performing an on-line resize of /dev/mapper/rootvg-lv_root to 25068544 (4k) blocks.
The filesystem on /dev/mapper/rootvg-lv_root is now 25068544 blocks long.
再次查看,已经扩容成功
[[email protected]_test etc]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-lv_root
95G 7.0G 83G 8% /
tmpfs 3.9G 88K 3.9G 1% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
[[email protected]_test ~]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x000b6327
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 6528 51915776 8e Linux LVM
/dev/sda3 6528 13054 52427455 5 Extended
/dev/sda5 6528 13054 52427423+ 83 Linux
Disk /dev/mapper/rootvg-lv_root: 102.7 GB, 102680756224 bytes
255 heads, 63 sectors/track, 12483 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/rootvg-lv_swap: 4160 MB, 4160749568 bytes
255 heads, 63 sectors/track, 505 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
[[email protected]_test ~]#
本文出自 “LOVE_瑶” 博客,请务必保留此出处http://20161215.blog.51cto.com/2276215/1795777
以上是关于Radhat linux 6.3根分区在线扩容的主要内容,如果未能解决你的问题,请参考以下文章