Linux Disk Management ~~~~raid1
Experimental environment
Add 2 30g -size disks to the Linux operating system's pc
Implementation steps:
1.0
Partitioning a disk
[[Email protected]~]# fdisk/dev/sdb
Device contains neither a valid dospartition table, nor Sun, SGI or OSF Disklabel
Building a new DOS disklabel with Diskidentifier 0x5a1d7a13.
Changes'll remain in memory only, Untilyou decide to write them.
After that, of course, the previous Contentwon ' t is recoverable.
Warning:invalid flag 0x0000 of partitiontable 4 would be corrected by W (rite)
Warning:dos-compatible mode is deprecated. It ' s strongly recommended to
Switch off the mode (command ' C ') and change display units to
Sectors (Command ' u ').
Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 1
First cylinder (1-3916, default 1):
Using Default value 1
Last cylinder, +cylinders or +size{k,m,g} (1-3916, default 3916): +300m
Command (M for help): W
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Syncing disks.
[Email protected] ~]# FDISK/DEV/SDC
Device contains neither a valid dospartition table, nor Sun, SGI or OSF Disklabel
Building a new DOS disklabel with Diskidentifier 0xa5a6acdf.
Changes'll remain in memory only, Untilyou decide to write them.
After that, of course, the previous Contentwon ' t is recoverable.
Warning:invalid flag 0x0000 of partitiontable 4 would be corrected by W (rite)
Warning:dos-compatible mode is deprecated. It ' s strongly recommended to
Switch off the mode (command ' C ') and change display units to
Sectors (Command ' u ').
Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 1
First cylinder (1-3916, default 1):
Using Default value 1
Last cylinder, +cylinders or +size{k,m,g} (1-3916, default 3916): +400m
Command (M for help): W
installing the Mdadm package
[Email protected] ~]# Mkdir/mnt/cdrom
[Email protected] ~]# mount/dev/cdrom/mnt/cdrom/
Mount:block device/dev/sr0 iswrite-protected, mounting read-only
[Email protected] ~]# cd/mnt/cdrom/packages/
[[email protected] packages]# ls mdadm*
mdadm-3.2.5-4.el6.x86_64.rpm
[Email protected] packages]# rpm-uvhmdadm-3.2.5-4.el6.x86_64.rpm
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/DF/wKioL1PssmHg37HoAABtLpsXM1k501.gif "title=" 111111.gif "alt=" Wkiol1pssmhg37hoaabtlpsxm1k501.gif "/>
Create RAID1
[Email protected] packages]# Mdadm-cv/dev/md0-l1-n2/dev/sdc/dev/sdb
Mdadm:/dev/sdc appears to Bepart of a RAID array:
LEVEL=RAID0 devices=0 ctime=thu Jan 1 08:00:00 1970
Mdadm:partition table EXISTSON/DEV/SDC but would be lost or
Meaningless after creating array
Mdadm:Note:this Array Hasmetadata at the start and
May is suitable as a boot device. If you plan to
Store '/boot ' on this device ensurethat
Your Boot-loader understands Md/v1.xmetadata, or use
--metadata=0.90
Mdadm:/dev/sdb appears to Bepart of a RAID array:
LEVEL=RAID0 devices=0 ctime=thu Jan 1 08:00:00 1970
Mdadm:partition table Existson/dev/sdb but would be lost or
Meaningless after creating array
Mdadm:size set to 31440768K
Continue creating array? Y
Mdadm:defaulting to version1.2 metadata
Mdadm:array/dev/md0 started.
[Email protected] packages]# ls/dev/md0
/dev/md0
View
[Email protected] packages]# mdadm--detail/dev/md0
/DEV/MD0:
version:1.2
Creation Time:thu 14 16:02:21 2014
Raid LEVEL:RAID1
Array size:31440768 (29.98 GiB 32.20 GB)
Used Dev size:31440768 (29.98 GiB 32.20 GB)
Raid Devices:2
Total Devices:2
Persistence:superblock is persistent
Update Time:thu 14 16:04:40 2014
State:clean, resyncing
Active Devices:2
Working devices:2
Failed devices:0
Spare devices:0
Resync status:89% Complete
name:host129.localdomain:0 (Local to host Host129.localdomain)
Uuid:10fa6c5d:1afaebc6:85f51847:e1f0b2ed
Events:14
Number Major Minor Raiddevice state
0 8 0 Active SYNC/DEV/SDC
1 8 1 Active Sync/dev/sdb
Formatting
[Email protected] packages]# mkfs.ext4/dev/md0
MKE2FS 1.41.12 (17-may-2010)
File system Label =
operating system : Linux
Block Size =4096 (log=2)
chunked size =4096 (log=2)
Stride=0 blocks, stripewidth=0 blocks
1966080 inodes, 7860192 blocks
393009 blocks (5.00%) reservedfor the Super User
first block of data =0
Maximum filesystem blocks=4294967296
Block groups
32768 blocks per group, 32768fragments per group
8192 inodes per group
Superblock Backups stored onblocks:
32768, 98304, 163840, 229376, 294912,819200, 884736, 1605632, 2654208,
4096000
writing inode table : Complete
Creating Journal (32768blocks): complete
Writing superblocks andfilesystem Accounting information: complete
This filesystem'll beautomatically checked every mounts or
Whichever comesfirst. Use Tune2fs-c or-i to override.
Create a System file
[Email protected] ~]# MKDIR/QQ
[Email protected] ~]# mount/dev/md0/qq/
[Email protected] ~]# LL/QQ
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/DD/wKiom1PssifjECrqAAAuhEY4ohs895.gif "title=" 22222. GIF "alt=" Wkiom1pssifjecrqaaauhey4ohs895.gif "/>
[Email protected] ~]# Vi/etc/txt
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/45/DF/wKioL1Pss3ehMZfuAAAY2idH3Rw870.gif "title=" 33333. GIF "alt=" Wkiol1pss3ehmzfuaaay2idh3rw870.gif "/>
View and write to config = file
[Email protected] ~]# Mdadm-ds
Array/dev/md0 metadata=1.2 name=host129.localdomain:0uuid=10fa6c5d:1afaebc6:85f51847:e1f0b2ed
[Email protected] ~]# Mdadm-ds >>/etc/mdadm.conf
Restart PC Machine to verify
[[Email protected]~]# reboot
[email protected] ~]# mount
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/DF/wKioL1Pss9WTGmlqAACPzu1nkUw406.gif "title=" 4444. GIF "alt=" Wkiol1pss9wtgmlqaacpzu1nkuw406.gif "/>
[Email protected] ~]# Cat/proc/mdstat
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/45/DF/wKioL1Pss_bT5OIVAAAn-bDrbJ8867.gif "title=" 55555. GIF "alt=" Wkiol1pss_bt5oivaaan-bdrbj8867.gif "/>
Delete a hard disk 2 make analog Failure
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/45/DD/wKiom1Pssvvy3cuSAABKdFXb8Pw116.gif "title=" 6666. GIF "alt=" Wkiom1pssvvy3cusaabkdfxb8pw116.gif "/>
View Logs
[Email protected] ~]# DMESG
Reorganization RAID1 analog Recovery, or 30GB the hard drive, adding a new disk file will 30GBC.VMDK
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/45/DF/wKioL1PstHzQeYLQAAAUkvVNZb8523.gif "title=" 12.gif "alt=" Wkiol1psthzqeylqaaaukvvnzb8523.gif "/>
Fdisk-l/dev/sdb
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/DF/wKioL1PstJfCZMmcAABjkcHZ6JU845.gif "title=" 112. GIF "alt=" Wkiol1pstjfczmmcaabjkchz6ju845.gif "/>
Join the new
[Email protected] ~]# mdadm/dev/md0-a/DEV/SDC
Mdadm:added/dev/sdc
[Email protected] ~]# Cat/proc/mdstat
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/DD/wKiom1Pss6GC4BWfAAA8o6VLxYg855.gif "title=" 11112. GIF "alt=" Wkiom1pss6gc4bwfaaa8o6vlxyg855.gif "/>
The process of rebuilding can be viewed in the log
This article from "Why, so painful" blog, declined to reprint!