Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I add a new hard drive? 5

Status
Not open for further replies.

Quintios

Technical User
Mar 7, 2002
482
US
I have a basic install of RH 7.3 with one hard drive. I just added a slave hard drive to the system. It's already formatted with FAT32.

I'm very very very new to Linux. This whole 'root' thing and mounting drives and such is a bit cryptic at the moment. I'm reading through my 'Dummies' book as fast as I can go.

Will the new hard drive appear somewhere? Where? How do I access it? Can I leave it in FAT32 and still use it with Linux?

Thanks!!

Onwards,

Q-
 
Quintios, hi

1: Can you leave FAT32 on the slave disk. You can have what ever type of filesystem you want on the slave disk. You just need to make sure you have the tools you need.

For using FAT32, use the vfat module. Most stock kernels have it built in.

If you have any questions feel free to ask.

 
Well, without doing any reading, I do have one question.

I have the computer set up as a server. I want to use it as a webserver and a ftp server. I'm going to load Apache, but when I did the install I selected the SMB module so it could talk to the other windows computers on my little network, and the FTP server cause I want to share files.

Does Apache do FTP as well as HTTP? Should I not have installed the FTP module? I know that the http files need to go in the htdocs directory in Apache. Most of the files I want to share are fairly big and I need to store them on the other hard drive that I added. How do I link to them from a web page stored in 'htdocs'.

I know I need to do some research before I ask these questions, but since you said "feel free to ask" I got all free and stuff. ;-)

I appreciate your help! Thanks!



Onwards,

Q-
 

1: Does Apache do FTP? It is not a FTP server, you should install something secure ftp like proftp or vsftp.

2: The apache document root is /var/ww/html. The conf files are in /etc/httpd/confs/

You can either edit the httpd.conf to point to the correct place, create a virtual dir, or create a link to where the docs are. Be very careful with links to make sure you do not open any security holes.

:)
 
Next question. If a drive only has one partition, and I delete the partition, does that unmount the drive.

I made it 3/4 the way through the FAQ mentioned in this thread, but I don't really know how to edit the fstab file.

I added /dev/hdb and the partition /dev/hdb1

I mounted it. And now I'm supposed to somehow edit the fstab file. I can't tell from what is currently in it what to add to it.

I'm finding that I'm so used to Windows that this is really confounding at the moment. All this mounting and unmounting...

Thanks again for your help!

Onwards,

Q-
 
ok, no need to despair. We will get through this.

1: The fstab tells the linux system what filesystems to mount on boot and how they are mounted.

To edit fstab, if you are not familiar with vi or emacs use pico. It is a very simple editor.

pico /etc/fstab

You should not have any problems using pico. I usually tell people that do not know how to use vi to use pico.

You will need to add your second hard drive. Which means you need to enter the information for your hard drive. What is important is the type of filesystem, ext2/3 vfat, etc where you want it to be permanantly mounted.

Example: I have a hard drive as a secondary master. {HDC}. It is both partitioned and formated. I want to have 1 big volume to share, so I will call my mount point Public.

I create the dir Public on the root of the os, so that it is read,write,execute by everyone.

mkdir /Public -m 0777

In fstab I add the following
/dev/hdc1 /Public ext3 defaults 1 1


If you have already mounted the drive to a different location unmount it.

umount /where_I/mounted_the_drive

type mount to make sure it is not mounted anymore.

Type mount -a to remount using the fstab.

Type mount to verify it is mounted in the correct location.
 
Oooooooo!

Now it makes sense!

What if you wanted to allocate the drive to two folders, say, htdocs and ftdocs? This particular drive is a slave, so it's hdb.

Would you:

mkdir /htdocs -m 0777
mkdir /ftdocs -m 0777

Edit fstab to read

/dev/hdb1 /htdocs ext3 defaults 1 1
/dev/hdb1 /ftdocs ext3 defaults 1 1

That's not right, is it? What are those two numbers out there at the end?

You're being extremely helpful. I tried to give you another star but it wouldn't let me. :(

Onwards,

Q-
 
>>>The fifth field, (fs_freq), is used for these filesystems by the dump(8)
command to determine which filesystems need to be dumped. If the fifth field is
not present, a value of zero is returned and dump will assume that the
filesystem does not need to be dumped.

This setting just seems to list the data from your present filesystems. I have
all of this setting on 0 for me. If anything, the output of this command
probably puts it in /proc.

/proc is a hardware/software lookup for your computer. If you type cat
/proc/cpuinfo , you see your cpu data. You might want to look at some of those
files. It's quite nice to identify that weird piece of hardware by looking what
cat /proc/pci
spits out ;-)


