On 06-Jul-98 Steve Cherry wrote:
> I am aadding a 2nd hard drive to my Linux box and am having trouble. I
> fdisk the drive and setup a partition. But I don't know what to do to allow
> the system to recognize the drive.. Can someone help me.
First of all are you using fdisk in Linux? I am going to assume you have some
basic knowledge of linux commands and the root user but I will try to fill in as
many details as I can without getting confusing, or that is what I will try to
do. :)
I am assuming you have an IDE HD but these instructions are pretty much the same
for SCSI except the drive designations are based on SCSI ID's and appear as
sda1, sdb3 etc...
In any case you have to use the Linux fdisk(Note I prefer fdisk over programs
like the RedHat Disk Druid cause that is what I started with, you mileage may
vary.) :)
eg.
[EMAIL PROTECTED]# fdisk /dev/hdb
Create the desired number of partitions and make sure you set the types
correctly.
If the partitions are to be Linux partitions then they have to be set to 83.
Linux fdisk sets partitions to 83 by default. If you want additional swap
partitions then you must set the type to 82 and dos I believe is 6 for >=32MB
Note: In order to get reasonable device designations I recommend setting
all of the partions to be primary(up to four). This will make your partitions
appear as hdb1, hdb2, hdb3 etc..
Once this is done you must create file systems on the appropriate partitions.
I will stick to ext2 for simplicity but making an msdos file systems is very
similar. I also assume on the basic linux tools ie no fstools GUI like that
which comes with RedHat, in my experience knowing the details will save your
butt in a pinch. :)
I also assume that you have created two partitions on the drive, both are Linux
partitions.
[EMAIL PROTECTED]# mkfs -t ext2 /dev/hdb1
This command will run and spit out a bunch of numbers, these are the inodes and
superblocks. They are not that important but they are interesting from a
technological perspective and how Unix file systems actually work. There are
several good books on the subject. BTW: The making of the filesystems should
occur relatively rapidly since we are not using any bad block checking. Feel
free to read the mkfs man pages to learn more about this command.
You can now create the file system on the second partition.
[EMAIL PROTECTED]# mkfs -t ext2 /dev/hdb2
Now that we have two file systems we need to mount them.
This can be done via the mount command.
First we need to create mount points for these drives. I have often found it
useful to have the /opt and /usr/local on different drives so that is how I
will set things up. /opt is used primarily for third party commercial apps like
Aplixware as well as the KDE, /usr/local is a good place to build programs that
are not available in binary format.
Another very useful mount is /tmp, especailly if your / is crowded and you are
running processes that create a lot of tmp files or logs. It is also a good
thing to do if you system is being used by multiple people as it will increase
realiability by preventing / from filling up so easily. It can also limit some
Denial of Service attacks etc.
I recommend taring up /usr/local if there is anything
important there. It will still be there, hidden under the mount however it will
be completely inaccesible while the new FS is mounted. If you tar up the
directory and then untar it onto the new mount (new partition) there should be
really no difference from a use perspective. The exception is that you cannot
move directories across partitions(You can cp and remove but cannot use a
direct mv(1) command). The details of why this is again are in the specifics
of how Unix FS like ext2 work.. The same goes for /opt if that is in use.
If either of these directories do not exist create them.
[EMAIL PROTECTED]# mkdir /opt
To test your new drives we need to mount them
[EMAIL PROTECTED]# mount -t ext2 /dev/hdb1 /opt
This should succeed and when you do a ls -l of the directory you should see a
dir called lost+found
[EMAIL PROTECTED]# ls -l /opt
drwxr-xr-x 2 root root 12288 May 11 14:36 lost+found/
[EMAIL PROTECTED]#
Why this dir is there is again the result of those Unic file system details
again. As an aside this directory is where the OS will place any lost files or
blocks, say if you had a power failure which resulted in some File System
corruption. See fsck(8) for more info.
Now you can try mounting the other partition
[EMAIL PROTECTED]# mount -t ext2 /dev/hdb1 /opt
Another way to test for the new partions is the df(1) command. This command
reports the currently mounted file systems as well as they usage. The new
partitions should appear in the df output along with 0% or very little usage.
Here are my df results.
# df
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/hdb1 446868 52375 371412 12% /
/dev/hda1 1658912 1613568 45344 97% /C
/dev/hdc2 2941835 1005262 1784441 36% /home
/dev/hdb3 669302 609546 25182 96% /opt
/dev/hdc1 1139799 569027 511882 53% /usr
Now that we have the filesystems we want them to come up on boot. To do this
you use the /etc/fstab file.
Here is mine
cat /etc/fstab
/dev/hdb1 / ext2 defaults 1 1
/dev/hda1 /C msdos defaults 0 0
/dev/hdc2 /home ext2 defaults 1 2
/dev/hdb3 /opt ext2 defaults 1 2
/dev/hdc1 /usr ext2 defaults 1 2
/dev/hdb2 swap swap defaults 0 0
/dev/fd0 /mnt/floppy ext2 noauto 0 0
/dev/cdrom /mnt/cdrom iso9660 noauto,ro 0 0
none /proc proc defaults 0 0
The important parts are those concerned with HD, those lines with /dev/hd??
On boot Linux scans this file and mounts the HD.
The first colmn is the device, the second the mount point, the third the file
system the fourth is for any options. The options should probably be set to
defaults, however in some special case you could use the ro option or read only
to create a read only file system for security reasons etc.
Anyway the last two columns are the mount order and the fsck order. (The order
in which the filesystems are checked). They are not that important as the
drives will mount or fsck in the order they occur in the file.
For our configuration you would add the following lines.
/dev/hdb1 /opt ext2 defaults 1 2
/dev/hdb2 /usr/local ext2 defaults 1 2
Now, _don't_ reboot. :) Not yet anyway. First we test the fstab file. It is a
real pain if this one gets screwed up, believe me I know. :) It usually
requires a single user mode boot to fix. :)
Anyway unmount those partitions we mounted above
# umount /usr/local
# umount /opt
Now mount them again but with the following commands
# mount /usr/local
# mount /opt
The reason we do this is that Linux will now scan first mtab file and not
finding that FS currently mounted will then scan the fstab file. Finding the
new lines you added it will mount them according to the instructions in fstab.
If you are succesful this should give a pretty reasonable indication of a good
fstab file.
If you want to you can reboot, but only do this if you are wanting to confirm
that it will reboot correctly. As wil most things in Linux a reboot is not
necessary just because you are doing something as basic as creating a FS,
unlike other OS's I know of but will not mention.;)
In fact letting it run for a while might be the better idea since it is easier
to fix problems from a command prompt than it is while trying to boot. :)
Anyway hope that answers your questions.
Regards
Terrence Martin
P.S.
Creating a new swap partition is a bit different and requires some additional
details. Let me know if this is something that you are looking at doing and I
can help you out.
>
> Steve
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> For daily digest info, email [EMAIL PROTECTED]
----------------------------------
E-Mail: [EMAIL PROTECTED]
Date: 06-Jul-98
Time: 23:52:46
This message was sent by XFMail
----------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For daily digest info, email [EMAIL PROTECTED]