VirtualBox 扩展虚拟硬盘
来源:互联网 发布:mac onedrive 打不开 编辑:程序博客网 时间:2024/05/19 04:27
the Extension of the Virtual Disk of the VirtualBox
Background:
I created a virtual disk of which the size is 5 GB for the cloud controller server. When I installed the mongodb, there is not enough space left.
Firstly, I will use the ‘df -h’ to check the usage of disk.
[cloud@controller ~(keystone_admin)]$ df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/controller--vg-root 2.6G 2.5G 272M 1% /udev 992M 4.0K 992M 1% /devtmpfs 201M 388K 200M 1% /runnone 5.0M 0 5.0M 0% /run/locknone 1001M 4.0K 1001M 1% /run/shm/dev/sda1 236M 59M 165M 27% /boot/dev/sdb1 100G 33M 100G 1% /srv/node/sdb1
In the situation, I have to extend the space of the hard disk. It is lucky that the ‘/dev/mapper/controller—vg-root’ is the LVM. the LVM can be extended easily. Now we have 2 ways to extend it. One way is to create a new virtual disk and add it into the volume group to extend it. Another way is to resize the original virtual disk and then create a new partition and add it into the volume group. the first way is easier than the other. So I select the more complicated way because I can learn more.
Step 1: extend the virtual diske size
Before you run the command, please close the related VM.
The format of the command:VBoxManage modifyhd <VirtualDiskFileName> --resize <final_disk_size_megabytes>
C:\Users\ezonghu\VirtualBox VMs\ub_ctrl>VBoxManage modifyhd ub_ctrl.vdi --resize 10240
the command means to change the ‘ub_ctrl.vdi’ virtual disk to 10GB.
Step 2: add partition
Use ‘fdisk’ to add a partition.
The format of the command:fdisk <device_path>
The original partitions:Device Boot Start End Blocks Id System/dev/sda1 * 2048 499711 248832 83 Linux/dev/sda2 501758 10483711 4990977 5 Extended/dev/sda5 501760 10483711 4990976 8e Linux LVM
Check the information of the partitions, you can see the size of the disk has been 10.7 GB. And then use the ‘n’ to add a new partition and the partition is primary and the start is 10483712 and the end is 20971519. At last use the ‘w’ to write the partition table. And use
sudo partprobe
to activate the configuration.cloud@controller:/var/log/mongodb$ sudo fdisk /dev/sdaCommand (m for help): pDisk /dev/sda: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000f20e5 Device Boot Start End Blocks Id System/dev/sda1 * 2048 499711 248832 83 Linux/dev/sda2 501758 10483711 4990977 5 Extended/dev/sda3 10483712 20971519 5243904 83 Linux/dev/sda5 501760 10483711 4990976 8e Linux LVM
And then use the command
sudo fdisk -l
to get the information of the whole disks.cloud@controller:/var/log/mongodb$ sudo fdisk -lDisk /dev/sda: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000f20e5 Device Boot Start End Blocks Id System/dev/sda1 * 2048 499711 248832 83 Linux/dev/sda2 501758 10483711 4990977 5 Extended/dev/sda3 10483712 20971519 5243904 83 Linux/dev/sda5 501760 10483711 4990976 8e Linux LVMDisk /dev/sdb: 107.4 GB, 107374182400 bytes43 heads, 44 sectors/track, 110843 cylinders, total 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x60e30023 Device Boot Start End Blocks Id System/dev/sdb1 2048 209715199 104856576 83 LinuxDisk /dev/mapper/controller--vg-root: 7247 MB, 7247757312 bytes255 heads, 63 sectors/track, 881 cylinders, total 14155776 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/controller--vg-root doesn't contain a valid partition tableDisk /dev/mapper/controller--vg-swap_1: 2143 MB, 2143289344 bytes255 heads, 63 sectors/track, 260 cylinders, total 4186112 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/controller--vg-swap_1 doesn't contain a valid partition table
Use the command
sudo mkfs.ext4 /dev/sda3
to make the ext4 filesystem.
Step3: create physical volume
use the command
sudo pvcreate /dev/sda3
to create the physical volume
use the commandsudo pvdisplay
to get the information of the physical volumes.
Step4: add a new physical volume to the volume group
use the command
sudo vgdisplay
to get the information of the volume group.
use the commandsudo vgextend controller-vg /dev/sda3
to extend the ‘contrller-vg’ volume group.
Step5: extend the logical volume
use the command
sudo lvdisplay
to get the information of the logical volume.
use the commandsudo lvextend -L +2048M /dev/controller-vg/root
to extend the 2GB space in the ‘/dev/controller-vg/root’ logical volume.
Step6: resize the file system
use the command
sudo resize2fs -p /dev/controller-vg/root
to resize.
Step7: check the result of the actions
generated by haroopad[cloud@controller ~(keystone_admin)]$ df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/controller--vg-root 6.6G 2.6G 3.7G 41% /udev 992M 4.0K 992M 1% /devtmpfs 201M 388K 200M 1% /runnone 5.0M 0 5.0M 0% /run/locknone 1001M 4.0K 1001M 1% /run/shm/dev/sda1 236M 59M 165M 27% /boot/dev/sdb1 100G 33M 100G 1% /srv/node/sdb1
- VirtualBox 扩展虚拟硬盘
- VirtualBox压缩虚拟硬盘
- VirtualBox扩展虚拟机硬盘
- VirtualBox扩展虚拟机硬盘
- virtualbox扩展硬盘方案
- VirtualBox 扩展虚拟硬盘容量
- VirtualBox下复制虚拟硬盘
- 【转载】挂载virtualbox虚拟硬盘
- virtualBox挂载新的虚拟硬盘
- virtualBox更换系统虚拟硬盘
- 调整virtualbox 虚拟硬盘大小
- VirtualBox加载虚拟硬盘文件
- VirtualBox虚拟硬盘文件管理
- virtualbox 扩展虚拟机硬盘大小
- Virtualbox 扩展虚拟磁盘空间大小
- 增加virtualbox虚拟硬盘的大小
- win7中virtualbox虚拟硬盘扩容方法
- VirtualBox 修改UUID实现虚拟硬盘复制
- 黑马程序员_多线程
- Android app 天气预报简介及要求功能实现
- 2014年辛星jquery解读第一节
- 我对博客的一点看法
- 7.22
- VirtualBox 扩展虚拟硬盘
- 天气预报主界面--main_interaface.xml
- 天气预报功能--查询广州天气的实现
- 2014年辛星jquery解读第二节
- 接口隔离原则
- 男孩卡在车窗上离奇身亡 停放不当车主要赔14万
- 2014年辛星jquery解读第三节 Ajax
- LeetCode 80. Remove Duplicates from Sorted Array II
- ELMAH and API controller in MVC4 not logging errors