Linux under Soft raid

Source: Internet
Author: User
Tags hex code

1. See how many hard drives are available
#fdisk-L
Well, in general, leave the system disk, the other disks if the size of the same, all together to do a raid.

2. Decide what type of RAID to do.
raid-0, Raid-1, raid-5?
If you have three disks (or more) of the same size, it is highly recommended to raid-5.
Otherwise please choose raid-0 or raid-1 according to the actual situation

3. Unmount the Mounted data disk
First look at the number of disks to do the raid is not already mounted
#mount
If so, delete the data and then uninstall it with Umount.
Then, also, open the/etc/fstab and comment out the partitions that were just unloaded. Lest the error in the operation, cause the machine to restart, and then it does not come up ...

4. Use Fdisk to change the hard disk partition type to Linux RAID auto
Take/dev/sdb as an example:
#fdisk/dev/hde

The number of cylinders for this disk was set to 8924.
There is nothing wrong with the, but this is larger than 1024,
And could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from the other OSs
(e.g., DOS fdisk, OS/2 fdisk)

Command (M for help):

Well, if you don't understand the use of Fdisk under Linux, you can start by entering m to see help.
(Note: FreeBSD and Windows, DOS also have Fdisk, but only the same name, the interface and usage are very different.) Windows XP and later versions discarded Fdisk)
Command (M for help): M
Command Action
A toggle a bootable flag
b Edit BSD Disklabel
C Toggle the DOS compatibility flag
D Delete a partition
L list known partition types
M Print this menu
n Add a new partition
o Create a new empty DOS partition table
P Print the partition table
Q Quit without saving changes
s create a new empty Sun Disklabel
t change a partition ' s system ID
U Change display/entry units
V Verify the partition table
W Write table to disk and exit
X Extra functionality (experts only)

