从零开始的Linux运维屌丝之路,资源免费分享平台   运维人员首选:简单、易用、高效、安全、稳定、社区活跃的开源软件

磁盘新建为LVM磁盘(支持大于2T)

发布:蔺要红09-19分类: 基础

概念图:


 
# 对新磁盘进行LVM分区
[root@elk4 server]# fdisk /dev/vdc
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Selected partition 1
Partition 1 is deleted

Command (m for help): 1
1: unknown command
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   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): p

Disk /dev/vdc: 1073.7 GB, 1073741824000 bytes, 2097152000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xdd3c79d9

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2097151999, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151999, default 2097151999):
Using default value 2097151999
Partition 1 of type Linux and of size 1000 GiB is set

# t 为lvm模式
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

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

Calling ioctl() to re-read partition table.

#  创建pv
[root@elk4 server]# pvcreate /dev/vdc1
WARNING: ext4 signature detected on /dev/vdc1 at offset 1080. Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/vdc1.
  Physical volume "/dev/vdc1" successfully created.

#  创建VG
[root@elk4 server]# vgcreate  es-vg /dev/vdc1
  Volume group "es-vg" successfully created

# 查看pV 和VG
[root@elk4 server]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vdc1
  VG Name               es-vg
  PV Size               <1000.00 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              255999
  Free PE               255999
  Allocated PE          0
  PV UUID               gdGl8u-vzvL-Vgnn-MZxd-UySq-hES1-FRD5o2

[root@elk4 server]# vgdisplay
  --- Volume group ---
  VG Name               es-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <1000.00 GiB
  PE Size               4.00 MiB
  Total PE              255999
  Alloc PE / Size       0 / 0
  Free  PE / Size       255999 / <1000.00 GiB
  VG UUID               mXvh6A-10C8-dvei-17NX-JNbD-0boL-Lh1QKk


# 把VG分配给LV
[root@elk4 server]# lvcreate  -L 900G -n es-lv es-vg
  Logical volume "es-lv" created.

[root@elk4 server]# mkfs.ext4 /dev/es-vg/es-lv


[root@elk4 /]# lvextend -l +100%FREE /dev/es-vg/es-lv
  Size of logical volume es-vg/es-lv changed from 900.00 GiB (230400 extents) to <1000.00 GiB (255999 extents).
  Logical volume es-vg/es-lv successfully resized.

[root@elk4 /]# resize2fs /dev/es-vg/es-lv
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/es-vg/es-lv is mounted on /1111; on-line resizing required
old_desc_blocks = 113, new_desc_blocks = 125
The filesystem on /dev/es-vg/es-lv is now 262142976 blocks long.
温馨提示如有转载或引用以上内容之必要,敬请将本文链接作为出处标注,如有侵权我会在24小时之内删除!

欢迎使用手机扫描访问本站