Tuesday, March 9, 2010

Ubuntu : Adding a new hard drive

After you have installed the hard drive and booted up do the following:

# lshw -C disk
  *-disk:0              
       description: ATA Disk
       product: ST3250410AS
       vendor: Seagate
       physical id: 0
       bus info: scsi@0:0.0.0
       logical name: /dev/sda
       version: 3.AA
       serial: 6RYC8Y1L
       size: 232GiB (250GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=5 signature=000d0ffe
  *-disk:1
       description: ATA Disk
       product: ST3500418AS
       vendor: Seagate
       physical id: 1
       bus info: scsi@1:0.0.0
       logical name: /dev/sdb
       version: CC34
       serial: 6VM0M7CJ
       size: 465GiB (500GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=5 signature=000d099d


In this case I added disk:1 to the system and we can see it assigned /dev/sdb as the logical drive. You can also look in the dmesg output to see what has been assigned but this is easier.

Next you need to create partitions on the drive using fdisk (as root):

fdisk /dev/sdb

Command (m for help): m
  Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

  Command (m for help):


Type n for new partition

Command action
   e   extended
   p   primary partition (1-4)

Type p

Partition number (1-4):

Enter 1 if you are just creating a single partition
Then type w to write and exit.

Now the partitions are created you need to create the file system on the drive:

mkfs -t ext3 /dev/sdb1

When done you need to create a mount point, in this case I made mine /storage, and then edit your /etc/fstab file so the OS can mount the drive:

mkdir /storage
vi /etc/fstab


Add the following

/dev/sdb1    /storage   ext3    defaults     0        2

When done you then execute the following to mount the drive

mount -a

Check the drive is there

df -h

Whallah!

No comments: