rss feed Twitter Page Facebook Page Github Page Stack Over Flow Page

How to install a new drive in Ubuntu

GParted is a fantastic tool to create new partition and format hard drive in Ubuntu. But if you need to install a remove drive without having access to any GUI or remote desktop access this can be hard to accomplish. Here's how to install a brand new (or shredded disk drive) using the command line in Ubuntu.

Setup the disk

Find the disk

sudo lshw -C disk

This should output something like:

    description: ATA Disk
    product: ST9160412AS
    vendor: Seagate
    physical id: 0
    bus info: scsi@0:0.0.0
    logical name: /dev/sdb
    version: D005
    serial: 5VG71M1T
    size: 149GiB (160GB)
    capabilities: partitioned partitioned:dos
    configuration: ansiversion=5 signature=000bbc87

Prepare the disk

sudo fdisk /dev/sdb

You now have a partitioned hard drive that is ready to be formatted.

Format the disk

sudo mkfs -t ext3 /dev/sdb1

** sdb1: since it's the first partition

Create A Mount Point

Create folder

sudo mkdir /media/newdisk

Now let's edit the fstab so Ubuntu recognize the disk the next time you reboot.

sudo vi /etc/fstab

Add this line to the end (for ext3 file system):

/dev/sdb1    /media/newdisk   ext3    defaults     0        2

You can now run "sudo mount -a" (or reboot the computer) to have the changes take effect.

If you want to allow a specific user to access files on this new drive, you need to change the user ownership of the root directory of the new drive

sudo chown -R myuser:myuser /media/newdisk