LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   How can I create raid 1 - Centos 5.7 64 minimal installation (https://www.linuxquestions.org/questions/linux-server-73/how-can-i-create-raid-1-centos-5-7-64-minimal-installation-914225/)

Adil Boyun 11-18-2011 05:53 AM

How can I create raid 1 - Centos 5.7 64 minimal installation
 
Hello,

I have a server working on centos 5.7-64 minimal installation. I have 3 separate physical drives:

120 gb ssd, 2x 3tb disks for storage.

My linux installation is on ssd disk, and I want to make raid 1 for these two 3tb disks and store data, like under /mnt/data.

Can you please tell me the path how this is possible?

Sorry if this is dublicate but I couldn't find information on this using search.

Here are some output of commands I ran for more data:

Code:

[root@CentOS-57-64-minimal tmp]# fdisk -l | grep '^Disk'
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sda: 120.0 GB, 120034123776 bytes
Disk /dev/sdb: 3000.5 GB, 3000592982016 bytes
Disk /dev/sdc: 3000.5 GB, 3000592982016 bytes

[root@CentOS-57-64-minimal tmp]# df -l
Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/sda3            113695432  1427792 106537696  2% /
/dev/sda2              520136    23576    470348  5% /boot

[root@CentOS-57-64-minimal tmp]# fdisk -l

Disk /dev/sda: 120.0 GB, 120034123776 bytes
64 heads, 32 sectors/track, 114473 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              2        2048    2096128  82  Linux swap / Solaris
/dev/sda2            2049        2560      524288  83  Linux
/dev/sda3            2561      114473  114598912  83  Linux

Disk /dev/sdb: 3000.5 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 3000.5 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table


smallpond 11-19-2011 04:12 PM

Its usually more flexible to build a RAID out of partitions than whole drives. So make sdb1 and sdc1 partitions using gparted, then use mdadm to make them a RAID 1. gparted is graphical and easy to use, but not included by default in most Redhat installations (I wonder why?) mdadm is command line and should be installed.

When I did this recently I did not use the whole disk. I created empty boot and OS partitions at the beginning of the drives in case I wanted to boot from the RAID in the future. So in my case the large RAID partitions were sdb3 and sdc3. I also didn't use all of the space. When you have to replace a drive, you will find out that the new drive will not have the exact same number of blocks as the old drive. If a partition is even 1 block smaller, it won't work as a replacement. Also, you may have a need for some free space, such as for swap. Also, unless something has changed, the max partition size is 2TB. You need to use larger block sizes than 512 bytes to go above that. Probably simpler to just make a couple of 2TB partitions.

The command to make your RAID is now:
Code:

mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1

Edit: The 2TB limit in fdisk, which some scripts used to check sizes. Most stuff should be using parted now, so it should not be a problem.

davemguru 11-19-2011 04:18 PM

Quote:

Originally Posted by Adil Boyun (Post 4527426)
Hello,

I have a server working on centos 5.7-64 minimal installation. I have 3 separate physical drives:

120 gb ssd, 2x 3tb disks for storage.

My linux installation is on ssd disk, and I want to make raid 1 for these two 3tb disks and store data, like under /mnt/data.

Can you please tell me the path how this is possible?

Sorry if this is dublicate but I couldn't find information on this using search.

Here are some output of commands I ran for more data:

Code:

[root@CentOS-57-64-minimal tmp]# fdisk -l | grep '^Disk'
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sda: 120.0 GB, 120034123776 bytes
Disk /dev/sdb: 3000.5 GB, 3000592982016 bytes
Disk /dev/sdc: 3000.5 GB, 3000592982016 bytes

[root@CentOS-57-64-minimal tmp]# df -l
Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/sda3            113695432  1427792 106537696  2% /
/dev/sda2              520136    23576    470348  5% /boot

[root@CentOS-57-64-minimal tmp]# fdisk -l

Disk /dev/sda: 120.0 GB, 120034123776 bytes
64 heads, 32 sectors/track, 114473 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              2        2048    2096128  82  Linux swap / Solaris
/dev/sda2            2049        2560      524288  83  Linux
/dev/sda3            2561      114473  114598912  83  Linux

Disk /dev/sdb: 3000.5 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 3000.5 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table


First you need to partition your drives (sdb and sdc) with parted. Not all versions of fdisk support GPT and your >2TB require GPT.
Code:

parted -s /dev/sdb  mklabel gpt
parted -s /dev/sdc  mklabel gpt

initialises the GPT. Then
Code:

parted -s /dev/sdb mkpart "primary" "ext3" 0TB 2.9TB
parted -s /dev/sdb set 1 "raid" on

parted -s /dev/sdc mkpart "primary" "ext3" 0TB 2.9TB
parted -s /dev/sdc set 1 "raid" on

and then make the raid1 device
Code:

yes| mdadm -C /dev/md2 --level=raid1 --raid-devices=2 /dev/sdb1 /dev/sdc1
If you want - you can leave off the "yes |" then you can answer any questions that mdadm may ask.
you will then be left with a the raid1 device /dev/md0 which you now create a filesystem on with
Code:

mke2fs -j /dev/md0
mkdir /mnt/data
mount /dev/md0 /mnt/data



Dave

Adil Boyun 11-19-2011 06:24 PM

First of all, really appreciate the help, and the work you put into this. Thank you a lot.
I assume creating array for md2 is a typo, just to indicate for later usage of info.

So far everything went like charm, i dont know if i need to creat a mdadm.conf file with
Code:

# mdadm --detail --scan --verbose > /etc/mdadm.conf
To make mounting permanent, i will add this to fstab, for my situation is it correct to add?
Code:

# echo '/dev/md0 /mnt/data ext3 noatime,rw 0 0' >> /etc/fstab
Final result so far:

Code:

(parted) print all                                                       

Model: ATA OCZ-VERTEX3 (scsi)
Disk /dev/sda: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End    Size    Type    File system  Flags
 1      1049kB  2147MB  2146MB  primary  linux-swap       
 2      2147MB  2684MB  537MB  primary  ext3             
 3      2684MB  120GB  117GB  primary  ext3             



Model: ATA ST33000651AS (scsi)
Disk /dev/sdb: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End    Size    File system  Name    Flags
 1      17.4kB  3001GB  3001GB  ext3        primary  raid



Model: ATA ST33000651AS (scsi)
Disk /dev/sdc: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End    Size    File system  Name    Flags
 1      17.4kB  3001GB  3001GB  ext3        primary  raid



Model: Unknown (unknown)
Disk /dev/md0: 3001GB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End    Size    File system  Flags
 1      0.00kB  3001GB  3001GB  ext3

Best regards.

davemguru 11-20-2011 04:02 AM

Quote:

I assume creating array for md2 is a typo
Yes -typo correctly assumed.
Quote:

Code:

# echo '/dev/md0 /mnt/data ext2 noatime,rw 0 0' >> /etc/fstab

"ext2" is also a typo right? :)
"Yes" to the /etd/mdadm.conf.

My only remaining thought... (Hmmmmmm) is the "physical/logical" sector sizes.
Some newer large capacity drives are using larger physical sector sizes. The ST33000651AS uses 512byte sectors - so, in this case it is not an issue. But, something to think about - should you ever re-use this knowledge.


Dave

Adil Boyun 11-20-2011 06:06 AM

Code:


[root@CentOS-57-64-minimal home1]# mdadm --detail --scan --verbose
mdadm: metadata format 1.00 unknown, ignored.
ARRAY /dev/md0 level=raid1 num-devices=2 metadata=1.00 name=0 UUID=7c7f9ebf:72a8cb15:f1d9c2e8:1c87d4eb
  devices=/dev/sdb1,/dev/sdc1

Direct logic: mk3fs makes ext3, mk2fs should do ext2 :D
I should have checked the output at least :)
So far everything works like charm, i marked the thread as solved, thanks^2 for help


All times are GMT -5. The time now is 09:42 AM.