Chinaunix首页 | 论坛 | 博客
  • 博客访问: 115652
  • 博文数量: 28
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 277
  • 用 户 组: 普通用户
  • 注册时间: 2014-10-20 16:21
文章分类
文章存档

2019年(1)

2018年(2)

2017年(22)

2016年(3)

我的朋友

分类: 系统运维

2017-10-30 11:09:17

前言:
挂载在 / 目录的/dev/mapper/VolGroup-lv_root卷空间不够了,需要扩容。

df -h 查看 / 只有14G 太小了

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 pcre-8.40]# df -h
  2. Filesystem Size Used Avail Use% Mounted on
  3. /dev/mapper/VolGroup-lv_root
  4.                        14G 5.6G 7.3G 44% /
  5. tmpfs 7.8G 0 7.8G 0% /dev/shm
  6. /dev/xvda1 485M 54M 407M 12% /boot
fdisk 查看剩余空间,/dev/xvda 还有一百多G可用

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 pcre-8.40]# fdisk -l

  2. Disk /dev/xvda: 214.7 GB, 214748364800 bytes
  3. 255 heads, 63 sectors/track, 26108 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Sector size (logical/physical): 512 bytes / 512 bytes
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes
  7. Disk identifier: 0x000eacf6

  8.     Device Boot Start End Blocks Id System
  9. /dev/xvda1 * 1 64 512000 83 Linux
  10. Partition 1 does not end on cylinder boundary.
  11. /dev/xvda2 64 1958 15214611 83 Linux

  12. Disk /dev/mapper/VolGroup-lv_root: 14.7 GB, 14722007040 bytes
  13. 255 heads, 63 sectors/track, 1789 cylinders
  14. Units = cylinders of 16065 * 512 = 8225280 bytes
  15. Sector size (logical/physical): 512 bytes / 512 bytes
  16. I/O size (minimum/optimal): 512 bytes / 512 bytes
  17. Disk identifier: 0x00000000


  18. Disk /dev/mapper/VolGroup-lv_swap: 855 MB, 855638016 bytes
  19. 255 heads, 63 sectors/track, 104 cylinders
  20. Units = cylinders of 16065 * 512 = 8225280 bytes
  21. Sector size (logical/physical): 512 bytes / 512 bytes
  22. I/O size (minimum/optimal): 512 bytes / 512 bytes
  23. Disk identifier: 0x00000000
fdisk 创建分区,pvcreate 创建物理卷

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 pcre-8.40]# fdisk /dev/xvda

  2. WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
  3.          switch off the mode (command 'c') and change display units to
  4.          sectors (command 'u').

  5. Command (m for help): m
  6. Command action
  7.    a toggle a bootable flag
  8.    b edit bsd disklabel
  9.    c toggle the dos compatibility flag
  10.    d delete a partition
  11.    l list known partition types
  12.    m print this menu
  13.    n add a new partition
  14.    o create a new empty DOS partition table
  15.    p print the partition table
  16.    q quit without saving changes
  17.    s create a new empty Sun disklabel
  18.    t change a partition's system id
  19.    u change display/entry units
  20.    v verify the partition table
  21.    w write table to disk and exit
  22.    x extra functionality (experts only)

  23. Command (m for help): p

  24. Disk /dev/xvda: 214.7 GB, 214748364800 bytes
  25. 255 heads, 63 sectors/track, 26108 cylinders
  26. Units = cylinders of 16065 * 512 = 8225280 bytes
  27. Sector size (logical/physical): 512 bytes / 512 bytes
  28. I/O size (minimum/optimal): 512 bytes / 512 bytes
  29. Disk identifier: 0x000eacf6

  30.     Device Boot Start End Blocks Id System
  31. /dev/xvda1 * 1 64 512000 83 Linux
  32. Partition 1 does not end on cylinder boundary.
  33. /dev/xvda2 64 1958 15214611 83 Linux

  34. Command (m for help): n
  35. Command action
  36.    e extended
  37.    p primary partition (1-4)
  38. p
  39. Partition number (1-4): 3
  40. First cylinder (1959-26108, default 1959):
  41. Using default value 1959
  42. Last cylinder, +cylinders or +size{K,M,G} (1959-26108, default 26108):
  43. Using default value 26108

  44. Command (m for help): w
  45. The partition table has been

  46. Calling ioctl() to re-read partition table.

  47. WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
  48. The kernel still uses the old table. The new table will be used at
  49. the next reboot or after you run partprobe(8) or kpartx(8)
  50. Syncing disks.

