Defragmenting XFS file systems on Ubuntu 13.04

After using the XFS file system for a while, you might see it slow down a bit.  If so, you may need to defragment the file system.  Doing so is very easy but does require root access and the xfsdump package:

sudo aptitude install xfsdump

Now that we have the xfsdump package, we can use the xfs_db utility to determine the current fragmentation percentage:

sudo xfs_db -r /dev/sda6
xfs_db> frag
actual 95343, ideal 85809, fragmentation factor 10.00%
xfs_db> quit

As you can see, the estimated fragmentation percentage is 10%. Not bad but let’s get that down:

 sudo xfs_fsr -v /dev/sda6
/home start inode=0
ino=138
extents before:2 after:1 DONE ino=138
ino=100725
extents before:19 after:1 DONE ino=100725
ino=103896
extents before:17 after:1 DONE ino=103896
ino=474184
extents before:3 after:1 DONE ino=474184
ino=474183
extents before:2 after:1 DONE ino=474183
ino=474185
....

We can have XFS defrag all the mounted file systems automatically by creating a crontab job in /etc/cron.daily/xfs-defrag.sh:

#!/usr/bin/env bash
/bin/date >> /var/log/xfs.log
/usr/sbin/xfs_fsr -v 2>&1 >> /var/log/xfs.log
/bin/date >> /var/log/xfs.log
Share Button

Received ‘Can’t call method “value” on an undefined value at /usr/share/perl5/IO/Uncompress/RawInflate.pm’ on Ubuntu 8.04 Server (Hardy Heron)

On my media server, I wanted to set up Perl’s CPAN but when I ran install Bundle::CPAN, I ctrl-c’d out of it when I noticed that bzip2 wasn’t installed.  Silly me.  Soon after I started receiving:

Can’t call method “value” on an undefined value at /usr/share/perl5/IO/Uncompress/RawInflate.pm

Reinstalling Perl and all the related ubuntu packages doesn’t fix it, nor does removing the ~root/.cpan dir.  There is an easy workaround though.

aptitude remove libcompress-raw-zlib-perl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
Building tag database... Done      
The following packages are BROKEN:
  libio-compress-zlib-perl 
The following packages have been kept back:
  bind9-host dnsutils libbind9-30 libisccfg30 
The following packages will be REMOVED:
  libcompress-raw-zlib-perl 
0 packages upgraded, 0 newly installed, 1 to remove and 4 not upgraded.
Need to get 0B of archives. After unpacking 319kB will be freed.
The following packages have unmet dependencies:
  libio-compress-zlib-perl: Depends: libcompress-raw-zlib-perl (>= 2.008) but it is not installable
Resolving dependencies...
The following actions will resolve these dependencies:

Remove the following packages:
apparmor-utils
libcompress-zlib-perl
libio-compress-zlib-perl
libmp3-tag-perl
librpc-xml-perl
libwww-perl
libxml-parser-perl
ubuntu-standard

Score is 592

Accept this solution? [Y/n/q/?] 

Make a note of the packages that it will remove, then tell it to go ahead. It will remove these packages!

Start cpan, and type in

install Bundle::CPAN

When it is complete, reinstall the ubuntu packages that you removed earlier (for example):

aptitude install apparmor-utils libcompress-zlib-perl libio-compress-zlib-perl libmp3-tag-perl librpc-xml-perl libwww-perl libxml-parser-perl ubuntu-standard

That’s it. Your cpan is working again 🙂

Share Button