四时宝库

程序员的知识宝库

Linux centos lvm磁盘空间扩容操作

[root@coremail /]# df -hT
文件系统                            类型      容量  已用  可用 已用% 挂载点
devtmpfs                            devtmpfs  3.8G     0  3.8G    0% /dev
tmpfs                               tmpfs     3.9G     0  3.9G    0% /dev/shm
tmpfs                               tmpfs     3.9G   12M  3.8G    1% /run
tmpfs                               tmpfs     3.9G     0  3.9G    0% /sys/fs/cgroup
/dev/mapper/centos-root             xfs        50G  2.0G   49G    4% /
/dev/sda1                           xfs      1014M  186M  829M   19% /boot
/dev/mapper/centos-home             xfs        92G   33M   92G    1% /home
/dev/mapper/vg_coremail-lv_coremail xfs       200G   33M  200G    1% /home/coremail
tmpfs                               tmpfs     781M     0  781M    0% /run/user/0
tmpfs                               tmpfs     781M     0  781M    0% /run/user/1000
tmpfs                               tmpfs      60M     0   60M    0% /var/log/rtlog
[root@coremail /]# fdisk -l /dev/sdd

磁盘 /dev/sdd:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

[root@coremail /]# fdisk /dev/sdd
欢迎使用 fdisk (util-linux 2.23.2)。

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

Device does not contain a recognized partition table
使用磁盘标识符 0x3d668d30 创建新的 DOS 磁盘标签。

命令(输入 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 (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-209715199,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-209715199,默认为 209715199):
将使用默认值 209715199
分区 1 已设置为 Linux 类型,大小设为 100 GiB

命令(输入 m 获取帮助):p

磁盘 /dev/sdd:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x3d668d30

   设备 Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048   209715199   104856576   83  Linux

命令(输入 m 获取帮助):t
已选择分区 1
Hex 代码(输入 L 列出所有代码):8e
已将分区“Linux”的类型更改为“Linux LVM”

命令(输入 m 获取帮助):p

磁盘 /dev/sdd:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x3d668d30

   设备 Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048   209715199   104856576   8e  Linux LVM

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

Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@coremail /]# fdisk -l /dev/sdd

磁盘 /dev/sdd:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x3d668d30

   设备 Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048   209715199   104856576   8e  Linux LVM
[root@coremail /]# pvcreate /dev/sdd1
  Physical volume "/dev/sdd1" successfully created.
[root@coremail /]# vgextend  vg_coremail /dev/sdd1
  Volume group "vg_coremail" successfully extended
[root@coremail /]# lvextend -L +99.9G /dev/vg_coremail/lv_coremail /dev/sdd1
  Rounding size to boundary between physical extents: 99.90 GiB.
  Size of logical volume vg_coremail/lv_coremail changed from 199.80 GiB (51150 extents) to <299.71 GiB (76725 extents).
  Logical volume vg_coremail/lv_coremail successfully resized.
[root@coremail /]# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                TjjDje-YB0x-yG7i-Qsm5-mSIw-hx0Z-aOAseS
  LV Write Access        read/write
  LV Creation host, time coremail, 2020-11-24 11:38:24 +0800
  LV Status              available
  # open                 2
  LV Size                <7.88 GiB
  Current LE             2016
  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                ctPV6m-wfeF-czMW-5c1v-Ae5i-lFba-1tJ4aC
  LV Write Access        read/write
  LV Creation host, time coremail, 2020-11-24 11:38:25 +0800
  LV Status              available
  # open                 1
  LV Size                <91.12 GiB
  Current LE             23326
  Segments               1
  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                4JEZxx-9i9z-0pQA-S9eH-cIYt-LnLB-Acg2oy
  LV Write Access        read/write
  LV Creation host, time coremail, 2020-11-24 11:38:25 +0800
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
   
  --- Logical volume ---
  LV Path                /dev/vg_coremail/lv_coremail
  LV Name                lv_coremail
  VG Name                vg_coremail
  LV UUID                YYTqFI-8Uty-JDM3-hIdL-OOx7-VVap-XXa60C
  LV Write Access        read/write
  LV Creation host, time coremail, 2020-12-08 11:18:29 +0800
  LV Status              available
  # open                 1
  LV Size                <299.71 GiB
  Current LE             76725
  Segments               3
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:3
   
[root@coremail /]# df -hT | grep /home/coremail
/dev/mapper/vg_coremail-lv_coremail xfs       200G   33M  200G    1% /home/coremail
[root@coremail /]# xfs_growfs /dev/vg_coremail/lv_coremail
meta-data=/dev/mapper/vg_coremail-lv_coremail isize=512    agcount=8, agsize=6547200 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=52377600, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=12787, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 52377600 to 78566400
[root@coremail /]# df -hT | grep /home/coremail
/dev/mapper/vg_coremail-lv_coremail xfs       300G   33M  300G    1% /home/coremail

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言
    友情链接