fdisk -l  查看分区

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 ~]# fdisk -l

  2. Disk /dev/xvda: 214.7 GB, 214748364800 bytes
  3. 255 heads, 63 sectors/track, 26108 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Sector size (logical/physical): 512 bytes / 512 bytes
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes
  7. Disk identifier: 0x000eacf6

  8.     Device Boot Start End Blocks Id System
  9. /dev/xvda1 * 1 64 512000 83 Linux
  10. Partition 1 does not end on cylinder boundary.
  11. /dev/xvda2 64 1958 15214611 83 Linux
  12. /dev/xvda3 1959 26108 193984875 83 Linux

  13. Disk /dev/mapper/VolGroup-lv_root: 14.7 GB, 14722007040 bytes
  14. 255 heads, 63 sectors/track, 1789 cylinders
  15. Units = cylinders of 16065 * 512 = 8225280 bytes
  16. Sector size (logical/physical): 512 bytes / 512 bytes
  17. I/O size (minimum/optimal): 512 bytes / 512 bytes
  18. Disk identifier: 0x00000000


  19. Disk /dev/mapper/VolGroup-lv_swap: 855 MB, 855638016 bytes
  20. 255 heads, 63 sectors/track, 104 cylinders
  21. Units = cylinders of 16065 * 512 = 8225280 bytes
  22. Sector size (logical/physical): 512 bytes / 512 bytes
  23. I/O size (minimum/optimal): 512 bytes / 512 bytes
  24. Disk identifier: 0x00000000
pvdisplay 查看物理卷

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 ~]# pvdisplay
  2.   --- Physical volume ---
  3.   PV Name /dev/xvda2
  4.   VG Name VolGroup
  5.   PV Size 14.51 GiB / not usable 1.02 MiB
  6.   Allocatable yes (but full)
  7.   PE Size 4.00 MiB
  8.   Total PE 3714
  9.   Free PE 0
  10.   Allocated PE 3714
  11.   PV UUID kbUoQF-zSiv-IwgC-3OtP-JbIV-9SXR-oPWJef
vgdisplay 查看逻辑卷组

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 ~]# vgdisplay
  2.   --- Volume group ---
  3.   VG Name VolGroup
  4.   System ID
  5.   Format lvm2
  6.   Metadata Areas 1
  7.   Metadata Sequence No 5
  8.   VG Access read/write
  9.   VG Status resizable
  10.   MAX LV 0
  11.   Cur LV 2
  12.   Open LV 2
  13.   Max PV 0
  14.   Cur PV 1
  15.   Act PV 1
  16.   VG Size 14.51 GiB
  17.   PE Size 4.00 MiB
  18.   Total PE 3714
  19.   Alloc PE / Size 3714 / 14.51 GiB
  20.   Free PE / Size 0 / 0
  21.   VG UUID lvi8Kt-MMja-nTvI-terh-7ljb-ImyV-SScwRk

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 ~]# vgdisplay
  2.   --- Volume group ---
  3.   VG Name VolGroup
  4.   System ID
  5.   Format lvm2
  6.   Metadata Areas 1
  7.   Metadata Sequence No 5
  8.   VG Access read/write
  9.   VG Status resizable
  10.   MAX LV 0
  11.   Cur LV 2
  12.   Open LV 2
  13.   Max PV 0
  14.   Cur PV 1
  15.   Act PV 1
  16.   VG Size 14.51 GiB
  17.   PE Size 4.00 MiB
  18.   Total PE 3714
  19.   Alloc PE / Size 3714 / 14.51 GiB
  20.   Free PE / Size 0 / 0
  21.   VG UUID lvi8Kt-MMja-nTvI-terh-7ljb-ImyV-SScwRk
