Virtualbox扩容

打开VB的“管理”

管理—>虚拟介质管理
image.png
但这里仅仅增加了虚拟内存的大小,还需要在终端进行操作增加实际分区的内存大小。

Centos系统扩容

  1. 查看一下调整后的磁盘状态 ```bash [root@HDPmaster cy]# fdisk -l /dev/sda

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

设备 Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 16777215 7339008 8e Linux LVM /dev/sda3 16777216 167772159 75497472 8e Linux LVM

  1. 2. 磁盘分区
  2. ```bash
  3. [root@HDPmaster ~]# fdisk /dev/sda
  4. 欢迎使用 fdisk (util-linux 2.23.2)。
  5. 更改将停留在内存中,直到您决定将更改写入磁盘。
  6. 使用写入命令前请三思。
  7. 命令(输入 m 获取帮助):m
  8. 命令操作
  9. a toggle a bootable flag
  10. b edit bsd disklabel
  11. c toggle the dos compatibility flag
  12. d delete a partition
  13. g create a new empty GPT partition table
  14. G create an IRIX (SGI) partition table
  15. l list known partition types
  16. m print this menu
  17. n add a new partition
  18. o create a new empty DOS partition table
  19. p print the partition table
  20. q quit without saving changes
  21. s create a new empty Sun disklabel
  22. t change a partition's system id
  23. u change display/entry units
  24. v verify the partition table
  25. w write table to disk and exit
  26. x extra functionality (experts only)
  27. 命令(输入 m 获取帮助):n
  28. Partition type:
  29. p primary (2 primary, 0 extended, 2 free)
  30. e extended
  31. Select (default p): p
  32. 分区号 (3,4,默认 3):3
  33. 起始 扇区 (16777216-167772159,默认为 16777216):
  34. 将使用默认值 16777216
  35. Last 扇区, +扇区 or +size{K,M,G} (16777216-167772159,默认为 167772159):
  36. 将使用默认值 167772159
  37. 分区 3 已设置为 Linux 类型,大小设为 72 GiB
  38. 命令(输入 m 获取帮助):t
  39. 分区号 (1-3,默认 3):3
  40. Hex 代码(输入 L 列出所有代码):8e
  41. 已将分区“Linux”的类型更改为“Linux LVM”
  42. 命令(输入 m 获取帮助):w
  43. The partition table has been altered!
  1. 使用partprobe重新读取分区表,或者重启机器

    1. [root@localhost]# partprobe
  2. 格式化分区 ```bash [root@HDPmaster cy]# mkfs.ext3 /dev/sda3 mke2fs 1.42.9 (28-Dec-2013) 文件系统标签= OS type: Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 4718592 inodes, 18874368 blocks 943718 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=4294967296 576 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成

  1. 5. 添加新LVM到已有的LVM组,实现扩容
  2. 关于lvm的一些基础知识可以参考这里:[http://blog.csdn.net/wuweilong/article/details/7565530](http://blog.csdn.net/wuweilong/article/details/7565530)<br />a. 初始化刚才的分区
  3. ```bash
  4. [root@HDPmaster cy]# lvm
  5. lvm> pvcreate /dev/sda3
  6. WARNING: ext3 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: y
  7. Wiping ext3 signature on /dev/sda3.
  8. Physical volume "/dev/sda3" successfully created.

b. 将初始化过的分区加入到虚拟卷组

  1. vgextend centos /dev/sda3

c. 扩展已有卷的容量

  1. lvm> lvextend -l +81920 /dev/mapper/centos-root
  2. Insufficient free space: 81920 extents needed, but only 18431 available
  3. lvm> lvextend -l +18431 /dev/mapper/centos-root
  4. Size of logical volume centos/root changed from <6.20 GiB (1586 extents) to 78.19 GiB (20017 extents).
  5. Logical volume centos/root successfully resized.

d. 退出

  1. quit
  1. 扩展/root文件系统
    1. xfs_growfs /dev/mapper/centos-root