Categories
Linux

How to add a new hard disk to a Linux operating System?

Once the new harddisk is connected, you can verify the connected harddisk by  issuing the below comment.
$fdisk -l

see the screenshot below.

 

 

 

 

 

 

 

As you can see above the second hard disk is detected as “/dev/sdb”

Steps for creating a new ext3 partition
1. #fdisk /dev/sdb
type “m” to see all the options available.
use “p” to print the partition table.
Now use “n” to create a new partition

 

 

 

 

it will be prompted to select

1. extended partition(e) or
2. primary partition(p)

Select the partition type based on your requirement, and press enter

Then enter the partition number, default will be 1, Then press “Enter”
Enter the desired size for the partition for example, if you want to give 5GB, you can enter +5000MB.

For saving and exit the fdisk menu enter “w”

2. Verify the created partition by issuing “fdisk -l” again.

output below

********************************************************************************
[root@redhatdemo ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2610 20860402+ 8e Linux LVM

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 609 4891761 83 Linux

********************************************************************************

you can see the new partition “/dev/sdb1”

3. Creating filesystem

#mke2fs -j /dev/sdb1

We can use mke2fs command to create a new ext3 filesystem, “-j” flag is used to enable journaling, even we can continue without enabling journaling.

4. Partition Labelling

Newly created partition can be named using the e2label command

#e2label /dev/sdb1 /newhome

5. Mounting filesystem during startup.

a. create a folder under root as “/newhome”

b. add the below entry to /etc/fstab

LABEL=/newhome /newhome ext3 defaults 1 2

save and exit.

6. Reboot and enjoy. 🙂

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *