tag:blogger.com,1999:blog-85114998094460547982024-02-19T01:07:10.426-08:00Linux HowToMichaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-8511499809446054798.post-23753665548439740782012-08-15T09:54:00.000-07:002012-09-01T10:37:43.075-07:00Gentoo Portage SquashFS + zsync<div dir="ltr" style="text-align: left;" trbidi="on">
If you are Gentoo user and you're wondering about how to reduce portage tree disk usage and makes emerge --sync faster, this article is for you.<br />
<br />
Lets talk about key problems of portage tree:<br />
<ul style="text-align: left;">
<li>Large disk usage because of uncompressed text data</li>
<li>Heavy inode usage because of huge amount of files</li>
</ul>
The above problems result in excessive disk I/O during emerge operations. The most popular solution is to squash the portage tree. It is well-described in <a href="http://en.gentoo-wiki.com/wiki/Squashed_Portage_Tree" rel="nofollow" target="_blank">this article</a>. But I've made an easier <a href="http://linux-howto.codesvc.com/gentoo-portage-squashfs-zsync.html">script</a> that can handle all the headache for you. I hope you like it! :)</div>
Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com0tag:blogger.com,1999:blog-8511499809446054798.post-90192387327312620512010-03-24T02:23:00.000-07:002010-03-24T02:27:18.310-07:00Mysql Unknown Variable character-set-serverIf you've recently upgraded to MySQL 5.1.45, you might experience a problem running mysql client. The error message says:<br /><br />/usr/bin/mysql: unknown variable 'character-set-server=utf8'<br /><br />The reason is that mysql client no longer supports character-set-server parameter. Actually I don't know why, the official <a href="http://dev.mysql.com/doc/refman/5.1/en/news-5-1-45.html">ChangeLog</a> doesn't<br /> include any explanations. The solution is to disable character-set-server option<br /> inside /etc/mysql/my.cnf<br /><br />[mysql]<br />character-sets-dir=/usr/share/mysql/charsets<br />#character-set-server=utf8Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com0tag:blogger.com,1999:blog-8511499809446054798.post-29630031433072434202010-01-27T06:22:00.000-08:002010-01-27T06:24:02.463-08:00Vim Terminal CommandsThere is a possibility to run terminal commands inside Vim. Just type:<br /><br />:! command [Hit Enter]<br /><br />Also you can invoke a shell inside Vim:<br /><br />:! bash [Hit Enter]<br /><br />Also Vim has third party addons (vim-shell) that allow to use shell in more natural manner. But I would not recommend you to use Vim this way. There is much better way to achieve the same things - just use <span style="font-style:italic;">screen</span>. It allows you to split your terminal vertically by pressing Ctrl-A S. Then you can use Ctrl-A Tab or Ctrl-A Ctrl-I to switch between them.Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com0tag:blogger.com,1999:blog-8511499809446054798.post-82360271488049160402009-11-23T01:39:00.000-08:002009-11-23T01:41:44.696-08:00Xorg events repeated twiceI've recently upgraded to xorg-x11 1.6 (it is shipped with several up-to-date Linux distributions like OpenSuSe 11.2) and encountered a problem with my keyboard. All keypresses repeated twice, which made impossible to use xorg-server. After looking through /var/log/Xorg.0.log I found that somehow Xserver decided to add my keyboard twice. So all events from the keyboard were processed two times. I fixed this problem by adding this line to xorg.conf into Section "ServerFlags" block<br /><span style="font-style:italic;">Option "AutoAddDevices" "off"</span>Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com0tag:blogger.com,1999:blog-8511499809446054798.post-89462684007593763972009-11-02T12:11:00.000-08:002009-11-02T12:32:31.653-08:00Alsa Audio MeterIf you need to watch the realtime sound output level on some graphical meter, you might consider difficult to find the program for these needs. After some searching I found nice software called ameter especially for these functions. This program can be used with the most of ALSA and OSS apps.<br />After program installation you should create .asoundrc in your home directory with the following contents:<br /><blockquote><br />pcm_scope.ameter {<br /><br />type ameter<br /><br />}<br /><br />pcm_scope_type.ameter {<br /><br />lib /usr/local/lib/libameter.so<br /><br />}<br /><br />pcm.ameter {<br /><br />type meter<br /><br />slave.pcm 'hw:0,0' #can be hw or hw:0,1 etc...<br /><br />scopes.0 ameter<br /><br />}<br /><br />pcm.dsp0 ameter</blockquote><br /><br />The program source can be downloaded from <a href="http://laugeo.free.fr/ameter.html">here</a><br /><br />Also I have created an ebuild for easy installation on Gentoo Linux. Simply add it to your local overlay<br /><span style="font-style:italic;"><br /># Copyright 1999-2009 Gentoo Foundation<br /># Distributed under the terms of the GNU General Public License v2<br /># $Header: $<br /><br />EAPI="2"<br /><br />DESCRIPTION="Alsa meter plugin for audio software with GUI"<br />HOMEPAGE="http://laugeo.free.fr/ameter.html"<br />SRC_URI="http://laugeo.free.fr/ameter-0.44.tar.gz"<br /><br />LICENSE=""<br />SLOT="0"<br />KEYWORDS="~amd64"<br />IUSE=""<br /><br />DEPEND="media-libs/alsa-lib<br /> media-libs/libsdl<br /> media-libs/sdl-image<br /> sys-devel/automake:1.7"<br />RDEPEND="${DEPEND}"<br /><br />RESTRICT="mirror"<br /><br />src_install() {<br /> make DESTDIR="${D}" install || die "make install failed"<br />}<br /><br /></span>Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com1tag:blogger.com,1999:blog-8511499809446054798.post-66676260396544411032009-10-15T11:41:00.000-07:002009-10-15T11:50:39.523-07:00Run hddtemp as userIf you want to get temperature of your hard drive, you can simply run <br /><br /># hddtemp /dev/sda<br /><br />This method has one disadvantage - hddtemp must be executed as root, otherwise you will get <br /><br />/dev/sda: open: Permission denied<br /><br />But there is a quick solution to run hddtemp as a normal user. Most Linux distributions have hddtemp daemon. After you run it you should be able to use just telnet or netcat as a normal use to get your hard drive temperature:<br /><br />~ telnet localhost 7634Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com1tag:blogger.com,1999:blog-8511499809446054798.post-44170961836676620462009-10-14T10:08:00.000-07:002009-10-14T10:22:28.755-07:00Google Custom Search Results per PageIf you are using Google Custom Search on your site, you may wonder how to change the count of search results per page. Okay, if you take a look at the custom search form html code, you will find this line<br /><br /><em><script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script></em><br /><br />Now open this script in browser and look into the code itself. This line does the trick<br /><br /><em>h=(h=b.googleNumSearchResults)?Math.min(h,20):10</em><br /><br />It checks if the variable googleNumSearchResults exists and if true, the count of search results per page will be set to minimum value from googleNumSearchResults and 20. If the googleNumSearchResults is not set, the count of search results per page will be set to 10. So you can easily customize the results count by adding this line to your custom search form code (remember you can't get more than 20 results per page)<br /><br /><em>var googleNumSearchResults = 15;</em>Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com2tag:blogger.com,1999:blog-8511499809446054798.post-40452469501178253492009-10-13T10:54:00.000-07:002009-10-13T11:24:37.480-07:00Mythfrontend for WindowsI've been looking for application simular to mythfrontend that can play Live TV from MythTV server (mythbackend) under Windows for a while. Currently there is a windows port of mythfrontend but it needs to be built from source with MinGW/MSys. So I searched for an easier way and found pretty good application called MythTV Player. It doesn't require any additional software or multimedia codecs and simply works out of the box. It is still in development stage so you may experience some issues during video playback, but after almost week of hard usage there was quite few player hangs and no other noticeable bugs. Here is the screenshot and the download link<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK7NEag7P95BZslLcI31DqsAr5TghK4A8oEVMbGu9fl94eHjtt2TcaOFOVSiW5M14Z1-IvgYr1lhep1tNO-LCHPNG3umR5716n4qQ73teXybCGYEL1jwex97ilSFlUmW2iazw2R2Nb09PX/s1600-h/mythtv-player.jpg"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 227px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK7NEag7P95BZslLcI31DqsAr5TghK4A8oEVMbGu9fl94eHjtt2TcaOFOVSiW5M14Z1-IvgYr1lhep1tNO-LCHPNG3umR5716n4qQ73teXybCGYEL1jwex97ilSFlUmW2iazw2R2Nb09PX/s320/mythtv-player.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5392151541431688850" /></a><br /><a href="http://sourceforge.net/projects/mythtvplayer/files/" rel="nofollow">MythTv Player latest version</a>Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com0tag:blogger.com,1999:blog-8511499809446054798.post-33598869397118785962009-10-10T02:21:00.000-07:002009-10-10T03:23:57.604-07:00Increase USB Flash Drive Write SpeedThe one of the biggest problems of usb flash drives is a slow data write speed. This article will guide you through the process that can possibly increase your flash stick write speed.<br /><br />Okay, first I bought Transcend 8GB usb flash stick. It had been formatted with FAT32 filesystem initially. So I decided to run data read/write speed test. Mount the filesystem and execute following<br /><br /><span style="font-style:italic;"># hdparm -t /dev/sdb<br /><br />/dev/sdb:<br />Timing buffered disk reads: 102 MB in 3.05 seconds = 33.43 MB/sec<br /><br />$ dd count=100 bs=1M if=/dev/urandom of=/media/disk/test<br />100+0 records in<br />100+0 records out<br />104857600 bytes (105 MB) copied, 29.5112 s, 3.6 MB/s<br /></span><br /><br />The disk read speed is good enough, but the write speed is not so good. That's because most of NAND flash drives (the most commonly used flash sticks) have 128k erase block size. Filesystems usually have 4k (4096 bytes) block size. And here we came into problem. If the filesystem blocks are not aligned to flash drive blocks, the performance overhead during disk writes will increase. So what we can do is to align filesystem properly. The best way to do this is to use 224 (32*7) heads and 56 (8*7) sectors/track. This produces 12544 (256*49) sectors/cylinder, so every cylinder is 49*128k.<br /><br /><span style="font-style:italic;"># fdisk -H 224 -S 56 /dev/sdb</span><br /><br />Now turn on expert mode with fdisk and force the partition to begin on 128k alignment. In my case I have set new beginning of data to 256. Create as many partitions as you need (I created only one - /dev/sdb1).<br />Do not forget to save changes and write new layout to flash drive (all data on the flash disk will be lost)<br />Now it's time to create the filesystem. I used ext4 because there is a way to tell it to specify a strip width to keep your filesystem aligned:<br /><br /><span style="font-style:italic;"># mke2fs -t ext4 -E stripe-width=32 -m 0 /dev/sdb1<br /></span><br />Now lets mount the filesystem and test the overall performance<br /><br /><span style="font-style:italic;"># hdparm -t /dev/sdb<br /><br />/dev/sdb:<br /> Timing buffered disk reads: 102 MB in 3.01 seconds = 33.94 MB/sec<br /><br />$ dd count=100 bs=1M if=/dev/urandom of=/media/disk/test<br />100+0 records in<br />100+0 records out<br />104857600 bytes (105 MB) copied, 17.0403 s, 6.2 MB/s</span><br /><br />As we can see, the data read performance is almost the same while the write speed is considerably faster.Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com42tag:blogger.com,1999:blog-8511499809446054798.post-46317328454977571552009-10-01T10:14:00.000-07:002009-10-01T11:01:10.397-07:00Directory Checksum<p>Recently I found on some of my websites suspicious files. After some research I discovered that most of my custom html and php files were also modified and were containing base64 encoded code. So I decided to make universal script that will allow me to take site fingerprint and then manually check it for any changes in my files weekly. This php script takes md5sums of all files in directory specified (including subdirectories) and save the result in custom data file. The next time you run it it will show you new files, files that were not changed and files that WERE CHANGED. The output and some other options can be customized inside the code itself. Anyway if you have ssh access to your webserver, you can do almost the same by running</p><br /><p><i>find test5 -type f | xargs md5sum</i></p><br /><p><pre><?php<br />#comment this if you want to debug the script<br />error_reporting(0);<br />function lookDir($path) {<br /> $handle = @opendir($path);<br /> if (!$handle)<br /> return false;<br /> while ($item = readdir($handle)) {<br /> if ($item!="." && $item!="..") {<br /> if (is_dir($path."/".$item))<br /> lookDir($path."/".$item);<br /> else<br /> checkFile($path."/".$item);<br /> }<br /> }<br /> closedir($handle);<br /> return true;<br />}<br /><br />function checkFile($file) {<br /> global $hashes;<br /> global $output;<br /> global $force_update;<br /> if (is_readable($file))<br /> if (!isset($hashes[$file])) {<br /> $hashes[$file] = md5_file($file);<br /> if ($output["new"])<br /> echo $file."\t\tNew\n";<br /> } elseif ($hashes[$file] == md5_file($file)) {<br /> if ($output["success"])<br /> echo $file."\t\tSuccess\n";<br /> }<br /> else {<br /> if ($output["failed"])<br /> if ($force_update) {<br /> $hashes[$file]=md5_file($file);<br /> echo $file."\t\tUpdate forced\n";<br /> }<br /> else<br /> echo $file."\t\tFailed!\n";<br /> }<br />}<br /><br />#directory for checking integrity<br />$dir = "./test5";<br /><br />#file for storing fingerprints, should be writeable in case of fingerprints update<br />$file = "./fingerprints";<br /><br />#set this value to false if you do not want to update fingerprints<br />$can_update = true;<br /><br />#set this to value to true if you want to update fingerprints of modified files<br />#you should do this only if you had modified files yourself<br />$force_update = false;<br /><br />#the output parameters<br />$output["new"] = true;<br />$output["success"] = true;<br />$output["failed"] = true;<br /><br />header("Content-Type: text/plain");<br />$hashes = unserialize(file_get_contents($file));<br />if (!$hashes || !is_array($hashes))<br /> $hashes = array();<br />if (!lookDir($dir))<br /> echo "Could not open the directory ".$dir."\n";<br />if ($can_update)<br /> if (file_put_contents($file, serialize($hashes)))<br /> echo "Fingerprints were updated\n";<br /> else<br /> echo "The file cannot be opened for writing! Fingerprints were not updated\n";<br />else<br /> echo "Fingerprints were not updated\n";<br /><br />?></pre></p>Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com0tag:blogger.com,1999:blog-8511499809446054798.post-41226929914840787952009-10-01T03:03:00.000-07:002009-10-01T03:06:08.379-07:00.htaccess remove authentification from child directorySuppose you have a public directory on Apache webserver protected with AuthType Basic using .htaccess file. And you want to remove the authentification from some child directories. There is no AuthType None option for .htaccess. The solution is to place an .htaccess file into the desired child directory with the following option<br /><span style="font-style: italic;"><br />Satisfy Any<span style="font-style: italic;"></span><br /></span>Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com0tag:blogger.com,1999:blog-8511499809446054798.post-19584681221497313982009-10-01T01:38:00.000-07:002009-10-08T00:51:57.876-07:00Mysqld-bin logs problemAfter continuous running of Mysql server, I've noticed that /var/lib/mysql directory uses too much disk space. The reason of that problem was a set of mysqld-bin.xxxxxx files. Each of that file was 1GB in size. First I thought that I can stop the Mysql server and remove that files, but I didn't want to act this way because there was sensitive data in databases that I didn't want to loose. So I found the better way to achieve this. Connect to Mysql server and perform the following<br /><br /><span style="font-style: italic;">mysql> flush logs;</span><br /><br /><span style="font-style: italic;">mysql> reset master;</span><br /><br />That's it! After that the all logbin files should be removed. Also you can disable mysqld-bin logging completely by commenting out log-bin line in my.cnf and restarting Mysql server daemon.Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com10tag:blogger.com,1999:blog-8511499809446054798.post-3297331444684994012009-09-27T06:11:00.000-07:002009-09-27T06:24:42.504-07:00VLC Alsa Surround Sound 5.1The recent versions of VLC require some extra setup for alsa 5.1 surround sound. By default vlc chooses the alsa device 'default'. When you're trying to switch the audio mode to "Surround 5.1", you got the error message<br /><br /><em>VLC Audio output failed: The audio device "surround51" is already in use</em><br /><em></em><br />This can be solved by running vlc from terminal like this<br /><br /><em>vlc --aout alsa --alsa-audio-device surround51</em><br /><em></em><br />Surround51 is the alsa device you want to play audio with. You can get the list of available alsa audio devices by typing <em>aplay -L</em> in the terminalMichaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com2tag:blogger.com,1999:blog-8511499809446054798.post-18849357934179802022009-09-07T01:42:00.000-07:002009-09-27T06:26:01.102-07:00Compro VideoMate Vista M5F Linux Setup<span style="font-family:arial;">If you've recently purchased Compro VideoMate Vista M5F tv tuner card and want to get it working on your linux machine, then you are just in a few steps before you will get this done. I bought this card two weeks ago and finally setup it yesterday. But don't be upset, this will not take so long for you. So lets begin.<br />First check that you card is correctly plugged into the system<br /><br /># lspci -v</span><br /><span style="font-family:arial;">04:00.0 Multimedia controller:</span><br /><span style="font-family:arial;">Philips Semiconductors SAA7131/SAA7133/SAA7135 Video Broadcast Decoder (rev d1)</span><br /><span style="font-family:arial;">Subsystem: Compro Technology, Inc. VideoMate T750</span><br /><span style="font-family:arial;">Flags: bus master, medium devsel, latency 32, IRQ 21</span><br /><span style="font-family:arial;">Memory at 90100000 (32-bit, non-prefetchable) [size=2K]</span><br /><span style="font-family:arial;">Capabilities: [40] Power Management version 2</span><br /><span style="font-family:arial;">Kernel driver in use: saa7134</span><br /><span style="font-family:arial;">Kernel modules: saa7134<br /><br />If you see that then the card is connected and you can continue. On my linux distribution (Archlinux) the card is automatically detected as Compro VideoMate T750 and all required saa7134 modules are loaded. This is not right so unload these modules<br /><br /># rmmod saa7134_dvb && rmmod saa7134_alsa && rmmod saa7134<br /><br />Now you can load the saa7134 module using valid card and tuner numbers<br /><br /># modprobe saa7134 card=49 tuner=54 alsa=1 i2c_scan=1<br /><br />After you loaded the module check if the device /dev/video0 exists and if the new soundcard was added<br /><br /># ls /dev/video*<br />/dev/video /dev/video0<br /># ls /dev/dsp*<br />/dev/dsp /dev/dsp1<br /><br />If you cannot see this, examine dmesg log for errors. Do not forget to set the volume levels for the new sound device<br /><br /># alsamixer -c 1<br /><br />Now you can try to perform a channels scan using your favourite tv software (MythTV, tvtime, xawtv). If the scan was successful, you can add the modules options to the modprobe.conf file<br /><br />options saa7134 card=49 tuner=54 alsa=1 i2c_scan=1</span>Michaelhttp://www.blogger.com/profile/09683047404854369708noreply@blogger.com6