How to use tunefs

2

Introduction:

I'm planning a performance-oriented clean install of OS X (10.6) on my Mac and I've decided (among other things) to split the hard drive into multiple partitions.

Two of them will be specific for swap files and hibernate-file (sleepimage) respectively so I wish to tune their file systems in order to achieve the best results but, there's a problem: I've never used tunefs and I don't know how to start using it.


Part 1:

According to the man page:

The tunefs utility cannot be run on an active file system. To change an active file system, it must be downgraded to read-only or unmounted.

and this seems to be clear but, as I'm still on a single-partition, I would like to test this a bit.

I've tried to make (and mount) a disk image file by using hdiutil, but when I try to read (by using tunefs -N /dev/disk1s1) the values, I get — I know, it's still mounted… — the following error: "tunefs: cannot open /dev/disk1s1 for reading: Resource busy" either with and without root execution.

So I've tried to unmount the test disk from Disk utility and then retrying the command above. This time, however, I've got: "tunefs: /dev/disk1s1: bad magic number: No such file or directory".

How can I accomplish the lecture of the parameters ?


Part 2:

I've thinked to tune the two HFS+ (Journaled) filesystems with the e, o and s parameters for the Sleep partition and with the f, m and o parameters for the Swap one. But… what about the values ?

Starting with the first one (e), this should be useful because the 5 GBs Sleep partition would contain only a big (4+ GBs) file and the man says:

This indicates the maximum number of blocks any single file can allocate out of a cylinder group before it is forced to begin allocating blocks from another cylinder group. Typically this value is set to about one quarter of the total blocks in a cylinder group. The intent is to prevent any single file from using up all the blocks in a single cylinder group, thus degrading access times for all files subsequently allocated in that cylinder group. The effect of this limit is to cause big files to do long seeks more frequently than if they were allowed to allocate all the blocks in a cylinder group before seeking elsewhere. For file systems with exclusively large files, this parameter should be set higher.

But, how can I choose the value ? (or retrieve the informations needed to decide it)


Now the second one (f). This should be easy except for a detail: the unit size. The man only says:

Specify the expected average file size.

I've thinked to use the number of bytes, but I can't be sure. Do you have any idea ?


Another one very easy, the m one. This represent a percentage value, but what does it wants ? an integer or a string with the % symbol ? As before, man only says:

Specify the percentage of space held back from normal users; the minimum free space threshold. The default value used is 10%. This value can be set to zero, however up to a factor of three in throughput will be lost over the performance obtained at a 10% threshold. If the value is raised above the current usage level, users will be unable to allocate files until enough files have been deleted to get under the higher threshold.

I'm oriented to the integer one… I hope it's correct.


For the o parameter I'm pretty convinced…

In the Sleep partition the sleepimage file always exists (I think it is overwritten) but it is rarely used (I've made a script to activate the Safe sleep only under a certain threshold of battery level).

In the Swap partition (4 GBs) I've seen that there is always almost one file (each of them will be 192 MBs in size) but they may come and go in rare occasion (the file size is calibrated due to my average swap usage — when used).

Is more convenient to optimize the file systems for the space or for the time ? For either of them, I'm oriented to the time.


The last one (s) is ambiguous because even if in my Sleep partition there will be only one file, I have reasons to think that the file system may put some extra (hidden) files. The man says:

Specify the expected number of files per directory.


Conclusion:

Thanks in advance for the help and excuse me for the long question…

dezzeus

Posted 2013-05-10T17:06:13.263

Reputation: 688

I've found a source code of tunefs and I've noticed the use of atoi C function for some parameters, so I think that for the m parameter, an integer is expected. Within the same source code I've also noticed the use of a data structure who reminded me to the fs.h code (of another UNIX-like OS) who was commented with this "All values are given in byte-offset form, so they do not imply a sector size." so I think that I was right regarding the f parameter. – dezzeus – 2013-05-11T13:53:32.603

No answers