dmesg human output

There is a neat tip on Gentoo forums, I guess you'll like it too. Latest versions of sysvinit and util-linux will help you get readable dmesg output like (it's on ~amd64 on gentoo):

$ dmesg -HT | tail -4
[Prş Mar 13 09:58:36 2014] usbcore: registered new interface driver usbhid
[Prş Mar 13 09:58:36 2014] usbhid: USB HID core driver
[Prş Mar 13 09:58:37 2014] nvidia 0000:01:00.0: irq 49 for MSI/MSI-X
[Prş Mar 13 09:58:42 2014] r8169 0000:04:00.0 enp4s0: link down

Localized dates ಠ_ಠ


Formatting and mounting a single file in Linux

Ext3 has 30K directory limit inside one single directory and I needed to create ~180K.
Crap, I need another filesystem, which might be ext4, xfs or something like it. But I can't shutdown a production server or plug another disk. So I created one file which is big enough for my needs (let's say 100G):

$ truncate -s 100G my_ext4_blockfile

Let's format the file:

$ mkfs.ext4 my_ext4_blockfile

Now, you can mount the file wherever you like:

$ mkdir new_disk
$ mount -t ext4 my_ext4_blockfile new_disk

System will mount it with help of loop device, you might check it via mount command.


My goverment is filtering my internet access, what can I do?


I live in Turkey.

And I suspect the goverment started to filter my internet heavily.

Here is a little list of what you can do to prevent that (well, partly).


  • Increase your voice!

Tell them you don't want this. They might understand.


  • SSL. For. Everything!

Not every website might support SSL. But damn, at least you should try.

For browsing interwebz, you can use a browser extension (like this).

For other stuff, choose the most secure service possible.


  • Use VPN.

This might sound slower. But if your goverment is also blocking lots of websites, you should try this.

You can buy or use a free one.

Or if you have a VPS, you can create your private VPN (or just a tunnel to browse)


  • Become an immigrant!

If you have a chance, this is probably the best (also hardest) one!




Use your old netbook as home server

I have an old-ish Sony VAIO netbook (this) which has few broken buttons on keyboard (I've probably shouldn't open the case). Thing has 1.83GHz Atom CPU (yay! calculator!) and 2G RAM.

This thing was sitting on the shelf since I realized that I can't bear the low CPU power. Lately decided to use it for something, but what?

After little playing around, now it's really doing something as a low-powered (I hope), 7/24 open home server!

Here is what I did:


- Installed Ubuntu Server LTS.

You can use everything of course. Selected Ubuntu Server because it's easy and I won't need an X interface. SSH is enough.


- Gave static IP on LAN.

You might want this to access from outside.


- Created a Virtual Server on my router's interface and redirected some ports (80, an ssh port and another custom port)

Now if I enter my router's IP address from outside, I'll go directly to the home server.


- Got a noip account.

I can't remember my router's IP address! Must gave it a domain. Luckily my router has DDNS (Dynamic DNS) support. Now I can use this domain name to access my homeserver. Even if IP changes, this service will refresh the domain name's IP address.


- Plugged an old webcam.

Why not? Thing was dying on corner.


- Installed fswebcam to get frequent captures.

Like a security camera. Well, not quite. I don't 'record' these captures. Also streaming a video is not for me. Not so much happening in my home.

Didn't configure it much: Using 'screen' to get a never-ending bash session and getting this command to snap a picture every 5 sec:

$ fswebcam -d /dev/video1 --no-banner --set brightness=80% --set lights=on -S 30 --no-shadow --scale 640x464 --no-banner -l 5 --quiet /var/www/webcam.jpg


- Installed a webserver to serve these captures (with http auth of course).

Be careful! You can violate privacy of yourself or your homemates. I'm running this command rarely to see my cat's evil actions. Hope to not to see anyone else :)


- Installed deluge torrent client with web interface to serve from that custom port (which I set up on router).

This is wonderful. I can add a torrent file from work and see download finished when I get back.


- Installed samba.

This is useful if someone in the house is using Windows. Deluge download directory could be shared.


- Installed 'wakeonlan'. 

I might wake up my main dragon with homeserver.


And some more shitty work.. I'm still thinking to expand it's usage area. But for now, it's running quite good. It's battery helps it to survive power failures.

$ uptime
20:04:53 up 39 days, 9 min, 1 user, load average: 0.14, 0.09, 0.06

Another Nginx 502 bad gateway problem

I was getting 502 error on Debian Wheezy (nginx 1.2.1):

...recv() failed (104: Connection reset by peer) while reading response header from upstream...

Nothing on php-fpm config helped. And my solution to use newer version from DotDeb repo. Also it has the "nginx-cache-purge" module if you want to use wordpress nginx helper module.