Jump to content


Photo

Using Two Hard Drives With Linux Only System


  • Please log in to reply
9 replies to this topic

#1 zenarcher

zenarcher

    enthusiast

  • Members
  • 238 posts

Posted 03 July 2005 - 03:27 PM

I am using Mandriva PowerPack 2005 LE. I have two, 80GB SATA hard drives in my system, as I had the intent to set them up in RAID0 array, using mdadm.

I've spent no less than 3 months, trying to set up a RAID0 array with mdadm, but I'm not competent enough in Linux nor SATA RAID to do so. I've even tried several email conversations with Neil Brown, who handles the mdadm application. While he has really attempted to assist, he is not familiar with Mandriva.

One of the forum members here, "blackpage" spent a lot of time working with me on the problem, as well. He finally worked out the procedure, by setting up a system on his own box. He emailed, telling me that he had it all working and would be giving me a step-by-step procedure. He stated that one of the problems was that Mandriva would not allow the transfer of some /usr folders, such as /lib, nor would it allow symbolic links for those. Anyway, he had worked through tbe problem, but before getting the information to me, something happened and he sort of disappeared. I have been unable to contact him for over a month.

So, at the moment, I have everything on sda, the first hard drive, although I have also formatted and partitioned sdb, the second drive.

I hate to have a second hard drive in the system, doing absolutely nothing. RAID seems to be an impossibility, as I've tried every forum and am met with blank stares. As such, I'd like to figure what I must do to use both my sda and sdb drives in the system.

I'm thinking that perhaps I could use the second hard drive, sdb, as a /home partition. I don't mind reformatting, partitioning and re-installing the system. I just would like to do whatever I have to do to be able to use both hard drives. If I can't, I might as well pull them both out and buy a larger single SATA drive.

Could anyone suggest what they think would be the best way to partition the two drives (I have 1GIG of RAM)and explain to me if I have to do anything special, when doing the partitioning and re-install, so that both drives will just work correctly and store and use the data on them, as I've tried to describe above?

I'd appreciate any thoughts or suggestions on partition naming and sizing...as well as any other information I might need. I am running only Mandriva on my system...I am not using any version of Windows.

Oh, I might also ask if anyone would know if setting up SATA RAID0 might be easier with SUSE than Mandrake. I'm wondering that, due to the note from "blackpage" that Mandrake doesn't like transferring /usr folders nor symbolic links.

Thanks,
zenarcher

#2 danleff

danleff

    Carpal Tunnel

  • Moderators
  • 2903 posts

Posted 03 July 2005 - 04:45 PM

I wonder where Blackpage is as well. This is what makes this forum useful, everyone has an area of expertise.

I saw your post on Mandrivausers as well.

I have never set up sata raid in Linux, but maybe this will bump a potential answer.

The problem is that sata raid is fairly new in Linux. There is nil to find using Google.

#3 egorgry

egorgry

    enthusiast

  • Members
  • 315 posts

Posted 03 July 2005 - 07:22 PM

I know very little about raids on linux and I know very little about mandriva and suse so I'm not going to be much help in that respect. However I have two drives set up one is sliced up as follows
/
/swap
/home

the other is for media with sub directories
/media
-music
-movies
-photos

I put all my media files in the second and create a symlink to my home directory
/home/music
/home/movies
/home/photos

I hope this helps somewhat. If you have your heart set on a raid I'll keep my eyes open for anything. Just run fdisk on the hdb drive and set up your FS and add it to the fstab, Doen't mandriva have a good partitioning utility? if that's true use that instead unles you're comfortable using the cmd line.

#4 zenarcher

zenarcher

    enthusiast

  • Members
  • 238 posts

Posted 03 July 2005 - 08:00 PM

I appreciate the thoughts and help, guys. Maybe I can post here what Blackpage has given me and someone will have an idea. He was sure there might be some errors, but the last email said he had it all worked out, which I will include, after the information he has given me and documented......Here is what he gave me so far:

SATA RAID0 WITH MANDRIVA
USING MDADM


PARTITION DRIVES

DRIVE 1

Partition Size Name Type Name
01 10G / Ext3 sda1
02 1G Swap Swap sda5
03 69G /home Ext3 sda6

DRIVE 2

Partition Size Name Type Name
01 1G Swap Swap sdb1
02 79G /home2 Ext3 sdb5


mdadm -C /dev/md0 -l 0 -n 2 /dev/sda6 /dev/sdb5
mkfs -j /dev/md0
mv /home /home.tmp
mkdir /home
chmod 755 /home
mount /dev/md0 /home
# if there is anything worth keeping in /home.tmp then
cp -a /home.tmp/. /home
rm -r /home.tmp

