Getting Started

This tutorial assumes that the new physical hard drive has been installed on the system and is visible to the operating system. The best way to do this is to enter the system BIOS setup during the boot process and ensure that the BIOS sees the disk drive. Sometimes the BIOS will provide a menu option to scan for new drives. If the BIOS does not see the disk drive double check the connectors and jumper settings (if any) on the drive.

Finding the New Hard Drive in Ubuntu

Assuming the drive is visible to the BIOS it should automatically be detected by the operating system. Typically, the disk drives in a system are assigned device names beginning hd or sd followed by a letter to indicate the device number. For example, the first device might be /dev/sda, the second/dev/sdb and so on.


ls /dev/sd*

This shows that the disk drive represented by /dev/sda is itself divided into three partitions, represented by /dev/sda1, /dev/sda2 and /dev/sda5.

The following output is from the same system after a second hard disk drive has been installed and detected by the operating system:

ls /dev/sd*


Creating Linux Partitions

The next step is to create one or more Linux partitions on the new disk drive. This is achieved using the fdisk utility which takes as a command-line argument the device to be partitioned (in this case /dev/sdb):

sudo fdisk /dev/sdb
[sudo] password for johndoe:
Building a new DOS disklabel with disk identifier 0xc2fe324b.


Command (m for help): 


Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xc2fe324b

   Device Boot      Start         End      Blocks   Id  System

As we can see from the above fdisk output, the disk currently has no partitions because it is a previously unused disk. The next step is to create a new partition on the disk, a task which is performed by entering n (for new partition) and p (for primary partition):

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4): 


Partition number (1-4): 1
First cylinder (1-261, default 1): 
Using default value 1
Using default value 261


Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.


ls /dev/sd*

Now that the disk has been successfully partitioned, the next step is to create a file system on our new partition.

Creating a Filesystem on an Ubuntu Disk Partition


sudo mkfs.ext3 -L /photos /dev/sdb1
mke2fs 1.40.2 (12-Jul-2007)
Filesystem label=/photos
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
262144 inodes, 524112 blocks
26205 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or

Mounting a Filesystem

Now that we have created a new file system on the Linux partition of our new disk drive we need to mount it so that it is accessible. In order to do this we need to create a mount point. A mount point is simply a directory into which the file system will be mounted. For the purposes of this example we will create a /photos directory to match our file system label (although it is not necessary that these values match):

sudo mkdir /photos


sudo mount /dev/sdb1 /photos


devshm on /dev/shm type tmpfs (rw)
/dev/sdb1 on /photos type ext3 (rw)

Configuring Ubuntu to Automatically Mount a Filesystem

In order to set up the system so that the new file system is automatically mounted at boot time, an entry needs to be added to the /etc/fstab file. This may be edited by issuing the following command in a terminal window:

sudo gedit /etc/fstab

The following example shows an /etc/fstab file configured to automount our /photos partition:

# /etc/fstab: static file system information.
proc            /proc           proc    defaults        0       0
# /dev/sda1
UUID=4a621e4d-8c8b-4b39-8934-98ab8aa52ebc /               ext3    defaults,errors=remount-ro 0       1
# /dev/sda5
UUID=9c82bf09-c6f7-4042-8927-34e46518b224 none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec 0       0
/dev/sdb1       /photos         auto    defaults        0       0