bash script to automate compiling alsa in Ubuntu
Labels: tech on 22 October, 2007 at 3:38 PM
Most of the laptops I've owned have had trouble with sound to some degree. The only solution is to compile the latest version of alsa manually, as most GNU/Linux distros have an out of date alsa (even the recently released Ubuntu 7.10 - Gutsy Gibbon)
This wouldn't be a big deal, but every time you get a kernel update, you have to compile alsa again. This can become a bit of a pain, so I wrote a bash script that would do it all for me.
First the script will download all alsa's dependencies. Then it will download:
alsa-driver-1.0.15.tar.bz2
alsa-lib-1.0.15.tar.bz2
alsa-utils-1.0.15.tar.bz2
it will then extract them (whilst deleting the .bz2), move them to /usr/src/alsa and compile them each.
just copy the first block of text to a text file and save as alsa_1.sh, and then the second block to alsa_2.sh and then cd to it in a terminal and type "sudo sh alsa_1.sh"
then reboot, and then type "sudo sh alsa_2.sh"
(make sure the scripts have execute privileges. (by typing "chmod a+x alsa_1.sh")
#!/bin/sh
#
#install necessary stuff
apt-get install build-essential ncurses-dev gettext
apt-get install linux-headers-`uname -r`
echo "downloading alsa packages..."
wget ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.15.tar.bz2
wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.15.tar.bz2
wget ftp://ftp.alsa-project.org/pub/utils/alsa-utils-1.0.15.tar.bz2
echo "extracting alsa packages..."
tar -xjf alsa-driver*.tar.bz2
tar -xjf alsa-lib*.tar.bz2
tar -xjf alsa-utils*.tar.bz2
rm alsa*.tar.bz2
echo "setting up alsa for compilation"
mkdir -p /usr/src/alsa
mv alsa-* /usr/src/alsa
#alsa-driver
cd /usr/src/alsa/alsa-driver*
./configure --with-cards=hda-intel
make
make install
#alsa-lib
cd /usr/src/alsa/alsa-lib*
./configure
make
make install
#alsa-utils
cd /usr/src/alsa/alsa-utils*
./configure
make
make install
echo "now reboot your machine, and run alsa_2"
#end of alsa_1
#!/bin/sh
#for after reboot
cp -v /lib/modules/2.6.22-*/kernel/sound/pci/hda/snd-hda-intel.ko /lib/modules/2.6.22-*/ubuntu/media/snd-hda-intel/snd-hda-intel.ko
cp -v /usr/src/alsa/alsa-driver*/modules/* /lib/modules/2.6.22-*/kernel/sound/
depmod -a
#end of alsa_2
note, in its bare form, this will work in any distro, but my script installs the dependencies using APT (so this will only work for debian based distros - Debian, Ubuntu, LinuxMint, Mepis etc..)
also, alsa_2 is assuming kernel 2.6.22. If you have a different kernel, or several .22 kernels, you'll need to specify. Also, my script compiles the alsa-driver for intel-hda sound cards. This is the most common card for laptops (if you have an intel processor, chances are you have it). If not, replace with your sound cards name
Martin said,
Thanks Antony
Works great with my Acer Aspire 5720
Thanks!
I couldn't compile alsa till I found this scripts!
Hp Compaq nx7300
Antony,
nice script. Sound is now working on my Acer Aspire 5720 w/ Ubuntu 7.10. Had to append
options snd-hda-intel model=acer
to my /etc/modprobe.d/alsa-base to get it going.
David said,
Worked great with my Toshiba Satellite a205-s4537
Thanks!
You my friend are THE MAN! I've been playing with an Acer 7720 "coffee top" for the last 3 weeks trying to get sound to work and FINALLY its a go! Thanks!
Yikes!
Now I'm actually further away... clicking on volume control tells me "No Volume control GStreamer plugins and/or devices found" I have no idea what went wrong (I also have no idea what I'm doing), I'm sure I followed your steps.
Informed Linux beginner followed instructions to the letter on gutsy with 8086:27d8 Sigmatel Audio on a Panasonic Toughbook CF-51P and got the same error as "Yikes!" on post above.
Thank you.
Norm said,
This is fantastic!
I was wondering what you would do to make this work with the Creative labs USB sound card?
The Live 24bit to be exact.
Thanks--greatly eased getting sound playback and recording working on an Acer Aspire 3050 running ubuntu 7.10.
The tip from paetz I think is what got the recording finally working:
options snd-hda-intel model=acer
here are the scripts with some modifications:
1. takes the latest non rc version
2. for any kernel, not just 2.6.22
3. uses checkinstall instead of make install so packages can be easily removed with dpkg -r
here are the scripts:
alsa_1.sh
----------------------------
#!/bin/sh
#
#install necessary stuff
apt-get install build-essential ncurses-dev gettext
apt-get install linux-headers-`uname -r` checkinstall
/bin/rm -f /usr/src/alsa
mkdir -p /usr/src/alsa
cd /usr/src/alsa
echo "downloading alsa packages..."
ver=`wget -O - ftp://ftp.alsa-project.org/pub/driver/|grep driver/alsa-driver|sort -n|grep -v '[0-9]rc[0-9]'|tail -1|sed 's/^.*alsa-driver-//;s/.tar.*//'`
wget ftp://ftp.alsa-project.org/pub/driver/alsa-driver-${ver}.tar.bz2
wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-${ver}.tar.bz2
wget ftp://ftp.alsa-project.org/pub/utils/alsa-utils-${ver}.tar.bz2
echo "extracting alsa packages..."
tar -xjf alsa-driver*.tar.bz2
tar -xjf alsa-lib*.tar.bz2
tar -xjf alsa-utils*.tar.bz2
rm alsa*.tar.bz2
#alsa-driver
cd /usr/src/alsa/alsa-driver*
./configure --with-cards=hda-intel
make
#make install
mkdir ./doc-pak
echo "alsa-driver-${ver}" > description-pak
dpkg -r alsa-driver*
checkinstall -D --pkgname alsa-driver --pkgversion ${ver}-cust
#alsa-lib
cd /usr/src/alsa/alsa-lib*
./configure
make
#make install
mkdir ./doc-pak
echo "alsa-lib-${ver}" > description-pak
dpkg -r alsa-lib*
checkinstall -D --pkgname alsa-lib --pkgversion ${ver}-cust
#alsa-utils
cd /usr/src/alsa/alsa-utils*
./configure
make
#make install
mkdir ./doc-pak
echo "alsa-utils-${ver}" > description-pak
dpkg -r alsa-utils*
checkinstall -D --pkgname alsa-utils --pkgversion ${ver}-cust
echo "now reboot your machine, and run alsa_2"
#end of alsa_1
alsa_2.sh
------------------------
#!/bin/sh
#for after reboot
cp -v /lib/modules/`uname -r`/kernel/sound/pci/hda/snd-hda-intel.ko /lib/modules/`uname -r`/ubuntu/media/snd-hda-intel/snd-hda-intel.ko
cp -v /usr/src/alsa/alsa-driver*/modules/* /lib/modules/`uname -r`/kernel/sound/
depmod -a
#end of alsa_2
in the end i found the script is not needed.
just booted into kernel 2.6.22-generic (instead of the default 2.6.22-i386)
and i have sound working ...
pea said,
Antony, you are great man!
Since last kernel update I had audio problems and could not manage compiling
alsa.
Regards,
Vittorio
Hello,
I don't really understand what's the purpose of the 2nd script. Could someone explain it to me? Thanks!
Antony
You are god! It worked on my gateway mt3707 (a problem lappie if ever there was one) using mint xfce cassandra. I had to change the kernel from 22 to 20-16. It works! My time of great punishment is over. I can now lead a normal life, though my transition back into society, after months of doing nothing but linux distros, may be problematic.
Thanks again.
on 2/1/08 23:24
curuxz said,
Thanks so much!!!!
Now I have sound on my pretty acer 7720! :)
I also had to do "options snd-hda-intel model=acer" to get mine working :)
on 7/1/08 03:25
Cool, got the sound working on my acer travelmate 6592g. Had to add the option to alsa-base too..
Thanx
Henrik
http://www.antonywilliams.com/2007/10/www.karlsenfoto.dk
I have more than one card on my laptop, after this script only the intel hda was detected and enabled. Also, if I plug in my usb audio card it is not detected anymmore, while it was before using the script.. How can I solve this?
I tried to get my sound working with a Crystal CS4237B sound chip on an ISA bus on UBUNTU. However, I think the first script ended in an error and then when I restarted I could not login to any desktop (even recovery mode)
Finally, logged in at the terminal only and issued the following command to at least get Ubuntu working again.
"sudo apt-get install --reinstall libasound2"
Still cannot get regular sound to work yet
I bow down to you. After 3 days of frustration trying to get this *&%#ing sound card to work with Ubuntu, I ran your scripts (and added "options snd-hda-intel model=hp" to my /etc/modprobe.d/alsa-base file) and lo, I am now listening to the glory that is "What's Up?" by 4 Non Blondes! Bless you!
Thanks a bunch the script worked like a charm!
on 6/2/08 18:51
WOW! So far this has worked great with my Gateway MT3422
Thanks a bunch!
Francisco Jácomo Cunha said,
Thank you very much Anthony, works like a charm;)
on 5/3/08 05:03
Cabal said,
Sweet!
Worked perfectly with my AMD64 with and Asus M2N-MX SE motherboard. Had to reboot twice, but everything went fine fine fine :)
A big thank you!
Thanks so much for this script. Used the erez version of these two scripts. It almost installed perfect, but we have this error while running alsa_1.sh:
Selecting previously deselected package alsa-lib.
(Reading database ... 144171 files and directories currently installed.)
Unpacking alsa-lib (from .../alsa-lib_1.0.16-cust-1_i386.deb) ...
dpkg: error processing /usr/src/alsa/alsa-lib-1.0.16/alsa-lib_1.0.16-cust-1_i386.deb (--install):
trying to overwrite `/usr/lib/libasound.so.2.0.0', which is also in package libasound2
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
/usr/src/alsa/alsa-lib-1.0.16/alsa-lib_1.0.16-cust-1_i386.deb
/
So now what? Running ubuntu 7.10 on a new Dell inspiron here, with the intel chip, the problem with sound in headset but no mic working. Need step-by-step help to resolve this problem; been running Debian on desktop machine for awhile but I'm not all that good at stuff like this. Need skype to work.
Thanks extremely
on 1/4/08 01:01
Acer Aspire 7720
I also received the error "No Volume control GStreamer plugins and/or devices found" when I first tried the script.
Rebooting again fixed it. (I also modified the alsa-base file before rebooting... bad experimental technique I guess.)
Thank you immensely for the script!
on 2/4/08 18:22
Great information. I tried to compile Alsa 1.0.16 and got an error when apt-get tried to install ncurses-dev. It gave an error message about unable to install the file. Will you please modify this script to work with the 1.0.16 packages?
THANKS!
Many thanks for your scripts. I had just upgraded to ubuntu 8.04 and noticed i had forfit many features that worked fine in 7.10 such as sound...
Man....Kudos to u!!u r a real genius 2 me....
I had just installed Hardy heron ( Ubuntu 8.04) n did go through a lot of pain in the ass to discover that the linuxant packages :
alsa-driver-linuxant_1.0.16.1-1_all.deb
hsfmodem_7.68.00.10full_k2.6.24_16_generic_ubuntu_i386.deb
the versions present in the website are not compatible.as the hsf driver supposedly needs alsa 1.0.15. Now,the unavailability of .deb packages of alsa-1.0.15 is again an altogether different story.I was beginning to realise that I could use only Dial-up or Sound-system at a time,by re-install and re-boot of the diff. packages,but not both....... until I saw your script.
Man now both are working fine thanx 2 u'r script.....
well,but I hav a query-the alsa_2.sh actually gave an error message :
`/lib/modules/2.6.24-16-generic/kernel/sound/pci/hda/snd-hda-intel.ko' -> `/lib/modules/2.6.24-*/ubuntu/media/snd-hda-intel/snd-hda-intel.ko'
cp: cannot create regular file `/lib/modules/2.6.24-*/ubuntu/media/snd-hda-intel/snd-hda-intel.ko': No such file or directory
cp: cannot stat `/usr/src/alsa/alsa-driver*/modules/*': No such file or directory
and it was actually never required.I would be grateful if u could interpret this message....
Thanx again :)
Tidak ada komentar:
Posting Komentar