Click Technology

Linux, Windows, Mac it's all good

Create Virtual Disk from physical hardware

February6

This came up the other day, how do you add a disk to VirtualBox that physically exists? E.G. you have created a test vbox and would like to plug in your old laptop hard drive and have a look at the contents..

Here goes..


sudo lsblk

And get the following similar output..


NAME                       MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                          8:0    0 465.8G  0 disk  
|-sda1                       8:1    0   243M  0 part  /boot
|-sda2                       8:2    0     1K  0 part  
|-sda5                       8:5    0 465.4G  0 part  
  +-sda5_crypt (dm-0)      252:0    0 465.4G  0 crypt 
    +-mint--vg-root (dm-1) 252:1    0 465.4G  0 lvm   /
sdb                          8:16   1   7.5G  0 disk  
|-sdb1                       8:17   1   459M  0 part  /media/your-username/usbstick
sdc                          8:32   0 465.8G  0 disk  
|-sdc1                       8:33   0   243M  0 part  
|-sdc2                       8:34   0     1K  0 part  
|-sdc5                       8:37   0 111.6G  0 part  

Examine the tree and find out what your old hardware is called, e.g. /dev/sdc in this case.

Now create a directory for the virtual disk..


mkdir -p /home/your-username-here/VirtualBox/spare_disks

And use vBox’s commandline tools to create the image, changing /dev/sdX for your device location, prolly /dev/sdc.


sudo VBoxManage internalcommands createrawvmdk -filename "/home/your-username-here/VirtualBox/spare_disks/500GB-hard-disk.vmdk" -rawdisk /dev/sdX

Now chown and chmod the varioius relevant locations and that’s it..


sudo chown your-username-here:your-username-here /home/your-username-here/VirtualBox/spare_disks/500GB-hard-disk.vmdk
sudo chmod 777 "/home/your-username-here/VirtualBox/spare_disks/500GB-hard-disk.vmdk"
sudo chmod 777 /dev/sdX

Now open VirtualBox and add in the disk in the usual way (Select your box, then –> settings –> storage –> select disk controller –> click ‘adds hard disk’ icon –> Select vmdk file and that’s it. Fire up your machine and voila, the machine sees the external disk. Nice.

posted under Linux Tips | Comments Off on Create Virtual Disk from physical hardware

How to create and mount shared folders in VirtualBox

February2

On your workstation host, open VirtualBox. Select the host you want to set up shared folders on, right click and click ‘Settings’.

3

In the Settings panel (shown above), click ‘Shared Folders’ in the left pane.

Click ‘Machine Folders’ in the right pane and then the new path folder icon on the extreme right hand side.

4

Add a folder path. This location is on the host workstation and will be made available to the virtual machine, for example…

Folder Path : /home/username/VirtualBox/shared_folders/linux_mint
Folder Name : linux_mint

Click OK. Now start the client OS.

Install VBox Addidtions

Install VBox Additions by now switching to the VM you have just started.

1

In the window of this device, click on the Devices menu, Insert Guest Additions CD Image. That mounts the Additions CD.

2

Now open a terminal prompt. Switch directories to the CD. It’s auto-mounted at

/media/username/VBOXADDITIONS_4.3.18_96516

or similar, depending on revision / edition etc. so cd into it thus..

cd /media/username/VBOXADDITIONS_4.3.18_96516

Now run the command below..

sudo ./VBoxLinuxAdditions.run

It’s installed.

Now, switch back to the host workstation. Open a command line and type the following…

sudo mkdir -p /mnt/hostOS
sudo mount -t vboxsf linux_mint /mnt/hostOS/ -o rw,exec,uid=1000,gid=1000,dev

Finished.

 

posted under Linux Tips | No Comments »

Start a VirtualBox server in headless mode

October2

Sometimes (in fact, why not every time?), you will want to start a server on your machine but not have it display a console. In other words, start it ‘headless’.

First, list all your machines. From the command prompt…

VBoxManage list vms

You get a list of all the machine images thus..

"Windows XP" {f0e63449-61bc-40e1-a82f-5a9bc6fb2434}
"Debian Basic" {b596b383-04e7-4895-bfaf-94a206f66960}
"Homestead_default_1407795525403_97441" {7abc2b40-5f57-4a6f-a647-8583c8790a62}
"UDA" {68999d0c-6391-4792-b13a-c120649ab240}
"PXE Boot" {fe1480eb-68d1-493a-9a90-6c36f819410e}
"Tiny Linux" {44ed7a1d-4e75-4d21-9bdd-a23699603af4}
"Turnkey Linux" {a2194ccb-c88d-48b9-aa6f-12b0805500c9}

So, to boot the Turnkey Linux box, just enter..

VBoxManage startvm "Turnkey Linux" --type headless

You should get

VBoxManage startvm "Turnkey Linux" --type headless
Waiting for VM "Turnkey Linux" to power on...
VM "Turnkey Linux" has been successfully started.

Now, just ssh straight onto the machine

ssh root@192.168.10.123

Obviously, you need to know the ip address of the machine in advance or see your DHCP log to see what address it picked up. Otherwise, you’re ready to log in.

To shut it down again…

VBoxManage controlvm "Turnkey Linux" poweroff

Sweet!

View post on imgur.com

Check out the well-written and compact documentation for VirtualBox here.

posted under Linux Tips | No Comments »

This is my website for short blog posts and interesting materials that are noteworthy or have some handy-tip value.