Assigning the priority of services during the boot process

Linux provides the following choices for Process Scheduling:

  • SCHED_FIFO: Static Priority scheduling
  • SCHED_RR: round-robin variant of the SCHED_FIFO
  • SCHED_OTHER: default scheduling policy which uses the Completely Fair Scheduler (CFS)
  • SCHED_BATCH: for “batch” style execution of processes
  • SCHED_IDLE: for running very low priority background jobs

Usually to check and assign policies we use the chrt command, for example:

Checking Current policy of PID 1012:

# chrt -p 1012
pid 1012's current scheduling policy: SCHED_OTHER
pid 1012's current scheduling priority: 0

Assigning Policy FIFO with priority 50 to PID 1012:

#chrt -fifo -p 50 1-12 # chrt -p 1012
pid 1012's current scheduling policy: SCHED_FIFO
pid 1012's current scheduling priority: 50


But if we want a service to always have the same Scheduling policy, we may modify systemd service file as follows:


Then reloading daemon  (systemctl daemon-reload) and restarting service will show our service with new scheduling.


Redefining CFLAGS in Makefile

I am used to the old way of defining CFLAGS in the console when needed but recently in Debian exporting CFLAGS didn’t have the desired effect.

So In case CFLAGS variable for command line and even in makefile doesn’t work for you, this will make the trick in Makefile:

EXTRA_CFLAGS += foo bar baz

Adding a permanent network route in Windows

It’s not that common to add a network route in windows, but if you have more than one network interface and there are many networks hidden over there, you will need to do it

The syntax is quite simple

route -p add the_network mask the_netmask the_gateway metric the_metric

As an example, we will use the following information:

the_metric 10

And the resulting command is:

route -p add mask metric 10

-p means the network will be added permanently in windows registry, if you want to play with this new network until the next reboot, don’t use it.
If you do not what to do with metric , simply use 10

To check the routing table, use the command

route print

Squid 3.3 in Raspbian Wheezy

I have been playing recently with Squid and “Splash pages”, but this function works fine on Squid 3.2 and later; however Raspbian only offers Squid 3.1.

I looked for a ready to install 3.2+ version in the Webz but didn’t find one, so I backported the Debian Jessie version.

For the lazy ones, here are the links (try them at your own):

libecap2 (This dependency is not available in Wheezy)



Then install squid3 (install according to your needs)







Mounting a partition from a dd image

At some point, everybody may have done a dd image of a USB/SD stick, as the below example shows:

dd if=/dev/sdb of=foo.img 

But it is usual that at some point in time we would like to access the information inside the image, doing that is quite easy:

First,you should do a fdisk on the image:

fdisk -l foo.img

Disk foo.img: 7998 MB, 7998537728 bytes, 15622144 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002fc6d

Device Boot      Start         End      Blocks   Id  System
foo.img1   *             15622143     7811071+   c  W95 FAT32 (LBA)

Then some maths are needed. The operators are the start of the partition and the sector size in bytes.  The operation is simply start * sector size in bytes.

In this particular case the operation is 1 * 512 = 512.

Now that we have the result, that we call the offset. In other words, 512 is the offset where the partition starts in this dd image.

So the command to mount the partition is:

mount -t vfat -o loop,ro,noexec,offset=512 foo.img /mnt/mountpoint

And then we can copy the information from the partition inside!





Seeing what is being written or read in real time in Linux

Have you ever wondered which processes/tasks write or read to disk in Linux?  Maybe a real time log?

It’s quite simple to enable that feature with the following command:

echo 1 >/proc/sys/vm/block_dump

The output of the command goes to /var/log/messages or /var/log/kernel.log . It depends on the distribution you are using and how your log manager is configured.

Nov  9 21:21:01 hellboy kernel: [140072.428410] bash(31632): READ block 14156776 on md126p4 (8 sectors)
Nov  9 21:21:01 hellboy kernel: [140072.443138] bash(31632): READ block 14156816 on md126p4 (8 sectors)
Nov  9 21:21:57 hellboy kernel: [140127.746763] gnome-shell(5073): WRITE block 120375776 on md126p4 (8 sectors)
Nov  9 21:21:57 hellboy kernel: [140127.765385] gnome-shell(5073): dirtied inode 3627285 (?) on md126p4
Nov  9 21:22:00 hellboy kernel: [140130.602614] nvidia-settings(31743): dirtied inode 689070 (exe) on proc

The output shows the timestamp, the process name, the operation being done (read/write/dirty inode), block or inode number and the device.

Just to take note, a dirty inode is an inode that has had new data written into it but it has not been flushed to disk.


Dropping Linux Memory Cache

A Linux server of my own executes from time to time an rsync script, which one it finishes up doing its magic, leaves behind a lot of stuff cached in memory.

In order to “make available” the memory again to other applications, I recommend reading the following as seen on

Kernels 2.6.16 and newer provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can help free up a lot of memory. Now you can throw away that script that allocated a ton of memory just to get rid of the cache…

 To use /proc/sys/vm/drop_caches, just echo a number to it.

 To free pagecache:

# echo 1 > /proc/sys/vm/drop_caches

To free directory entries and inodes:

# echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

echo 3 > /proc/sys/vm/drop_caches

This is a non-destructive operation and will only free things that are completely unused. Dirty objects will continue to be in use until written out to disk and are not freeable. If you run “sync” first to flush them out to disk, these drop operations will tend to free more memory.


Purging WINS cache on Windows

On cmd execute:

nbtstat -R

parted: the resulting partition is not properly aligned for best performance

Rather than explaining the problem the title says, I’ll point you to the link you must read to understand/fix it:

net-news/liferea-1.8.3 has improved its startup speed

For everybody out there complaining about liferea’s decreased performance in the 1.8.x releases, upstream has released 1.8.3 which uses sqlite 3 WAL journaling.

This basically improves the overall liferea’s performance, so if you are hating 1.8.x, please try the latest 1.8.3

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.