What we're going to do is change the hard drive partition type, so enter t
Command (M for help): t
Selected partition 1
Hex code (type L to list codes):
Because my hard drive has only one partition, it automatically chooses partition 1.
The following is the 16 binary code that should be entered for the partition type. But how do I know what to enter?
OK, first enter the uppercase L to see what type
0 Empty 1e Hidden W95 FAT1 pc/ix be Solaris boot
1 FAT12 NEC DOS Minix BF Solaris
2 Xenix root Plan 9 Bayi minix/old Lin C1 drdos/sec (fat-
3 Xenix usr 3c partitionmagic the Linux swap C4 drdos/sec (fat-
4 FAT16 <32m Venix 80286, Linux c6 drdos/sec (fat-
5 Extended PPC PReP Boot os/2 hidden c:c7 syrinx
6 FAT16 SFS-Linux extended da non-fs data
7 Hpfs/ntfs 4d qnx4.x NTFS Volume set db cp/m/CTOS/.
8 AIX 4e qnx4.x 2nd part volume NTFS set de Dell Utility
9 AIX Bootable 4f qnx4.x 3rd part 8e Linux LVM DF bootit
A os/2 Boot manag ontrack DM Amoeba E1 DOS Access
b W95 FAT32 Wuyi Ontrack DM6 Aux 94 Amoeba BBT E3 DOS r/o
C W95 FAT32 (LBA) cp/m 9f bsd/os e4 speedstor
E W95 FAT16 (LBA) Ontrack DM6 Aux A0 IBM Thinkpad hi EB BeOS FS
F W95 Ext ' d (LBA) OnTrackDM6 a5 FreeBSD ee EFI GPT
Ten OPUS ez-drive a6 OpenBSD ef EFI (fat-12/16/
One Hidden FAT12 Bow A7 NeXTSTEP f0 linux/pa-risc b
Compaq Diagnost 5c Priam edisk A8 Darwin UFS F1 SpeedStor
Hidden FAT16 <3 speedstor A9 NetBSD f4 SpeedStor
Hidden FAT16, GNU HURD or Sys ab Darwin boot F2 DOS Secondary
Hidden hpfs/ntf Novell Netware b7 BSDI FS FD Linux RAID Auto
AST smartsleep Novell Netware b8 BSDI swap fe lanstep
1b Hidden W95 FAT3 disksecure Mult bb Boot Wizard hid FF BBT
1c Hidden W95 FAT3
Did you find it? The FD should be entered
Hex code (type L to list codes): FD
Changed system type of partition 1 to FD (Linux raid AutoDetect)

Are you sure you didn't enter any errors? Enter p to check
Command (M for help): P

disk/dev/sdb:73.4 GB, 73407820800 bytes
255 heads, Sectors/track, 8924 cylinders
Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System
/DEV/SDB1 * 1 8924 71681998+ fd Linux raid AutoDetect

Well, there's no mistake, so the next step is to write our changes to the hard drive
Command (M for help): W
The partition table has been altered!

Calling IOCTL () to re-read partition table.
Syncing disks.

Ha ha. wonderful!

Below...... Follow the above steps to get each hard drive to go through it.

5, the most core step: do raid
I picked 4 pieces of the same size hard drive to do RAID-5.
#mdadm –create–verbose/dev/md0–level=5–raid-devices=4/dev/sdb1/dev/sdc1/dev/sdd1/dev/sde1

Mdadm:layout defaults to Left-symmetric
Mdadm:chunk size defaults to 64K
Mdadm:/dev/sdb1 appears to contain an EXT2FS file system
size=71681996k Mtime=mon Jul 2 15:18:11 2007
Mdadm:/dev/sdc1 appears to contain an EXT2FS file system
size=71681996k Mtime=mon Jul 2 15:18:11 2007
Mdadm:/dev/sdd1 appears to contain an EXT2FS file system
size=71681996k Mtime=mon Jul 2 15:18:11 2007
Mdadm:/dev/sde1 appears to contain an EXT2FS file system
size=71681996k Mtime=mon Jul 2 15:18:11 2007
Mdadm:size set to 71681920K
Continue creating array?
It will let me confirm, enter Y.
Well, a few parameters, simple introduction under:
–LEVEL=5: Representative raid-5, if you want to do raid-1, then it is –level=1
–raid-devices=4: How many hard drives are used for raid? Well, I have 4 bucks.
The next few are the partitions used to make the raid. Note that the following number 1 Oh.
If nothing happens, it will tell you
Mdadm:array/dev/md0 started.

6. Check the raid status.
#cat/proc/mdstat

Personalities: [RAID5]
Md0:active RAID5 sde1[4] sdd1[2] sdc1[1] sdb1[0]
215045760 blocks level 5, 64k chunk, Algorithm 2 [4/3] [uuu_]
[A]. ..... ......... Recovery = 0.4% (299776/71681920) finish=35.7min speed=33308k/sec
Unused devices: <none>
That one...... Need and so on.
All the way up here.
# Cat/proc/mdstat

Personalities: [RAID5]
Md0:active RAID5 sde1[3] sdd1[2] sdc1[1] sdb1[0]
215045760 blocks level 5, 64k chunk, Algorithm 2 [4/4] [uuuu]

Unused devices: <none>

7, Lattice plate
This one... You don't have to say much.
#mkfs. ext3/dev/md0
Then brushless brushless to look at it.

8. Create mdadm.conf
First, open/etc/mdadm.conf with a text editor (without creating one), write a line like this
Device/dev/sdb/dev/sdc/dev/sdd/dev/sde
is to list all the raid disks behind the device.
And then run
#mdadm –detail–scan
Can you see some interesting information?
array/dev/md0 LEVEL=RAID5 num-devices=4 uuid=af563620:2568f63a:face1db6:9d9f34f1
Devices=/dev/sdb1,/dev/sdc1,/dev/sdd1,/dev/sde1
These are required to be added to the/etc/mdadm.conf.
# Mdadm–detail–scan >> mdadm.conf
Well, it's better to check again.
# more/etc/mdadm.conf

9. Modify/etc/fstab and Mount
Well, where do you hang it? I usually hang it under the/data1.
Add something like this to the/etc/fstab.
/dev/md0/data1 ext3 Defaults 1 2
Then mount
#mount/data1

OK, you are done!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.