Tag Archive for 'gentoo'

Gentoo: setarch blocking util-linux upon emerge -uD world?

You might have noticed that setarch blocks util-linux on a recent “emerge -uD world” update.

[blocks B ] sys-apps/setarch (is blocking sys-apps/util-linux-2.13-r2)

!!! Error: The above package list contains packages which cannot be installed
!!! at the same time on the same system.

util-linux-2.13 now includes setarch, so setarch is redundant and can be safely unmerged.

emerge -Cav setarch
emerge -uDav world

See this forum thread and this bug for more information.

If you liked this post, please subscribe to my feed. Thanks for visiting!

The Gentoo Foundation is no more, but Gentoo Linux will live on

I, and many Gentoo users and fans, have just found out that the Gentoo Foundation ceased to exist a few weeks ago because the current trustees failed to renew and file mundane NPO paperwork in New Mexico. See this discussion on the Gentoo mailing lists and this blog post by Gentoo Founder and ex-Chief Architect Daniel Robbins (drobbins). Even more shocking is the fact that no hint of this monumental bungle is mentioned on gentoo.org.

And so, the non-profit foundation behind one of the most innovative and well-respected Linux distributions is dead because the leadership went MIA and neglected to file a few pieces of paper.

Fortunately, Gentoo Linux will outlive the Gentoo Foundation as long as the developers and users will it so. Many have cited the fact that Gentoo only made one official release in 2007 as a sign of impending doom. Some do not realize that Gentoo uses a rolling update system. Updates and improvements were made to Gentoo without pause throughout 2007. One “emerge -u world” updates a Gentoo installation to the most current version. Whereas most distributions like Ubuntu need new releases to implement drastic improvements, and encourage users to perform clean installs of new releases, Gentoo users never need an official release aside from saving time on fresh installations on new computers. Gentoo Linux might have slowed down and made mistakes that prevented a flashy 2007.1 release, but it is far from dead.

Gentoo Founder Daniel Robbins has offered to return and serve as President, a part-time leader of the Gentoo Foundation. There is no question that Gentoo Linux has suffered in terms of popularity and public opinion since Daniel Robbin’s resignation as Chief Architect. Perhaps Gentoo would be in better shape now if Daniel Robbins had remained the leader of the project. Perhaps Robbins’ strong guiding hand is just what Gentoo needs now. However, I’m worried:

  • drobbins left Gentoo voluntarily; he obviously did not have the desire and/or ability to continue leading Gentoo. Is that different now?
  • drobbins is only offering to return in a part-time capacity. Since the project has suffered from leaders and developers with different priorities going MIA, do we need yet another part-time leader?
  • drobbins returned to Gentoo a few months ago as a regular developer. He left a day or two later over an argument on the mailing lists (satirical account here). Can he do any better this time around in managing a community in turmoil, with tensions running higher than ever?
  • Some Gentoo developers and leaders seem to be very much against drobbins’ return. See Tsunam’s take on drobbins’ offer for example.

Nevertheless, I do hope drobbins’ offer is accepted. Call me a fanboy, but I believe drastic measures are needed to rescue the project quickly, and drobbins is best suited to serve as Gentoo Dictator (temporarily?).

Whether drobbins returns or not, reports of Gentoo’s demise are very much premature.

Good luck, Gentoo! You truly stand out in the crowded field of copycat Linux distributions. You captured my heart and that of countless others.
Long live Gentoo!

Setting up multiple hosts for Nginx (on a Gentoo VPS)

These are the steps I took to setup multiple hosts for Nginx on a 256MB Slicehost VPS running Gentoo Linux. They should work in other similar Linux environments. YMMV.

I followed this multiple hosts layout intended for a single admin/user, and adapted for Nginx this virtual host permissions setup written for Apache.

Place your user account in the web server (Nginx) group:

sudo usermod -a -G nginx myuser

Logout, login again, check if you are in the “nginx” group by typing:

groups

Create the “public_html” or “htdocs” or whatever directory that will hold all your websites:

mkdir /home/myuser/public_html

Create a directory for your “default” or “catch-all” website:

mkdir /home/myuser/public_html/default

Make sure the “public_html” directory is owned by your user and belongs to the web server group:

sudo chgrp -R nginx /home/myuser/public_html

Make any files and directories created in the future under “public_html” inherit the same ownership and permissions, so you don’t have to set these permissions again:

sudo chmod -R 2750 /home/myuser/public_html

Edit Nginx’s config file:

sudo nano /etc/nginx/nginx.conf

Modify the “server” section to look something like this: (source)

        server {
                listen          80 default;
                server_name     _ *;
 
                access_log      /var/log/nginx/localhost.access_log main;
                error_log       /var/log/nginx/localhost.error_log info;
 
                location / {
                        index   index.html,index.htm,index.php;
                        root    /home/myuser/public_html/default;
                }
                location ~ .*.php$ {
                        include /etc/nginx/fastcgi_params;
                        fastcgi_pass    127.0.0.1:1026;
                        fastcgi_index   index.php;
                        fastcgi_param   SCRIPT_FILENAME  /home/myuser/public_html/default/$fastcgi_script_name;
                }
        }

Start Nginx:

sudo /etc/init.d/nginx start

Set Nginx to automatically start on bootup:

sudo rc-config add nginx

And you’re done! If you need to add another website in the future, simply add another “server” section to nginx.conf.

Speed up PHP with XCache on Gentoo Linux

