Centos 虚拟机Linux 扩展/dev/mapper/VolGroup-lv_root容量

Linux  扩展/dev/mapper/VolGroup-lv_root容量


    
    
    
    

本文来自:https://blog.csdn.net/max229max/article/details/80356250


# Step 0: 查看磁盘空间,lv_root 经常100%,目的扩容 lv_root


     
     
     
     
  1. [root@localhost ~] # df -h
  2. Filesystem Size Used Avail Use% Mounted on
  3. /dev/mapper/VolGroup-lv_root
  4. 12G 3.2G 7.7G 30% /
  5. tmpfs 1.9G 0 1.9G 0% /dev/shm
  6. /dev/sda1 485M 32M 429M 7% /boot

# Step 1:给VM添加磁盘大小

通过命令行查找对应UUID:

VBoxManage.exe list hdds

在location处找到对应的vdi名,找到第一行的UUID

重新分配内存:

VBoxManage modifyhd UUID --resize(--resizebyte) 20480(单位为Mb)

# Step 2:fdisk 查看磁盘信息


   
   
   
   
  1. [root@localhost ~] # fdisk -l
  2. Disk /dev/sda: 107.4 GB, 107374182400 bytes # 磁盘扩容到100G
  3. 255 heads, 63 sectors/track, 13054 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: 0x000c9934
  8. Device Boot Start End Blocks Id System
  9. /dev/sda1 * 1 64 512000 83 Linux
  10. Partition 1 does not end on cylinder boundary.
  11. /dev/sda2 64 2089 16264192 8e Linux LVM
  12. Disk /dev/mapper/VolGroup-lv_root: 12.5 GB, 12490637312 bytes
  13. 255 heads, 63 sectors/track, 1518 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: 4160 MB, 4160749568 bytes
  19. 255 heads, 63 sectors/track, 505 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

#Step 3:fdisk 进入/dev/sda, 创建新分区 /dev/sda3


   
   
   
   
  1. [root@localhost ~] # fdisk /dev/sda
  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): n # new 新分区
  6. Command action
  7. e extended
  8. p primary partition (1-4)
  9. p # 选择主分区
  10. Partition number (1-4): 3 # 分区序号 3
  11. First cylinder (2089-13054, default 2089): # 分区开始块,回车使用默认
  12. Using default value 2089
  13. Last cylinder, +cylinders or +size{K,M,G} (2089-13054, default 13054): # 分区结束块,回车使用默认
  14. Using default value 13054
  15. Command (m for help): t # 修改分区格式
  16. Partition number (1-4): 3 # 选择分区序号
  17. Hex code (type L to list codes): 8e # 格式选择8e linux LVM
  18. Changed system type of partition 3 to 8e (Linux LVM)
  19. Command (m for help): p # 显示分区信息
  20. Disk /dev/sda: 107.4 GB, 107374182400 bytes
  21. 255 heads, 63 sectors/track, 13054 cylinders
  22. Units = cylinders of 16065 * 512 = 8225280 bytes
  23. Sector size (logical/physical): 512 bytes / 512 bytes
  24. I/O size (minimum/optimal): 512 bytes / 512 bytes
  25. Disk identifier: 0x000c9934
  26. Device Boot Start End Blocks Id System
  27. /dev/sda1 * 1 64 512000 83 Linux
  28. Partition 1 does not end on cylinder boundary.
  29. /dev/sda2 64 2089 16264192 8e Linux LVM
  30. /dev/sda3 2089 13054 88079039 8e Linux LVM # 新建的分区,格式8e
  31. Command (m for help): w # 保存信息
  32. The partition table has been altered!

# Step 4:重启

[root@localhost ~]# shutdown -r now
   
   
   
   

# Step 5:创建物理卷


   
   
   
   
  1. [root@ganxide ~] # pvcreate /dev/sda3
  2. Writing physical volume data to disk "/dev/sda3"
  3. Physical volume "/dev/sda3" successfully created

# Step 6: 查看新建的物理卷和大小


   
   
   
   
  1. [root@ganxide ~] # pvdisplay
  2. --- Physical volume ---
  3. PV Name /dev/sda2
  4. VG Name VolGroup # lv_root卷组
  5. PV Size 15.51 GiB / not usable 3.00 MiB
  6. Allocatable yes (but full)
  7. PE Size 4.00 MiB
  8. Total PE 3970
  9. Free PE 0
  10. Allocated PE 3970
  11. PV UUID 1GHup8 -7fYH-IpYZ-QPgO-cxSl-on5z-M9oPrU
  12. "/dev/sda3" is a new physical volume of "84.00 GiB" #新的物理卷
  13. --- NEW Physical volume ---
  14. PV Name /dev/sda3 # 卷名
  15. VG Name # 卷组
  16. PV Size 84.00 GiB
  17. Allocatable NO
  18. PE Size 0
  19. Total PE 0
  20. Free PE 0
  21. Allocated PE 0
  22. PV UUID ZnLTXE-nGPK-jQAq-wMwy-f1Mb -5cvQ -4lhkmU

# Step 7:添加新的物理卷到lv_root同一个卷组


   
   
   
   
  1. [root@ganxide ~] # vgextend VolGroup /dev/sda3
  2. Volume group "VolGroup" successfully extended

# Step 8:查看卷组信息


   
   
   
   
  1. [root@ganxide ~] # vgdisplay
  2. --- Volume group ---
  3. VG Name VolGroup
  4. System ID
  5. Format lvm2
  6. Metadata Areas 2
  7. Metadata Sequence No 4
  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 2
  15. Act PV 2
  16. VG Size 99.50 GiB
  17. PE Size 4.00 MiB
  18. Total PE 25473
  19. Alloc PE / Size 3970 / 15.51 GiB
  20. Free PE / Size 21503 / 84.00 GiB # 未分配空间
  21. VG UUID pwCU5u-NikD-vMp3-goth-CXJU-Pf18 -0ihmoV

# Step 9:增加lv_root的大小,增加50G


   
   
   
   
  1. [root@ganxide ~] # df -h
  2. Filesystem Size Used Avail Use% Mounted on
  3. /dev/mapper/VolGroup-lv_root
  4. 12G 5.3G 5.7G 49% /
  5. tmpfs 1.9G 0 1.9G 0% /dev/shm
  6. /dev/sda1 485M 32M 429M 7% /boot
  7. [root@ganxide ~] # lvresize -L +50G /dev/mapper/VolGroup-lv_root
  8. Extending logical volume lv_root to 61.63 GiB
  9. Logical volume lv_root successfully resized

# Step 10:重新识别大小, xfs_qrowfs 是centos7的命令,在centos6.X中是resize2fs


   
   
   
   
  1. [root@ganxide ~] # 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 = 4
  5. Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 16156672 ( 4k) blocks.
  6. The filesystem on /dev/mapper/VolGroup-lv_root is now 16156672 blocks long.

# Step 11:查看扩容后的大小


   
   
   
   
  1. [root@ganxide ~] # df -h
  2. Filesystem Size Used Avail Use% Mounted on
  3. /dev/mapper/VolGroup-lv_root
  4. 61G 5.3G 53G 10% / # 空间增加到61G 原来只有15G
  5. tmpfs 1.9G 0 1.9G 0% /dev/shm
  6. /dev/sda1 485M 32M 429M 7% /boot

你可能感兴趣的:(Linux)