Discussion Locked

Add a Hard Drive

0 helpful
12 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have Debian installed with a SCSI HDD as the Boot Drive.

I want to add a second HDD. The second HDD is a Western Digitial 20 GB IDE Drive. Debian sees it as it boots up but I can't find out how to prepare it to be used with Debian.

What are the steps for adding a second HDD in Linux?

Thanks

12 replies

by jaqui

1) run fdisk to create the partition structure on hda
2) assign mount point(s)
3) edit fstab to mount at boot if wanted.

or, if already existing partion,
run mount to mount it.
define the mount point first naturally.

existing partiton is most likely fat32 or ntfs

by andeanderson

When I try to fdisk the hda, fdisk /dev/hda, I receive the following message "cdrom: open failed"

Why is it trying to fdisk my cdrom?

I am new to Linux and you lost me after fdisk. The Help file tells me no help topics match either "fdisk" or "mount."

Wouldn't Linux format the new partition? When I use fdisk then all FAT or NTFS partitions would be deleted and I would have to repartition and reformat the hard drive for whichever file system I wanted to use. At least that is what it does with the fdisk that I have beeen using for the last 15 years.

I asked here because the documentation I found only talks about Hard Drives during the installation. The other documentation I found only talks about unmounting and remounting.

Thanks for trying.

by jaqui

swap the channels to the cdrom and hard drive.
seems you have the cdrom in channel0 and hard drive in 1
( primary = 0 secondary =1 )

that is why fdisk is going after the cdrom.

or, type fdisk hdc

no, this will not autmatically remove partitions.
try typing fdisk --help to get full fdisk options in usage.
yes the -- is needed if you use the help.
single - with just h will do same thing, display the help screen.

moount is the system tool to be able to access hard drives, cdroms, dvdroms, or floppy drives.
if there is a disk in and you don't mount the device, then it won't be accessable.

maybe it's been named umount or umount2 ( I've seen both used )
you have to explicitly tell linux fdisk to do something, same as with microsoft's version.

by earlezo

Hi,
linux refers to devices according to the way they are installed. Primary Master is /dev/hda, Primary Slave is /dev/hdb and Secondary MAster is /dev/hdc. Secondary IDE channel slave is referred to as /dev/hdd

A cd rom can be known as either /dev/cdrom or the drive place in the connection schema above.

You use the command fdisk to partition the drive. "cfdisk" is more user fiorendly if installed. Alternatively, you can use a commercial tool such as Partition Magic. There are many others but cfdisk is quite easy. ALso look at bootitng to manage partitions. Do NOT install it - use it in maintenance mode.

Once you have created a partition, you need to create a "mount point" on your directory tree.

Assume you wish to use this drive to replace your existing /home directory to store user files.

I will assume for example that the drive is /dev/hdc.

Back up your existing /home and test it.
After partitioning, use the mke2fs command to format the drive. If it is /dev/hdc1 the command is mke2fs /dev/hdc1

Then you can copy the existing /home to the partition using the command
dd if=/home of=/dev/hdc1

Verify that the copy was successful

Use the mv command to rename /home as /oldhome
Create a new directory /home
Issue the command mount /dev/hdc1 /home

Run the command mtab and you will see the line that refers to /home and /dev/hdc1

Copy that line to the file /etc/fstab

IF all is well, you can after a prudent amount of time, delete the /oldhome directory freeing up the space.

I hope that has been helpful

by andeanderson

Sorry, but if I knew what a mount point was it might help. And why would I want to move the home directory?

by jdclyde

In my experience, THIS WILL NOT WORK.

I tried to do something like this not long ago and found the if you put an IDE drive in your system, the system will try to boot to that INSTEAD of the SCSI drive.

There was not an option in the BIOS to select the SCSI drive before the IDE.

I had a three SCSI drives, and wanted to throw one big IDE drive in for a quick ADDITIONAL backup. We have some users that pooch files quite often, and would have been much quicker to retrieve from an internal hard drive than to search the tape backups. This was going to be in addition to the tape. Didn't work so.

by andeanderson

Sounds like what I'm trying to do. I have a Boot SCSI Hard Drive, my BIOS allows this and can see the IDE Drive, but I can't get Linux to accept or use the IDE HDD.

by stress junkie

I've read the previous answers. If I didn't know the answer already those answers wouldn't help much. I looked around the Internet to see if there was a good procedure. I couldn't find one. Maybe this will help.

First you have to understand how the disks are named in Linux. The master disk on the first IDE controller is /dev/hda. The slave disk on the first IDE controller is /dev/hdb. The first SCSI disk is /dev/sda. The second SCSI controller is /dev/sdb. And so on.

When you originally installed Linux you should have had the CDROM as the master on the first IDE controller. That would make it /dev/hda. If you do $ls -l /dev/cdrom it probably points to /dev/hda. Now you want to install another IDE disk. You should install it as the master on the second IDE controller. That will probably make it accessible through /dev/hdb or /dev/hdc.

