adding a hard disk under linux

chris (2003-09-06 00:42:41)
6579 views
1 replies
To add a disk to your linux box:

First plug the thing in - make sure you get the jumpers fixed right and if you're unsure of what you're doing, just check in the BIOS that the system can smell the new device.

Then once you've booted and you have a shell running, try the following:

ls /proc/ide/drivers
hda hdb hdc hdd ide0 ide1 piix

let's say the new one is hdd - so first we need to create whatever partitions we want.

fdisk /dev/hdd

and use the following commands:
m - for help
p - to print the current state of the partition table
d - to delete an existing partition
n - to add a new partition - select '1' for the 1st number, then defaults for the next two
w - to write the new partition table and exit

once that's done, you can format the partition with mkfs as follows:

mkfs -t ext2 /dev/hdd1

and then mount into wherever you want it:

cd /
mkdir mnt
mount /dev/hdd1 -t ext1 /mnt

job done :)
comment
chris
2005-04-16 20:23:32

fdisk -l

Just as a side note.. I've just realised how useful fdisk is when run with the 'l' option. As the docs say, -l will:

-l List the partition tables for the specified devices and then exit. If no devices are given, those mentioned in /proc/partitions (if that exists) are used.

Here's the output on a machine with two HDD's plugged in:

bash-2.05b# fdisk -l

Disk /dev/hdd: 255 heads, 63 sectors, 4111 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hdd1 * 1 914 7341673+ b Win95 FAT32
/dev/hdd2 915 5004 32852925 f Win95 Ext'd (LBA)
/dev/hdd5 915 1958 8385898+ b Win95 FAT32
/dev/hdd6 1959 5004 24466963+ 7 HPFS/NTFS

Disk /dev/hda: 255 heads, 63 sectors, 4982 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 4741 38082051 83 Linux
/dev/hda2 4742 4982 1935832+ 82 Linux swap


Kinda useful, cos now I know which partition I want to mount.


Christo



reply icon