lvdispaly 查看逻辑卷

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 ~]# lvdisplay
  2.   --- Logical volume ---
  3.   LV Path /dev/VolGroup/lv_root
  4.   LV Name lv_root
  5.   VG Name VolGroup
  6.   LV UUID tYQ8YA-ImhM-NLo8-HgVj-6snL-8qgS-32YBNi
  7.   LV Write Access read/write
  8.   LV Creation host, time localhost.localdomain, 2014-04-08 02:10:19 +0000
  9.   LV Status available
  10.   # open 1
  11.   LV Size 13.71 GiB
  12.   Current LE 3510
  13.   Segments 2
  14.   Allocation inherit
  15.   Read ahead sectors auto
  16.   - currently set to 256
  17.   Block device 253:0
  18.    
  19.   --- Logical volume ---
  20.   LV Path /dev/VolGroup/lv_swap
  21.   LV Name lv_swap
  22.   VG Name VolGroup
  23.   LV UUID PF53Ol-MDZF-nWZb-jJeG-WIHZ-GFQJ-HvKKM5
  24.   LV Write Access read/write
  25.   LV Creation host, time localhost.localdomain, 2014-04-08 02:10:20 +0000
  26.   LV Status available
  27.   # open 1
  28.   LV Size 816.00 MiB
  29.   Current LE 204
  30.   Segments 1
  31.   Allocation inherit
  32.   Read ahead sectors auto
  33.   - currently set to 256
  34.   Block device 253:1
让分区生效
pvcreate 创建物理卷

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 ~]# partx -a /dev/xvda
  2. [root@ip-172-30-0-175 ~]# partx -a /dev/xvda3 /dev/xvda
  3. [root@ip-172-30-0-175 ~]# pvcreate /dev/xvda3
  4.   Physical volume "/dev/xvda3" successfully created
  5. [root@ip-172-30-0-175 ~]# pvdisplay
      --- Physical volume ---
      PV Name               /dev/xvda2
      VG Name               VolGroup
      PV Size               14.51 GiB / not usable 1.02 MiB
      Allocatable           yes (but full)
      PE Size               4.00 MiB
      Total PE              3714
      Free PE               0
      Allocated PE          3714
      PV UUID               kbUoQF-zSiv-IwgC-3OtP-JbIV-9SXR-oPWJef
       
      "/dev/xvda3" is a new physical volume of "185.00 GiB"
      --- NEW Physical volume ---
      PV Name               /dev/xvda3
      VG Name               
      PV Size               185.00 GiB
      Allocatable           NO
      PE Size               0   
      Total PE              0
      Free PE               0
      Allocated PE          0
      PV UUID               b7Ykqm-c3ra-sAx7-srWW-kbT6-l4R1-R1cimn
       
将剩余空间都分配给 VolGroup 卷组

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 ~]# vgextend VolGroup /dev/xvda3
  2.   Volume group "VolGroup" successfully extended
  3. [root@ip-172-30-0-175 ~]# vgdisplay
      --- Volume group ---
      VG Name               VolGroup
      System ID             
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  6
      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               199.50 GiB
      PE Size               4.00 MiB
      Total PE              51073
      Alloc PE / Size       3714 / 14.51 GiB
      Free  PE / Size       47359 / 185.00 GiB
      VG UUID               lvi8Kt-MMja-nTvI-terh-7ljb-ImyV-SScwRk

将卷组中的剩余空间都分配给/dev/VolGroup/lv_root 逻辑卷

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 ~]# lvextend -l +100%FREE /dev/VolGroup/lv_root
  2.   Extending logical volume lv_root to 198.71 GiB
  3.   Logical volume lv_root successfully resized
调整分区大小 resize2fs   /dev/mapper/VolGroup-lv_root

点击(此处)折叠或打开

  1. [root@ip-172-30-0-175 ~]# resize2fs /dev/mapper/VolGroup-lv_root
  2. resize2fs 1.41.12 (17-May-2010)
  3. Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
  4. old desc_blocks = 1, new_desc_blocks = 13
  5. Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 52089856 (4k) blocks.
  6. The filesystem on /dev/mapper/VolGroup-lv_root is now 52089856 blocks long.
  7. [root@ip-172-30-0-175 ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                          196G  5.6G  181G   3% /
    tmpfs                 7.8G     0  7.8G   0% /dev/shm
    /dev/xvda1            485M   54M  407M  12% /boot


可以看到 /dev/mapper/VolGroup-lv_root 的大小由14G变成196G了。








阅读(1551) | 评论(0) | 转发(0) |
0

上一篇:zabbix2.4.8 配置sendEmail告警

下一篇:书单

给主人留下些什么吧!~~