echo "/dev/md0 /home ext3 defaults 0 2" >> /etc/fstab
# edit /etc/fstab and make sure it looks "right"
mdadm -Db /dev/md0 | sed '/devices=/d' >> /etc/mdadm.conf
# edit /etc/mdadm.conf and make sure it looks "right"


NOTES:

You would need to be sure that "mdadm -As" or similar is run by the rc scripts. I don't know exactly how Mandrake decides whether to do that or not. Hunt around in /etc/init.d to see.
IF you aren't confident in judging if fstab and mdadm.conf are
"right", feel free to email them to me and I will look.

Well, we have e.g. these two lines ...

echo "/dev/md0 /home ext3 defaults 0 2" >> /etc/fstab
# edit /etc/fstab and make sure it looks "right"

The first line utilizes the "echo"-command which normally "echos" text to the console. By using the "I/O redirection" operator (">>") you can tell echo to not use the screen as output but the file "/etc/fstab" instead. In other words: Output to screen is redirected.

The ">>" operator means that the string "/dev/md0 /home ext3 defaults 0 2" is to be appended at the very end of /etc/fstab. Please, do take care that you really use ">>" and NOT ">" instead, as ">" means "replace content in file" and not "append to file".

What Neil meant by "check if it looks right" is just to make sure that appending the string with echo and I/O-redirection has worked properly.

Ad instructions and setup:
Well, the setup as described here is fairly similar to our setup with one exception: The operating system's partition (that's where /usr, /sbin, /bin and all the other OS relevant folders are) is not being RAID-ed. But just setting up /home is good enough for starters, and if you remember: I was not all too fond of doing a RAID-0 on the system partition neither

So from my point of view the setup and instructions look quite allright so far.

About /etc/init.d and rc-scripts ...
If you recall, we've been at that point too when I was telling you in one post that I'm not sure if you need to add a startup script to make the RAID-volume persistent and available automatically at boot time. This is where RC-scripts are needed ...

Lean back and relax, as this can get sort of lengthy

Fact 1:
Every Linux distro, and therefore Mandriva too, has a so called "startup folder". This top-level startup folder is called "rc.d" and resides in "/etc/rc.d"

Fact 2:
During startup every Linux flavor runs through different levels of initialization which are called "runlevels". The different runlevels tell the system quite early what "mode" it should prepare. E.g. runlevel "1" means "preare for single user mode", runlevel "3" means "prepare for full multi user mode" and runlevel "5" e.g. will also prepare a multi user mode with the X-GUI available.

You can check what runlevel Mandriva is running by opening a console and entering the command

user@box# runlevel

and the output of this command should be something like ...

N 5

which tells us that Mandriva is in runlevel "5". So much for the runlevel-basics.

Fact 3: "S" and "K"-scripts
If you peek around in "/etc/rc.d" you will find a flock of subfolders ...

rc0.d
rc1.d
rc2.d
.
.
rc6.d

As you can guess: These folders correspond to the runlevels. If you peek into one of these folders, let's say "rc5.d" you will find all the scripts that actually handle the starting of processes that are used for this runlevel.

I don't know what scripts exactly Mandriva adds to the various rcX.d-folders, but that's not so important now. What you will see in e.g. rc5.d is a list of files like this ...

S10syklogd
S20network
S22portmap
S23xinetd
and so on ...

It's not important now WHAT commands are actually launched here, and it's also not imortant if the numbers at the beginning of the filenames ("Sxx") correspond to your entries.

The secret is a very simple one: "S" stands for "START" and the following number determines the sequence in which the scripts are launched. In the above example "sysklogd" is started BEFORE "network" as it has a lower number (10) than "network".

You will also mention that each entry is only a symbolic link to a script that actually is stored in "/etc/rc.d".

In other "rcX.d"-folders, e.g. in "rc0.d" and "rc6.d" you will also find files named like this ...

K25mysql
K30sshd
etc.
etc.

Yup, you're right, "K" stands for "KILL". At this point Linux reveals that it has a crush for Blood, Sweat & Tears as it obeys the rule "What goes up must come down" quite strictly In the above example the database "MySQL" is shut down, as is the SSH-daemon.

That's the whole thing behind startup and kill-scripts. They ensure that needed daemons and processes are started at boot time (the "S"-scripts) and properly killed/stopped when the system goes down again (the "K"-scripts).

A lil summary:
If there a rcX.d-folder that correspond to the runlevels we can extrapolate the following info:

rcX.d-folders with "S"-scripts are used at boot-time. From this we know that the runlevel that corresponds to the number of the respective rc-folder (e.g. "rc5.d") is one the system enters when it starts up.

rcX.d-folders with a majority of "K"-scripts indicate a runlevel that is entered when the system shuts down (either shut-down or reboot).

