Tuesday, September 1, 2009

Adding a new disk to a Linux Fedora machine

as root:
fdisk -l to find the new disk.

You'll get something like this:

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000a121f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 1044 8185117+ 8e Linux LVM

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table


So the new disk is /dev/sdb

To create a new partition:
fdisk /dev/sdb
n (new partition)
p (primary partition)
1 (partition 1)
hit enter (first cylinder)
hit enter (last cylinder)
w (write changes and quit)

now check the new status with
fdisk -l

and now you'll get something like this:

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000a121f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 1044 8185117+ 8e Linux LVM

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x6fad050b

Device Boot Start End Blocks Id System
/dev/sdb1 1 1044 8385898+ 83 Linux

Now format the new partition
mkfs.ext3 /dev/sdb1

Create a new folder to mount the new partition:
mkdir /disk2

and edit /etc/fstab to mount it after the next reboot adding this line
/dev/sdb1 /disk2 ext3 defaults 1 2

then reboot

No comments: