Linux: Quickly allocating space

A classic that makes you wait:

$ time dd if=/dev/zero of=swapfile bs=1MB count=5000
5000+0 records in
5000+0 records out
5000000000 bytes (5.0 GB, 4.7 GiB) copied, 5.88192 s, 850 MB/s
real 0m6.269s
user 0m0.007s
sys 0m3.829s

An improvement on the classic that creates a sparse file (file with lots of zeroes):

$ time dd if=/dev/zero of=swapfile count=0 bs=1MB seek=5000
0+0 records in
0+0 records out
0 bytes copied, 7.7025e-05 s, 0.0 kB/s
real 0m0.008s
user 0m0.002s
sys 0m0.001s

A modern version that creates a sparse file, too (not guaranteed to be allocated, you can definitely ask for more space than you have, etc):

$ time truncate -s 5G swapfile
real 0m0.004s
user 0m0.001s
sys 0m0.003s

Modern, but filesystem specific (guaranteed to be allocated by the filesystem with no I/O):

$ time fallocate -l 5G swapfile
real 0m0.017s
user 0m0.000s
sys 0m0.005s


Linux PSA (potential for data corruption): alpm=min_power

If you’re on a powersaveprofile through tuned, your system’s disk journal might crash during periods of idling and/or sleep.

In /usr/lib/tuned/powersave/tuned.conf

  1. Change alpm=min_power to alpm=med_power_with_dipm
  2. Apply with tuned-adm profile powersave
  3. cat /sys/class/scsi_host/host*/link_power_management_policy to verify

This was somehow the default on my computer and difficult to find.

Reference: Arch Linux – Power management

Firefox Quantum on Fedora Linux – 6000: Renderer not available

6000: Renderer not available

This might apply to other distributions too, but the packaging is likely going to be different.

But to fix this error:

  1. Install RPMFusion (Fedora does not provide these packages for a number of reasons):
  2. sudo dnf install gstreamer1-vaapi gstreamer1-libav
  3. Restart FireFox Quantum and test on a site that shows the error

MythBox: Connection to mythtv host failed

