Wednesday, June 9, 2010

Creating Ext4 filesystem in a RAID setup

In this post I am going walk you through a simple procedure on how you can create ext4 partitions for a large filesystem.  Thanks to Garvin W. Burris on his original how-to which simplifies how things are done.  Read on

Ext4 on CentOS for a Large Filesystem

I thought I'd give ext4 in CentOS 5.4 a spin on my server, since I've been using ext4 on my Fedora netbook for some time. The ext4 filesystem is still a Technology Preview in RHEL, but there have been many recent fixes. XFS is also another option for large data, and I dream of ZFS support, but I'd rather try what will soon be the default filesystem for Enterprise Linux. I have an 12TB RAID6 (15x 1TB drives) on /dev/sdc with 128k blocks and one hot spare.

First initialize the device as an LVM physical volume, wiping GPT info, and accounting for 128k stripe alignment of the RAID array:
# dd if=/dev/urandom of=/dev/sdc bs=512 count=64
# pvcreate --metadatasize 250k /dev/sdc
# pvs -o pe_start

Create an LVM volume group for the RAID array, and then create the LVM logical volume, using 100% of the volume group:
# vgcreate RaidVolGroup00 /dev/sdc
# lvcreate --extents 100%VG --name RaidLogVol00 RaidVolGroup00

Now format the logical volume as ext4:
# yum -y install e4fsprogs
# mkfs -t ext4 -E stride=32 -m 0 -O extents,uninit_bg,dir_index,filetype,has_journal,sparse_super /dev/RaidVolGroup00/RaidLogVol00
# echo "/dev/RaidVolGroup00/RaidLogVol00 /data0 ext4 defaults 0 0" >>/etc/fstab
# mount /data0