硬盘扩容---lvextend实录

[root@hdp1 ~]# fdisk -l

磁盘 /dev/sda:37.6 GB, 37580963840 字节,73400320 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000d731a

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    41943039    20458496   8e  Linux LVM

磁盘 /dev/mapper/centos-root:18.8 GB, 18798870528 字节,36716544 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

[root@hdp1 ~]# fdisk /dev/sda
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。


命令(输入 m 获取帮助):m
命令操作
   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)

命令(输入 m 获取帮助):n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
分区号 (3,4,默认 3):3
起始 扇区 (41943040-73400319,默认为 41943040):
将使用默认值 41943040
Last 扇区, +扇区 or +size{K,M,G} (41943040-73400319,默认为 73400319):
将使用默认值 73400319
分区 3 已设置为 Linux 类型,大小设为 15 GiB

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
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)
正在同步磁盘。
[root@hdp1 ~]# fdisk -l

磁盘 /dev/sda:37.6 GB, 37580963840 字节,73400320 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000d731a

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    41943039    20458496   8e  Linux LVM
/dev/sda3        41943040    73400319    15728640   83  Linux

磁盘 /dev/mapper/centos-root:18.8 GB, 18798870528 字节,36716544 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

[root@hdp1 ~]# pvcreate /dev/sda3
  Device /dev/sda3 not found (or ignored by filtering).



[root@hdp1 ~]# fdisk -l

磁盘 /dev/sda:37.6 GB, 37580963840 字节,73400320 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000d731a

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    41943039    20458496   8e  Linux LVM
/dev/sda3        41943040    73400319    15728640   83  Linux

磁盘 /dev/mapper/centos-root:18.8 GB, 18798870528 字节,36716544 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

[root@hdp1 ~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created.
[root@hdp1 ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree
  /dev/sda2  centos lvm2 a--  <19.51g     0
  /dev/sda3         lvm2 ---   15.00g 15.00g
[root@hdp1 ~]# vgextend centos /dev/sda3
  Volume group "centos" successfully extended
[root@hdp1 ~]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree  
  centos   2   2   0 wz--n- 34.50g <15.00g
[root@hdp1 ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   18G  8.5G  9.1G   49% /
devtmpfs                 477M     0  477M    0% /dev
tmpfs                    493M     0  493M    0% /dev/shm
tmpfs                    493M  7.2M  486M    2% /run
tmpfs                    493M     0  493M    0% /sys/fs/cgroup
/dev/sda1                497M  154M  344M   31% /boot
tmpfs                     99M  8.0K   99M    1% /run/user/42
tmpfs                     99M     0   99M    0% /run/user/0
[root@hdp1 ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                zk0Ifz-tqLh-shJC-yq1r-20vf-wwKz-IB16nc
  LV Write Access        read/write
  LV Creation host, time localhost, 2018-08-01 13:14:19 +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/root
  LV Name                root
  VG Name                centos
  LV UUID                1ZaMHo-U63q-bDzg-MuNB-uEqJ-TtZk-0jtqlV
  LV Write Access        read/write
  LV Creation host, time localhost, 2018-08-01 13:14:19 +0800
  LV Status              available
  # open                 1
  LV Size                <17.51 GiB
  Current LE             4482
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
   
[root@hdp1 ~]# lvextend +15000 /dev/centos/root
  Please specify a logical volume path.
  Run `lvextend --help' for more information.
[root@hdp1 ~]# lvextend -l +15000 /dev/centos/root
  Insufficient free space: 15000 extents needed, but only 3839 available
[root@hdp1 ~]# lvextend -l +3839 /dev/centos/root
  Size of logical volume centos/root changed from <17.51 GiB (4482 extents) to 32.50 GiB (8321 extents).
  Logical volume centos/root successfully resized.
[root@hdp1 ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   18G  8.5G  9.1G   49% /
devtmpfs                 477M     0  477M    0% /dev
tmpfs                    493M     0  493M    0% /dev/shm
tmpfs                    493M  7.2M  486M    2% /run
tmpfs                    493M     0  493M    0% /sys/fs/cgroup
/dev/sda1                497M  154M  344M   31% /boot
tmpfs                     99M   12K   99M    1% /run/user/42
tmpfs                     99M     0   99M    0% /run/user/0
[root@hdp1 ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=1147392 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=4589568, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
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 4589568 to 8520704
[root@hdp1 ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   33G  8.5G   25G   27% /
devtmpfs                 477M     0  477M    0% /dev
tmpfs                    493M     0  493M    0% /dev/shm
tmpfs                    493M  7.2M  486M    2% /run
tmpfs                    493M     0  493M    0% /sys/fs/cgroup
/dev/sda1                497M  154M  344M   31% /boot
tmpfs                     99M   12K   99M    1% /run/user/42
tmpfs                     99M     0   99M    0% /run/user/0

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值