I said "majority" above cause it can happen that a rcX.d-folder may containa "K"-script even though the respective runlevel would not make the system shut down. Some Linux distros (Debian e.g.) use runlevel 2 for "console only" mode. In this case the rc2.d-folder might contain a "K"-script for graphical UI managers, as these are not needed in console mode. An entry in "rc2.d" like "K80kdm" is quite commonplace and only means "shut down KDM".

Many facts, I admit, but we're already through with it

So what does that mean for your RAID setup?
To tell Mandriva that it should start the RAID-volume, you need to add a startup script in the folder that corresponds to the proper runlevel. For Mandriva this folder should be "rc5.d".

The things to do are as follows:

1: create a startup script in /etc/init.d (or should this be /etc/rd.d)
2: make a symbolic-link to that script in "rc5.d"

Ad 1: open a text editor and enter the following text ...

#!/bin/bash
mdadm -As

Save this to "/etc/init.d/startraid". (or should this be /etc/rc.d/startraid)

Ad 2: Open a console and change directory to the folder "rc5.d".

Once you're in this directory make a symbolic-link to the "/etc/init.d/startraid"-file (or should this be .etc.rc.d/startraid). Before we come to the actual command a few things are to be considered:

1: you need the RAID volume to be started
=> that means the link-name will start with an "S"

2: you need it to start quite early
=> that means the number after the "S" should be low, not too low, but in all cases lower than the number of any script that launches the GUI (as the GUI already needs the config files from the /home folder which is on the RAID volume)

3: we should make the symbolic link "relative" and not absolute
=> that means we should use "../../"-syntax to point to the startraid-file instead of entering the "hard" path

Points 1 & 2 are explained yet, and for point 3 just have a look at the links in rc5.d. Type "ls -l" in the console to view the contents of "rc5.d" ... output should be ...

[blah ... file stats] S20network -> "../../network"

So whatever "../"-combos you see, we will use the same. I assume there is just a single "../"-block for the next command.

Still being in rc5.d type this command ...
user@box# ln -s ../startraid S22startraid

As it goes for the number: Launch the RAID manager quite immediately after network if this is possible. So whatever number is not taken after "SXXnetwork", choose that.

That should be it.

FINAL THINGS:
Mandriva expects mdadm.conf to be in "/etc/madadm". Make a symbolic link to ensure the file is found. Check if you have an "mdadm"-folder already in your /etc-folder. If not create it and enter the following command in the console ...

user@box: ln -s /etc/mdadm.conf /etc/mdadm/mdadm.conf

We need to do that as the auther of mdadm suggested this command ...
mdadm -Db /dev/md0 | sed '/devices=/d' >> /etc/mdadm.conf

which adds the the sed-filtered output to /etc/mdadm.conf. That's absolutely OK and we only ensure that /etc/mdadm/mdadm.conf points to the proper file.

Following this information, I received an email from Blackpage, indicating the following:



Heya Stan

I'm pleased to inform you that I spent the last two days
fiddling around with mdadm-based RAID in Mandriva 10.2.

Everything went peachingly well (with some exceptions),
and so I'm currently processing around 50+ pics that will
be used to demonstrate the tasks necessary to build a RAID
volume.

As soon as I have finished the HTML-pages I will inform you,
and post launch a new thread on linuxcompatible where we
can discuss the matter further in front of the community.

As a lil teaser: the first part will demonstrate a RAID-0 volume
hosting the "/home" folder. I plan to extend this by transferring
the "/usr" folder to the RAID volume too.

Some folders can't be transferred in Mandriva (e.g. "/lib")
as the references needed by the operating system seem to

a) not like symbolic links (e.g. /usr -> /raid/usr) and

B) rely on "early binding" which means that parts within
/lib are needed before "mdadm" is/can be started

That is not really a problem as RAID-0 volume offers the
most meat with dynamic data, which normally resides in the
various directories under "/home".

#5 zenarcher

zenarcher

    enthusiast

  • Members
  • 238 posts

Posted 03 July 2005 - 08:04 PM

Dan, you are right. I've searched everywhere.....several other people have searched...and the only information available is from the source of mdadm. Unfortunately, there is no specific information for using mdadm with Mandriva that I've found. I'd switch to SUSE Professional, if I could find information on that. If all else fails and I cannot set up a SATA RAID0 array, I'm wondering if it might be a good idea to use the second hard drive for /home. If so, I'm not exactly sure how to do that, starting with a fresh installation of Mandriva.

zenarcher

#6 danleff

danleff

    Carpal Tunnel

  • Moderators
  • 2903 posts

Posted 03 July 2005 - 11:49 PM

Interesting stuff! But a little over my head, I'm afraid.

I aways thought of the whole idea of raid is to "mirror" the drives, so that if one goes south, you have the other drive as a backup.

But, if you decide to just split the drives, this should work fine.

When you install Mandriva, you should choose the "expert" option in the partitioning utility during the Mandriva installation. This way, you can assign the partitions the way that you want to.

