Category: Linux

Enabling “swap” in an OpenVZ container

By , 2012-03-23 19:28

Oracle client for Linux for some reason requires 1GB of swap space, and will refuse to install, even if you have 9999999999TB of RAM, but 0 swap. Go figure.

Anyway, an OpenVZ container created with Proxmox will by default have 0 swap allocated, despite the Web UI allowing you to specify swap space.

In order to add swap to the container, from a shell prompt, run

On a somewhat related note, here’s how to install oracle client on Debian:

http://randrianiriana.wordpress.com/2010/08/25/debian-php5-oracle-oci8/

vzctl set 213 –swappages 262144 –save

 

Where 213 is your CTID, and 262144 is the amount of swappages you want. 1 page=4096 bytes , so 262144 = rougly 1024MB.

Also, Oracle installer detects 262144 swappages as 1023MB and change, so you will have to put something like 262200 instead.

 

ALSA: cannot find card ‘0’ when using USB sound card

By , 2012-02-24 10:16

I was trying to get my Alix board to properly output audio. It has no VGA and no onboard sound card, so I’m using a USB to audio adapater. The card was detected, all appropriate snd- modules loaded according to lsmod, and it showed up in /proc/asound/cards. Problem is it was card1, and alsamixer and most programs use card0 by default.

It seems that Debian configures snd-usb-audio in /etc/modprobe.d/alsa-base.conf with the index=2 option to prevent it from being the primary card. To disable this behaviour, simply comment out the line.

 

Original answer:

So are you using a USB sound card as your audio device?It looks like you might have removed some audio device from your computer, that is why card0 is missing, where as usb card is configured as card1.

Edit /etc/modprobe.d/alsa-base.conf, include/modify the line for snd-usb-audio

snd-usb-audio index=0

This would update snd-usb-audio to card0, in case you want that as the first card.

via Debian User Forums • View topic – ALSA: cannot find card ‘0’.

Missing shutdown button – lightdm-unity-greeter

By , 2012-02-02 15:13

Found the problem! Your log says ‘/usr/lib/indicators3/6/libsession.so does not exist.’ That file is part of the ‘indicator-session’ package, which provides the shutdown buttons for Unity and Lightdm.

via AUR en – lightdm-unity-greeter.

XBMC on Ubuntu clean install

By , 2012-01-14 17:22

Note to self: Always install ubuntu-restricted-extras first. Without it, XBMC will crash when playing MP3s since libmad is missing.

Ubuntu. TV for human beings. I gotta feeling.

By , 2012-01-12 14:14

So Ubuntu is getting into the TV business. If they can pull it off, and get into Cable/Satellite/IPTV STBs, the would would be a much better place. This looks way better than Microsoft Mediaroom or any proprietary cable box software I’ve seen.

Now, is it just me or does that video sound a lot like this one?

I have to say, I gotta feeling that Canonical might have got it right. Unfortunately, past experience says Big Telecom isn’t very interested in what’s good for the customer.

more at

http://www.ubuntu.com/tv
http://www.theverge.com/2012/1/10/2697982/interview-ubuntu-tv-pete-goodall

Why I use Debian and Ubuntu (Apt)

By , 2011-12-21 10:35

OK, rant time.

Way back in the day (I mean 2001 or so), I used to use rpm-based distros. Red Hat, Mandriva – or rather Mandrake- and they worked fine. As long as you didn’t have to install any packages. To be fair, this was in the early days of package managers and the like, and I was a novice Linux user at the time. Mandrake had put in a good effort with urpmi, but I still had to visit sites like http://rpm.pbone.net/ and http://rpmfind.net/ very often to find this or that package.

Then, in 2004/2005, I discovered Ubuntu. (The OS, not the philosophy. Ha ha.) It was a world of difference. Need a program? apt-get install program would automagically fetch and install it for you. Don’t know the name of the package, or exactly what you’re looking for? apt-cache search can help. If that package you want installed has dependencies, and those have dependencies? No problem, everything gets pulled in and the proposed changes are listed for you. The other advantage was that seemingly any program I could possibly want was available in a Debian/Ubuntu repo.

Fast forward to today. I’ve pretty much been using Debian based distros since then, although I have tried Arch and Slax, and possibly many others that I can’t remember right now. All my servers run either Debian or Ubuntu Server, and my Linux PCs are Ubuntu or Arch. Package management has become so easy that I rarely ever have to worry about it, unless I’m trying to make some major changes outside of repo packages.

Recently, however, I’ve started using some RPM distros again, to see how things have been on that side of the fence. It’s been mostly CentOS and a few CentOS/PBX distros (Elastix, Trixbox, pbxinaflash…). I have to say though, I can’t believe the state of the package management system. CentOS has got yum, which seems to be good in principle, but somehow I’ve seen it massively fail in ways that Apt never has for me. The first issue is not really to do with the package manager, but more the repositories.

