tag:blogger.com,1999:blog-96345632024-02-08T10:56:25.153-08:00Yan Li's WordsMy words on free/open source softwareYan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.comBlogger53125tag:blogger.com,1999:blog-9634563.post-85834571163686178312016-11-05T15:19:00.000-07:002018-10-25T08:59:40.039-07:00Dell Precision 15 7510 Running CentOS 7.5<p>I set up my new laptop/mobile workstation. It's a certified refurbished Dell Precision 15 7510 from eBay. I'm pretty satisfied with the hardware as it looked brand new to me, although FedEx's shipping caused me some confusion and trouble. I installed CentOS 7.2 and am happy with the results.</p>
<h2>Hardware</h2>
<p>I purchased this latest Skylate model because I checked dell.com and was sure that it has pretty good Ubuntu support. The following is a summary of this laptop's hardware:</p>
<ul>
<li>6th Generation Intel Core i7-6820HQ (Quad Core 2.70GHz, 3.60GHz Turbo, 8MB 45W, w/Intel HD Graphics 530)</li>
<li>Graphics: 4GB Nvidia Quadro M2000M</li>
<li>15.6" UltraSharp UHD IGZO (3840x2160) Wide View Anti-Glare LED-backlit</li>
<li>HD1: 512GB M.2 Samsung PCIe NVMe Class 40 Solid State Drive</li>
<li>HD2: SK hynix SC210 2.5 7MM 512GB</li>
<li>Intel Dual-Band Wireless-AC 8260 Wi-Fi with Bluetooth 4.1 Wireless Card (2x2)</li>
<li>Webcam: 0x1bcf Sunplus Innovation Technology Inc.</li>
</ul>
<h2>Storage Performance: RAID-0 slower than single disk?</h2>
<p>The new laptop has two drives:</p>
<ol>
<li>512 GB M.2 PCIe NVMe Class 40 Solid State Drive</li>
<li>512 GB 2.5 inch High Performance SATA Class 30 Solid State Drive</li>
</ol>
<p>I'd like my CentOS to run fast so it should be on the NVMe drive. I was curious about whether I can use RAID0 to make a super fast partition so I set up Linux RAID using two partitions of the same size on these two drives and compared its performance with a regular XFS partition on the NVMe drive. The result was a surprise.</p>
<p>First the mkfs.xfs ran very slowly on the RAID0 partition. It took about 30 minutes to finish while when running on a non-RAID partition it needed only a few seconds.</p>
<p>I then run <a href="https://github.com/axboe/fio">fio</a> using the <a href="https://github.com/axboe/fio/blob/master/examples/ssd-test.fio">ssd-test.fio</a> workload. I changed the run time to 300 seconds to get more accurate numbers. The results are:</p>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
<script type="text/javascript">
google.charts.load('current', {packages: ['corechart', 'bar']});
google.charts.setOnLoadCallback(drawNonLUKSPerf);
function drawNonLUKSPerf() {
var data = google.visualization.arrayToDataTable([
['Throughput', 'RAID-0 (no encryption)', 'NVMe Only (no encryption)', 'NVMe Only (w/ encryption)'],
['Sequential read', 454696, 607131, 318319],
['Random read', 104698, 169412, 99045],
['Sequential write', 389674, 586156, 183654],
['Random write', 422795, 580285, 170866],
]);
var options = {
title: 'FIO ssd-test Throughputs (4 kB, direct I/O)',
chartArea: {width: '50%', height: 500},
hAxis: {
title: 'Throughputs',
minValue: 0
},
vAxis: {
title: 'Workloads'
}
};
var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<p>The RAID-0 chunk size was 128 kB. File system was XFS with 4096 sector size. You can see that, without encryption, RAID-0 is actually slower than NVMe in every workload, and LUKS encryption has a pretty big impact on I/O throughput.</p>
<h2>Setting It Up</h2>
<ol>
<li>Updated BIOS to the latest version. This can be done in Windows or using a FreeDOS USB if your Windows is gone.</li>
<li>Disabled SecureBoot in BIOS. It is possible to install CentOS with SecureBoot but I don't want to deal with it right now.</li>
<li>Disabled Intel Rapid Storage Technology and switched to AHCI mode for SATA. I tried accessing Intel RST disk using a Fedora 25 Beta LiveCD, it still can't be recognized by the 4.8.0 kernel.</li>
<li>Disabled built-in Intel graphics and using nVIDIA only, because there's no easy way to do live switching between graphics card with X yet.</li>
<li>Installed all Windows 10 Pro updates and cleaned up unnecessary bits to reduce the Windows footprint</li>
<ol>
<li>Uninstall unneeded software: Intel management stuff, trialware if there are any.</li>
<li>Turn off unneeded Windows feature (can be found on the Uninstall control panel module).</li>
<li>Disable hibernation: <tt>powercfg /hibernate off</tt> (as administrator) to free up around 32 GB (your RAM size).</li>
<li>Reduce page file size if needed.</li>
<li>Install WinDirStat and see if there are other useless files.</li>
<li>Disk cleanup -> System cleanup -> More options -> Cleanup old restore points.</li>
<li>Run a full system disk cleanup.</li>
</ol>
<li>Created a Windows recovery USB (16 GB is necessary) in case I need to recover it later.</li>
<li>Luckily the pre-shipped Windows 10 Pro is on the SATA drive so I have the whole NVMe drive for CentOS. I used gparted and shrunk the Windows partition so I can save more things on the SATA drive using CentOS. There are around 3 or 4 other tiny partitions on the SATA drive for UEFI booting and I just left them alone.</li>
<li>Ran memcheck to make sure the RAM is in good shape (it also tested that my machine isn't vulnerable to <a href="https://en.wikipedia.org/wiki/Row_hammer">the Row hammer attack</a>).</li>
<li>Boot up a CentOS 7 Live USB.</li>
<li>Created partitions on /dev/nvme0n1 using fdisk because I don't know how Anaconda aligns partitions.
<ul>
<li>nvme0n1p1: EFI partition (150 MB), nvme0n1p2: /boot (2 GB), nvme0n1p3: / (70 GB), nvme0n1p4: swap (16 GB), nvme0n1p5: /home (389 GB)
<li>I was overcautious and made sure all partitions are 4 MiB aligned using fdisk (parted also has auto-alignment checking but I couldn't figure out what align size parted was using).</li>
<li>Created LUKS partitions and made XFS file systems on top of them. I don't need LVM and wasn't sure if I could disable LVM in Anaconda so I just created the LUKS partition and file systems myself. I used "mkfs.xfs -s size=4096" to create XFS with 4096 sector size.</li>
<li>I don't know if this is correct but NVMe reports its physical sector size as 512 (/sys/block/nvme0n1/queue/physical_block_size) so mkfs.xfs creates file systems with 512 sector size. I guess this is actually harmless but I'm just a little paranoid about using 4096 sector size since all my other SSDs are reporting 4096 sector size. I created the /home partition myself and told Anaconda not to format it. But Anaconda insisted that the / partition must be formatted by itself and didn't provide an easy way to pass parameters to mkfs and it. What I did is to rename <tt>/usr/sbin/mkfs.xfs</tt> to <tt>/usr/sbin/mkfs.xfs.orig</tt> and create a script in place to always pass <tt>-s size=4096</tt> to mkfs.xfs. After installation I checked using xfs_info and all newly created XFS partitions are using 4096 sector size.</li>
</ul></li>
<li>After the installation finished, the system wouldn't boot. efibootmgr correctly created a new entry "CentOS Linux" that points to /EFI/somedrive/centos/shim.efi. However, it pointed to the WRONG drive. In my case, it pointed to the SATA drive that had a Windows partition instead of the NVMe drive that hosted the Linux UEFI partition. This is very likely a bug in Anaconda, which just uses whichever UEFI partition it detected first and assumed the system has only one UEFI partition. Finding the cause wasted me some time but once you found the reason fixing is easy: just boot into BIOS and create a new UEFI boot entry that points to the right shim.efi on the right drive. Dell's BIOS is pretty powerful and can do all sorts of UEFI/legacy booting mode mingled together.</li>
<li><del>Installed the <a href="https://elrepo.org/tiki/kernel-ml">kernel-ml package</a> since CentOS 7.2 doesn't support Skylake yet.</del> CentOS 7.3 and later has Skylake support out-of-the-box.</li>
<li>HiDPI (my laptop has a 4K internal display) works great after installing the mainline kernel.</li>
<li>Added <tt>rd.luks.options=discard</tt> to <tt>/etc/default/grub</tt> and <tt>discard</tt> to <tt>/etc/crypttab</tt> to enable LUKS discard support. This enables the LUKS device mapper layer to pass along the <a href="https://en.wikipedia.org/wiki/Trim_(computing)">discard/trim command</a> from the file system above and can help to keep the flash drives run at optimal performance. The downside is this can make the LUKS encryption less secure by leaking locations of the unused blocks (which is not a big deal for me).</li>
<li>I didn't mount XFS with discard, because that slows down daily operation and the XFS FAQ warns against that. Instead I just enabled weekly fstrim timer in systemd by running: <tt>systemctl enable fstrim.timer</tt></li>
<li>Installed iwl7260-firmware-25.30.13.0-68.fc25.noarch from Fedora 25 to provide the firmware for the Intel 8260 wireless card.</li>
<li>Installed nVIDIA Proprietary driver 370.28 (latest version).</li>
<li>Connected my external low DPI monitor. By default everything looked huge on it because of the 2.0 scaling factor GNOME defaults to on the internal monitor. I used the nvidia-settings tool and enabled panning and changed scaling on the external monitor. The external monitor's resolution is 1920x1200, so I enabled panning 3840x2400 and set ViewPortIn to 3840x2400. After that the external screen became blank because of a <a href="https://devtalk.nvidia.com/default/topic/891207/-355-11-358-09-viewportin-on-2nd-monitor-results-in-garbled-display-for-values-over-3211x1800">bug</a> so I also needed to run this command to enable <tt>"ForceFullCompositionPipeline=On"</tt>: <pre>nvidia-settings --assign CurrentMetaMode="DPY-5: nvidia-auto-select @3840x2160 +0+0 {ViewPortIn=3840x2160, ViewPortOut=3840x2160+0+0}, DPY-2: nvidia-auto-select @3840x2400 +3840+0 {ViewPortIn=3840x2400, ViewPortOut=1920x1200+0+0, ForceFullCompositionPipeline=On}"</pre></li>
<li>Used PowerTOP to check that the CPU can actually enter deep sleeping mode (C10). If not your CPU <a href="https://mjg59.dreamwidth.org/41713.html">might be dying faster</a>.<pre>
Package | Core | CPU 0 CPU 4
POLL 0.0% | POLL 0.0% | POLL 0.0% 0.0 ms 0.0% 0.0 ms
C1E-SKL 0.8% | C1E-SKL 1.3% | C1E-SKL 1.1% 0.4 ms 1.6% 3.2 ms
C3-SKL 0.4% | C3-SKL 1.1% | C3-SKL 2.1% 0.4 ms 0.1% 0.4 ms
C6-SKL 7.9% | C6-SKL 13.3% | C6-SKL 25.0% 0.7 ms 1.7% 1.1 ms
C7s-SKL 0.0% | C7s-SKL 0.0% | C7s-SKL 0.0% 0.0 ms 0.0% 0.0 ms
C8-SKL 29.0% | C8-SKL 31.0% | C8-SKL 43.4% 1.6 ms 18.6% 3.3 ms
C9-SKL 0.0% | C9-SKL 0.0% | C9-SKL 0.0% 0.0 ms 0.0% 0.0 ms
C10-SKL 51.0% | C10-SKL 44.0% | C10-SKL 17.0% 5.1 ms 71.0% 16.9 ms
</pre>
</li>
<li>Updated on Nov. 24th, 2016: I discovered that the headphone jack had no sound. This is fixed by adding a file <tt>/etc/modprobe.d/alsa-base.conf</tt> with the following content:
<pre>
options snd-pcsp index=-2
alias snd-card-0 snd-hda-intel
alias sound-slot-0 snd-hda-intel
options snd-hda-intel model=laptop
options snd-hda-intel position_fix=1 enable=yes
</pre>
I heard that you will need to completely shutdown and restart the laptop to make this work. I got the instruction from <a href="https://askubuntu.com/questions/686361/no-sound-through-headphones-while-speakers-work-fine?rq=1&newreg=c168961c026c40f89723b6a212ece528">here</a>.
</li>
<li>Brightness of internal display is not remembered across reboot. Per Soon's comment, you can set a fixed value on boot by adding:
<pre>
echo 100 > /sys/class/backlight/acpi_video0/brightness
chmod 666 /sys/class/backlight/acpi_video0/brightness
</pre>
to /etc/rc.d/rc.local, and then <tt>chmod +x /etc/rc.d/rc.local</tt>.
</li>
<li>Updated on Apr. 25th, 2017: Setting the screen backlight brightness to max when working in direct sun. CentOS 7.3's kernel defaults to using ACPI backlight control. It works great but cannot set the screen brightness to the maximum possible level, i.e., it's max brightness level is a little darker than the max level the hardware can reach. For now, in order to reach the max brightness level you can do a reboot and set the brightness level to max in BIOS (and disable any change to the brightness level you added such as the one above). After the system boots up, if you change the brightness level you wouldn't be able to come back to max again. The other workaround is to add the <tt>acpi_backlight=vendor</tt> kernel option, which switches to using the dell_backlight driver. The dell_backlight driver, however, is buggy; it would fix the brightness at the max level and you wouldn't be able to change it.
</li>
</ol>
<h2>End Result</h2>
Everything else works well, including suspend-to-RAM, external display, HDMI, DisplayPort, webcam, sound, Wi-Fi, SD Card Reader, and USB-C.
<h2>Some nitpicks</h2>
<ul>
<li>Brightness of internal display is not remembered across reboot.</li>
<li>Sometimes after suspend to RAM, the CPU frequency scaling doesn't work well and all CPUs are stuck at around 400 to 500 MHz, like:<pre>
analyzing CPU 0:
driver: intel_pstate
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 0.97 ms.
hardware limits: 800 MHz - 3.60 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 800 MHz and 3.60 GHz.
The governor "powersave" may decide which speed to use
within this range.
current CPU frequency is 468 MHz.
boost state support:
Supported: yes
Active: yes
</pre>
It doesn't happen most of the times, and I haven't figured out why. If I feel the machine is sluggish I just run <tt>sudo cpupower frequency-set --governor performance</tt> (with it binded to a hotkey). There are <a href="https://bugzilla.kernel.org/show_bug.cgi?id=90421#c60">some other people</a> having the same issue.</li>
<li>I wish the battery could last longer. I don't have time to do any manual tuning yet. Now when on battery I can get like 4 hours regular use or 1 hour heavy use (running my CPU heavy machine learning code). This is on par with <a href="http://www.notebookcheck.net/Dell-Precision-7510-4K-IGZO-Mobile-Workstation-Review.167586.0.html">an early review</a> of this laptop running Windows. I am pretty sure it can do better if I do some power usage tuning in PowerTOP.</li>
<li>Live switching between nVIDIA and Intel graphics card not working but I'm ok with using nVIDIA only since the Intel Skylake driver is buggy anyway. The downside is probably more power consumption.</li>
</ul>
<hr/>
Some random thought. This new laptop's nVIDIA graphics feels much faster than the Intel graphics in my old Late 2013 Retina MacBook Pro. I'm just talking 2D performance here. The old Intel graphics in the rMBP always stutters when driving one external monitor and crashes when I add two external monitors. It drives two external monitors fine when running macOS so this is likely a software issue. I can't help but think that Intel doesn't allocate enough resources for their Linux drivers. There are other problems with Intel's driver:
<ul>
<li>No easy way to install different versions on RHEL/CentOS. The official installer <a href="https://01.org/jira/browse/VSM-76">doesn't support</a> RHEL/CentOS yet. The nVIDIA driver, while being closed source, always support most Linux distros on the market and I can install any version I choose.</li>
<li><a href="https://wiki.archlinux.org/index.php/intel_graphics#H.264_decoding_on_GMA_4500">Buggy</a> and <a href="https://www.phoronix.com/scan.php?page=news_item&px=Intel-VA-API-ILK-Old">incomplete</a> 2D acceleration support.</li>
<li>3D performance <a href="http://www.phoronix.com/scan.php?page=news_item&px=OB-Analytics-Win-Linu-AMDNV">much slower</a> than Windows driver.</li>
<li>The Xorg running on my old rMBP had an about 20% chance crashing when plugging in an external monitor. I don't know if I should blame the Xorg server or the Intel driver but with the same Xorg using nVIDIA driver in the new laptop, it has never crashed once yet.</li>
</ul>
Even though I hail Intel's engagement with the open source community and their open source drivers, I feel that the quality of their drivers is not on par with nVIDIA's proprietary drivers.
<h2>Updates</h2>
<ul>
<li>Oct. 2018: Upgraded to CentOS 7.5</li>
<li>Nov. 2017: Tested USB-C using a Google Pixel 2 XL</li>
<li>Dec. 2016: Upgraded to CentOS 7.3</li>
</ul>Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com6tag:blogger.com,1999:blog-9634563.post-48111188957496795732011-10-09T21:40:00.002-07:002011-10-09T21:46:43.254-07:00Using rsync to migrate data between Linux and Apple Mac OS X<div dir="ltr" style="text-align: left;" trbidi="on">
I got a new MacBook Air running Mac OS X (10.7.1) "Lion", and I managed to migrate my archive data (around 1.3TB) from an old Linux laptop running Debian Testing "Wheezy." The process was not smooth and I hit several blocks. Here I document several points that you need to pay attention to when migrating data across operating systems:<br />
<br />
<h2>
Zeroth</h2>
Use the latest rsync (3.0.8 from MacPorts was used here). The old version of rsync is buggy on Mac. The version of rsync on Linux doesn't matter much because rsync on Linux has been quite stable since long ago.<br />
<br />
<h2>
First</h2>
Disable "Ignore ownership on this volume" (you can use Finder or from command line). If not rsync won't be able to set file permission correctly. I think if you don't instruct rsync to preserve permission and mode then you might not need to do this but I'm not very sure.
<br />
<br />
<h2>
Second</h2>
Disable antivirus software like McAfee because they <a href="http://help.bombich.com/discussions/problems/651-subsequent-backups-both-full-and-incremental-slow">interfere with</a> rsync's time preservation.
<br />
<br />
<h2>
Third</h2>
Use rsync's "<tt>--iconv=UTF8-MAC,UTF-8</tt>" option (only available after rsync 3.0), because Mac's HFS+ <a href="http://rsync.samba.org/FAQ.html#2">decompose</a> UTF-8 before storing it so the filename would be different from that of Linux if no conversion is done right.<br />
<br />
If you saw "<tt>iconv_open("UTF-8", "UTF8") failed</tt>", try swapping the parameters of iconv.
<br />
<br />
<h2>
Fourth</h2>
This is not directly related to rsync nor Mac, but a general rule for handling archive data: use another piece of software to do the verification. Your rsync might be buggy, the OS might be buggy, the disk or USB cable might be kaput, you might have used the wrong options or settings. Therefore you should always use another piece of software other than rsync to verify the data before and after the migration. I used AIDE to do file checksum and time verification.</div>
Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com8tag:blogger.com,1999:blog-9634563.post-38513196237082487192011-02-16T18:34:00.004-08:002011-02-17T05:53:39.558-08:00openSUSE Build Service (OBS): Break the Link Between a Branched Package and Its SourceWe are using openSUSE Build Service (OBS) for the development of MeeGo. I have an old package, which was branched from a Trunk package long ago. But every time the source pakcage in Trunk is updated my package would be broken because the changes between them are so large that it's become meaningless to keep the link between them any more. So I think I should just remove the link between them.<br /><br />The simplest way may be just removing my package and start a new package from scratch, however, this action not only removes the package history but will also reset the cumulative release version number, which is unacceptable since that would make it impossible for client machines to follow updates to this package.<br /><br />I have carried out a long search but failed to find a hint to this issue, and after some trail-and-error I think I have found a way:<br /><br /><ol><br /><li>Check out the project's unexpanded files by using "<tt>osc co -u PRJ/PKG</tt>"</li><br /><li>Remove the "<tt>_link</tt>" file by running "<tt>osc rm _link</tt>"</li><br /><li>Copy in the latest package files since the link is now broken</li><br /><li>Check-in the changes</li><br /></ol><br /><br />I've done a test and the steps above worked. <b>However</b>, it seems that by those steps the release version number will also be reset.<br /><br />Update: darix from freenode/#opensuse-buildservice said 'osc in git has "osc detachbranch" exactly for that.'Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com0tag:blogger.com,1999:blog-9634563.post-65917152264189072482010-12-25T16:47:00.008-08:002016-11-05T15:25:56.277-07:00Easy way to align Linux partitions for SSD and myths debunkedRecently I got a laptop from my employer with an Intel X25-M SSD drive in it. I have spent some time trying to figure out the best and easiest way to install Linux onto it while retaining the Windows 7 (so I have to use MBR instead of GPT). There are numerous discussions you can find on the net, some of them are quite complex and some are simply misleading (if not wrong). In fact this task is quite easy with modern Linux and here's a documentation of what I've done. This blog is not meant to be a full discussion on this topic, but only intended as a cheat sheet for those experienced Linux users (if you want a more detailed and correct discussion on this topic, I recommend Ted Ts'o's blog: <a href="http://thunk.org/tytso/blog/2009/02/20/aligning-filesystems-to-an-ssds-erase-block-size/">Aligning filesystems to an SSD’s erase block size</a>.)<br />
<br />
For those impatient readers, here's an overview: the disk geometry (or C-H-S value) you see from partition programs as well as the warning about partitions are not aligned to cylinder boundary don't matter at all so there's no point to spend time on tuning loose knobs. New <a href="http://gparted.sourceforge.net/">GParted</a> (I used 0.7.1 from <a href="http://www.sysresccd.org/">SysRescueCD</a>, not to be confused with "GNU parted") is a very easy to use tool and it now defaults to create partitions aligned on 1 MiB (I heard that Ubuntu 10.10 and later can do partition alignment automatically too but I haven't tried that).<br />
<br />
Here's the detail:<br />
<br />
<h3>
The myth: Does the C-H-S value still matter?</h3>
<br />
<a href="http://forum.corsair.com/v2/showthread.php?t=83608">A</a> <a href="https://wiki.archlinux.org/index.php/SSD#Using_MBT_-_DEPRECIATED_METHOD_-_Using_GPT_is_Recommended">lot</a> of discussions were about checking the disk geometry after partitioning. However, in fact no modern operating system pays attention to those values any more (see the <a href="http://thunk.org/tytso/blog/2009/02/20/aligning-filesystems-to-an-ssds-erase-block-size/#comment-1781">comment</a> by Ted Ts'o). And those "<code>-H xx -S xx</code>" options passed to fdisk are only meant to make that fdisk program happy so it can create partitions aligned with cylinder boundaries. Although the C-H-S values are stored in MBR, they are not used by the Linux kernel who runs the whole system. Instead of paying attention to choosing or checking those C-H-S values, you should only need to make sure that the start and end sectors of partitions are multiples of the size of your erase block. Of course you can use any good partition programs to do this.<br />
<br />
<h3>
So you don't have to use that fdisk program</h3>
<br />
and you can simply choose any program that you are familiar with. For me I'm comfortable with sfdisk and GParted. This time I tried latest GParted and was very happy to see it had supported partition alignment on 1 MiB boundary. So my work is done in one minute without using a calculator. After that I also carefully checked the partition table with "<code>sfdisk -uM</code>" and was sure that those partitions were aligned on MiB boundaries. The extended partition was not aligned but I thought that didn't matter as long as all logical partitions in it were aligned correctly.<br />
<br />
<h3>
A few more tips:</h3>
<ul>
<li>If you want to have TRIM/DISCARD support you can use a 2.6.33+ kernel with Ext4 file-system, mounted with <code>-o discard</code>.</li>
<br />
<li>When making the Ext4 file-system, make sure you use the <code>stripe-width</code> option and let it align with erase block boundary too (see Ted's post above).</li>
<br />
<li><strike>Don't use LVM or dm-crypt since they don't support TRIM/DISCARD command yet.</strike> Newer kernel supports TRIM/DISCARD passing along in LVM and dm-crypt.</li>
</ul>
<br />
<br />
<h3>
compilebench test result:</h3>
<br />
Intel's X25-M is very smart that even if you don't align the access correctly the drive will do magic under the hood so the initial benchmark data doesn't differ too much, however, the performance will degrade much more quickly as the internal mapping tables getting more and more complex due to unaligned writes. Here I post the file-system benchmark result when it's still new. I'll try to do benchmark again after several months to see if there's any performance degrade (although my usage is not heavy).<br />
<br />
I used <a href="http://oss.oracle.com/~mason/compilebench/">compilebench</a> v0.6 because I think it mimics daily desktop usage very well.<br />
<br />
Machine spec:<br />
System: Debian Squeeze (testing)<br />
Kernel: 2.6.37-rc5-amd64 from Debian experimental repo<br />
Test command: <code>sudo ./compilebench -D t -i 10 --makej</code> (the same option used by Phoronix Test Suite)<br />
File system: Ext4, mount option: <code>rw,noatime,discard</code><br />
<br />
compilebench Initial Create test result: 105.24 MB/s (on 2010-12-27).<br />
<br />Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com3tag:blogger.com,1999:blog-9634563.post-30576284031133907562010-12-20T18:47:00.003-08:002010-12-20T19:13:10.061-08:00MeeGo: Auto-Start an Application on Session StartFor modern Linux desktop, it's a common way to auto-start an application in a user-session by placing a ".desktop" file into <code>/etc/xdg/autostart</code>. But if you are writing or porting an application to MeeGo and found that the application is not auto-started after you put in a seemingly correct .desktop, please check this:<br /><br />If there's an "<code>OnlyShowIn=</code>" item, it must contain the string <code>X-MOBLIN-NB</code>. For example:<br /><pre><br />OnlyShowIn=GNOME;X-MEEGO-NB<br /></pre><br /><br />Another caveat is that MeeGo's uxlaunch doesn't honor <code>AutostartCondition</code> key yet, for the sake of simplicity and fast-boot.<br /><br />For code under the hood, check <a href="http://meego.gitorious.org/meego-os-base/uxlaunch/blobs/master/desktop.c">MeeGo's uxlaunch/desktop.c</a>.Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com0tag:blogger.com,1999:blog-9634563.post-39334761330681810042010-12-18T04:20:00.003-08:002010-12-18T04:31:02.004-08:00Very hard to make bootable USB drive from Ubuntu 10.10's CD ImageI was spoiled by MeeGo's super convenient USB live image so I was very surprised when I found that it was very hard to make a bootable USB drive from Ubuntu 10.10's CD-ROM image for my wife.<br /><br />On Linux, Ubuntu only officially supports making bootable USB drive from its CD-ROM image by using "ubuntu-usb-creator", which is not available in any Linux installations I'm using now (MeeGo, Debian, CentOS). Ubuntu's official help document <a href="https://help.ubuntu.com/10.10/installation-guide/i386/boot-usb-files.html">mentions</a> one alternative way -- to download a small image and combine it with the iso file -- doesn't work, and community posts pointed out that that methods only worked with "alternative iso" (not desktop iso).<br /><br />Finally I found a way (and the only way) to make a usable USB drive for installation is from <a href="https://wiki.ubuntu.com/LiveUsbPendrivePersistent#Method 3: Copying the ISO CD image to the USB drive">this post</a>.<br /><br />So what? I think Canonical really should release official USB images since most netbooks shipped today have no CD-ROM drive.Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com4tag:blogger.com,1999:blog-9634563.post-29402643195139039862010-07-14T19:30:00.003-07:002010-07-14T19:33:01.385-07:00Google Chrome (Chromium) Sync Server AddressIf you want to know the host name and address of the sync server Google Chrome (or Chromium) uses, see here:<br /><br /><a href="http://src.chromium.org/svn/trunk/src/chrome/browser/sync/profile_sync_service.cc">http://src.chromium.org/svn/trunk/src/chrome/browser/sync/profile_sync_service.cc</a><br /><br />For now, the sync service's URL is<br /><br />https://clients4.google.com/chrome-syncYan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com0tag:blogger.com,1999:blog-9634563.post-65238908550832835392010-06-27T00:33:00.004-07:002010-06-27T04:21:34.533-07:00HOWTO: Run Plants vs Zombies™ in Linux under Wine (includes how to Register!)I have to admit that I found PopCap's <a href="http://www.popcap.com/games/pvz">Plants vs Zombies™</a> (referred to as PvZ below) interesting. It runs on Windows, Mac and iPhone but not on any Linux yet.<br /><br />You can download the trial version from the official site above, and it runs amazingly well on a recent <a href="http://www.winehq.org/">Wine</a>, without any special configuration. Well done, Winehq!<br /><br />Now comes the problem, if you decide to buy it after 60 minutes play, the registration process is a bit hard with Wine. The reason is that PvZ requires an Internet Explorer or Firefox to finish the registration process. Obviously it has to gather some local hardware/system information and upload it to their activation server so that they can know how many machines you are running PvZ on, therefore you won't to able to give away free copies of the game to all your friends. I think this whole thing is OK, though instead of writing codes in PvZ to let it communicate with their server, instead, sadly, they choose to use ActiveX running in IE for this.<br /><br />Some early posts reported that the registration process can be finished if you install an IE into the same Wine directory. Running IE on Wine is not impossible but hard, especially when IE4Linux project is no longer maintained.<br /><br /><h2>The HOWTO</h2><br />Now I have found that you can also finished the registration process using not IE but Firefox instead. Thanks for their being in the same free software camp, Firefox runs very well on Wine. Just <a href="http://getfirefox.com/">grab</a> a Windows copy and install it into the same Wine directory.<br /><br />Then run Firefox in your Wine, go to <a href="http://store.popcap.com/license.php">PopCap's Registration Page</a>, follow the instruction there to download and install the Firefox plugin. After that, close your Firefox (for some unknown reasons, the Firefox Wine process may still linger in the background after its window is closed, run "<code>ps -ef | grep -i firefox</code>" and kills the linger process if need).<br /><br />Now starts PvZ by running its <b>in your winefile</b>. Because the PvZ and Firefox need to be started in a same Wine instance so they collect the identical hardware/system information. Register it following the normal process. It may fail at the first attempt to start a web browser, keep clicking the "Retry" button until it shows it's waiting for the registration process to finish (it's waiting for web browser plugin to return registration key). Start a Firefox instance <b>from that same winefile program</b>. Go to <a href="http://store.popcap.com/license.php">PopCap's Registration Page</a>, now if your plugin is installed successfully, it should show a web page asking for your POP Order Number, give it and the registration process should finish successfully and the PvZ program should proceed to the game.<br /><br />It's not rocket science, just nuisance.<br /><br />PvZ runs very well in Wine during my 2 days play. I can say it's perfectly running on Linux for now.<br /><br /><h2>Known Problems</h2><br /><ol><br /><li>Sound effects may not work on some machines with some old Wine versions (try upgrade to latest Wine.)</li><br /><li>The full-screen mode will be always "full-screen," which means that if you have a non-4:3 screen, it will be slightly torted.</li><br /><li>The between-battle preview screen may be a bit slow sometimes, but as soon as the battle begins the speed returns to normal (not sure if it shows similar issue when running on a real Windows.)<br /></ol>Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com0tag:blogger.com,1999:blog-9634563.post-6080498718891617442010-06-26T22:28:00.003-07:002010-06-27T04:21:15.342-07:00Running Wine on MeeGoOne of the good thing of MeeGo is that it contains a standard X server along with full 2D/3D acceleration. Having a full X stack running on your netbook enables the possibility to use a good variety of exist fun Linux programs. Such as <a href="http://www.winehq.org/">Wine</a>.<br /><br />In order to play <a href="http://www.popcap.com/games/pvz">Plants vs Zombies™</a> and <a href="http://www.popcap.com/games/free/zuma">Zuma™</a>, I have installed Wine on MeeGo. Wine is not in MeeGo's official repo (yet), so I just downloaded all <tt>wine-*.rpm</tt> from Fedora's rawhide repo and the installation was a breeze. I hope MeeGo will have it's own Wine package soon, it should be quite easy to repackage with minor tweaks from Fedora's packaged Wine. Thanks Fedora project! Anyone in the community want to volunteer?Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com2tag:blogger.com,1999:blog-9634563.post-70189850076513995992010-05-02T19:47:00.003-07:002010-06-09T23:08:10.490-07:00HOWTO: Disable IPv6 in MeeGoWith traditional desktop Linux distros, the IPv6 can be disabled by removing the ipv6-related modules, but not with <a href="http://meego.com">MeeGo</a> since it's ipv6 module is compiled in kernel (for fastboot). The following instructions apply to similar situations where you can't remove the ipv6 module (like you have no control over the kernel, or using a Xen VM, etc.)<br /><br />The ipv6 module will always assign an address to all NIC during startup, there's no way to disable it, we have to disable ipv6 autoconf, and remove all assigned IPv6 addresses:<br /><br />Create a file <code>/etc/sysctl.d/disable_ipv6</code>:<br /><br /><pre><br /># disable autoconf<br />net.ipv6.conf.default.autoconf=0<br />net.ipv6.conf.all.autoconf=0<br />net.ipv6.conf.eth0.autoconf=0<br /><br /># block all received Router-Advertisement (RA) packets<br />net.ipv6.conf.default.accept_ra = 0<br />net.ipv6.conf.all.accept_ra = 0<br />net.ipv6.conf.eth0.accept_ra = 0<br /><br /># NOTE: the *.all* above applies to newly created NICs only, <br /># not to existing NICs. So you have to list all NIC's explicitly<br /># here. For example, if you have a wireless card wlan0, add the <br /># following lines:<br />#net.ipv6.conf.wlan0.autoconf=0<br />#net.ipv6.conf.wlan0.accept_ra = 0<br /></pre><br /><br />Then delete all pre-allocated ipv6 address by adding the following lines in <code>/etc/rc.local</code>:<br /><pre><br />ifconfig lo inet6 del ::1/128<br />IPV6ADD=`ifconfig eth0 | grep inet6 | awk '{print $3}'`<br />ifconfig eth0 inet6 del "$IPV6ADD"<br /></pre><br /><br />Don't forget to:<br /><pre><br />chmod +x /etc/rc.local<br /></pre><br /><br /><b>Update:</b><br />I've discovered that sshd running on MeeGo can't accept X11 forwarding requests after made above changes. You can find the following error message in /var/log/secure:<br /><pre><br />sshd[]: error: Failed to allocate internet-domain X11 display socket.<br /></pre><br /><br />The reason is that sshd is still trying to bind to an IPv6 address but there's no IPv6 address available. To solve this issue, we need to start sshd with "<tt>-4</tt>" option.<br /><br />Create a new file For MeeGo at <tt>/etc/sysconfig/sshd</tt>:<br /><pre><br />OPTIONS="-4"<br /></pre><br /><br />And restart sshd:<br /><pre><br />service sshd restart<br /></pre><br /><br />Reference:<br /><ul><br /><li><a href="https://help.ubuntu.com/community/WebBrowsingSlowIPv6IPv4">https://help.ubuntu.com/community/WebBrowsingSlowIPv6IPv4</a></li><br /><li><a href="http://beranger.org/index.php?article=1127&page=3k">http://beranger.org/index.php?article=1127&page=3k</a></li><br /></ul>Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com0tag:blogger.com,1999:blog-9634563.post-25615918076610388422010-03-28T04:11:00.005-07:002010-03-28T05:44:36.521-07:00MeeGo is in Google Summer of Code 2010<a href="http://meego.com">MeeGo</a> has joined <a href="http://socghop.appspot.com/">Google Summer of Code 2010</a>. If you are a student, have some free time this summer and have interests in developing operating system or applications for new small form factor devices, please consider <a href="http://socghop.appspot.com/document/show/gsoc_program/google/gsoc2010/faqs">join</a> us!<br /><br />MeeGo is the <a href="http://en.wikipedia.org/wiki/MeeGo">combined Moblin and Maemo</a> and is sponsored by <a href="http://en.wikipedia.org/wiki/Linux_Foundation">Linux Foundation</a>, Nokia and Intel. To make it simple, MeeGo is the new operating system, inspired by the rising interests and challenge in smart phone and mobile internet devices, for future Intel and Nokia ARM platforms (or more if other handset makers join).<br /><br />To distinguish it from other smart phone platforms such as iPhone and Android, MeeGo is proudly bearing the badge "open." It is not controlled by a single authority, but under the non-profit consortium <a href="http://en.wikipedia.org/wiki/Linux_Foundation">Linux Foundation</a> and welcome all parties and individuals who interests in making the best mobile platform in the world.<br /><br />Another thing that distinguishes MeeGo from other mobile platforms is that MeeGo runs full Linux desktop stack. It is running unmodified Linux kernel, X server, compiled by unmodified GCC, includes full GTK / GNOME and Qt libraries. So all your expertise on desktop Linux continues to thrive here.<br /><br />But MeeGo is not yet-another-Linux-distro. Smart minds may already spot the great challenge here. How could we build a competing platform by using just commodity GNU/Linux OS codes? The answer from us is that we are focusing on usability plus aggressive optimization. We believe the codes from those great upstream free software community is the best in the world and we can build the solid state-of-art platform based on them. What we have to do is try our best to integrate them together and focus on design a great user experience.<br /><br />So if you are interested, please take a look at the <a href="http://wiki.maemo.org/GSoC_2010/Project_ideas">MeeGo project ideas</a>. Of course we are more than happy if you can come up with you own great ideas. And try to get yourself a <a href="http://socghop.appspot.com/document/show/gsoc_program/google/gsoc2010/faqs#administrivia">$5,000 stipend</a>.<br /><br /><small>(all words above are my personal opinion and reflect no idea from MeeGo committee, Linux Foundation, Nokia or Intel)</small>Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com1tag:blogger.com,1999:blog-9634563.post-29963367585595673712009-10-20T03:26:00.003-07:002009-10-20T03:39:34.275-07:00Understanding how fontconfig scan conf filesI've been fixing fonts issues in <a href="http://moblin.org">Moblin</a> for some time, and I've to admit that GNOME <a href="http://fontconfig.org">fontconfig</a> is really hard to understand.<br /><br />The rules in /etc/fonts/conf.d/ are scanned in alphanumeric order. After carefully read the <a href="http://fontconfig.org/fontconfig-user.html">fontconfig user's manual</a>, I thought that if they were processed in alphanumeric order, the later conf should overwrite the earlier conf. WRONG! But rules scanned first take precedence over rules later. Let's see how they are applied to the Pattern.<br /><br />For example: if you run `<tt>fc-match sans</tt>`, the Pattern here is <tt>family="sans"</tt>.<br /><br />Let's say we've a 01-rulefile:<br /><pre style="color:#000000; background-color:#ffffff; font-size:10pt; font-family:'Courier New';"><span style="color:#000000; font-weight:bold"><alias></span><br /> <span style="color:#000000; font-weight:bold"><family></span>sans<span style="color:#000000; font-weight:bold"></family></span><br /> <span style="color:#000000; font-weight:bold"><prefer><family></span>DejaVu<span style="color:#000000; font-weight:bold"><family></prefer></span><br /><span style="color:#000000; font-weight:bold"></alias></span><br /></pre><br /><!--HTML generated by highlight 2.12, http://www.andre-simon.de/--><br /><br />After processing it the Pattern becomes:<br /><pre><br />family="DejaVu", "sans"<br /></pre><br /><br />Then a 02-rulefile:<br /><pre style="color:#000000; background-color:#ffffff; font-size:10pt; font-family:'Courier New';"><span style="color:#000000; font-weight:bold"><alias></span><br /> <span style="color:#000000; font-weight:bold"><family></span>sans<span style="color:#000000; font-weight:bold"></family></span><br /> <span style="color:#000000; font-weight:bold"><prefer><family></span>Droid<span style="color:#000000; font-weight:bold"><family></prefer></span><br /><span style="color:#000000; font-weight:bold"></alias></span><br /></pre><br /><!--HTML generated by highlight 2.12, http://www.andre-simon.de/--><br /><br />After it the Pattern becomes:<br /><pre><br />family="DejaVu", "Droid", "sans"<br /></pre><br /><br />Noted that the <tt>"Droid"</tt> from 02-rulefile is prepended to <tt>"sans"</tt>, not<br />the whole Pattern. So 01-rulefile takes precedence over 02-rulefile.Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com0tag:blogger.com,1999:blog-9634563.post-29260541840690657682009-10-13T20:14:00.003-07:002009-10-13T20:18:12.177-07:00Zero Config! Huawei EC1260 / China Telecom CDMA2000 EVDO 3G USB Dongle on Debian SidI bought a Huawei EC1260 USB modem to access the CDMA2000 EVDO mobile broadband provided by China Telecom. To my big surprise, the USB modem works out-of-box on my Debian Sid. Plug the USB modem and click the CDMA item in my NetworkManager and Bingo! I'm online! This is really zero config!<br /><br />Thank you, great developers of NetworkManager and Debian for making this great progress.Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com2tag:blogger.com,1999:blog-9634563.post-89722990467661534152009-03-15T20:06:00.005-07:002009-03-15T20:10:56.678-07:00Beijing Tax Declaration Website Supports Firefox, Great!I'm glad to finish my tax declaration online by using Firefox running on Linux. Every function of <a href="http://gszxsb.tax861.gov.cn">Beijing Taxation Bureau's website</a> works well with Firefox.<br /><br />Though there are spaces for them to improve, such as adding HTTPS support.Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com1tag:blogger.com,1999:blog-9634563.post-59167532833173438832009-03-15T00:03:00.004-07:002009-03-15T00:21:01.157-07:00Compiling GIMP 2.6.5 on CentOS 5<a href="http://gimp.org/release-notes/gimp-2.6.html">GIMP 2.6.5</a> is the fantastic tool for photographers that live in the <a href="http://en.wikipedia.org/wiki/Free_software">free world</a>. But sadly it has no official RPM built for CentOS/RHEL users. I have spent 4 hours and compiled GIMP 2.6.5 on <a href="http://www.centos.org/">CentOS 5</a> for Tina by using the official tarball.<br /><br />I planned to use the GIMP SRPM from Fedora Rawhide (which was 2.6.5) but after Fedora 10 the Rawhide had moved to a new format of RPM and I have no way to install nor unpack those new SRPMs to get the code (neither on CentOS 5 or Debian Unstable). Therefore I had to fall back to use official tarball and install it to /opt. By this I lost the benefit of package management. So I have no RPM here to share with you but only a rough record of the steps:<br /><ol><br /><li>download, build and install babl 0.0.22</li><br /><li>download, build and install gegl 0.0.22</li><br /><li>install intltool RPM from Fedora 10</li><br /><li>download gettext SRPM (gettext-0.17-8.fc10.src.rpm) from Fedora 10 and rpmbuild it (with Java disabled). the GCJ shipped with CentOS 5 couldn't compile the Java code within gettext so they had to be disabled by the patch following.</li><br /><li>build GIMP 2.6.5</li><br /></ol><br />The patch to disable Java of gettext:<br /><pre><br />--- /usr/src/redhat/SPECS/gettext.spec 2008-08-29 09:07:58.000000000 +0800<br />+++ gettext-for-el5.spec 2009-03-15 11:06:11.000000000 +0800<br />@@ -1,5 +1,5 @@<br /> # libintl.jar requires gcj >= 4.3 to build<br />-%define buildjar 1<br />+%define buildjar 0<br /><br /> Summary: GNU libraries and utilities for producing multi-lingual messages<br /> Name: gettext<br />@@ -86,12 +86,12 @@<br /> export JAR=fastjar<br /> %endif<br /> %configure --without-included-gettext --enable-nls --disable-static \<br />- --enable-shared --with-pic-=yes --disable-csharp --enable-java \<br />+ --enable-shared --with-pic-=yes --disable-csharp --disable-java \<br /> --disable-rpatha<br /> make %{?_smp_mflags} GCJFLAGS="-findirect-dispatch"<br /><br /> # For generating gettext-tools/src/gnu.gettext.*<br />-make -C gettext-tools/src gnu.gettext.DumpResource<br />+#make -C gettext-tools/src gnu.gettext.DumpResource<br /><br /><br /> %install<br />@@ -215,7 +215,7 @@<br /> %{_infodir}/gettext*<br /> %{_mandir}/man1/*<br /> %{_libdir}/%{name}<br />-%exclude %{_libdir}/%{name}/gnu.gettext.*<br />+#%exclude %{_libdir}/%{name}/gnu.gettext.*<br /> %dir %{_datadir}/%{name}<br /> %{_datadir}/%{name}/archive.tar.gz<br /> %{_datadir}/%{name}/styles<br />@@ -244,8 +244,8 @@<br /> %{_libdir}/preloadable_libintl.so<br /> %{_mandir}/man3/*<br /> %{_datadir}/%{name}/javaversion.class<br />-%doc gettext-runtime/intl-java/javadoc*<br />-%{_libdir}/%{name}/gnu.gettext.*<br />+#%doc gettext-runtime/intl-java/javadoc*<br />+#%{_libdir}/%{name}/gnu.gettext.*<br /><br /><br /> %files libs<br /></pre>Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com4tag:blogger.com,1999:blog-9634563.post-82026031424480258332009-02-04T21:54:00.003-08:002009-02-04T22:01:47.704-08:00Another GPL violation case from top China IT firm? Hanwang this time.Hanwang's eBook Reader products (汉王电纸书产品系列, <a href="http://www.hw99.com/product/productkind-13.htm">http://www.hw99.com/product/productkind-13.htm</a>) are very popular in China market. They features an ARM processor and are running Linux with cramfs, which can be easily discovered from the update firmware the company has released. Also they are shipping BusyBox within them.<br /><br />By no means I can find the source code to their Linux kernel / BusyBox. So perhaps this is yet another GPL violation case from top China IT firm. Anyone bother a law suit?Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com0tag:blogger.com,1999:blog-9634563.post-71029668185339228152009-01-03T00:40:00.007-08:002016-06-17T07:23:38.288-07:00Safely remove an USB hard drive in LinuxI bought a new USB hard drive, Western Digital <a href="http://www.wdc.com/en/products/Products.asp?DriveID=353">My Book® Essential Edition™ 1TB</a>, and use it with Linux. Here I'm discussing about how to safely remove (then disconnect) it from a Linux system. <br />
<br />
<b>The problem:</b> according to its user manual, you should disconnect the drive safely when it is not active, but in a Linux system how to do this is not very straightforward. You may notice that after you unmount it (whether through command-line or a desktop environment), the drive is still spinning and it's LED on. If you read it's user manual carefully you'll find that the manufacturer never said it's safe to disconnect it from your system in such condition.<br />
<br />
<b>The quick solution to this problem:</b><br />
<ol><br />
<li>send SYNC, then STOP command to the device, this can be done easily in Linux by <a href="http://lwn.net/Articles/143397/">unbinding</a> the device</li>
<br />
<li>suspend the USB port by echoing a "suspend" to the "/sys/bus/usb/devices/$DEVICE/power/level", where $DEVICE corresponding to the device of your USB device.</li>
</ol>
<br />
To put it simple, I wrote a script to do this for you. <a href="http://github.com/mlogic/suspend-usb-device/raw/master/suspend-usb-device">Download</a> and try it. For developers, you can get it from the <a href="http://github.com/mlogic/suspend-usb-device">github repo</a>.<br />
<br />
If you saw an error message like this when running it:<br />
<pre>
bash: /sys/bus/usb/devices/5-8/power/level: No such file or directory</pre>
<br />
that means your kernel doesn't support USB suspend. You can just disconnect your device now, it's already safer enough to unplug it.<br />
<br />
To those who is interested, discussion of technical detail following.<br />
<br />
From the hardware aspect, the drive should only be removed when the following requirements are met:<br />
<ol><br />
<li>there's no pending I/O request and software cache flushed</li>
<br />
<li>it's hardware cache flushed</li>
<br />
<li>it's driver spins down (means "not spinning")</li>
<br />
<li>(optional) the USB port is put into "suspend" mode</li>
</ol>
<br />
<br />
The user's manual read (page 6, section "Turning Off/Disconnecting the Device"): <i>"(for Windows systems): Right-click the Safely Remove Hardware icon in your system tray and select <b>Safely Remove Hardware</b>. You may hear the drive power down before the Power LED <b>turns off</b>. The drive is now shut down properly, and you may disconnect the drive safely. (for Macintosh systems) Drag the My Book icon to the Trash icon for proper dismount. You may <b>hear</b> the drive <b>power down</b> as the Power LED flashes. When the Power LED is <b>steady</b>, you may press the Power button once or disconnect the drive’s power cord to turn off the drive safely."</i> (there's a mistake, this device doesn't have a Power button) If you read carefully you can tell that Windows and Macintosh don't do the same things when told to remove an USB device. As the bold text as shown, in a Windows system it will be <b>turned off</b> while in a Macintosh system you <b>hear</b> the drive <b>power down</b> but the Power LED would finally become <b>steady</b> rather than off. Therefore we know that Windows does all 4 steps and Macintosh do the first 3 steps only when told to remove a USB device. (BTW, it's funny that you have to use your ear before disconnecting a device.)<br />
<br />
(This is only the case for Windows XP. For Windows Vista seems only the first 3 steps are done thus the drive remained active after you removing it from the system.)<br />
<br />
<br />
Some may argue that they always disconnect their drives directly after unmounting (step 1 only) and never experience any damage, but as an operating system developer and a serious user, I always follow the manufacturer's manual or specification whenever it make sense and possible because I know electronic devices are <b>fragile</b>, <b>rigid</b> and <b>obtuse</b> if you don't use them as the way they are designed. For a well-designed and robust piece of hardware, theoretically you can disconnect the device safely when the first two steps are done. The firmware on the device would notice the USB cable was unplugged and shut down the disk drive properly. If not, the drive would be stopped sharply as if you pulled it's power when it's running and this damages the hardware gradually. As an outsider of the manufacturer, we hardly know whether it's well-designed or not so the only safe principle is to follow it's manual, means we should not disconnect the device until at least all three steps are done.<br />
<br />
At the Linux kernel part. To finish all the 4 steps, you have to unmount the device, unbind the device from the driver, then tell the USB core driver to put that device into suspend mode, as shown in the solution above. And you have to be running a kernel with CONFIG_USB_SUSPEND enabled.<br />
<br />
CONFIG_USB_SUSPEND is not enabled by default in a vanilla kernel. I'm pushing it in <a href="http://lkml.org/lkml/2009/1/1/48">this discussion</a>.<br />
<br />
Properly removing a device from a running Linux should be done by either the HAL or desktop manager. If you can, please push the developers you know working on any DM that missing this feature to implement this function properly.<br />
<br />
Try my script, and write me if you found a problem. Welcome patches.Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com89tag:blogger.com,1999:blog-9634563.post-49435998332536010542009-01-01T07:46:00.001-08:002009-01-01T07:47:51.143-08:00Google Picasa Web Album's Horrible Automatic TranslationsSee the comments at <a href="http://picasaweb.google.com/rjmaomao/XUwsFC#5214582494506069602">http://picasaweb.google.com/rjmaomao/XUwsFC#5214582494506069602</a> you'll know the latest trick from Google about web comments.Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com0tag:blogger.com,1999:blog-9634563.post-62025084693519344832008-12-27T21:22:00.002-08:002008-12-27T21:26:07.545-08:00Using ext4 and 2.6.28 kernel on my new laptopHoolia! Now on my new laptop (Lenovo ThinkPad T61). I'm using Debian 5.0 (Lenny) with self-built shinning new 2.6.28 kernel and <a href="http://kernelnewbies.org/Ext4">ext4</a>. So far so good.<br /><br />Next step is to install the latest Intel Graphics drive to benefit from <a href="http://lwn.net/Articles/283793/">GEM</a>.Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com7tag:blogger.com,1999:blog-9634563.post-59027462927470406042008-11-07T23:37:00.002-08:002008-11-07T23:41:59.999-08:00Don't use APT::Default-Release in Ubuntu unless you know what you are doingSetting APT::Default-Release in Ubuntu blocks all future security fixes and updates.<br /><br />This is related to all versions before Hardy (include). I haven't tested this on Intrepid so I'm not sure about those versions after Hardy.<br /><br />According to apt_preferences manpage, the target release can be set on the apt-get command line or in the APT configuration file /etc/apt/apt.conf, and "APT::Default-Release "stable";" is given out as an example. This is a very common and popular practice used in Debian community to set the default release and using apt-pin, but doing this in Ubuntu leads to serious security impact with no obvious warning.<br /><br />After setting APT::Default-Release to "hardy", which is the "Suite" name for main hardy source, no security fixes nor updates would be installed unless their priorities are also set explicitly in apt_preferences. This is because that in Ubuntu's world, security fixes are from "hardy-security" source and other updates are from "hardy-updates" source, which bear different "Suite" from the main source. Setting APT::Default-Release rises the priority of packages from main source to 990, but doesn't cover packages from hardy-security and hardy-updates, so the latter are ignored since their packages now has lower priority (priority 500 only) than those old ones in main source (990).<br /><br />I set APT::Default-Release to "hardy" on Sep this year until I found this problem today. Removed that setting and I'm surprised to found that I can install 46 security fixes and updates accumulated. Which is pretty sad to me that got known I haven't got security fixes for more than 2 months.<br /><br />This is a radical deviation from the Debian practice. In Debian all security fixes and updates bear the same "Suite" (etch or lenny) so setting APT::Default-Release to "etch" covers all security fixes and updates.<br /><br />I think it's unlikely that Ubuntu changes the organization of it's source, so at least a fix to this problem is patching the apt_preferences manpage, alerting people not to use APT::Default-Release like they have used this in Debian and the reason and the following impacts.<br /><br />I've opened a bug about this: <a href="https://bugs.launchpad.net/ubuntu/+source/apt/+bug/295448">https://bugs.launchpad.net/ubuntu/+source/apt/+bug/295448</a>Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com2tag:blogger.com,1999:blog-9634563.post-8424416520693100282008-10-31T06:11:00.005-07:002009-01-22T04:28:37.453-08:00Ripping VCD in LinuxI've got some old VCD discs so I've spent some time on studying how to rip them for backing up.<br /><br />There are two methods available:<br /><ol><li>To make a perfect ripping, use <code>cdrdao read-cd</code>:<br/><br /><code>cdrdao read-cd --device ATA:1,1,0 --driver generic-mmc-raw --read-raw image.toc</code><br/><br />the <code>--device</code> is optional. By using this you got a TOC/BIN file pair that contains all the tracks from VCD which can be used to produce exact 1:1 copies. You can also generate a CUE/BIN pair by passing a filename with <tt>.cue</tt> extension. Although it is said that mplayer and totem can play the BIN file if proper decoding plugins are installed, I have never been able to do that, which is a big problem for me.<br/><br />Credit goes to manmath: <a href="http://ubuntuforums.org/archive/index.php/t-217997.html">http://ubuntuforums.org/archive/index.php/t-217997.html</a></li><br /><li>For easy playing back, you can extract MPG files by using GNU <a href="http://www.gnu.org/software/vcdimager/">VCDImager</a>, which is included in many popular distros. Using the vcdxrip program:<br/><br /><code>vcdxrip -C=/dev/cdrom</code><br/><br />By this you got all videos in usable MPG files.</li></ol><br />Though you may be able to copy DAT files from VCD to your hard drive directly in Windows, this is not the case in Linux systems, you'll get I/O errors. The reason is that the file system of VCD disc is not valid ISO-9660 and never meant to support direct copying video data as plain files. Windows must be doing some conversion behind the hood.Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com5tag:blogger.com,1999:blog-9634563.post-59903404239785308362008-10-31T05:34:00.002-07:002008-10-31T05:50:49.985-07:00mplayer and ASS subtitles in UTF-16 with BOMTina got a piece of .mkv video with ASS subtitles, which was in UTF-16 and began with BOM (<tt>0xFF 0xFE</tt>), perhaps generated by using some programs from Windows kingdom. mplayer can't load ASS that begins with BOM and produces the following error message:<br /><br /><pre><br />Matroska file format detected.<br />VIDEO: [avc1] 864x480 24bpp 23.976 fps 0.0 kbps ( 0.0 kbyte/s)<br />SUB: Could not determine file format<br />Cannot load subtitles: file.ass<br /></pre><br /><br />The remedy:<br /><ol><br /><li>Convert the ASS file to UTF-8 (or whatever encoding you are comfortable with). I used iconv: <code>iconv -f utf16 -t utf8 < file.ass > result.ass</code></li><br /><li>Play it by using the "<code>-utf8</code>" switch of mplayer: <code>mplayer -ass -utf8 file.mkv</code>. If the ASS contains special characters (such as CJK chars), use a good font by "<code>-font /usr/share/font/cjk.ttf</code>"</li><br /></ol>Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com2tag:blogger.com,1999:blog-9634563.post-86490430780960669132008-09-20T07:10:00.004-07:002008-09-20T07:32:56.917-07:00Fix nVidia's Proprietary Driver's Poor 2D Performance on LinuxCall me a fool. I bought an XFX GeForce FX 5200 PCI for my workstation (which is actually a Dell SC440 tower server who has no AGP slot). And nVidia's poor proprietary driver is <a href="http://www.heise-online.co.uk/open/Kernel-Log-New-Nvidia-drivers-are-still-slow-Linux-2-6-26-1-soon--/news/111232">notorious slow</a> of 2D on Linux. The CPU usage of the <tt>Xorg</tt> process easily goes up to around 70% on my Xeon Core 2 @ 1.86GHz even when scrolling the text in <tt>gnome-terminal</tt>, not to say reading web pages in Firefox, which slows down everything else. And I've been sticking to a years old pristine GNOME (2.14 shipped with Debian 4.0 Etch) with nothing eye-candy here.<br /><br />Finally I've found a workaround: <a href="http://www.nvnews.net/vbulletin/showpost.php?p=1704073&postcount=1">http://www.nvnews.net/vbulletin/showpost.php?p=1704073&postcount=1</a>: <b>Update (2008-07-18)</b> worked for me. In courtesy of <a href="http://www.nvnews.net/vbulletin/member.php?u=102359">xsolarwindx</a>.<br /><br />The improvement: now with this little fix the time used to build an Linux kernel on my workstation is only <b>half</b> as before just because the little baby likes writing its progress onto the terminal and old nVidia hates this so it made the displaying of text even more time-consuming than compiling the multi-million-line kernel itself!<br /><br />I've been running nVidia's driver 173.14.12 x86_64 on a stock Debian 4.0 Etchnhalf kernel (2.6.24-etchnhalf.1-amd64).<br /><br />I'll never buy an nVidia unless they released full GPL drivers.Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com1tag:blogger.com,1999:blog-9634563.post-33348939372299434412008-09-14T03:14:00.004-07:002008-09-14T07:18:19.817-07:00Install ATI's fglrx Catalyst 8.8 Driver (v 8.522) on Linux 2.6.27The Linux kernel 2.6.27 has changed an API (<code>smp_call_function()</code>) that breaks compilation of ATI's Catalyst 8.8 fglrx driver. You get error like this:<br /><br /><pre><br />/usr/src/fglrx-8.522/firegl_public.c:3080:50: error: macro "smp_call_function" passed 4 arguments, but takes just 3<br />/usr/src/fglrx-8.522/firegl_public.c: In function ‘__ke_flush_cache’:<br />/usr/src/fglrx-8.522/firegl_public.c:3080: error: ‘smp_call_function’ undeclared (first use in this function)<br />/usr/src/fglrx-8.522/firegl_public.c:3080: error: (Each undeclared identifier is reported only once<br />/usr/src/fglrx-8.522/firegl_public.c:3080: error: for each function it appears in.)<br />...<br /></pre><br /><br />Loïc Minier has made a <a href="http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/6086b1cb7674fc43">patch</a> for Catalyst 8.7, and I've adapted it to Catalyst 8.8:<br /><pre><br />From 42a6390f599294c60a4960b0a6cd4e399b1a81ee Mon Sep 17 00:00:00 2001<br />From: Yan Li <elliot.li.tech@gmail.com><br />Date: Sun, 14 Sep 2008 17:45:48 +0800<br />Subject: [PATCH] patch for building on 2.6.27<br /><br />ref: http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/6086b1cb7674fc43<br />---<br /> firegl_public.c | 15 +++++++++++----<br /> 1 files changed, 11 insertions(+), 4 deletions(-)<br /><br />diff --git a/firegl_public.c b/firegl_public.c<br />index bdc94b2..d85a567 100644<br />--- a/firegl_public.c<br />+++ b/firegl_public.c<br />@@ -202,6 +202,13 @@<br /> #define preempt_enable()<br /> #endif<br /> <br />+/* Since 2.6.27 smp_call_function doesn't have a nonatomic/retry argument */<br />+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)<br />+#define SMP_CALL_FUNCTION(func, info, retry, wait) smp_call_function(func, info, wait)<br />+#else<br />+#define SMP_CALL_FUNCTION(func, info, retry, wait) smp_call_function(func, info, retry, wait)<br />+#endif<br />+<br /> // ============================================================<br /> /* globals */<br /> <br />@@ -3077,7 +3084,7 @@ int ATI_API_CALL __ke_flush_cache(void)<br /> {<br /> #ifdef __SMP__<br /> /* write back invalidate all other CPUs (exported by kernel) */<br />- if (smp_call_function(deferred_flush, NULL, 1, 0) != 0)<br />+ if (SMP_CALL_FUNCTION(deferred_flush, NULL, 1, 0) != 0)<br /> panic("timed out waiting for the other CPUs!\n");<br /> <br /> /* invalidate this CPU */<br />@@ -4796,7 +4803,7 @@ struct _agp_memory* ATI_API_CALL __ke_agp_allocate_memory_phys_list(<br /> void ATI_API_CALL KCL_CallFuncOnOtherCpus(firegl_void_routine_t func_to_call) <br /> {<br /> #ifdef CONFIG_SMP<br />- smp_call_function( firegl_smp_func_parameter_wrap, (void*)func_to_call, 0, 1 );<br />+ SMP_CALL_FUNCTION( firegl_smp_func_parameter_wrap, (void*)func_to_call, 0, 1 );<br /> #endif<br /> }<br /> <br />@@ -4910,7 +4917,7 @@ static int ATI_API_CALL KCL_enable_pat(unsigned int save_orig_pat)<br /> }<br /> <br /> #ifdef CONFIG_SMP<br />- if (smp_call_function(KCL_setup_pat, NULL, 0, 1) != 0)<br />+ if (SMP_CALL_FUNCTION(KCL_setup_pat, NULL, 0, 1) != 0)<br /> return 0;<br /> #endif<br /> KCL_setup_pat(NULL);<br />@@ -4929,7 +4936,7 @@ static void ATI_API_CALL KCL_disable_pat(void)<br /> }<br /> <br /> #ifdef CONFIG_SMP<br />- if (smp_call_function(KCL_restore_pat, NULL, 0, 1) != 0)<br />+ if (SMP_CALL_FUNCTION(KCL_restore_pat, NULL, 0, 1) != 0)<br /> return;<br /> #endif<br /> KCL_restore_pat(NULL);<br />-- <br />1.5.4.3<br /></pre><br /><br />I suggest use the <code>--buildpkg</code> function of the ATI driver to build packages for your system. Those packages use dkms to build the kernel module needed. (For Debian/Ubuntu flavor Linux, I suggest use the way as described in <a href="https://help.ubuntu.com/community/BinaryDriverHowto/ATI">https://help.ubuntu.com/community/BinaryDriverHowto/ATI</a>.) Apply the above patch after installed the <tt>fglrx-kernel-source.*.deb</tt> to <tt>/var/lib/dkms/fglrx/8.522/source</tt>, then run "<code>sudo dkms build -m fglrx -v 8.522</code>" to build the kernel module.<br /><br />Reference:<br /><a href="http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/6086b1cb7674fc43">http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/6086b1cb7674fc43</a>Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com0tag:blogger.com,1999:blog-9634563.post-56624060295147555472008-08-07T02:52:00.003-07:002008-08-07T03:05:45.358-07:00Generating Gantt from Bugzilla Tasks by Using TaskJugglerWe've been using <a href="http://www.bugzilla.org/">Bugzilla</a> in various projects to track tasks' status and it turned out to be an excellent tool for collaboration and project management. Gantt is useful in various ways for project status checking and planning. Today I've spent some time to set up automatically generation of Gantt from Bugzilla tasks by using a combination of various tools.<br /><br /><ul><br /><li><a href="http://www.taskjuggler.org/">TaskJuggler</a>: excellent free software on task scheduling and report generation, with beautiful GUI and powerful command-line interface.</li><br /><li><a href="http://wiki.mozilla.org/TaskJugglerIntegration">Bugzilla:TaskJugglerIntegration</a>: export Bugzilla tasks to TaskJuggler project file.</li><br /></ul><br /><br />The script bztotj.py from Bugzilla:TaskJugglerIntegration is easy to understand, and by changing the SQL in it you can export tasks from Bugzilla by arbitrary filters.<br /><br />TaskJuggler's task is written in plain text so it's good for change management. It also features a nice GUI editor. You may need some time to learn to write project files but once you get it you can write versatile project files and, by writing scripts to manipulate them, implement complex project scheduling schema.<br /><br />If you want to generate Gantt from TaskJuggler tasks without human interference, you can use this tool: <a href="http://blog.gustavobarbieri.com.br/2007/04/19/generating-gantt-graphs-from-taskjuggler-projects-without-using-its-ui/">http://blog.gustavobarbieri.com.br/2007/04/19/generating-gantt-graphs-from-taskjuggler-projects-without-using-its-ui/</a>Yan Lihttp://www.blogger.com/profile/02019884916024750698noreply@blogger.com1