You can assign everything to /, or choose multiple partitions for say, /usr, /home...etc.

So, you could assign, for example, / for everything, then assign the second sata drive (either in whole or as a limited space partition) to /home. You just highlight the partition(s) that you want to assign, hit the edit button and choose what designation that partition is to be. I think the choices are;

/
/boot
/usr
/home
/var


...and so on. this way you can split the assignments to either drive and/or partition that you want.

Once you assign a mount point, then that option is not repeated or allowed when you edit and assign the next partition, to prevent errors.

#7 zenarcher

zenarcher

    enthusiast

  • Members
  • 238 posts

Posted 04 July 2005 - 12:11 AM

Hey Danleff,

Yes, you are talking about RAID1. There are different RAID configurations and RAID1 mirrors, so you actually have a backup. RAID0, which I am trying to do puts data on both drives...so actually, you are combining the drives (i.e. 80GB plus 80GB= 160GB. The concept is that the drives can access data much more quickly. Of course, if either drive dies, everything crashes with RAID0.

If I'm understanding you correctly, concerning the two drives, I think I can do this. I can partition the first drive (sda) as I normally would...deciding on my partition sizes, etc. Then, I can partition the second drive (sdb)...using the entire drive size as ./home (probably Ext3) and when I install Mandriva, everything for ./home will automatically go to the second drive (sdb). I wouldn't have to do anything special, beyond just naming the partitions. Is that correct?

zenarcher

#8 zenarcher

zenarcher

    enthusiast

  • Members
  • 238 posts

Posted 04 July 2005 - 01:08 AM

Looking at the link below, I'm wondering if SUSE 9.3 Professional might be the way to go with RAID. At least what I've read doesn't look like it's as complex as what I've been trying to do in Mandrake.

http://www-uxsup.csx...ystem.raid.html

Anyone have any thoughts on this?

zenarcher

#9 danleff

danleff

    Carpal Tunnel

  • Moderators
  • 2903 posts

Posted 04 July 2005 - 03:37 AM

Originally posted by zenarcher:
Quote:
Hey Danleff,

Yes, you are talking about RAID1. There are different RAID configurations and RAID1 mirrors, so you actually have a backup. RAID0, which I am trying to do puts data on both drives...so actually, you are combining the drives (i.e. 80GB plus 80GB= 160GB. The concept is that the drives can access data much more quickly. Of course, if either drive dies, everything crashes with RAID0.


Now i understand the concepts mush better between the types, from the link that you gave to SuSE 9.3. So, your purpose is to access the data quicker, rather than have a complete mirror image on both drives.

Quote:
If I'm understanding you correctly, concerning the two drives, I think I can do this. I can partition the first drive (sda) as I normally would...deciding on my partition sizes, etc. Then, I can partition the second drive (sdb)...using the entire drive size as ./home (probably Ext3) and when I install Mandriva, everything for ./home will automatically go to the second drive (sdb). I wouldn't have to do anything special, beyond just naming the partitions. Is that correct?

zenarcher


Yes, this is correct. In this senario, the /etc/fstab file will reference the location of each partition. In your case, the /home partition will be located on the second sata drive and occupy the whole drive, or a partition on the drive that you customize to a size to fit your needs.

This is always useful for those who do not want to lose their data files (usually kept in the home folder) if they decide to reinstall or use another Linux distro. This multi-partition" scheme allows you to use a different partition for each main directory, /usr, /var... allowing you to more fully customize how large each partition is.


#10 zenarcher

zenarcher

    enthusiast

  • Members
  • 238 posts

Posted 04 July 2005 - 12:44 PM

Hey Danleff,

Thanks for the information. That sounds like the best way to go, if I can't get the RAID setup figured out. I know that both sda and sdb drives are recognized, as there is no problem partitioning them, during the install, so that part is okay. I understand what you are saying about the /home on the second drive...and that makes sense. I am wondering if I should put anything else on the second drive, for the same reason, in the event of a reinstall, so I wouldn't lose my personal settings, etc. If you have any suggestions there, it would be appreciated, as well. I have a post on an SUSE forum right now, waiting for an answer, too. I'm trying to find out of anyone in the world has actually ever set up SATA RAID with SUSE 9.3. According to that link, it looked reasonable to do. If I can find anyone who has done so, I'd be more than happy to try a switch from Mandriva to SUSE. I tried SUSE 9.1, without success, which is why I went with Mandriva. After booting up with SUSE 9.1...somewhere between 30 seconds and two minutes later, the entire system would lock up, forcing me to reboot by turning off the power switch. First, the ethernet connection would freeze...then, almost immediately, everything would freeze. I couldn't find any help resolving the issue. Anyway, I then installed Mandrake and it worked without a hitch.

zenarcher




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

IPB Skin By Virteq