The system setup:
MythTV backend running on a separate machine (e.g.
XBMC MythBox plugin running on a separate computer (e.g.

This error occurs during MythBox setup, stating the following after MySQL credentials are entered: Connection to mythtv host failed: (10061..

This can be a plain MySQL error, but it can also be an error where the MySQL connection is successful but MythBox is referred back to when it tries to connect (by settings on the mythtv backend system).

– Ensure that the MySQL user can connect remotely. To test this from another computer:

$ mysql -h -u mythtv -p

If not working, check MySQL permissions for the mythtv user (make sure the host field for the user is ‘%’) and look at my.cnf (find the file with `locate my.cnf`).

From the mythtv backend:
$ mysql -u root -p
mysql> use mysql;
mysql> select * from user where user = 'mythtv';

* If MySQL is working, ensure that the MythTV backend is setup properly.

Run mythtv-setup
Go General -> IP Address
Set both IP addresses to the external IP of the machine you are connecting to from XBMC (setting only Local Backend to an external address did not work).


KDE 4: Turning off desktop switch via scroll wheel

There seems to be an kerfuffle with the layout of KDE settings. The option for this is not in the main ‘System Settings,’ but in another area entirely, named ‘Desktop Settings,’ which can be found by going to:

(From the desktop)

Right click -> Desktop Settings -> Mouse Actions

Click the minus sign by Middle-Scroll to delete it. Then click Apply.

Enabling webGL with Fedora 16

In Fedora 16, detection of WebGL fails for some reason (I haven’t looked into this too throughly).

What worked for me was to visit (in Google Chrome):


I then enabled “Override software rendering list” and clicked the restart button at the bottom left.

WebGL worked without a hitch (i’m using a Sapphire ATI 6850 graphics card if it matters).

Increasing the size of a LUKS cryptfs partition

Warning: This guide assumes that the partition you’re expanding into is adjacent to a pool of free space. Things get a bit trickier if that isn’t the case (re-arranging your partitions is probably necessary).

The system that I performed this on: Fedora 16 KDE install, on a 120GB SSD installation (migrated from an 80GB SSD using Acronis True Image). Fedora doesn’t set encryption up via LVM in the installer, seemingly opting for a plain vanilla container.

Step 0: Boot into a live CD environment. I used a Fedora 16 KDE respin CD which had all these tools. Open a console (in KDE this was `konsole`).

Step 1: Blow away the partition itself. You’ll need to do this with `fdisk`. Make a new partition, with the cluster of free space included. Select Linux for type when prompted (usually 82 OR 83). Write changes to disk.

Step 2: Open your crypted filesystem:

# Replace /dev/sda2 with your own filesystem

# cryptsetup luksOpen /dev/sda2 root 

Step 3: Expand the crypted FS

# cryptsetup resize root

# e2fsck -f /dev/mapper/root

# resize2fs -p /dev/mapper/root

Step 4: Safety hat

# cryptsetup luksClose root

# sync; sync; reboot

Including one package in a yum repository

Yum can be surprisingly simple and frustrating at once. To add only one package from a repository you can do the following.

In the yum configuration file for the repository (normally this is /etc/yum.repos.d/$repository.repo).


You can also glob to include all packages of that type, such as:


Save the file, and search/install new packages. Yum will only see packages of “vlc” and nothing else.

If you are looking to do the opposite, the keyword is `exclude`. To exclude all rpms from a repository for instance:


Don’t add both exclude and includepkgs together without careful consideration.

Arduino: Pushing the world forward

With the Arduino movement fully underway and unlikely to lose steam, there is something to be said about how the world was before it.

Revolutionary ideas take things that were once hard and distill them into safe, guided, and easy experiences.

Some of the more experienced scoff at projects like Arduino because at the core, they eat into hard knowledge bought with time. A computer scientist might be a bit miffed if tomorrow they would be somewhat replaced by clever self-optimizing algorithms (pending the submission of a million dollar proof, of course).

Before Arduino, building an AVR breakout board from a knowledge base of zero would have required knowing even beginning electronics lingo (by asking such inane questions like: “what is ground?”) to finally making the selection of AVR over PIC, ARM, FPGAs and otherwise.

A beginner doesn’t really need to understand the innate difference between a crystal and a resonator (the crystal has better quality), or why one is needed in the first place (its used as a sort of heartbeat for microchips).

This is often why hard problems remain hard, and why few people tackle them. Smart (and rich) people remove irrelevancies like these.

Good projects that change the world have this embedded in them as a core value (distilling hard problems) and have become wildly successful because they pander to the masses, and not exclusively to the experts.

Ubuntu for instance, became synonymous with “Linux” on several forums because it was a great entry-level distribution.

Ruby on Rails for quite some time has been the de-facto web framework, and arguably ushered in MVC as a mainstream way of doing web development. Its framework and “opinionated” way of doing things made web development less boilerplate and more manageable.

Knocking down barriers is something that can be done with nearly all that is hard in every field: Mathematics, Biology, Teaching, and Engineering.

While brain ‘trusts’ are nice and elite, drawing many smart people to a field and having them stay is more valuable to society as a whole.

Here is to the next framework, or hard problem solver that makes a massive splashdown on a problem once ruled solely by experts. Things can only get more interesting as people figure out how to craftily exploit making hard things easy. Because problems only get more interesting.

opsview and notifications

To send a notification to an external party in opsview (3.13.1) there are a few things to do:

1. Attach keywords in the host configuration to that particular host (unique no, spaces, special characters, underscores are okay).
2. Setup a new role (with the NOTIFYSOME permission, which is vaguely documented) + check off the ‘all’ box in the keywords permission section.
3. Add a contact with an e-mail address.
4. Add a notification profile attached to that e-mail address, with specific keywords to notify on checked off.
5. In the keywords section, click to flag all services with the specified keyword (otherwise no notifications will appear).

For the lazies (which means pretty much every systems administrator out there) there is, (thankfully) a *full* REST API with JSON built into opsview (unlike some of the other Nagios derivatives). More on that later hopefully.