Thoughts on Linux, technology and life in general.

Hard and Soft Limits In ulimit

ulimit is one of those commands that you kinda forget about until you really need it. The most common usage is for setting file size limits, and for me it is often utilized to control the max size of core files, as I often work with software that "dumps core like a little girl."

Really all ulimit is, is a front end for particular uses of sysctl. sysctl can set the many, many kernel parameters. Run "sysctl -a" for the full rundown.

One of the oft confused components of ulimit is the notion of "hard" and "soft" limits. If you've ever worked with Linux disk quota management, then this concept will not at all be foreign to you, but for everyone else it does come off rather mysterious at first glance.

"ulimit -a" will give you the current soft limits for the attributes that ulimit can control. "ulimit -Ha" will give the hard limits. To set the soft limit for max file size of a core file to 0 bytes run "ulimit -c 0". If you check /etc/profile, you will probably see that this is already done for you at boot, which is good because any changes you make with ulimit will not persist across reboots.

Soft limits can be set on a per user basis, and these values can be set to a value no greater than the hard limit. Some applications will actually ignore the soft limit and only adhere to the hard limit. Java 5 is an example of this, and will only use the hard limit for the core file setting in effort to ensure the generation of a core file.

So think of a soft limit as a user massagable value and the hard limit as the uncrossable threshold that is set by the sys admin. To make these changes persistant across logins/logouts and reboots, you will want to add these values to the /etc/security/limits.conf file. Just take a look in there near the bottom and you will see some commented out lines that will give you an idea of how to set the limits.

Mouting ISOs and keeping your RPMS local

Something that we as Linux folk often do is download an ISO of the latest and greatest distro of our choice. After the install/upgrade, one of my favorite things to do is copy all of that distros packages (In my case, RPMS) to some local filesystem. In case of a network outage, or the non-availability of an Internet connection, this proves useful.

My package management tool of choice is yum, although I do love apt-get(especially for my iPhone). Sometimes I can't find the package I need with Yum, although I swear that it exists, and a corresponding search of rpmfind.net corroborates my thought. If I have the package local already, I can just install it, however I am not saved from the possibility of dependency hell. However, since you do have the RPMs local, you shouldn't have to scour the Internet looking for those dependencies. You can get around that though, using YUM and creating a local repo, which is outlined HERE.

So, taking that ISO we've downloaded, we want to mount it as so:

# mount -o loop -t iso9660 file.iso /mnt

Now you can navigate to the directory on your "media" which contains the RPMS/.dpkg files that you want to copy locally. Copy them to some directory( I use /OS_RPMS) and you are done. Honestly, I think making that directory a local YUM repo is the way to go, but even if you don't do that you are still eventually going to be happy that you have all your OS packages local.