XCache is a PHP opcode cacher created by the same developer who brought us Lighttpd. An opcode cacher significantly increases PHP’s performance by caching the compiled state of PHP code to avoid time-consuming recompilation each time a script is executed. There are a handful of great opcode cachers on the market currently, incuding APC and eAccelerator (here’s a more comprehensive list). APC is written by some of the developers of PHP and will be bundled with PHP6. eAccelerator has a long history and might be the most popular and widely supported opcode cacher. I chose XCache due to its reputation for superior performance (source) and its ability to take advantage of multi-core processors.

Setting up XCache on Gentoo Linux is dead simple.

Install XCache

emerge -va dev-php5/xcache

Configure XCache

nano /etc/php/cgi-php5/ext-active/xcache.ini

Edit anything you see fit. See this page for details.
Since Slicehost is running on twin dual-core processors, I changed “xcache.count” to 5 (n+1 where n is the number of processors) to take advantage of the Splitted Cache feature.

Restart PHP
I have PHP running as a FastCGI daemon, so I restart with

/etc/init.d/fcgi.php restart

Check phpinfo() to verify that XCache is loaded. You should see the following in the “Powered by Zend” box:

with XCache v1.2.1, Copyright (c) 2005-2007, by mOo

Convert your Linux filesystem safely and easily (even on a VPS)

I was shocked to discover that converting one’s filesystem is simple as pie and totally safe. The process goes like this:

  1. Remove cruft from your system (optional)
  2. Reboot into a LiveCD environment (optional if the partition you want to convert can be mounted read-only without rebooting)
  3. Mount the partition you want to convert in read-only mode
  4. Copy the contents of the partition somewhere temporarily (ex. another partition, external drive, DVD, etc.)
  5. Unmount the copied partition
  6. Format the partition with your desired filesystem
  7. Mount the formatted partition and copy all the files back
  8. Edit /etc/fstab to reflect the new filesystem
  9. Reboot and profit

Thanks to Slicehost’s wonderful Rescue Mode with a 2GB Rescue Slice, I was able to use this method to convert my Gentoo VPS from ext3 to XFS. Here’s a step-by-step account. These steps were performed on a 256MB VPS at Slicehost. YMMV.
Continue reading ‘Convert your Linux filesystem safely and easily (even on a VPS)’

Slicehost’s Rescue Mode rocks; Gentoo’s Xen guest /proc /sys mounting bug

This is a tutorial / fan post for Slicehost’s Rescue Mode. Rescue Mode saved me from my own stupid mistakes and also a known Gentoo bug.

While fiddling around in my /etc/fstab file (added “data=writeback” to the mount options), I rendered my Gentoo VPS unbootable. Oh well, I just need to boot a LiveCD and fix my stupid fstab. Wait, this isn’t a physical Gentoo box in front of me, but a virtual server hosted miles away from me…

Ta da, Slicehost’s Rescue Mode to the, uhh, rescue. I log into SliceManager, go to the Rescue panel of my slice, and click “Enter Rescue Mode”. SliceManager gives me a temporary root password, and finishes building the Rescue Slice in a few minutes. Instant LiveCD-like rescue environment!

To fix my fstab, I SSH into my Rescue Slice with the temporary root password. The partition holding my regular slice is available as /dev/sda1 (and my swap partition is /dev/sda2 if I need that for some reason). I mount my regular slice,

mkdir /mnt/slice
mount /dev/sda1 /mnt/slice

fix my fstab file,

nano /mnt/slice/etc/fstab

and finally return to SliceManager and click “Exit Rescue Mode”. Problem solved. Slicehost’s Rescue Mode rocks!

Unfortunately, my VPS failed to boot again but with a different error. It died upon trying to mount /proc.

The "mount" command failed with error: proc already mounted

It turns out this is a known Gentoo bug when working with Xen. Apparently Gentoo Xen guests should not try to mount /proc and /sys. I don’t understand what triggered this problem or why I did not encounter it before.

So back I go into Rescue Mode to fix this by commenting out the section of /sbin/rc that attempts to mount /proc and /sys (if you only skip /proc mounting, the next bootup will die trying to mount /sys).

mkdir /mnt/slice
mount /dev/sda1 /mnt/slice
nano /mnt/slice/sbin/rc

Around line 217, comment out these chunks of code like so: (source)

#       check_statedir /proc
#
#       ebegin "Mounting proc at /proc"
#       if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
#               mntcmd=$(get_mount_fstab /proc)
#       else
#               unset mntcmd
#       fi
#       try mount -n ${mntcmd:--t proc proc /proc -o noexec,nosuid,nodev}
#       eend $?

and a few lines later:

#       if [ "$(get_KV)" -ge "$(KV_to_int '2.6.0')" ] ; then
#               if [[ -d /sys ]] ; then
#                       ebegin "Mounting sysfs at /sys"
#                       if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
#                               mntcmd=$(get_mount_fstab /sys)
#                       else
#                               unset mntcmd
#                       fi
#                       try mount -n ${mntcmd:--t sysfs sysfs /sys -o noexec,nosuid,nodev}
#                       eend $?
#               else
#                       ewarn "No /sys to mount sysfs needed in 2.6 and later kernels!"
#               fi
#       fi

That’s it. Happy rescuing. :)

Nginx with PHP as FastCGI on Gentoo Linux

Nginx (pronounced “Engine X”) is a high performance web server (and proxy server, but we will be using it as a web server here). In small VPS environments where memory is precious, Apache is at best overkill and uses memory that could be spent elsewhere (like MySQL query caching), at worst a terrible bottleneck that will consistently bring down your site under very moderate loads. If you are willing to live without .htaccess files and Apache-style mod_rewrite rules, Nginx is a great replacement that will lower memory usage and increase performance.

This is a draft. Comments, suggestions, corrections, improvements are very much welcome!

Continue reading ‘Nginx with PHP as FastCGI on Gentoo Linux’