>>>The sixth field, (fs_passno), is used by the fsck(8) program to determine
the order in which filesystem checks are done at reboot time. The root
filesystem should be specified with a fs_passno of 1, and other filesystems
should have a fs_passno of 2. Filesystems within a drive will be checked
sequentially, but filesystems on different drives will be checked at the same
time to utilize parallelism available in the hardware. If the sixth field is
not present or zero, a value of zero is returned and fsck will assume that
the filesystem does not need to be checked.

FSCK is a FileSystem ChecK which checks your drives for possible errors, and as
a general maintenance. What usually happens on bootup is your / partition gets
mounted READ-ONLY at first. Since it's a bad idea to write on a possibly bad
partition, fsck checks the disk before going to READ-WRITE. If there's any
errors, the corrections are the first to be wrote to the disk.

The idea with this is your root partition ( /) is the first thing that needs to
be mounted, so it has to be checked first. After / , you might still have
non-removable media which you may wish to check too (very good idea). This is
how you tell mount in what order you wish to scan.

As an example, say you have
2 physical hard drives (one being your /partition), (/dev/hda1 /dev/hdb1)
a cd-rom, (/dev/hdc)
a floppy, /dev/fd0)
and a zip disk. (/dev/hdd)

Your / partition would have a 1 in this field. Then you want to set your other
HD to be scanned, so you set that as a 2. It'd be fairly useless to have
bad-block scanning on your CD-rom, as you dont have constant writes to it, so 0
it is. You could also scan your floppy, but picture having to scan a 2MB floppy
(remember, whole disk scan) every time before full bootup. 0 is just infinitely
easier. The zip disk might not be a bad idea to turn on to a 2, just so you can
scan if the disk is ok. It's your call on that one.


***Sections shamelessly taken from the command "man mount". So sue me.. ;-)

Please let Tek-Tips members know if their posts were helpful.
 
When you say allocate the drive to 2 folders, the way that you have it presented, the second will mount on top of the first.

[ HTDOCS ]

||
||
\/

[ FTDOCS ]

All you need is 1 mount point for the drive itself. If you have multiple partitions, then you add a mount point for each partition.

Once the mount point is established and the partition is mounted you can use the drive now.

You can make a link to /Public to look like each of htdocs and ftdocs.

A link in *nix is like a windows shortcut, but better. With a link, you can virtually point to anywhere on the filesystem to be somewhere else.

So you can make a link called htdocs and ftdocs put them wherever you want them and access the same place.

If I knew what exactly you are tyring to do, i can see if I can better answer your question. :)

PS. Thanks for the compliment. :)

 
Just to elaborat a little on clonny2's post.... to create a link to a directory the command is

ln -s /the/directory/you/are/linking/to /the_link/location

if you have a hard drive with one partition and 2 top level directories (htdocs and ftdocs) on the partition, and you would like these to appear as top level directories (ie. /htdocs and /ftdocs) then I would do the following:

1.created a directory using mkdir in /mnt . Let's name it "otherdrive"

2. as listed above add a line to fstab specifying that you are going to mount the hard drive to the folder
/mnt/otherdirve

3. create links in the top level directory for htdocs and ftdocs by executing the following commands:

ln -s /mnt/otherdrive/htdocs /htdocs
ln -s /mnt/otherdrive/ftdocs /ftdocs

-Venkman
 
There's a lot of information that is very new to me in this thread. It's going to take me a couple days to digest it (I only have one hour to mess with this stuff every evening...)

To answer your question as to what I'm trying to do, here it is:

I have one hard drive for the system, programs, and all that other stuff. The second hard drive will serve as the source for HTML and FTP files. I'm sitting behind a cable modem, so I'll use dyndns to set this computer up as a webserver and a ftp server.


Here's my current fstab file:
Code:
LABEL=/                /               ext3  defaults         1 1
LABEL=/boot            /boot           ext3  defaults         1 2
none                   /dev            devpts gid=5,mode=620 0 0 
LABEL=/home            /home           ext3  defaults         1 2
none                   /proc           proc  defaults         0 0
none                   /dev/shm        tmpfs defaults        0 0
LABEL=/usr             /usr            ext3  defaults         1 2
LABEL=/var             /var            ext3  defaults         1 2
/dev/hda5              /swap           swap  defaults         0 0
/dev/cdrom             /mnt/cdrom      iso   **stuff
/dev/fd0               /mnt/floppy     auto  **stuff
/dev/hdb1              /public         ext3  defaults        1 1

What I'm basically saying is that I want to have hdb available with two directories at the root, htdos and ftdocs. I don't want to allocate individual partitions to each of those because I don't want to limit the space each one has to work with. Something tells me that you can let partitions grow and stuff, but I'd rather not worry about that now. Just two dir's at the root please. :)

