Adding a New SCSI or IDE Hard Disk to Your Linux Box (Redhat, CentOS)
1, Find out if your new hard disk is IDE or SCSI drive. Use the following table for naming convention. For example, if you are adding second SCSI drive, use sdb for your hard disk. This guide uses SCSI as example.
IDE SCSI Primary Slave Primary Slave hda hdb sda sdb
2, Verify your system is using SCSI hard disk
[root@innovitainc ~]# df -h
Filesystem
Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 32G 26G 4.1G 87% /
/dev/sda1 99M 33M 62M 35% /boot
none 1.5G 0 1.5G 0% /dev/shm
3, Create Partitions
[root@innovitainc ~]# 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):
p Disk /dev/sdb: 73.4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System
Command (m for help):
n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-8924, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-8924, default 8924):
Using default value 8924
Command (m for help): p Disk /dev/sdb: 73.4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System
/dev/sdb1 1 8924 71681998+ 83 Linux Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
4. Format hard disk
[root@innovitainc ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
8962048 inodes, 17920499 blocks
896024 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=20971520
547 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
5. Make a directory for mounting the new partition
[root@innovitainc ~]# mkdir /disk2
6, Use vi to edit the /etc/fstab file.
[root@innovitainc ~]# vi /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/dev/hda /media/cdrom auto pamconsole,exec,noauto,managed 0 0
/dev/sdb1 /disk2 ext3 defaults 1 2
add the following line to /etc/fstab
/dev/sdb1 /disk2 ext3 defaults 1 2
the file should be like this:
# This file is edited
by fstab-sync - see 'man fstab-sync' for details
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/dev/hda /media/cdrom auto pamconsole,exec,noauto,managed 0 0
save and exit vi.
7, Mount the partition.
[root@innovitainc ~]# mount /dev/sdb1
or mount -t ext3 /dev/sdb1 /disk2
8, Verify the new drive is mounted
[root@innovitainc ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 32801652 26871124 4264276 87% /
/dev/sda1 101086 32856 63011 35% /boot
none 1557528 0 1557528 0% /dev/shm
/dev/sdb1 70557052 86080 66886876 1% /disk2
[root@innovitainc ~]# mount
/dev/mapper/VolGroup00-LogVol00
on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /boot type ext3 (rw)
none on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sdb1 on /disk2 type ext3 (rw)
[root@innovitainc ~]# fdisk -l
Tags: Linux
Disk /dev/sda:
36.4 GB, 36420075008 bytes
255 heads, 63 sectors/track, 4427 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 4427 35455455 8e Linux LVM
Disk /dev/sdb: 73.4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 8924 71681998+ 83 Linux