Matt's Linux Blog

My linux problems (and their respective solutions)

Thursday, May 1, 2008

 

Moving my RAID array to XFS

I've got a 1TB RAID 5 array, which I use for backups. I use a script I made based on rsync, which pretty much mimics Time Machine functionality. That means in /storage/backup-lithium, there are directory entries for about 30 copies of my laptop's filesystem tree, even though most of them point to the same inode (i.e. data is shared between them). I've been using ext3 for this storage array, but I noticed it's really slow for searching through that crazy amount of directory entries, so I decided to try copying all my data to XFS to see whether it was any better.

Since I use LVM, this was pretty painless. First I shrunk my ext3 partition, which took a couple hours:
# e2fsck -f -C 0 /dev/storage/main
# resize2fs -p /dev/storage/main 400G
# lvresize -L 400G storage/main

Then I created a new logical volume:
# lvcreate -l 100%FREE -n xfs storage
# mkfs.xfs /dev/storage/xfs
# mkdir /xfs
# mount /dev/storage/xfs /xfs

I copied all my files from the ext3 to the XFS volume, which took about 22½ hours:
# time cp -av /storage/* /xfs

Now that I had two filesystems equally populated with directory entries, I ran bonnie++ and got very similar benchmarks on both volumes, suggesting that the change didn't really affect raw speed much. Then I tried something that would have to traverse the directory tree, with pretty drastic results:
# time du -sh /storage/backup-lithium
90G /storage/backup-lithium
real 56m40.618s

# time du -sh /xfs/backup-lithium
86G /xfs/backup-lithium
real 12m0.409s

The time it took to determine the total size of that folder went from 56 minutes to 12 minutes. To be even more sure of that result, I ran it again, giving me the same numbers within just a few seconds difference. I also noticed that XFS seems a bit more efficient at allocating files, since I confirmed that the contents of the directories were the same.

All in all, I think I'm going to mount the XFS volume as /storage and let the change be pretty much transparent. I've already checked to make sure that there were no files on /storage that were modified during the move. I'm not going to wipe the ext3 volume quite yet, since I still have plenty of space in the XFS partition — I'll do that when I actually fill up the disk.

Labels:


Archives

May 2007   June 2007   August 2007   October 2007   April 2008   May 2008   January 2009   May 2011  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]