Solved

Mirror

Posted on 1999-01-15
8
574 Views
Last Modified: 2013-12-15
How would I create a mirror of HD0 and mirror it to HD1
0
Comment
Question by:ntstud
  • 4
  • 2
  • 2
8 Comments
 
LVL 1

Expert Comment

by:fmismetti
ID: 1632155
I assume that HD1 has a valid Linux partition, hdb1, and HDA is mounted as /.

1. mount /dev/hdb1 partition in /disk2 (this directory must exist).

2. Run this script:

#! /bin/bash
#
cd / && cp -a `/bin/ls -1A | egrep -v "^disk2$|^proc$"` /disk2

This will copy all files from "/" to "/disk2" except directories /disk2 and /proc (you can add more; use "^disk2$|^proc$|^tmp$" if you want to exclude also /tmp.

Last thing: the mirrored disk will not boot. If you want this, you need to do some tricks. Look in the document Hard-Disk-Upgrade mini-HOWTO. This document explains also another ways to duplicate your hard-disk (I learned about the method above there).

Let me know if this solves your problem.
0
 

Author Comment

by:ntstud
ID: 1632156
Where would I setup the script, or just create a txt file and make it Xacutable?

new to scripts, NTstud remember!
0
 
LVL 1

Expert Comment

by:fmismetti
ID: 1632157
First, you did not explain the reason for reject the answer. I did not notice the "NTstud" and I had no means to know that you did not know how to setup scripts.

You can put this text in any text file, let's say /usr/myscripts/mirrordisk. Then you have two choices:

1. run "chmod +x /usr/myscripts/mirrordisk" and then you can just run the file from the command line.

2. run the plain text file invoking the shell and passing the text file as a parameter, like "/bin/bash /usr/myscripts/mirrordisk"


0
 
LVL 2

Expert Comment

by:vx
ID: 1632158
You could also use RAID-1 to mirror your disk. This way, all data will be written to two disks at the time, not just when you run the script.

For more information on RAID-1, have a look at:
http://metalab.unc.edu/LDP/HOWTO/mini/Software-RAID.html
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:ntstud
ID: 1632159
thanks fmismetti, i will award you the points (answer again).

Danny

this WILL work right?  I have an ISP's server to mirror, silly rabbit, ISP are for pros.
0
 
LVL 1

Accepted Solution

by:
fmismetti earned 20 total points
ID: 1632160
I have 6 servers using this script. It is not a really mirror as a raid that vx told. For my purposes I run this script twice a day, using crontab.

Also, with the information in the "Hard-Disk-Upgrade mini-HOWTO" I setup the second disk to be bootable and to have an entry in the /etc/lilo.conf like:

# Linux hdb1 bootable partition config begins
image = /vmlinuz
  root = /dev/hdb1
  label = LinuxB
  read-only
# Linux bootable partition config ends

Then you can press Shift-key when the system starts and choose to boot from the mirror. This is very confortable when you need to perform tasks like e2fsck in the primary disk or when something goes really wrong. The only thing you need to add to the script above is one line to fix the /etc/fstab from the second disk, like:

cp -a /etc/fstab.hdb /disk2/etc/fstab

fstab.hdb should be similar to you original fstab but referencing hdb instead of hda, like:

/dev/hdb2       swap     swap        defaults   1   1
/dev/hdb1       /        ext2        defaults   1   1
none            /proc    proc        defaults   1   1

Hope it helps you.
0
 
LVL 1

Expert Comment

by:fmismetti
ID: 1632161
Ops, I forgot that the rejected answer would be gone. here is a copy from my browser cache:

I assume that HD1 has a valid Linux partition, hdb1, and HDA is mounted as /.

1. mount /dev/hdb1 partition in /disk2 (this directory must exist).

2. Run this script:

#! /bin/bash
#
cd / && cp -a `/bin/ls -1A | egrep -v "^disk2$|^proc$"` /disk2

This will copy all files from "/" to "/disk2" except directories /disk2 and /proc (you can add more; use "^disk2$|^proc$|^tmp$" if you want to exclude also /tmp.

Last thing: the mirrored disk will not boot. If you want this, you need to do some tricks. Look in the document Hard-Disk-Upgrade mini-HOWTO. This document explains also another ways to duplicate your hard-disk (I learned about the method above there).

Let me know if this solves your problem.
0
 
LVL 2

Expert Comment

by:vx
ID: 1632162
Before you accept this answer, ask yourself the following question:
Do I want to make a backup or a mirror?

If you want to make a backup, you'd want to do as proposed. But this can be done only at specific times, so you won't have the latest copy of your disk.

If you want to make a mirror, you want the latest copy of your disk. With RAID-1, all data will be written to two disks simultaneously.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Install Dell OpenManage on Ubuntu PowerEdge R410 3 44
Linux as a middle box 7 64
Virtualizing very old guest OS 4 80
Steps to follow for Maintenance of Servers 4 54
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.…
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

863 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

26 Experts available now in Live!

Get 1:1 Help Now