Solved

Setting up RAID1 to new HDD on running Linux Web Server

Posted on 2004-08-07
6
406 Views
Last Modified: 2013-12-15
I need to set up RAID1 mirror on a currently running web server with 100 domains, 500 mail accounts.  Here is what we have:

Linux 7.3 with standard kernal 2.4
RAIDTOOLS installed
pretty much standard install, few things added from standard, nothing big

1 80Gb IDE HDD (hda) partitioned as follows:

1 Linux  1 6 /boot
2 Linux swap  7 134 swap
3 Extended  135 10011  
  5 Linux  135 389 /  
  6 Linux  390 772 /usr  
  7 Linux  773 1410 /var  
  8 Linux  1411 10011 /home

1 new 80Gb IDE HDD (hdc) identical to hda, not yet partitioned

I am accessing the server (leased, dedicated) remotely with SSH, as root.

No tape backup

cat /proc/mdstat
Personalities : [raid0] [raid1] [raid5]
read_ahead not set
unused devices: <none>

============================

Here is what we want to do:

We need to keep everything mirrored so that if one or the other hard disks fails, we will neither lose data nor have to take more than a short time to recover with a new hard disk.

What I want is a step by step guide for partitioning the new hard disk and setting up the necessary filesystems (ext2, ext 3, LINUX raid????) or devices, then creating the raidtab file and any other files that need to be created or edited or updated (fstab?), then starting the thing and making sure it is running.

I hope this is enough to get us going...  THANKS!

Richard
0
Comment
Question by:rbartz
  • 3
  • 2
6 Comments
 
LVL 40

Accepted Solution

by:
jlevie earned 500 total points
ID: 11745294
Below you'll find the procedure that I use to do this:

 1) Get a list of the partitions on the boot drive with 'fdisk -l
    /dev/hda'. Then create partitions with fdisk on the second drive
    of the same size and mark those partitions as being "Linux raid"
    (type fd in fdisk).

 2) Create /etc/raidtab listing entries for both drives and all
    partitions. Mark the current boot drive as failed.

 3) Execute mkraid on each md device you've defined in /etc/raidtab.

 4) Make a file system on each md device except the one used for swap. Specify
    the appropriate label (/, /home) for those file systems. For the swap
    device execute mkswap.

 5) Make an initrd image and make sure that Grub is configured to use it.

 6) For each file system on the boot disk use dump/restore to transfer those
    file systems to the corresponding md device. Note that you'll have to
    specify the device, not the mount point. E.G., use:

    mkdir /mnt/disk
    mount /dev/md0 /mnt/disk
    dump 0f - /dev/hda1 | (cd /mnt/disk; restore rf -)

    not:
   
    mount /dev/md0 /mnt/disk
    dump 0f - /boot | (cd /mnt/disk; restore rf -)
   
    It is safest to do the dump/restore in single user mode.

 7) Make a boot floppy (mkbootdisk)

 8) Mount the md device that contains /boot and edit grub.conf to set "root="
    to point to the correct md device. Also edit the fstab file on the md
    device to point swap to the correct md device.

 9) Reboot and you should be running off of the md devices. If something goes
    wrong you have the boot floppy.

10) Use fdisk to change the partition types on hda to be "Linux raid".

11) For each md device, execute 'raidhotadd /dev/md? /dev/hda?'.

12) Edit /etc/raidtab and remove the 'failed flag' for hda.

Note:

grub-install seems to get confused by md devices. So to install grub in the
MBR you can use the grub shell. Execute grub and then use:

grub> root (hd0,0)
grub> setup --stage2=/boot/grub/stage2 --prefix=/grub (hd0)

Example raidtab:

# /boot
raiddev                /dev/md0
raid-level                1
nr-raid-disks                2
chunk-size                64k
persistent-superblock          1
nr-spare-disks                0
    device          /dev/hda1
    raid-disk     0
    device          /dev/hdb1
    raid-disk     1
# /
raiddev                /dev/md1
raid-level                1
nr-raid-disks                2
chunk-size                64k
persistent-superblock          1
nr-spare-disks                0
    device          /dev/hda2
    raid-disk     0
    device          /dev/hdb2
    raid-disk     1
# swap
raiddev                /dev/md2
raid-level                1
nr-raid-disks                2
chunk-size                64k
persistent-superblock          1
nr-spare-disks                0
    device          /dev/hda3
    raid-disk     0
    device          /dev/hdb3
    raid-disk     1
# /var
raiddev                /dev/md3
raid-level                1
nr-raid-disks                2
chunk-size                64k
persistent-superblock          1
nr-spare-disks                0
    device          /dev/hda5
    raid-disk     0
    device          /dev/hdb5
    raid-disk     1
# /home
raiddev                /dev/md4
raid-level                1
nr-raid-disks                2
chunk-size                64k
persistent-superblock          1
nr-spare-disks                0
    device          /dev/hda6
    raid-disk     0
    device          /dev/hdb6
    raid-disk     1
0
 
LVL 4

Expert Comment

by:marko020397
ID: 11750170
I was doing the exactly same thing some time ago. I didn't have the courage to do this on the production machine so I tested the whole procedure on a test computer before. I had many problems when making RAID but I finally succeded. It was a while ago and I don't remember all the problems.

