Virtualbox扩容
打开VB的“管理”
管理—>虚拟介质管理
但这里仅仅增加了虚拟内存的大小,还需要在终端进行操作增加实际分区的内存大小。
Centos系统扩容
- 查看一下调整后的磁盘状态 ```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
2. 磁盘分区```bash[root@HDPmaster ~]# fdisk /dev/sda欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。命令(输入 m 获取帮助):m命令操作a toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partitiong create a new empty GPT partition tableG create an IRIX (SGI) partition tablel list known partition typesm print this menun add a new partitiono create a new empty DOS partition tablep print the partition tableq quit without saving changess create a new empty Sun disklabelt change a partition's system idu change display/entry unitsv verify the partition tablew write table to disk and exitx extra functionality (experts only)命令(输入 m 获取帮助):nPartition type:p primary (2 primary, 0 extended, 2 free)e extendedSelect (default p): p分区号 (3,4,默认 3):3起始 扇区 (16777216-167772159,默认为 16777216):将使用默认值 16777216Last 扇区, +扇区 or +size{K,M,G} (16777216-167772159,默认为 167772159):将使用默认值 167772159分区 3 已设置为 Linux 类型,大小设为 72 GiB命令(输入 m 获取帮助):t分区号 (1-3,默认 3):3Hex 代码(输入 L 列出所有代码):8e已将分区“Linux”的类型更改为“Linux LVM”命令(输入 m 获取帮助):wThe partition table has been altered!
使用partprobe重新读取分区表,或者重启机器
[root@localhost]# partprobe
格式化分区 ```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: 完成
5. 添加新LVM到已有的LVM组,实现扩容关于lvm的一些基础知识可以参考这里:[http://blog.csdn.net/wuweilong/article/details/7565530](http://blog.csdn.net/wuweilong/article/details/7565530)<br />a. 初始化刚才的分区```bash[root@HDPmaster cy]# lvmlvm> pvcreate /dev/sda3WARNING: ext3 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: yWiping ext3 signature on /dev/sda3.Physical volume "/dev/sda3" successfully created.
b. 将初始化过的分区加入到虚拟卷组
vgextend centos /dev/sda3
c. 扩展已有卷的容量
lvm> lvextend -l +81920 /dev/mapper/centos-rootInsufficient free space: 81920 extents needed, but only 18431 availablelvm> lvextend -l +18431 /dev/mapper/centos-rootSize of logical volume centos/root changed from <6.20 GiB (1586 extents) to 78.19 GiB (20017 extents).Logical volume centos/root successfully resized.
d. 退出
quit
- 扩展/root文件系统
xfs_growfs /dev/mapper/centos-root
