码迷,mamicode.com
首页 > 其他好文 > 详细

centos7 LV XFS添加磁盘

时间:2016-04-14 19:37:42      阅读:1205      评论:0      收藏:0      [点我收藏+]

标签:lvm xfs

在centos7环境下实现,原来centos7的磁盘分区是lv+xfs格式。


现在需要添加一块磁盘来扩展LV的空间。步骤日志如下:


查看原来磁盘格式:

[root@localhost~]# df -hT

Filesystem              Type      Size Used Avail Use% Mounted on

/dev/mapper/centos-rootxfs        18G  947M  17G   6% /

devtmpfs                devtmpfs  1.9G    0  1.9G   0% /dev

tmpfs                   tmpfs     1.9G    0  1.9G   0% /dev/shm

tmpfs                   tmpfs     1.9G 8.5M  1.9G   1% /run

tmpfs                   tmpfs     1.9G    0  1.9G   0% /sys/fs/cgroup

/dev/sda1               xfs       497M 120M  378M  25% /boot


发现新加磁盘名称为/dev/sdb

[root@localhost~]# fdisk -l

 

Disk/dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors

Units= sectors of 1 * 512 = 512 bytes

Sectorsize (logical/physical): 512 bytes / 512 bytes

I/Osize (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Diskidentifier: 0x0008e34b

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *       2048     1026047      512000  83  Linux

/dev/sda2         1026048    41943039   20458496   8e  Linux LVM

 

Disk/dev/sdb: 42.9 GB, 42949672960 bytes, 83886080 sectors

Units= sectors of 1 * 512 = 512 bytes

Sectorsize (logical/physical): 512 bytes / 512 bytes

I/Osize (minimum/optimal): 512 bytes / 512 bytes

 

 

Disk/dev/mapper/centos-root: 18.8 GB, 18756927488 bytes, 36634624 sectors

Units= sectors of 1 * 512 = 512 bytes

Sectorsize (logical/physical): 512 bytes / 512 bytes

I/Osize (minimum/optimal): 512 bytes / 512 bytes

 

 

Disk/dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors

Units= sectors of 1 * 512 = 512 bytes

Sectorsize (logical/physical): 512 bytes / 512 bytes

I/Osize (minimum/optimal): 512 bytes / 512 bytes



分区新磁盘 如果大于2T磁盘使用parted工具

[root@localhost~]# fdisk /dev/sdb

Welcometo fdisk (util-linux 2.23.2).

 

Changeswill remain in memory only, until you decide to write them.

Becareful before using the write command.

 

Devicedoes not contain a recognized partition table

Buildinga new DOS disklabel with disk identifier 0x1cfab789.

 

Command(m for help): p

 

Disk/dev/sdb: 42.9 GB, 42949672960 bytes, 83886080 sectors

Units= sectors of 1 * 512 = 512 bytes

Sectorsize (logical/physical): 512 bytes / 512 bytes

I/Osize (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Diskidentifier: 0x1cfab789

 

   Device Boot      Start         End      Blocks  Id  System

 

Command(m for help): n

Partitiontype:

   p  primary (0 primary, 0 extended, 4 free)

   e  extended

Select(default p): p

Partitionnumber (1-4, default 1):

Firstsector (2048-83886079, default 2048):

Usingdefault value 2048

Lastsector, +sectors or +size{K,M,G} (2048-83886079, default 83886079):

Usingdefault value 83886079

Partition1 of type Linux and of size 40 GiB is set

 

Command(m for help): w

Thepartition table has been altered!

 

Callingioctl() to re-read partition table.

Syncingdisks.

[root@localhost~]# fdisk -l

 

Disk/dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors

Units= sectors of 1 * 512 = 512 bytes

Sectorsize (logical/physical): 512 bytes / 512 bytes

I/Osize (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Diskidentifier: 0x0008e34b

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *       2048     1026047      512000  83  Linux

/dev/sda2         1026048    41943039   20458496   8e  Linux LVM

 

Disk/dev/sdb: 42.9 GB, 42949672960 bytes, 83886080 sectors

Units= sectors of 1 * 512 = 512 bytes

Sectorsize (logical/physical): 512 bytes / 512 bytes

I/Osize (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Diskidentifier: 0x1cfab789

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sdb1            2048    83886079   41942016   83  Linux

 

Disk/dev/mapper/centos-root: 18.8 GB, 18756927488 bytes, 36634624 sectors

Units= sectors of 1 * 512 = 512 bytes

Sectorsize (logical/physical): 512 bytes / 512 bytes

I/Osize (minimum/optimal): 512 bytes / 512 bytes

 

 

Disk/dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors

Units= sectors of 1 * 512 = 512 bytes

Sectorsize (logical/physical): 512 bytes / 512 bytes

I/Osize (minimum/optimal): 512 bytes / 512 bytes

 

查看原来lv状态

[root@localhost~]# vgdisplay

  --- Volume group ---

  VG Name               centos

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

  PE Size               4.00 MiB

  Total PE              4994

  Alloc PE / Size       4984 / 19.47 GiB

  Free  PE / Size       10 / 40.00 MiB

  VG UUID              EDjB3T-qhXo-Mmml-rN8w-bPYk-AdL6-Cf0Y6u

  

创建物理卷

[root@localhost~]# pvcreate /dev/sdb1

  Physical volume "/dev/sdb1"successfully created


将新的物理卷加入卷组中

[root@localhost~]# vgextend centos /dev/sdb1

  Volume group "centos" successfullyextended


查看新加入物理卷后的卷组状态

[root@localhost~]# vgdisplay

  --- Volume group ---

  VG Name              centos

  System ID            

  Format                lvm2

  Metadata Areas        2

  Metadata Sequence No  4

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

  PE Size               4.00 MiB

  Total PE              15233

  Alloc PE / Size       4984 / 19.47 GiB

  Free  PE / Size       10249 / 40.04 GiB

  VG UUID              EDjB3T-qhXo-Mmml-rN8w-bPYk-AdL6-Cf0Y6u

  

[root@localhost~]# df -h

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/centos-root  18G  946M   17G  6% /

devtmpfs                 1.9G     0 1.9G   0% /dev

tmpfs                    1.9G     0 1.9G   0% /dev/shm

tmpfs                    1.9G  8.5M 1.9G   1% /run

tmpfs                    1.9G     0 1.9G   0% /sys/fs/cgroup

/dev/sda1                497M  120M 378M  25% /boot


查看增加逻辑卷容量命令lvextend的用法

[root@localhost~]# lvextend --help

  lvextend: Add space to a logical volume

 

lvextend

       [-A|--autobackup y|n]

       [--alloc AllocationPolicy]

       [--commandprofile ProfileName]

       [-d|--debug]

       [-f|--force]

       [-h|--help]

       [-i|--stripes Stripes [-I|--stripesizeStripeSize]]

       {-l|--extents[+]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}] |

        -L|--size[+]LogicalVolumeSize[bBsSkKmMgGtTpPeE]}

        --poolmetadatasize[+]MetadataVolumeSize[bBsSkKmMgG]}

       [-m|--mirrors Mirrors]

       [--nosync]

       [--use-policies]

       [-n|--nofsck]

       [--noudevsync]

       [-r|--resizefs]

       [-t|--test]

       [--type VolumeType]

       [-v|--verbose]

       [--version]

       LogicalVolume[Path] [PhysicalVolumePath... ]


把整个剩余容量都添加到逻辑卷中

 [root@localhost ~]#lvextend -l+10249 /dev/centos/root

  Size of logicalvolume centos/root changed from 17.47 GiB (4472 extents) to 57.50 GiB (14721extents).

  Logical volume root successfully resized


这个地方需要说明一下,如果磁盘格式是XFS文件系统,则使用xfs_growfs命令,如果磁盘是ext格式则需要使用resize2fs命令


修改xfs文件系统容量

[root@localhost ~]# xfs_growfs /dev/mapper/centos-root

meta-data=/dev/mapper/centos-rootisize=256    agcount=4, agsize=1144832blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=0        finobt=0

data     =                       bsize=4096   blocks=4579328, 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

datablocks changed from 4579328 to 15074304



查看扩容后的逻辑卷大小

[root@localhost~]# df -hT

Filesystem              Type      Size Used Avail Use% Mounted on

/dev/mapper/centos-root xfs        58G 946M   57G   2% /

devtmpfs                devtmpfs  1.9G     0 1.9G   0% /dev

tmpfs                   tmpfs     1.9G    0  1.9G   0% /dev/shm

tmpfs                   tmpfs     1.9G 8.5M  1.9G   1% /run

tmpfs                   tmpfs     1.9G    0  1.9G   0% /sys/fs/cgroup

/dev/sda1               xfs       497M 120M  378M  25% /boot

[root@localhost~]#


centos7 LV XFS添加磁盘

标签:lvm xfs

原文地址:http://ting2junshui.blog.51cto.com/975290/1763847

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!