Once you have the cables and jumpers on the new disk set up then boot Linux. There are numerous utilities to show you what hardware is in your system but we'll use trial and error because it is simple and fast.

Log in as root. Start a terminal window such as xterm or gnome-terminal. Check to see if there is a program called /sbin/cfdisk. If that exists then run it. If /sbin/cfdisk doesn't exist then run /sbin/fdisk. Either way you want to pass one of the disk paths to the program as follows:

# /sbin/cfdisk /dev/hda

If you passed the path to the CDROM the program will fail saying that it cannot access the disk. In that case try another device path. If no device paths work then Linux cannot 'see' your new disk. Check the master/slave jumper. Check the data cable connector to see if it is inverted.

Once you have the right device path then cfdisk or fdisk will show you their opening screens. cfdisk is graphical. fdisk is like MS-DOS FDISK. It is command line. Press m and press enter to get a list of commands.

That should get you started. It seems that I've used up my 2000 character limit. I will add a comment for mo

by stress junkie

So now you have one or more partitions on your new disk. Each partition is addressed by succeeding integers as 1, 2, 3, and 4. Now you have to create a file system on the partition(s). I recommend the basic ext2 file system. Once you get more experience you can always play with the other file system types. In the following command we'll use the default values for most of the configurable options. We will assume that the new IDE disk is /dev/hdb. As root enter the following command:

/sbin/mke2fs -n -v -T news /dev/hdb1

This will test run the command. It will not actually do anything. If you get no errors then run the command without the -n as follows:

/sbin/mke2fs -v -T news /dev/hdb1

When that is finished you have to create an empty directory in the existing file system. This will be the access point for the file system on the new disk. You need a mount point for each partition. You could create a mount point as a subdirectory to the existing /mnt directory. Let's do that. Enter the following command:

mkdir /mnt/newdisk

Now you can mount the disk to that empty mount point as follows:

mount -t ext2 /dev/hdb1 /mnt/newdisk

Now enter the following command:

df

This should show that /mnt/newdisk has a file system mounted.

Now enter the following commands

cd /etc
cp fstab fstab.original
chmod u+w fstab
pico fstab

This will get you into a text editor, pico, which is very easy to use. Add the following line to the bottom of the file:

/dev/hdb1 /mnt/newdisk ext2 defaults 1 1

Save the file. Then enter the following commands:

umount /mnt/newdisk
df

You should be able to see that the /dev/hdb1 disk/partition is no longer mounted. Now enter:

mount -a
df

You should be able to see that /dev/hdb1 is once again mounted on /mnt/newdisk. The system will automatically mount this when you restart Linux.

by andeanderson

I went through this. My IDE HDD is a FAT32 drive. So the ext2 type didn't work. In Debian I read that I had to use the VFAT type for my hard drive.

I set-up a mount point in the /fstab but Linux still refuses to recognize the IDE HDD, I think. If I try to manually mount it with mount -a I get a no mount points available to mount. Yet, the new directory shows up as available. So, where is the new directory actually located?

On the IDE or SCSI HDD? I can find no way to verify where this directory was, apparently, magically created from the /fstab file. Since everything appears to be assigned by directory name then there is no way to know what is physically on what HDD.

Makes it kind of hard to check on available disk space doesn't it?

Sorry, but I have to be able to reconcile what is physically on what HDD in my own mind. I don't want to end up filling a HDD and having it crash when it runs out of room, like I have seen happen before.

by stress junkie

I don't completely understand your response to Answer 5. This is what I think you said.
The new hard disk already has a VFAT file system.
Someone told you that you have to have a VFAT file system.
When you try to mount the partition the mount command says that the mount point does not exist.

If I understand you then it seems like all that you have to do is to create a mount point for the disk/partition and make sure that the mount command understands that the partition is formatted as VFAT.

First, you do NOT have to use VFAT. If the disk already has a formatted VFAT partition that you want to preserve that's fine.

Let's keep the idea that you want to mount the new partition at /mnt/newdisk in the Unix file system. Make sure that the /mnt/newdisk directory exists and is empty. You didn't mention about how Debian "sees" the disk. I will continue as in Answer 5 to refer to this new disk/partition as /dev/hdb1. Then enter the following command. Adjust your actual command accordingly.

mount -t vfat /dev/hdb1 /mnt/newdisk
df

That should do it. Now if the df command shows that a file system exists at /mnt/newdisk then just edit the /etc/fstab file accordingly.

Let me know how it works out. I will be happy to provide more assistance if required. If this doesn't work then when you comment on this answer let me know what messages Debian gives you to make you believe that it sees the new hard disk. Also, you can still use /sbin/cfdisk or /sbin/fdisk to verify that the new disk already has a VFAT file system on a partition. I recommend that you do that. Good luck.

This discussion is closed to new replies.