VirtualBox

Resize Storage in Centos7

Recently one of the VirtualBox system (OS is Centos7) is running out of space, so trying to enlarge the storage. Change disk/snapshot size in VirtualBox Open Vitual Media Manager Select the disk or snapshot to be resized, current is 20GB Enter the new size 40GB and click Apply turn on the system, and check with lsblk # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 40G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 17G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] Allocate the Free Space Enter command cfdisk Select the Free Space one Select New and Press Enter Select Primary and Press Enter Update Size or keep default to use full free space, and Press Enter Select Write and type yes to write the partition table to disk Select Quit to exit from cfdisk Extend partition # fdisk /dev/sda Enter p to print the initial partition table Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM /dev/sda3 41943040 83886079 20971520 83 Linux Enter t then 3 then 8e to change the new partion type to “Linux LVM” Enter p to print the new partition table Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM /dev/sda3 41943040 83886079 20971520 8e Linux LVM Enter w to write the partition table to disk Update kernel in-memory partition table Update the kernel in-memory partition table, and we can see sda3

Add Disk Storage to VirtualBox on Centos7

Add the Virtual Dirve Open Oracle VM VirtualBox Manager, select the virtual box which we want to add the storage, click Settings Click Storage, Select Drive (Controller: SCSI or Controller: IDE etc.) and click Adds hard disk Follow the instructions to enter all the details, such as disk file location, size etc. Partition the New Drive and file system # the new driver assigned to /dev/sdb ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sdb # partition with fdisk fdisk /dev/sdb # change: DOS Compatibility flag is not set (command 'c') and Changing display/entry units to sectors (command 'u') # enter n (new partion) , p(primary partition), 1 (partition number) ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdb1 # create a file system /sbin/mkfs.