Disclaimer: As with all howto posts here, I do not take any responsibility if you lose your data. I have done research to make sure that all information provided here is as accurate as possible, but there are always variables. Make sure that the information below is relevant your environment and make sure to always have a complete backup before trying this at home (or the office) 🙂
I have two Iomega IX2-200 NAS devices, they do a great job of storing my media as well as providing some iSCSI and NFS storage for my VMware lab. Unfortunately because they only have two drives in them they have always been fairly slow, but in an effort to squeeze as much performance out of them as possible I decided to see if the main XFS file system could be defragmented. Much to my surprise, the utilities to do so were already installed and ready to run on one of my two IX2-200’s.
Note for IX2’s that are not the “Cloud” version
I should make a note that even though my IX2-200’s are both the non-cloud versions, I did have a friend upgrade one of them to the cloud version’s firmware. The cloud IX2 is the one that includes the XFS defrag utilities, however I found that all i needed to do was use SFTP to copy the utility over to the non cloud IX2 and it ran fine there as well. Since you may not have a cloud IX2 available to you I have tar’ed the file that is missing and you can download it HERE. After downloading it use something like WinSCP to transfer it to the root directory of your IX2 and when needed, you can run it by typing ./xfs_fsr …. Please note if you dont already have SSH enabled you will need to do the next part before trying to upload the xfs_fsr utility to your IX2.
In order to get to the linux shell we need to enable SSH on the IX2, this is a fairly simple task that is done from the web interface. Here are the steps:
- First login to the IX2-200 via the normal admin page.
- Next browse to https://The_NAS_IP/support.html
- Click “Support Access”
- Check the box next to “Allow remote access for support (SSH and SFTP)”
Here is a screenshot of the non-cloud version of the IX2
Now that you have SSH enabled we can login using Putty or other SSH utilities. The username is root and the password is a combination of your web interface password and “soho”. For example if your password is “jpaul” then your root password is “sohojpaul”.
Do you need to defragment ?
After we have enabled SSH and uploaded the xfs_fsr utility we can now check to see if we really need to defrag our NAS. To help make things easier I have one screenshot which multiple highlighted areas, each with different colors. As I explain the process I will reference the same screenshot and note which color I am referring to.
The first thing to do after getting logged into the IX2 is to type the mount command (highlighted in yellow). This will list the mounted file systems on the NAS, we are looking for the last line in the out put which normally contains “/mnt/pools/A/A0” (If you have a non-cloud version it will say “/mnt/soho_storage”. After you find that look over to the left and copy that information (highlighted in blue) to notepad or something. That is the RAID1 mirror that we will be defragmenting.
Next we need to run the ‘xfs_db’ command (highlighted in purple), this command is the debug command that will help us find out how badly fragmented the file system is. first type ‘xfs_db -r’ then paste in the information you copied (highlighted in blue). This will bring you to a debug shell for XFS. Type ‘frag’, and you will see a % fragmented for your NAS… mine is 85.77% (highlighted in orange). Type ‘quit’ to drop back to the linux shell.
The next command is the actual defragmentation process, and will take several hours to complete. It is highlighted in red. Type ‘xfs_fsr -v’ then paste in the information you copied earlier. PLEASE NOTE: if you have a non-cloud edition IX2 then you will need to type ‘./xfs_fsr -v’ after making sure you are in the directory where you extracted the xfs_fsr utility.
You should start to see something like “extends before:XXX after:1 DONE” this lets you know that the process is running, also if you are close by the NAS you will notice the hard drive light is on almost solid.
Video: HDD light during defrag
After your defrag completes you are probably thinking that you dont want to wait that long again, nor do you want performance to get degraded if you forget to run it on a regular basis. For this purpose I will explain how to add a scheduled task so that it runs this process automatically each week.
To implement this we will create a cronjob that will execute at midnight on Sunday night (or Monday morning).
Type ‘crontab -e’ as root and you will be brought into a text editor where we can paste the last command that we used before. The only difference is that we need to add the required numbers so the command runs when required.
For my system here is what I needed to paste in:
0 0 * * 0 /sbin/xfs_fsr -v /dev/mapper/40ad0e07_vg-lv4408ab81
For your system you will need to change the “/dev/mapper/40ad0e07_vg-lv4408ab81” to whatever you copied earlier which was in blue.
If you have a non-cloud version of the IX2 then your command will look like this:
0 0 * * 0 /xfs_fsr -v /dev/mapper/40ad0e07_vg-lv4408ab81
If you did not extract the xfs_fsr utility to root ( / ) then modify the command as needed, you will also need to change the /dev/mapper/… to whatever is specific to your system, you copied it down earlier 😉
Ok you should be all set at this point, you should have a NAS with a defraged file system as well as a weekly maintenance task that will run the defrag command each week to keep things working nicely. If you do need to change the time when the command runs please reference this site: http://www.adminschoice.com/crontab-quick-reference as it has a great overview on how crontab works.
Update / Results:
I wrote this post just after starting the defrags on both NAS systems, this morning (the next day) I ran the ‘xfs_db -r’ command again to check to see how much fragmentation was left now that both devices had completed their run.
NAS1 before was 85.77%, Now after the defrag it is only 1.54% fragmented!
NAS2 before was in the neighborhood of 65% (apparently I didn’t record that info), but now it is only .27%!
Hopefully this will make a little difference in my day to day use of the systems.