For example, we had a service on a server at work that absolutely required “Arial”. In Ubuntu or Debian, all you have to do is enable the non-free repo, or an Arch, use one of the excellent AUR frontends such as yaourt. Then install msttcorefonts (Debian) or ttf-ms-fonts (Arch). The package manager will fetch the MS fonts package and its dependency, cabextract. It then downloads each of the fonts’ self-extracting EXEs from sourceforge, cabextracts them, then installs them to the appropriate fonts directory. Now, on the CentOS 5 server, no such luck.

$ yum install msttcorefonts
Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.nexicom.net
 * extras: centos.mirror.nexicom.net
 * updates: centos.mirror.nexicom.net
Excluding Packages from CentOS-5 - Addons
Finished
Excluding Packages from CentOS-5 - Base
Finished
Excluding Packages from CentOS-5 - Extras
Finished
Excluding Packages from CentOS-5 - Updates
Finished
Setting up Install Process
No package msttcorefonts available.
Nothing to do
$

Awesome. Time to break out the manual package manager, AKA Google. Which brings me to the corefonts sourceforge project homepage, fortunately with clear instructions on how to install on an rpm-based system.

  1. Make sure you have the following rpm-packages installed from from your favourite distribution. Any version should do.
    • rpm-build
    • wget
    • A package that provides the ttmkfdir utility. For example
      • For Fedora Core and Red Hat Enterprise Linux 4, ttmkfdir
      • For old redhat releases, XFree86-font-utils
      • For mandrake-8.2, freetype-tools
  2. Install the cabextract utility. For users of Fedora Core it is available from extras. Others may want to compile it themselves from source, or download the source rpm from fedora extras and rebuild.
  3. Download the latest msttcorefonts spec file from here
  4. If you haven’t done so already, set up an rpm build environment in your home directory. You can to this by adding the line %_topdir %(echo $HOME)/rpmbuild to your $HOME/.rpmmacros and create the directories $HOME/rpmbuild/BUILD and $HOME/rpmbuild/RPMS/noarch
  5. Build the binary rpm with this command:
    $ rpmbuild -bb msttcorefonts-2.0-1.spec

    This will download the fonts from a Sourcforge mirror (about 8 megs) and repackage them so that they can be easily installed.

  6. Install the newly built rpm using the following command (you will need to be root):
    # rpm -ivh $HOME/rpmbuild/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm

Sounds like fun. Let’s try and see if we’re lucky.

yum install wget rpm-build cabextract

Cool! rpm-build was installed! but wait, how about wget and cabextract? It didn’t mention those!

wget is probably installed, but let’s try anyway:

$ wget
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.

OK, how about cabextract?

$ cabextract
sh: cabextract: command not found

Well then, that’s wonderful. Thanks for mentioning that you didn’t install cabextract, yum.

Fortunately the good people at corefonts provided a link to the download for cabextract, and fortunately, my server is i386 (I know it doesn’t seem like it from the screenshot), so I can use the pre-built RPM. (For those who need it, the x86_64 package) Now to the final step.

$ wget -O - http://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec | rpm -bb msttcorefonts-2.0-1.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.77304
+ umask 022+ cd /usr/src/redhat/BUILD

[… a hundred or so lines…]

Wrote: /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.22861
+ umask 022
+ cd /usr/src/redhat/BUILD
+ '[' /var/tmp/msttcorefonts-root '!=' / ']'
+ rm -rf /var/tmp/msttcorefonts-root
+ exit 0

Phew, that’s a lot of output. Well exit 0, that’s good. Aaand “Wrote: /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm”. cool!

And finally:

$ rpm -ivh /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm
Preparing...                ########################################### [100%]
   1:msttcorefonts          ########################################### [100%]
$

(Another thing that bugs me – no success message! After all that, not even a Yay! Package installed!? I’m disappointed, rpm.)

For illustrative purposes, Debian:

# apt-get install msttcorefonts
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  cabextract ttf-liberation ttf-mscorefonts-installer
The following NEW packages will be installed:
  cabextract msttcorefonts ttf-liberation ttf-mscorefonts-installer
0 upgraded, 4 newly installed, 0 to remove and 4 not upgraded.
Need to get 1103kB of archives.
After this operation, 2109kB of additional disk space will be used.
Do you want to continue [Y/n]? Y

[…]

All fonts downloaded and installed.
Updating fontconfig cache for /usr/share/fonts/truetype/msttcorefonts
Setting up msttcorefonts (2.7) ...
Setting up ttf-liberation (1.04.93-1) ...
Updating fontconfig cache for /usr/share/fonts/truetype/ttf-liberation