Thanks again for everyone's help!

Onwards,

Q-
 
Real quick.

Both FTP and Apache have a default root location specified in conf files.

You can
1: Both share the same space.
2: Both have seperate dirs both located on hdb.
3: More complicated, more secure, but no need to worry about yet is to setup what is called a chroot jail. This will mean that when you come in from those protocols you are trapped inside virtual directory space. You can only see and get to what you are allowed to. If security is important, i would later look into something like this. However you can securely setup both ftp and apache with out chroot.


Then modify the conf files to say where the dirs are located. Should be very easy. :)
 
From what I understand LVM allows you to setup resizable partitions. I've never used it so I don't know very much about it, but there is plenty of info about it on the web.

-Venkman
 
LVM does not let you resizr partitions, I don't think. IT allows you to resize a volume. The partitions onthe hard drive is another issue.
 
/dev/hdb1 /public ext3 defaults 1 1

>What I'm basically saying is that I want to have hdb ?>available with two directories at the root, htdos and >ftdocs. Just two dir's at the root please. :)

Linux (and Unix) can only have ONE root for the entire system. If you want to create 2 dirs below root in
separate drives you would have to create 2 parts like:
/dev/hdb1 /htdos ext3 defaults 1 1
/dev/hdb2 /ftdocs ext3 defaults 1 1

if you don't want to go thru the trouble of undoing your /public partition, just create 2 dirs below
/public/htdos and /public/ftdocs and create 2 soft links
ln -s /public/htdos /htdos
ln -s /public/ftdocs /ftdocs
so they will behave the same and will not have partition resinzin issues.


 
At the risk of being a complete noob, what's the procedure for undoing the mount and /public partition? It's prolly answered up at the beginning of the thread somewhere.

Can I put ftdocs and htdocs on hdb without two partitions?


*walks off cursing my Windows-centric brain...

Onwards,

Q-
 
I think you're missing the basic concepts behind file structure and partitioning in Linux. No biggy, we were all newbies at some point and I still consider myself one in many ways. In order to understand what's been said here, you should understand the basics:

partitioning makes your hard drive act like multiple hard drives, so just about everything that is said about a partition can be said about a hard drive with one partition.

After making a partition you must create the filesystem on it, just like formatting a floppy drive.

once the filesystem is created, it acts like a directory. It has subdirectories and files just like any other directory. Only one filesystem can live on a partition. So there is only one top level directory per a partition.

now at the beginning of your system boot a filesystem/partition is mounted at the top level ("/"). At this point any file you could access would be on that partition. Most linux installations contain multiple partitions for different folders. These are mounted on empty directories found within the the top level filesystem. For instance, my home directory ("/home/") is on a seperate partition. This means that within the top level filesystem ("/"), which exists on the second partition of the hard drive, there is an empty directory ("/home/"). My home folder is actually the root of the filesystem on the 4th partition on my hard drive. So the OS after mounting "/" now mounts the 4th partition on the "/home/" directory that exists within the second partition on the drive. This means that if I cd /home/ I now am at the top level of the 4th partion, similarly if I cd / I am at the top level of the 2nd partition.

Okay, now to get to your question, you have 2 directories. Do they exist at the top level of a partition other than the partion mapped to "/"? I believe from your previous posts they do. There is no way to map the directories within a partition (other than the top level) without using symbolic links to other directories. So if both of these folders exist on the one and only partition on hdc (the secondary master ide device/hard drive), then hdc must be mounted to an empty folder on another partion (say "/mnt/newdrive", which should be a subdirectory within the "/" partition/filesystem). You may then create links (or shortcuts) to these folders in "/" by a command like:

ln -s /htdocs /mnt/newdrive/htdocs

This says create a symbol link ("ln -s") at /htdocs to the directory /mnt/newdrive/htdocs. Note that just like in windows this link will become dead if you unmount the filesystem at /mnt/newdrive.

BTW, to explicity mount the file system the command is (assuming you are logged in as root):

mount /dev/hdc /mnt/newdrive


To reiterate, you cannot mount a subdirectory of a filesystem without mounting the whole thing. This is why you cannot mount these two directories in seperate places.

I suggest you pick up "Running Linux" published by O'Reilly. They give a good introduction to linux, detailing concepts like this.

-Venkman
 
Holy cow! Thank you so much for putting that much effort into a post for a complete newbie...

I have two books, one for dummies, and one for JR admins. I fall somewhere inbetween. I'll try to pick up the book you recommend...

Thanks again!

Onwards,

Q-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top