new disk on ubuntu

Basic MAchine

I built a Basic Ubuntu 14.03 machine - nothing fancy.

In VirtualBox I choose to allocate 8Gb of storage.

Looking in the Machine

The machine reboots - and I check the disk space...

df -kh

Create a Disk

With the Machine powered down create a new Drive and Attach it via VirtualBox

Adding The Storage

Boot the machine - and as root

df Take note of the mounted devices (/dev/sda1)

fdisk -l

Now see what devices you have

Take note of the filesystem partition of your physical volume sits (ex. /dev/sda2)

Creating a New Device


Let us assumes that the new device shows up as /dev/sdb.

fdisk /dev/sdb We need to organise the partitions

Select your partition (we are creating from new from /dev/sdb)

n Create a new partition p Make it a primary partition 1 The partition number to make it on (same as we deleted) Set the starting block (keep the default as it is usually correct) Set the ending block (keep the default as it is fine for our use case) w Write the partition (will also exit fdisk shell)

reboot We must reboot in order to have the new partition table loaded

fdisk -l

Shows /dev/sdb and is 2.6 Gb is size.

fdisk /dev/sdb

o create new Partition Table

n New Partition

p Primary

1 Partition No

return Start Block

return End Block

w Write and Exit

Create a File System

Now we need to make a file system

mkfs -t ext4 /dev/sdb1

At this point we can mount the disk

2 ways

  • by Device Name
  • by BLKID

BLKID is more reliable, DeviceID is a little simpler.