
This procedure has been tested on Ubuntu 12.04 LTS. I cannot guarantee that it will work seamlessly on older versions. So let's get started.
Physically install your hard drive
The first obvious step is to physically attach your hard drive with all the cables in place. Boot your PC and go to BIOS settings to confirm whether it has been successfully detected or not. Once you see the BIOS entry of your new hard drive, you can move ahead booting the system.Decide on the filesystem to be used
Linux systems fly on ext3/ext4 filesystems and that should be your preference when installing a storage device on your Ubuntu desktop. If you're going to use it both in Windows and Linux, you should choose fat32/ntfs filesystem. For simplicity's sake, we will not consider the dual usage of the new disk with two different operating systems.Check and note down important drive information
The next step involves noting down important information related to your new hard disk so that you can use that information for partitioning and mounting (activating) the hard disk. Make sure you run these commands from an administrator account. The following command will retrieve all the information Ubuntu has gathered about your new hard disk and the path it has been assigned.sudo lshw -C disk
*-disk
description: ATA Disk
product: DG098DF09G809D-0
vendor: Samsung
physical id: 0
bus info: ide@0.0
logical name: /dev/sdb
version: DA5GH62J
serial: G709DGDG809DG8
size: 126GB
capacity: 126GB
Now, we are only interested in the following line from this output - logical name: /dev/sdb. This is the logical device path (/dev/sdb) assigned by Ubuntu to your newly installed hard disk. We'll be using this logical path in different commands to complete the configuration and installation of the hard disk.
Partition and format the hard disk
At this stage, your hard disk is in a raw state and is not usable by the operating system for general reading and writing. You have to create a logical partition on your hard drive and must format it with the appropriate filesystem to make space for storage.You can partition and format your hard disk in different ways on a Linux system. You can complete this task both from the graphical desktop environment and through the regular shell commands.
Method - 1
You can use the GNOME Partition Editor to partition and format your hard disk directly from the graphical interface. If it's not installed on your Unbuntu desktop, you can easily install it through the following command.
sudo apt-get install gparted
- Right-click on the white bar and choose 'New' option to create a fresh logical partition.
- Choose 'maximum allowable' for the 'New size' option. This ensures you use the entire disk space for that single partition.
- While selecting the partition type - choose 'Primary Partition'.
- Next important step involves selecting the filesystem. Choose ext3 and click 'Add'.
- This will change the graphical list and now you can see a new partition in the list.
- Finally, click 'Apply' and wait till the entire partition is formatted.
Power users can opt for shell based partition and formatting commands to complete the same process discussed above. Here's a step-by-step procedure to get things done via shell prompt. Reminder: You must have the administrator privilege to use these commands.
- Start with issuing the following command - sudo fdisk /dev/sdb. This will open the shell-based partition manager to configure your hard disk.
- Now we need to create a new partition on the raw disk. Press 'n' and enter key to complete the command.
- Next, we have to tell the type of partition it is going to be. Press 'p' and enter key to complete the command. This tells the partition manager that it's going to be a primary partition.
- In the next step, you have to tell the application about the partition number for the newly created space. Press '1' as it will be sole partition on the disk.
- Now press 'w' and enter key to write the new partition's entry in the system's partition table.
sudo mkfs -t ext3 /dev/sdb1
- You new hard disk has been successfully installed (physically) in your computer.
- Your Linux desktop has assigned the following logical path for the entire raw hard disk - /dev/sdb.
- You've created a new primary partition on this new disk covering the entire disk space.
- Ubuntu has assigned the following logical path to the newly created primary partition on your new hard disk - /dev/sdb1.
Configure automated mounting of disk
Whenever a Linux computer boots, it reads the file /etc/fstab to mount (connect) different drives and partitions with their respective mount points (directories) so that data can be written and fetched from these drives and partitions. In simple words, this file brings all the hard drives in working condition such that users can use them easily through graphical or shell environment.To use our new hard drive, we must create an entry in this file so that it is also mounted every time our system boots up. Simply use the following command to open the file.
gksu gedit /etc/fstab
/dev/sdb1 /media/newharddisk ext3 defaults 0 2