Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

tmpfs: work with your data even faster

Currently improving IDEA performance by copying cache files into the RAM using tmpfs. Actually, tmpfs and ramfs are good ideas.

As described in Wikipedia: tmpfs is intended to appear as a mounted file system, but stored in volatile memory instead of a persistent storage device. Simply put, when you copy a file to such FS, this means that you copy a file to the RAM. When you create a file in this FS, this means you create a file in RAM. When you delete a file in this FS, this means you delete a file in a RAM. And so on.

The negative side of tmpfs is that it's not backed by any storage: on restart or system crash you'll lost your files and data stored in tmpfs. But on system start you can either copy files from the disk to the memory again and continue to work.

In case of IDEA cache, I will need to write a simple script that periodically copies the cache from tmpfs to the disk. So, on restart, I can simply restore cache, and don't need to wait while re-caching is done.

So, how to create a tmpfs storage? It's pretty easy to do with next commands. Here I create an empty directory tmp and mount it as tmpfs filesystem.
# mkdir ~/tmp
# mount -t tmpfs -o size=500m tmpfs ~/tmp
Option size=500m limits memory usage to 500m. tmpfs also supports flushing content to the swap when need. This is one of the main differences between tmpfs and ramfs. ramfs is not limited and can grow dynamically, and the used memory can't be freed or flush to swap. The negative side of such dynamic nature of ramfs is that system can hung when no free memory left.

To read from and write content to RAM is much much faster than to do the same operations with a file on disk. It's pretty good optimization if you need to support read-only content or content that can easily be restored when need.

Such type of content is a hosted website. You can decrease page or resource loading time by moving them from hard disk to the memory filesystem.
 # mkdir /var/www/www.example.com
 # mount -t tmpfs -o size=50M tmpfs /var/www/www.example.com
 # cp -R /home/www/www.example.com/* /var/www/www.example/com

To mount tmpfs automatically on system load, you will need to add another record to yours /etc/fstab configuration file. The only you need to do now is execute next command on system start:
 # cp -R /home/www/www.example.com/* /var/www/www.example/com

As a summary, tmpfs is a good way to work with large amount of files or data that need to be accessed or processed quickly. Such data also is either read-only or can be easily recreated. Samples of such data are static websites, website resources, temporary cache etc. When need to process large amount of data, you can also split it into small pieces and process each one by one. tmpfs is also takes a limited amount of RAM, and can increase over that amount.

Linux tools to generate password

Few days ago was looking for simple tool to generate passwords in linux console.
As result of my searching are 3 useful tools. They are:

  • apg

  • makepasswd

  • pwgen


apg


Install: sudo apt-get install apg

Asks to enter random data, that should be used to generate new password.
Example:

Please enter some random data (only first 16 are significant)
(eg. your old password):>
Opt8Ovuf (Opt-EIGHT-Ov-uf)
Uc1Gryec (Uc-ONE-Gryec)
jadJoav5 (jad-Joav-FIVE)
IshtIvawam3 (Isht-Iv-aw-am-THREE)
lakVosAfUrg7 (lak-Vos-Af-Urg-SEVEN)
dyijDus8 (dyij-Dus-EIGHT)

You can pass random string as parameter and use many different options:

$ apg -n 10 -m 8 -x 12 somerandomdata

Will generate 10 passwords with min length 8 and max length 12.

makepasswd


Install: sudo apt-get install makepasswd

Generates password, by default one. User may need to use options to set length of password and count of passwords. For example:

$ makepasswd --count=10 --minchars=5 --maxchars=10

Results:

mzd4f9q
gUWamL
NYiUXrYvq3
6hWDXKA
gQpu20IJGD
BSAT5ASFX
37FcKyLPb
ma7pC66A
cFpWPBy
0oTNhT7


pwgen


Install: sudo apt-get install pwgen

My favorite tool to generate password. By default generates 160 different passwords each with length 8 symbol. Programs takes 2 parameters:
- 1st is the length of the password and
- 2nd is the count of passwords to generates. For example:

$ pwgen 12 24

Results:

oHo2iethieze cheiS6ohPeed Oozufiorohv9 eic3aethei4L hiRohYie6Ue4 aephoiDieb0y
hieTh8eizaeK aid1EeNgaiSe yoh6chohX9ha aiPhae7dieMe wedooD8nai7y aic7deeB9eS8
ohFor3Achied Thaequu4aiph zaeghiem7keT Shee5ooxaex0 wePh2eiNgien aicohroo2Go3
Aagh0gahcah0 Zie8eazaitah aoha9AeXi7Bo Oojoob0oosh6 Olahgh4aeji6 oobae9UZ2phi

Ruslan and Linux

Давненько я нічого не писав...

За такий здавалося нетривалий період часу, багато чого встигло помінятися, тому, думаю, буде що розсказати.

Мабуть, найбільшою зміною для мене був цілковитий перехід на Linux. Ось уже від початку травня я є гордим користувачем Ubuntu 10.04. Перехід видався значно простішим, ніж можна було очікувати, але це скоріше за все результат моїх попередніх поривань в цю сторону, а також нетривалого, але плідного використання Slackware.

Важко далося використання MS SQL Server на локальній машині під Linux. Не можу сказати як я вирішив цю проблемо, тому що я її не вирішив. Використовувати віртуальну машину було нереально, адже в результаті тормозило все і вся. Тому довелося використовувати віддалений сервер і в результаті працювати тільки в онлайн. Благо, тепер потреба в ньому мінімальна.

Декілька слів про Ubuntu. Зручно, приємно, вражаюче і крім цього є консоль із всіма її потугами. Через кілька тижнів використання, я вже не міг собі уявити себе без Linux, а Windows 7 почав виглядати поцікавому і, навіть можна сказати, екзотично.
А ще недавнo я для себе відкрив, що в mc можна використовувати мишку. І це могло би перевернути мій світ, але не стало ;)

Люблю консоль. Консоль та набір скриптів дозволили оптимізувати роботу в Linux та роботу по проектах.

Screen cast on linux with ffmpeg

Few days ago I was happy to found the link with 10 useful Linux commands at http://www.catonmat.net/blog/top-ten-one-liners-from-commandlinefu-explained/.

The last one command was the most interesting for me, as it helps to make screen casts quickly and easy with only one command:

ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq ~/out.mpg


Moreover ffmpeg helps to setup video quality, convert it to FLV format, so you can publish video online with a few clicks!