I'm currently using Ubuntu 14.04.2 Server on Oracle VM VirtualBox as I'm trying to understand the deployment to be ready to deploy it in a real network.
Here is the situation. Currently, I have assigned a 8GB HDD to the VM which I use for the system. Now, I want to add another HDD, say 12GB, to be used with Samba for storing files to be shared among multiple users.
What I need to be able to do is:
- Add a new 12GB HDD to the VM
- Link the newly added HDD to the system
- Mount it as /srv/share/ which will be used with the Samba
What I also need to know, is the process the same for a real hardware?
The base HDD is 500GB and the secondary is 1TB
1 Answer
These are minimum steps to create and attach a new virtual hard drive to an existing virtual machine:
In the host:
Create a virtual hard drive
VBoxManage VBoxManage createhd --filename <path/to/name.vdi> --size <in MB>Attach this drive to the VM
VBoxManage storageattach "<VM name" --storagectl SATA-Controller --port <number> --type hdd --medium </path/to/name.vdi>Boot the virtual machine
Alternatively we may also just add a new partition to an already attached exisiting virtual drive by increasing it's size which then needs to be partitioned too.
In the guest:
Partition the new drive
You may want to find out the device decriptor of the new drive with
sudo fdisk lfirst.sudo parted /dev/<sdx> ## run parted on device sdx (parted) mklabel msdos ## create a msdos partition (parted) mkpart primary ext4 1MiB 100% ## create primary ext4 partition using whole disk (parted) quitFormat the new partition
sudo mkfs -t ext4 </dev/sdX1>Mount this partition
sudo mount <options> /dev/sdx1 <mountpoint>If mounting in 4. worked then optionally put an entry in
/etc/fstabfor mounting on boot:<UUID> <mountpoint> ext4 <options> 0 2The
<UUID>can be read fromsudo blkid,<options>as formount.
All steps can of course also be performed from a GUI. For steps 1. to 3. this would be the Virtual Box Manager in the host. For steps 4. to 5. it would be gparted in the guest (e.g. by temporarily booting to a live Ubuntu). Manual mounting needs a terminal, editing fstab can be done with any editor.
For more details on creating virtual hard drives also see the Virtual Box Manual.
8