Home Random Sh17cast Forums

Upgraded udev on a Gentoo Xen guest recently? Easy fix.

Wednesday, January 27, 2010

I guess some time in the last few months, I updated udev on my Gentoo Xen Guest. Normally, this wouldn’t be a problem and it wasn’t since I didn’t need to reboot the system until yesterday. It wouldn’t come back up automatically, so I consoled the domain with xm, and saw this:

* Mounting proc at /proc ... [ ok ]
* Mounting sysfs at /sys ... [ ok ]
* Your kernel is too old to work with this version of udev.
* Current udev only supports Linux kernel 2.6.25 and newer.
* Could not create /dev/pts!
* Checking root filesystem ...Failed to open the device '/dev/hda2': No such file or directory

* Filesystem couldn't be fixed :(
[ !! ]
Give root password for maintenance
(or type Control-D to continue):

Of course I didn’t read the obvious error at first, and started messing around with other things before finally realizing the kernel the Xen domain is booting from is still at version 2.6.18. I had two options:
1) upgrade the domu kernel from xen-sources (>2.6.18-r12 still being masked on this system) and copy it to the xen host for the vm to boot from.
2) downgrade udev and pretend it never happened.

I chose #2, mainly because it’d take less time and work.
In short, here’s what I did:
Note: This is all from root on the Xen Dom0, not the guest machine.. since it wouldn’t boot yet.

root@Dom-0:# mount /dev/sde5 /mnt/gentoo
root@Dom-0:# mount -t proc none /mnt/gentoo/proc
root@Dom-0:# mount -o bind /dev /mnt/gentoo/dev
root@Dom-0:# chroot /mnt/gentoo /bin/bash
root@Dom-0:# env-update; source /etc/profile; export PS1="(chroot) $PS1"
root@Dom-0:# echo ">=sys-fs/udev-141" >> /etc/portage/package.mask
root@Dom-0:# emerge -avDu udev

And that was it! Started up the gentoo xen domain again, and it booted right up.

posted by johntash at 3:34 pm  

Using Monit to keep your services online

Tuesday, December 1, 2009

Thesh17’s been running on a linode VPS for a month or so now.   It works great until it gets railed, and apache dies.     Then a few hours later I notice the site’s down and login to restart it.    Originally I wrote a shell script that would just check if httpd was running.  If it wasn’t, it’d start it.   It’d also check the output of ‘free -m’ and if memory usage(not counting buffers) was greater than 90%, restart apache.

You’d think that’d be good, right?  Wrong.   I don’t know why, but occasionally things would get confused.  It’d see httpd running, but it wasn’t serving any pages on port 80.    service httpd status would show it was stopped, but the script didn’t check http connectivity or the actual pid file. I honestly didn’t troubleshoot this much, and just manually killed the processes/restarted httpd.

I decided to search for some scripts similar to mine(and better), but instead ended up landing on a utility called Monit.   It’s basically a service monitor you can run(locally or remotely) and depending on different conditions, it will restart the service and make sure it’s running.     This can be as simple as the pid in the pid file not existing, or more complex like the process has been using 90% of the cpu for the last 30 minutes.

As an example, here’s what my apache monit config looks like right now:

check process httpd with pidfile /var/run/httpd.pid
group apache
start program = "/sbin/service httpd start"
stop program = "/sbin/service httpd stop;pkill -9 httpd"
if failed host 127.0.0.1 port 80 protocol http then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if children > 150 then restart
if loadavg(5min) greater than 10 for 8 cycles then alert
if memory > 90% for 2 cycles then restart
if 5 restarts within 5 cycles then timeout

Monit is pretty simple to install. It’s available in most distro’s repositories. On centos:

root@server:# yum install monit

On Gentoo:

root@server:# echo "=app-admin/monit-5.0.3" >> /etc/portage/package.keywords;
root@server:# emerge -av monit

I’m going to give Monit a try for a few weeks and see how it works out. I’ve been using nagios lately as well, but it seems kind of cumbersome to me and mainly one used for monitoring/reporting. Monit will actually restart a service if it detects a problem which *usually* is a good thing.

posted by johntash at 4:25 pm  

Linux spelled out for your window/mac people. (cracked.com)

Friday, November 20, 2009

I know it seems stupid to post a blog article with in a blog article, but the fine people at Cracked wrote this wonderful piece of litature for any one who is switching over to linux.

Right here.

Tl;dr version:

Linux is sleeker and faster than windows while much more personal than Mac (also its fucking free). However,it (even ubuntu) is a tough install (for a normal layman), but keep your chin above your tits because it will pay off in time.

Also if you don’t read Cracked, you should. Posibly one of the best blogs (internet magizine?) out there for people with a fetish with dick jokes and general bestiality.

posted by Kanchi_r0b0t at 11:30 pm  

