虚机磁盘扩展-lvm其他盘

来源:互联网 发布:it培训中心 编辑:程序博客网 时间:2024/06/08 02:12
[root@host-172-16-1-156 rel]# 
[root@host-172-16-1-156 rel]# fdisk /dev/vdb
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.


Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x425c2cd6.


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): 
First sector (2048-209715199, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): 
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set


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): p


Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0x425c2cd6


   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   209715199   104856576   8e  Linux LVM


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


Calling ioctl() to re-read partition table.
Syncing disks.
[root@host-172-16-1-156 rel]# mkfs.xfs /dev/vdb1
meta-data=/dev/vdb1              isize=512    agcount=4, agsize=6553536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=26214144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=12799, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@host-172-16-1-156 rel]# pvcreate /dev/vdb1
WARNING: xfs signature detected on /dev/vdb1 at offset 0. Wipe it? [y/n]: n
  Aborted wiping of xfs.
  1 existing signature left on the device.
[root@host-172-16-1-156 rel]# fdisk -l


Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x0008d4a1


   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048   125829119    62401536   8e  Linux LVM
/dev/vda3       125829120   209715199    41943040   8e  Linux LVM


Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0x425c2cd6


   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   209715199   104856576   8e  Linux LVM


Disk /dev/mapper/centos-root: 41.4 GB, 41448112128 bytes, 80953344 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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 /dev/mapper/centos-home: 63.2 GB, 63182995456 bytes, 123404288 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


[root@host-172-16-1-156 rel]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   39G   13G   27G  32% /
devtmpfs                 7.9G     0  7.9G   0% /dev
tmpfs                    7.9G     0  7.9G   0% /dev/shm
tmpfs                    7.9G  8.5M  7.9G   1% /run
tmpfs                    7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/mapper/centos-home   59G   19G   41G  32% /home
/dev/vda1                497M  141M  356M  29% /boot
tmpfs                    1.6G     0  1.6G   0% /run/user/0
[root@host-172-16-1-156 rel]# pvcreate /dev/vdb1
WARNING: xfs signature detected on /dev/vdb1 at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/vdb1.
  Physical volume "/dev/vdb1" successfully created.
[root@host-172-16-1-156 rel]# vgdisplay 
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               99.50 GiB
  PE Size               4.00 MiB
  Total PE              25473
  Alloc PE / Size       25458 / 99.45 GiB
  Free  PE / Size       15 / 60.00 MiB
  VG UUID               da0VMy-YF7C-eGM2-HST4-DOLn-2bud-o1lLXx
   
[root@host-172-16-1-156 rel]# vgextend centos /dev/vdb1
  Volume group "centos" successfully extended
[root@host-172-16-1-156 rel]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                hd2AGl-IgaC-cRU1-VsZW-A0Hd-MYOf-WwGSGM
  LV Write Access        read/write
  LV Creation host, time localhost, 2016-05-30 14:03:57 +0800
  LV Status              available
  # open                 2
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/centos/home
  LV Name                home
  VG Name                centos
  LV UUID                VfZpyF-Xed0-lbBe-xCmB-j2d5-nV7u-oziySz
  LV Write Access        read/write
  LV Creation host, time localhost, 2016-05-30 14:03:58 +0800
  LV Status              available
  # open                 1
  LV Size                58.84 GiB
  Current LE             15064
  Segments               3
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2
   
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                Q6QJSZ-Bf3x-2ZJt-LTjs-HZsS-RtG3-dPtCbw
  LV Write Access        read/write
  LV Creation host, time localhost, 2016-05-30 14:03:59 +0800
  LV Status              available
  # open                 1
  LV Size                38.60 GiB
  Current LE             9882
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
   
[root@host-172-16-1-156 rel]# vgdisplay 
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               199.50 GiB
  PE Size               4.00 MiB
  Total PE              51072
  Alloc PE / Size       25458 / 99.45 GiB
  Free  PE / Size       25614 / 100.05 GiB
  VG UUID               da0VMy-YF7C-eGM2-HST4-DOLn-2bud-o1lLXx
   
[root@host-172-16-1-156 rel]# lvextend   -L  +100.05 /dev/mapper/centos-home 
  Rounding size to boundary between physical extents: 104.00 MiB.
  Size of logical volume centos/home changed from 58.84 GiB (15064 extents) to 58.95 GiB (15090 extents).
  Logical volume centos/home successfully resized.
[root@host-172-16-1-156 rel]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   39G   13G   27G  32% /
devtmpfs                 7.9G     0  7.9G   0% /dev
tmpfs                    7.9G     0  7.9G   0% /dev/shm
tmpfs                    7.9G  8.5M  7.9G   1% /run
tmpfs                    7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/mapper/centos-home   59G   19G   41G  32% /home
/dev/vda1                497M  141M  356M  29% /boot
tmpfs                    1.6G     0  1.6G   0% /run/user/0
[root@host-172-16-1-156 rel]# xfs_growfs  /dev/mapper/centos-home
meta-data=/dev/mapper/centos-home isize=256    agcount=13, agsize=1234944 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=15425536, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0




data blocks changed from 15425536 to 15452160
[root@host-172-16-1-156 rel]# 
[root@host-172-16-1-156 rel]# 
[root@host-172-16-1-156 rel]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   39G   13G   27G  32% /
devtmpfs                 7.9G     0  7.9G   0% /dev
tmpfs                    7.9G     0  7.9G   0% /dev/shm
tmpfs                    7.9G  8.5M  7.9G   1% /run
tmpfs                    7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/mapper/centos-home   59G   19G   41G  31% /home
/dev/vda1                497M  141M  356M  29% /boot
tmpfs                    1.6G     0  1.6G   0% /run/user/0
[root@host-172-16-1-156 rel]# vgdisplay 
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  9
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               199.50 GiB
  PE Size               4.00 MiB
  Total PE              51072
  Alloc PE / Size       25484 / 99.55 GiB
  Free  PE / Size       25588 / 99.95 GiB
  VG UUID               da0VMy-YF7C-eGM2-HST4-DOLn-2bud-o1lLXx
   


[root@host-172-16-1-156 rel]# lvextend   -L  +99.95G /dev/mapper/centos-home 
  Rounding size to boundary between physical extents: 99.95 GiB.
  Size of logical volume centos/home changed from 58.95 GiB (15090 extents) to 158.90 GiB (40678 extents).
  Logical volume centos/home successfully resized.
[root@host-172-16-1-156 rel]# 
[root@host-172-16-1-156 rel]# xfs_growfs  /dev/mapper/centos-home
meta-data=/dev/mapper/centos-home isize=256    agcount=13, agsize=1234944 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=15452160, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0


data blocks changed from 15452160 to 41654272
[root@host-172-16-1-156 rel]# 
[root@host-172-16-1-156 rel]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   39G   13G   27G  32% /
devtmpfs                 7.9G     0  7.9G   0% /dev
tmpfs                    7.9G     0  7.9G   0% /dev/shm
tmpfs                    7.9G  8.5M  7.9G   1% /run
tmpfs                    7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/mapper/centos-home  159G   19G  141G  12% /home
/dev/vda1                497M  141M  356M  29% /boot
tmpfs                    1.6G     0  1.6G   0% /run/user/0
原创粉丝点击