Adding New Drive in Linux

Mindwatering Incorporated

Author: Tripp W Black

Created: 06/22/2007 at 11:02 PM

 

Category:
Linux
Configuration

After adding new hard drive (or VM drive). Linux will "see" it during the next boot.
To use the drive, you must partition it and format it.

If SCSI, the drives will be sdX, where X is letters a,b,c, etc.
The first SCSI drive is sda, the second is sdb, etc.

1. From command prompt, run fdisk, example: fdisk /dev/sdb.
(The drive's info will display along with a message that drive is too big for some operating systems. The text "Command (m for help):" lets you know that fdisk is ready for you to issue it commands.
2. Type m for menu. (It's nice to review the commands.)
3. Type p to print (display to you) any current partitions on the drive.
(This is VERY important to give you a sanity check that yes, this is the correct drive to repartition. It would be a shame to wipe-out an already existing drive by accident. You can also delete an existing partition by choosing d and then the partition number (if multiple partitions).
4. Type n to create a new partition. If you want to make it the maximum (biggest) size, take the default minumum and maximum values.
5. Type w to commit these changes. (There is no going back!)

Normally, you want to format it with ext3 or ext4 format.
If the GUI is installed, at this point, I switch and run the Disk Management tool and format the partition. I then test it by mounting it.
However, if the GUI is not installed, you can use the /sbin/mkfs.ext3 program.
e.g. enter "$ sudo mkfs.ext3 /dev/sdd1" to format ext3 take the default block size
e.g. enter "$ sudo mkfs.ext4 /dev/sdc1" to format ext4 and take the default block size

Next mount the drive to a folder to test it.
(See the mount/unmount instructions under Linux in this help database.)

After you mount and test it, you can edit /etc/fstab and add like below:
e.g. enter:
$ sudo vi /etc/fstab

Scroll down past the last line and "a" add a new line. Enter similar to the following:
/dev/sdb1 /local/datastore1 ext4 defaults 1 1
/dev/sdc1 /local/datastore2 ext4 defaults 1 1

Enter <esc> followed by :wq to save your changes.


previous page

×