Main Contents

inode diet

July 20, 2009

I keep all my music on a server in the corner of my office, so it’s accessible from any machine in the house. I recently rebuilt the OS install on the machine (Linux, of course), and reformatted the hard drives to get rid of ReiserFS and switch to ext3.

After putting back all the data to a single temporary partition, I took a look at my inode usage. df -i reported that the main data partition had 101875 inodes used out of 9281536, and df --si reported 135G used.

135,000,000,000 / 101875 = 1325153, so I’m using 1 inode per 1.3MB of disk space. And it’s worth noting that I also keep e-mail in the same partition, using Maildir format, so I have a ton of small files there too.

Why is this interesting? Because by default, Linux mkfs.ext3 creates an inode for every 16KiB of disk, at least on Ubuntu. So in spite of all those tiny mail messages, I had roughly 80x as many inodes as I needed, each eating up 128 bytes of space. All those unused inodes were chewing up over a gigabyte of disk.

By using mkfs.ext3 with the -i parameter, you can pick a more reasonable inode ratio for the long term home of my data. It’s best to err on the side of caution, as you can’t add more inodes later, so I decided to go with mkfs.ext3 -i 262144, or about five times as many inodes as I observed that I was using. In addition, since the data partition isn’t my root partition, I used -m 0 to skip reserving any space for root’s exclusive use; if the partition fills up, the system won’t fall over.

Filed under: Linux, System administration | Comments (0)

Leave a comment

Login