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:
*-disk
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
- First, add a new partition. Type "n" and press enter;
- Then create a primary partition. Enter "p" and enter;
- Since this will be the only partition on the drive, number 1. Enter "1" and enter; If it asks about the first cylinder, just type "1" and enter. (We are making 1 partition to use the whole disk, so it should start at the beginning.)
- Now that the partition is entered, choose option "w" to write the partition table to the disk;
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