Search and Replace using VIM

Sunday, November 1, 2009

I always forget little things like this.       Today I changed the dyndns hostname I’ve been using on a server, and needed to update my Apache vhost .conf file to reflect the new domain.      There’s only about 10-15 virtual hosts in this file, but I still didn’t want to manually edit it.    I’m lazy.

vim 90_bac.supercoolname.tld.conf

Once you’re in vim, it’s super-easy to do a find and replace.     This is the command I ran:

%s/bac.supercoolname.tld/bac.evenbettername.tld/g

%s tells vim to search through the entire file.

/g tells vim to replace every instance of bac.supercoolname.tld with bac.evenbettername.tld

There’s a ton of other useful stuff you can do with regular expressions, but this is something I forget a lot when I don’t use it frequently.

posted by johntash at 1:14 pm  

Installing MythTV from SVN on Ubuntu

Thursday, December 27, 2007

This is part one of a series about MythTV and using Ubuntu as a HTPC.  In this article we’ll explain the easiest (or hardest, to some people) step of the process of installing MythTV on Ubuntu Gutsy.

We’ll be installing MythTV using the svn source, which is the latest bleed-edge version of the source code.  There is a chance that the SVN version of MythTV may not be stable. Be Careful!

Lets start by downloading the source code:

  1. Install subversion
  2. sudo aptitude install subversion

  3. Checkout the mythv* trees
  4. cd ~
    mkdir src
    cd src
    svn co http://svn.mythtv.org/svn/trunk/mythtv
    svn co http://svn.mythtv.org/svn/trunk/mythplugins
    svn co http://svn.mythtv.org/svn/trunk/myththemes

Install the extra libraries and tools we need

sudo apt-get install checkinstall fakeroot debhelper libglut3-dev libxvmc-dev libmysqlclient15-dev libtiff4-dev libexif-dev libmad0-dev libid3tag0-dev libvorbis-dev libflac-dev libcdaudio-dev libcdparanoia0-dev fftw3-dev libfaad2-dev libsmpeg-dev libmp4v2-dev libtag1-dev
#we also need this header file for MythMusic
sudo wget http://faac.cvs.sourceforge.net/*checkout*/faac/faad2/common/mp4ff/mp4ff_int_types.h -P /usr/local/include

If you get any errors from the above two commands; leave a comment here and I’ll try to see if I’ve left something out.

Before we actually compile and install the svn version of MythTV; Remove the previous installation(if there is one)

aptitude remove ubuntu-mythtv-frontend mythtv-transcode-utils mythtv-common mythtv-frontend mythtv-themes mythtv-backend mythtv mythtv-frontend mythtv-database mythtv-backend-master


Change remove to purge if you want to delete the configuration files as well, not just upgrade.

Configure the Source

./configure --prefix=/usr
cd ../mythplugins
./configure --prefix=/usr
cd ../myththemes
./configure --prefix=/usr

Compiling the Source

Letting make run it’s course is the most time consuming part of the process, so if you have something else to do while it’s compiling. Go do it.

cd mythtv
make -j2
cd ../mythplugins
make -j2

Installation

Simply run checkinstall and answer a few questions

cd ~/src/mythtv; sudo checkinstall

When it promts you, simply enter Mythtv or whatever you want for the description. The package name should automatically be mythtv. By using checkinstall we are still using Ubuntu/debian’s package system to install Mythtv and everything will be a lot easier to uninstall or upgrade in the future.
IMPORTANT: Change the version field to something like 20071226 (todays date) so that we don’t get an error building the package.(see screenshot below)
Checkinstall version setting

If everything went well you should get something similiar to this:

**********************************************************************

Done. The new package has been installed and saved to

/home/bawls/src/mythtv/mythtv_999999-1_amd64.deb

You can remove it from your system anytime using:

dpkg -r mythtv

**********************************************************************

Do the same thing for mythplugins

cd ~/src/mythplugins
sudo checkinstall

Upgrading

Alright so now you want to upgrade to the latest and greatest again. Here’s how:

  1. Update the source
  2. cd ~
    cd src/mythtv
    svn update
    cd ../mythplugins
    svn update
    cd ../myththemes
    svn update

  3. Configure
  4. cd ~/src/mythtv
    ./configure --prefix=/usr
    cd ../mythplugins
    ./configure --prefix=/usr
    cd ../myththemes
    ./configure --prefix=/usr

  5. Install
  6. cd ~/src/mythtv; sudo checkinstall
    cd ~/src/mythplugins; sudo checkinstall
    cd ~/src/mythplugins; sudo checkinstall

    Only this time when you run checkinstall; increment the Release field. So if it’s 1 now, change it to 2. dpkg will upgrade it to this new package.

Conclusion / Possible Problems

