While using virtual box, we will face the below issues.
- Disk space Shortage: When you are running out of space in linux/windows machine.
- Moving Virtual machine to other machine: When you want to move your virtual machine to another laptop.
Increasing virtual machine space:
Shut down the Virtual box.
Note down the virtual hard disk path.
Go to Start →Run → CMD
Navigate to the virtual box installation directory where the utility VBoxManage present
Now enter the below command to increase virtual Disk size. Replace 20000 (MB) with the size you want.
VBoxManage modifyhd E:\Practice\Fedora20.vdi --resize 20000
Now we increased the Disk space. Check in virtual box once.
Space was increased as expected.
Now, we will increase space in fedora. The storage changes are not reflected in fedora until we manually
increase the filesystem.
increase the filesystem.
We have to manually extend the space.
[root@localhost ~]# fdisk -l /dev/sda
Disk /dev/sda: 19.5 GiB, 20971520000 bytes, 40960000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000de218
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 25165823 12069888 8e Linux LVM
Note down the Id of your partition.
[root@localhost ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.24).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sda: 19.5 GiB, 20971520000 bytes, 40960000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000de218
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 25165823 12069888 8e Linux LVM
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (25165824-40959999, default 25165824):
Last sector, +sectors or +size{K,M,G,T,P} (25165824-40959999, default 40959999):
Created a new partition 3 of type 'Linux' and of size 7.5 GiB.
Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8).
run partprobe(8) or kpartx(8).
Reboot the machine.
[root@localhost ~]# fdisk -l /dev/sda
Disk /dev/sda: 19.5 GiB, 20971520000 bytes, 40960000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000de218
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 25165823 12069888 8e Linux LVM
/dev/sda3 25165824 40959999 7897088 8e Linux LVM
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name fedora
PV Size 11.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 2946
Free PE 0
Allocated PE 2946
PV UUID escjAW-rsyC-oKh2-nMtZ-WBfW-vd21-WD11rO
[root@localhost ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name fedora
PV Size 11.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 2946
Free PE 0
Allocated PE 2946
PV UUID escjAW-rsyC-oKh2-nMtZ-WBfW-vd21-WD11rO
"/dev/sda3" is a new physical volume of "7.53 GiB"
--- NEW Physical volume ---
PV Name /dev/sda3
VG Name
PV Size 7.53 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID mTNEcF-wQbO-oOmL-Ss29-QU4Q-fnwH-kcPVEi
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name fedora
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 11.51 GiB
PE Size 4.00 MiB
Total PE 2946
Alloc PE / Size 2946 / 11.51 GiB
Free PE / Size 0 / 0
VG UUID bQ3KIS-pDYO-LRXH-DMVt-1kVm-IEoN-yNhGdv
[root@localhost ~]# vgextend fedora /dev/sda3
Volume group "fedora" successfully extended
[root@localhost ~]# lvextend /dev/fedora/root /dev/sda3
Extending logical volume root to 17.84 GiB
Logical volume root successfully resized
[root@localhost ~]# resize2fs /dev/fedora/root
resize2fs 1.42.8 (20-Jun-2013)
Filesystem at /dev/fedora/root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/fedora/root is now 4675584 blocks long.
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora-root 18G 3.0G 14G 18% /
devtmpfs 1.3G 0 1.3G 0% /dev
tmpfs 1.3G 148K 1.3G 1% /dev/shm
tmpfs 1.3G 708K 1.3G 1% /run
tmpfs 1.3G 0 1.3G 0% /sys/fs/cgroup
tmpfs 1.3G 16K 1.3G 1% /tmp
/dev/sda1 477M 81M 368M 18% /boot
Now the space was extended in the Fedora also.
Moving Virtual machine:
We need to move virtual machine when we running out of space in one drive or we have brand new
laptop with us.
laptop with us.
Here is the steps that help you to move the virtual machine.
We can move the virtual machine in two ways.
- Export and import
- Manually copying virtual hard disk.
Export and import
We will see how to export and import virtual machine in virtual box.
Choose the virtual machine
Go to File →Export appliances
Click Next
Choose the export file destination and click next
Click Export.
When it is finished, OVA file will be generated at the destination location.
Now you can use this OVA file to recreate virtual machine in another machine.
Import virtual machine.
To demonstrate how import is going to work, I will delete existing virtual machine and import it from
OVA file.
OVA file.
Open Virtual box. Go to file → Import appliances
And click Open appliance
Choose the OVA file.
Click NEXT.
Check the virtual machine settings once.
I recommend to check RAM size and virtual disk location values before importing
Now click Import.
And virtual machine successfully imported.
If you face the below error while importing the virtual machine.
Uncheck the DVD and USB controller options and import it again.
Manually copying virtual hard disk
You simply copy the VDI file from one machine to another machine to move the virtual machine
to another machine. Choose to create a new virtual machine.
to another machine. Choose to create a new virtual machine.
And select Use an existing virtual hard drive file option and choose the VDI/VMDK file.
And click create. Now the virtual machine will create using existing virtual hard disk.
After creating virtual machine, please check virtual machine settings once.
No comments:
Post a Comment