The biggest problem I think was that partitions on the original disk needed to be shortened because RAID needed to write some additional information at the end of partitions. I used software RAID and I have found instructions on the internet. I think it was one of HOWTOs for Linux.

I am not giving you a solution because I see jlevie has done that. I just want to warn you that you may get in trouble. And the last advice. Don't do it remotely.
0
 
LVL 40

Expert Comment

by:jlevie
ID: 11750216
I've not had the problems that marko has experienced. And those instructions were essentially notes I made while doing a conversion to RAID 1 very, very, remotely. I did have someone on-site that could reboot the system via the boot floppy, and I made sure that would work before starting the conversion. Since then I've done this  a number of times without anything odd occuring.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 4

Author Comment

by:rbartz
ID: 11758343
Thank you jlevie, and you too marko, I am warned...  :-)

Our server is leased, and I cannot get physical access to it.  Remote is my only choice.  I will need to arrange a time to do this so that a support tech can help with creating the floppy and rebooting (there may already be a bootable floppy on the machine).

I think RAID1 will be much better than using the second drive to do full and incremental backups.  That is easy enough to do, but will not help us get back on line quickly if a hard drive fails.  We need the best way that we can afford, and RAID1 is it for now.  The risk is worth the difference.

jlevie, I have questions about the following steps!  Appreciate your help.

Additional info:  our original hard disk is hda.  The new one is hdc.  They are identical drives in every way.  Also, I have Webmin installed, updated, and all the modules are working for creating partitions and so on, including the RAID module.

2...  how do I mark the current boot drive as failed when I create the /etc/raidtab?

4... how do I create the filesystem and labels on the new partitions?

5... How do I make an initrd image, and how do I know if my GRUB (vers. 0.90) is configured to use it?  I do not have a grub.conf file....!  Will we need to install GRUB?  I suppose we are using lilo, the lilo.conf file is:

prompt
timeout=10
default=linux
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
lba32

image=/boot/vmlinuz-2.4.17-ci
        label=linux-old-ci
        read-only
        root=/dev/hda5

image=/boot/vmlinuz-2.4.7-10smp
        label=emerg-smp
        initrd=/boot/initrd-2.4.7-10smp.img
        read-only
        root=/dev/hda5

image=/boot/vmlinuz-2.4.7-10
        label=emerg-up
        initrd=/boot/initrd-2.4.7-10.img
        read-only
        root=/dev/hda5

image=/boot/memtest
        label=memtest

image=/boot/vmlinuz-2.4.23-ci
        label=linux-old
        read-only
        root=/dev/hda5

image=/boot/vmlinuz-2.4.25-ci
        label=linux
        read-only
        root=/dev/hda5

image=/boot/vmlinuz-2.4.20-smp-rf1
        label=linux-scsi
        read-only
        root=/dev/hda5


8... the current root=/dev/hda5, so I assume that the new line would be something like root=/dev/md3...?

9.  Reboot should work without the floppy if I am reading between the lines here correctly.  Is there anything I should be aware of if it doesn't and we have to reboot from the floppy?  If the reboot failed from the hard drives, what would be the most likely reasons?

10... the correct command for fdisk to change the partition type?

I think I understand the rest,  I am travelling again tomorrow so will see about doing all this Wednesday night after making and downloadfing backups.  Thanks for your help.

Richard
0
 
LVL 40

Expert Comment

by:jlevie
ID: 11758782
For this task it would be best to forget that you ever had webmin installed. All of it will beed to be done from the command line using the utilities I mention in the notes. And you'd be well advised to not use webmin for maintenance of this server. I've made an obscene amount of money as a consultant in fixing systems that were mucked up beyond comprehension by webmin. Hmm, on second thought continue to use webmin and keep in mind that I do consulting, fo a fee...

Seriously, learning the in's and out's of managing a server via command line tools and direct editing of files is a skill worth having. It really isn't that hard to do, there's never any doubt as to what changes have been made, and it doesn't require that one have a functioning web server.

2... Using /boot as an example the initial raidtab entry would look like:

# /boot
raiddev              /dev/md0
raid-level              1
nr-raid-disks              2
chunk-size              64k
persistent-superblock         1
nr-spare-disks              0
    device         /dev/hda1
    raid-disk     0
    failed-disk  0
    device         /dev/hdc1
    raid-disk     1

4... You execute 'fdisk /dev/hdc' and create the partition (see 'man fdisk'). It's not as difficult as it might seem. The fdisk program is menu driven. In step 4 above you'd use 'mke2fs -j -L /boot /dev/md0', for example

5... You really should switch to Grub. Depending on what version of Lilo you have it may not be capable of booting from a RAID 1 system.

8... That all depends on how you define the RAID devices in the raidtab. The root (/) could be md0, md1 or anything else. All that matters is that the grub.conf and fstab point to the correct RAID device.

9... Yes, it should boot from the RAID device, but just in case you want to be sure that you have a bootable floppy and that it will work.

10... Within fdisk the 't' menu item is used to set the partition type.
0
 
LVL 4

Author Comment

by:rbartz
ID: 12531348
I apologize for the delay in accepting your answer, jlevie, I was travelling for last 5 months!

Works perfectly.

RDB
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now