If you already know how to configure and setup mythtv, you should be good to go on your own now (with the latest bleeding-edge features.)

Stay tuned for Part II in the series, but until then if you encounter any problems following this how-to guide; Please post a comment or send me an email with the issue you’re having.  We’ll get it resolved!

References:

[1]http://www.mythtv.org/wiki/index.php/Installing_MythTV_SVN_on_Ubuntu_Breezy
[2]https://help.ubuntu.com/community/MythTV_Gutsy_Backend_Frontend_Desktop
[3]http://www.mythtv.org/wiki/index.php/Ubuntu_Dapper_Installation#After_Installation

posted by johntash at 5:55 am  

Ubuntu: hellanzb for easy downloading from newsgroups

Saturday, December 1, 2007

Preface

This guide is written for Ubuntu or any debian-based distro of Linux; Mainly because I’m lazy and decided to use apt-get.
I’m also not going to explain newsgroups or .nzb files in general right now. I might write a follow-up for that later. I do however recommend the use of Giganews.

  • One: I get a small discount if you use my referral to sign up.
  • Two: It’s only $20 for the first month with unlimited download, 20 connections, and SSL.
  • Three: It’s the best usenet provider I’ve found so far and is able to max out my connection. Way faster than BitTorrent.


Update:   Astraweb is offering a special.    $11/mo for the life of your account.   I’ve been using them for several months with no complaints.    If you’re looking for the best deal, you may want to try Astraweb.

Hellanzb preview 1

What is HellaNZB?

Here’s a description straight from their website:

hellanzb is a Python application designed for *nix environments that retrieves nzb files and fully processes them. The goal being to make getting files from Usenet (e.g.: Giganews Newsgroups) as hands-free as possible. Once fully installed, all thats required is moving an nzb file to the queue directory. The rest; fetching, par-checking, un-raring, etc. is taken care of by hellanzb.

Installation of HellaNZB

  1. Open a terminal or connect to your server using SSH.
  2. Use apt-get to install the prereqs :
    sudo apt-get install rar unrar par2 python-dev python-twisted python-pyopenssl wget tar screen
  3. Download hellanzb and extract it. (Check the website to get the latest version)
    cd ~ ;
    wget http://www.hellanzb.com/distfiles/hellanzb-0.13.tar.gz ;
    tar xvf hellanzb*tar.gz ;
    cd hellanzb-0.13
  4. Install it (requires root access)
    sudo python setup.py install
  5. Copy the configuration file
    sudo cp /usr/etc/hellanzb.conf.sample /usr/etc/hellanzb.conf
  6. Edit the configuration file (replace vim with editor of choice)
    sudo vim /usr/etc/hellanzb.conf

    1. Make sure you configure the server information in the .conf file.  It’s pretty self explanatory and gives examples.
    2. If you’re planning to use SSL; make sure you enable the SSL option and change the port from 119 to 443.
    3. Set the PREFIX dir to something like /home/username/ or /mnt/storage/hellanzb/
  7. That’s it.  You can download a .nzb file and put it in PREFIX_DIR/nzb/daemon.queue/ and if hellanzb is running, it will automatically start processing the .nzb file and then download its contents.   Start hellanzb like this:
    hellanzb.py
  8. Once it finishes downloading a file.  It’ll check to make sure it’s all there and repair it using PAR if it needs to, then unrar it and copy the extracted content to PREFIX_DIR/usenet. It’ll also delete the .rar and .par files once it’s done with them.

Make Hellanzb startup on boot as an init script

I found this init.d script on the ubuntu forums that basically starts hellanzb in a screen session at boot.

  1. Download my slightly modified init.d script
    wget http://www.thesh17.com/wp/wp-content/uploads/2007/12/hellanzb ;
  2. Copy and chmod the script
    sudo cp hellanzb /etc/init.d/hellanzb
    sudo chmod +x /etc/init.d/hellanzb
  3. Set it to run on boot
    sudo update-rc.d hellanzb defaults
  4. Edit the init.d script to run hellanzb as your user(IMPORTANT)
    sudo vim /etc/init.d/hellanzb

    1. Change HELLAUSER=yourusernametorunhellanzbas to reflect your username.
  5. Start hellanzb to see if it all worked
    sudo /etc/init.d/hellanzb start

Alternate Method to start on boot

If you get any errors. Just add this line inside /etc/rc.local and change $HELLAUSER to whatever your username is.

su -c '/usr/bin/screen -S hellanzb -d -m /usr/bin/python /usr/bin/hellanzb > /dev/null 2> /dev/null' $HELLAUSER

Now then.  You should be all set.  Just use SFTP or one of the web interfaces to hellanzb and download .nzb files into the queue folder.

posted by johntash at 6:49 pm  

35 queries. 0.122 seconds.
Copyright © 2007-2010 http://www.thesh17.com