Wasn’t that easier? Also, a nice plain English message saying what was done: “All fonts downloaded and installed.” Take notes, rpm.

For completeness’ sake, Arch:

$ yaourt -S ttf-ms-fonts

==> Downloading ttf-ms-fonts PKGBUILD from AUR...
x PKGBUILD
x ttf-ms-fonts.install
x LICENSE

[…]

==> ttf-ms-fonts dependencies:
 - fontconfig (already installed)
 - xorg-fonts-encodings (already installed)
 - xorg-font-utils (already installed)
 - cabextract (package found)

[…]

Targets (1): ttf-ms-fonts-2.0-8

Total Download Size:    0.00 MB
Total Installed Size:   5.49 MB

Proceed with installation? [Y/n]
(1/1) checking package integrity                                         [########################################] 100%
(1/1) checking for file conflicts                                        [########################################] 100%
(1/1) installing ttf-ms-fonts                                            [########################################] 100%
Updating font cache... done.
$

A bit more user interaction, but that’s the point of Arch.

So, to summarize:

Arch/Debian package management > rpm package management (CentOS).

And that’s the end of my rant for today.

Quick and dirty bash script to apt-get update all OpenVZ containers

By , 2011-11-30 22:29

It’s a bit of a pain having to run upgrades on all servers. I could of course, set up unattended upgrades, but I always liked initiating the upgrade process myself. So I wrote a little bash script that will initiate apt-get update and apt-get upgrade on all running OpenVZ containers.

Note that this only works for Debian-based distros. So Debian, *buntu, Linux Mint and the like.

It’s very rough, no error-handling or safeguards, so use at your own risk. Works for me, but YMMV.

#!/bin/bash
#Delete temp file
rm /tmp/tmp-script.sh
#Get running VZ
CTIDS=$(vzlist | awk '{print $1}' | sed -e '/CTID/d' -e ':a;N;$!ba;s/\n/ /g' )
# Echo list of running IDs
echo "$CTIDS"
CTIDarray=($CTIDS)
for x in ${CTIDarray[@]}
do
    echo "#/bin/bash" > /tmp/tmp-script.sh
    chmod +x /tmp/tmp-script.sh
    echo vzctl exec $x "apt-get update &&;  apt-get -y upgrade" >> /tmp/tmp-script.sh
    screen -d -m /tmp/tmp-script.sh
done
#Delete temp file
rm /tmp/tmp-script.sh
#Show running screens
screen -x

First, we rm the /tmp/tmp-script.sh. Starting off with very bad form, I know, feeling lazy right now. Then I use awk and sed to get the IDs of running containers from the output of the vzlist command, and place them on a single line, separated by spaces. Those IDs are than put in an array, so that the update command can be called using a for loop.

For some reason, I couldn’t get screen to launch the

vzctl exec $x "apt-get update &&  apt-get -y upgrade"

command directly, hence the hideous use of a temp file. If anyone can fix/improve this, I would be glad to hear from you!

Quick bash script to restore all OpenVZ dumps

By , 2011-10-05 22:57

This script will read the container ID from the file name, and use it to restore the tgz dump to the same ID on the new OpenVZ/Proxmox server.

Note that this only works if the default name for the vzdumps is kept, and it only works for the next 89 years, because I’m lazy.

Thanks to
http://www.cyberciti.biz/faq/bash-loop-over-file/ and http://bashcurescancer.com/10-steps-to-beautiful-shell-scripts.html

#!/bin/bash
VZDUMPS=/path/to/backups/*.tgz
for f in $VZDUMPS
 
do
        f2=${f#*openvz-}
        VEID=${f2%-20*}
        echo "Restoring $f to $VEID"
        vzrestore $f $VEID
done

How to recursively delete files matching a pattern

By , 2011-09-13 09:45

cd to the folder, run :

$ find . -name '*attach*' | xargs rm

where attach is the keyword present in all filenames to delete.

3 monitors and Updated xorg mesa drivers for Ubuntu Natty

By , 2011-09-09 14:34

I’m currently running Ubuntu Natty as my primary OS at work.

My setup is a Precision T3500 workstation that came with two NVIDIA Quadro cards which were a nightmare for Linux support. I heard that ATI cards supported 3 monitors on one card, as long as one of them was DisplayPort. I saw a cheap Radeon HD 5450 on sale for about $40, so I picked it up only to notice that it had an HDMI port instead of DisplayPort. I figured I’d try it anyway and was surprised to find that with the open-source radeon driver, 3 monitors work! One is connected by VGA, one HDMI and one DVI.

I had, however been experiencing random X crashes, and I suspect the problem was with the radeon driver.

Currently testing out some updated xorg drivers found at:

http://phoronix.com/forums/showthread.php?50038-Updated-and-Optimized-Ubuntu-Free-Graphics-Drivers

 

My system specs:

$ sudo lshw -short
H/W path         Device      Class       Description
====================================================
                             system      Precision WorkStation T3500 ()
/0                           bus         09KPNV
/0/0                         memory      64KiB BIOS
/0/400                       processor   Intel(R) Xeon(R) CPU           W3530  @ 2.80GHz
/0/400/700                   memory      256KiB L1 cache
/0/400/701                   memory      1MiB L2 cache
/0/400/704                   memory      8MiB L3 cache
/0/1000                      memory      14GiB System Memory
/0/1000/0                    memory      2GiB DIMM DDR3 1333 MHz (0.8 ns)
/0/1000/1                    memory      2GiB DIMM DDR3 1333 MHz (0.8 ns)
/0/1000/2                    memory      2GiB DIMM DDR3 1333 MHz (0.8 ns)
/0/1000/3                    memory      4GiB DIMM DDR3 1333 MHz (0.8 ns)
/0/1000/4                    memory      4GiB DIMM DDR3 1333 MHz (0.8 ns)
/0/1000/5                    memory      DIMM DDR3 Synchronous [empty]
/0/100                       bridge      5520/5500/X58 I/O Hub to ESI Port
/0/100/1                     bridge      5520/5500/X58 I/O Hub PCI Express Root Port 1
/0/100/1/0       eth0        network     82574L Gigabit Network Connection
/0/100/3                     bridge      5520/5500/X58 I/O Hub PCI Express Root Port 3
/0/100/3/0                   display     Cedar PRO [Radeon HD 5450]
/0/100/3/0.1                 multimedia  Manhattan HDMI Audio [Mobility Radeon HD 5000 Series]
/0/100/7                     bridge      5520/5500/X58 I/O Hub PCI Express Root Port 7
/0/100/14                    generic     5520/5500/X58 I/O Hub System Management Registers
/0/100/14.1                  generic     5520/5500/X58 I/O Hub GPIO and Scratch Pad Registers
/0/100/14.2                  generic     5520/5500/X58 I/O Hub Control Status and RAS Registers
/0/100/1a                    bus         82801JI (ICH10 Family) USB UHCI Controller #4
/0/100/1a.1                  bus         82801JI (ICH10 Family) USB UHCI Controller #5
/0/100/1a.2                  bus         82801JI (ICH10 Family) USB UHCI Controller #6
/0/100/1a.7                  bus         82801JI (ICH10 Family) USB2 EHCI Controller #2
/0/100/1b                    multimedia  82801JI (ICH10 Family) HD Audio Controller
/0/100/1c                    bridge      82801JI (ICH10 Family) PCI Express Root Port 1
/0/100/1c.5                  bridge      82801JI (ICH10 Family) PCI Express Root Port 6
/0/100/1c.5/0    eth1        network     NetXtreme BCM5761 Gigabit Ethernet PCIe
/0/100/1d                    bus         82801JI (ICH10 Family) USB UHCI Controller #1
/0/100/1d.1                  bus         82801JI (ICH10 Family) USB UHCI Controller #2
/0/100/1d.2                  bus         82801JI (ICH10 Family) USB UHCI Controller #3
/0/100/1d.7                  bus         82801JI (ICH10 Family) USB2 EHCI Controller #1
/0/100/1e                    bridge      82801 PCI Bridge
/0/100/1f                    bridge      82801JIR (ICH10R) LPC Interface Controller
/0/100/1f.2      scsi0       storage     82801JI (ICH10 Family) SATA AHCI Controller
/0/100/1f.2/0    /dev/sda    disk        250GB ST3250318AS
/0/100/1f.2/0/1  /dev/sda1   volume      101MiB Linux filesystem partition
/0/100/1f.2/0/2  /dev/sda2   volume      4102MiB Linux swap volume
/0/100/1f.2/0/3  /dev/sda3   volume      20GiB EXT4 volume
/0/100/1f.2/0/4  /dev/sda4   volume      208GiB EXT4 volume
/0/100/1f.2/1    /dev/sdb    disk        1500GB WDC WD15EARS-00M
/0/100/1f.2/1/1  /dev/sdb1   volume      499GiB Data partition
/0/100/1f.2/1/2  /dev/sdb2   volume      897GiB Data partition
/0/100/1f.2/2    /dev/cdrom  disk        DVD-ROM TS-H353C
/0/100/1f.2/3    /dev/cdrw   disk        DVD+-RW TS-H653F
/0/100/1f.2/3/0  /dev/cdrw   disk        
/0/100/1f.3                  bus         82801JI (ICH10 Family) SMBus Controller

Custom theme by me. Based on Panorama by Themocracy