PV VG LV 的簡單使用

查看磁盤信息:

[root@PROD1 ~]# fdisk -l


Disk /dev/sda: 68.7 GB, 68719476736 bytes

255 heads, 63 sectors/track, 8354 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: 0x0003ad13


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26         548     4194304   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3             548        8355    62708736   83  Linux


Disk /dev/sdb: 21.5 GB, 21474836480 bytes

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


使用sdb創建基於磁盤的物理卷

[root@PROD1 ~]# pvcreate /dev/sdb 

  Physical volume "/dev/sdb" successfully created


查看物理卷創建是否成功

[root@PROD1 ~]# pvdisplay

  "/dev/sdb" is a new physical volume of "20.00 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/sdb

  VG Name               

  PV Size               20.00 GiB

  Allocatable           NO

  PE Size               0   

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               LDexlC-p56Q-knle-Gtxx-juj9-DmAD-nbaWgh


創建VG存儲池

[root@PROD1 ~]# vgcreate VolGroup01  /dev/sdb

  Volume group "VolGroup01" successfully created


分配LV邏輯卷

[root@PROD1 ~]# lvcreate -L 10G -n LogVol01 VolGroup01

  Logical volume "LogVol01" created.


格式化分區

[root@PROD1 ~]# mkfs.ext4 /dev/VolGroup01/LogVol01

mke2fs 1.43-WIP (20-Jun-2013)

文件系統標籤=

OS type: Linux

塊大小=4096 (log=2)

分塊大小=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

655360 inodes, 2621440 blocks

131072 blocks (5.00%) reserved for the super user

第一個數據塊=0

Maximum filesystem blocks=2684354560

80 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks: 

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632


Allocating group tables: 完成                            

正在寫入inode表: 完成                            

Creating journal (32768 blocks): 完成

Writing superblocks and filesystem accounting information: 完成 


添加/u02掛載點

[root@PROD1 ~]# mkdir /u02


掛載邏輯卷

[root@PROD1 ~]# mount /dev/VolGroup01/LogVol01 /u02

[root@PROD1 ~]# mount

/dev/sda3 on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw)

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

/dev/mapper/VolGroup01-LogVol01 on /u02 type ext4 (rw)


卸載邏輯卷

[root@PROD1 ~]# umount /u02/

[root@PROD1 ~]# mount

/dev/sda3 on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw)

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)


現在給系統新增加一塊盤


[root@PROD1 ~]# fdisk -l


Disk /dev/sda: 68.7 GB, 68719476736 bytes

255 heads, 63 sectors/track, 8354 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: 0x0003ad13


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26         548     4194304   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3             548        8355    62708736   83  Linux


Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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/sdc: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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/VolGroup01-LogVol01: 10.7 GB, 10737418240 bytes

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


使用sdc創建基於磁盤的物理卷

[root@PROD1 ~]# pvcreate /dev/sdc

  Physical volume "/dev/sdc" successfully created


查看物理卷創建是否成功


[root@PROD1 ~]# pvdisplay

  --- Physical volume ---

  PV Name               /dev/sdb

  VG Name               VolGroup01

  PV Size               20.00 GiB / not usable 4.00 MiB

  Allocatable           yes 

  PE Size               4.00 MiB

  Total PE              5119

  Free PE               2559

  Allocated PE          2560

  PV UUID               LDexlC-p56Q-knle-Gtxx-juj9-DmAD-nbaWgh

   

  "/dev/sdc" is a new physical volume of "20.00 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/sdc

  VG Name               

  PV Size               20.00 GiB

  Allocatable           NO

  PE Size               0   

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               IqjvIC-HoGD-p9OL-9CP2-pkkZ-wghY-9emOzR

   

將sdc添加到卷組

[root@PROD1 ~]# vgextend VolGroup01 /dev/sdc

  Volume group "VolGroup01" successfully extended


將sdc容量全部擴容到LogVol01

[root@PROD1 ~]# lvextend  /dev/VolGroup01/LogVol01 /dev/sdc

  Size of logical volume VolGroup01/LogVol01 changed from 10.00 GiB (2560 extents) to 30.00 GiB (7679 extents).

  Logical volume LogVol01 successfully resized


通過resize2fs命令令新增的空間在線(on-line)生效

[root@PROD1 ~]# resize2fs /dev/VolGroup01/LogVol01

resize2fs 1.43-WIP (20-Jun-2013)

Resizing the filesystem on /dev/VolGroup01/LogVol01 to 7863296 (4k) blocks.

The filesystem on /dev/VolGroup01/LogVol01 is now 7863296 blocks long.


擴容後效果

[root@PROD1 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda3              59G   12G   44G  22% /

tmpfs                1002M  280K 1001M   1% /dev/shm

/dev/sda1             190M   77M  100M  44% /boot

/dev/mapper/VolGroup01-LogVol01

                       30G   28M   28G   1% /u02



https://oracle-base.com/articles/linux/linux-logical-volume-management


http://blog.csdn.net/wuweilong/article/details/7565530


http://blog.itpub.net/29435844/viewspace-1071797/


http://blog.chinaunix.net/uid-1829236-id-161153.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章