Sunday, April 8, 2012

Tip: Fixing yum --disablerepo not working on CentOS 6.2

I came across a weird situation while meddling with repositories in CentOS 6.2.

# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: ftp.dei.uc.pt
 * c6-media:
 * extras: ftp.dei.uc.pt
 * updates: ftp.dei.uc.pt
file:///media/CentOS/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/CentOS/repodata/repomd.xml
Trying other mirror.
file:///media/cdrecorder/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/cdrecorder/repodata/repomd.xml
Trying other mirror.
file:///media/cdrom/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/cdrom/repodata/repomd.xml
Trying other mirror.
repo id                         repo name                                 status
base                            CentOS-6 - Base                           4,764
c6-media                        CentOS-6 - Media                              0
extras                          CentOS-6 - Extras                             0
updates                         CentOS-6 - Updates                            0
repolist: 4,764

So I figured that disabling the c6-media repository would fix things, however iIssuing yum --disablerepo=c6-media resulted in yum displaying it's help file.

While investigating the issue I came across Red Hat Bugzilla – Bug 689208 in which a user faced the same exact problem under Fedora 14.

The solution is:
# yum-config-manager --disable c6-media
Loaded plugins: fastestmirror, refresh-packagekit
================================ repo: c6-media ================================
[c6-media]
bandwidth = 0
base_persistdir = /var/lib/yum/repos/i386/6
baseurl = file:///media/CentOS/,
   file:///media/cdrom/,
   file:///media/cdrecorder/
cache = 0
cachedir = /var/cache/yum/i386/6/c6-media
cost = 1000
enabled = 0
enablegroups = True
exclude =
failovermethod = priority
gpgcadir = /var/lib/yum/repos/i386/6/c6-media/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/i386/6/c6-media/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
hdrdir = /var/cache/yum/i386/6/c6-media/headers
http_caching = all
includepkgs =
keepalive = True
mdpolicy = group:primary
mediaid =
metadata_expire = 21600
metalink =
mirrorlist =
mirrorlist_expire = 86400
name = CentOS-6 - Media
password =
persistdir = /var/lib/yum/repos/i386/6/c6-media
pkgdir = /var/cache/yum/i386/6/c6-media/packages
proxy =
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 30.0
username =


Now running yum update works as expected:
# yum update
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: ftp.dei.uc.pt
 * extras: ftp.dei.uc.pt
 * updates: ftp.dei.uc.pt
Setting up Update Process
No Packages marked for Update


Success ;)

Sunday, March 25, 2012

Tip: Improve NVIDIA driver performance on FreeBSD

When my desktop northbridge fan died I stopped both playing Enemy Territory and using FreeBSD to do so. I've recently replaced the northbridge cooling and went back to install FreeBSD, NVIDIA drivers for the graphics card and Enemy Territory.

I use the same demo file to benchmark Enemy Territory since 2003 and imagine my surprise as I score 33 FPS when I usually achieved ~100 FPS on the same exact setup under FreeBSD.

With X11 running I dropped to the ttyv0 and saw a suspicious message "NVRM: detected agp.ko, aborting NVIDIA AGP setup".

I suspected that FreeBSD AGP module agp.ko wasn't playing nice with NVIDIA's AGP module.

So I went back to my post on configuring NVIDIA driver on FreeBSD and read NVIDIA README /usr/local/share/doc/NVIDIA_GLX-1.0/README that is installed with the port.

Adding hint.agp.0.disabled="1" to /boot/device.hints and Option "NvAGP" "1" under the Device section of /etc/X11/xorg.conf fixed the problem.

Upon rebooting and running the benchmark again I scored 98,3 FPS which is close to 3x the score without NVIDIA's AGP module!

The solution was in both my old post and NVIDIA's README file all along ;)

Sunday, March 18, 2012

HowTo: Enabling Broadcom BCM4318 wireless on Linux Mint

After a HDD failure my wife asked for a Linux distribution (!) for her old HP dv5000 laptop. I picked Linux Mint due to its multimedia friendliness and restricted firmware support.

Funny enough it didn't attach a driver to the wireless chipset nor offered one through the restricted firmware pop-up.

lspci allowed me to identify the chipset, a Broadcom BCM4318 wireless device:

$ sudo lspci
00:00.0 Host bridge: ATI Technologies Inc RS480 Host Bridge (rev 01)
00:01.0 PCI bridge: ATI Technologies Inc RS480 PCI Bridge
00:05.0 PCI bridge: ATI Technologies Inc RS480 PCI Bridge
00:13.0 USB Controller: ATI Technologies Inc IXP SB400 USB Host Controller
00:13.1 USB Controller: ATI Technologies Inc IXP SB400 USB Host Controller
00:13.2 USB Controller: ATI Technologies Inc IXP SB400 USB2 Host Controller
00:14.0 SMBus: ATI Technologies Inc IXP SB400 SMBus Controller (rev 11)
00:14.1 IDE interface: ATI Technologies Inc IXP SB400 IDE Controller
00:14.3 ISA bridge: ATI Technologies Inc IXP SB400 PCI-ISA Bridge
00:14.4 PCI bridge: ATI Technologies Inc IXP SB400 PCI-PCI Bridge
00:14.5 Multimedia audio controller: ATI Technologies Inc IXP SB400 AC'97 Audio Controller (rev 02)
00:14.6 Modem: ATI Technologies Inc SB400 AC'97 Modem Controller (rev 02)
00:18.0 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration
00:18.1 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Address Map
00:18.2 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Miscellaneous Control
01:05.0 VGA compatible controller: ATI Technologies Inc Radeon XPRESS 200M 5955 (PCIE)
06:02.0 Network controller: Broadcom Corporation BCM4318 [AirForce 54g] 802.11a/b/g PCI Express Transceiver (rev 02)
06:04.0 CardBus bridge: Texas Instruments PCIxx21/x515 Cardbus Controller
06:04.2 FireWire (IEEE 1394): Texas Instruments OHCI Compliant IEEE 1394 Host Controller
06:04.3 Mass storage controller: Texas Instruments PCIxx21 Integrated FlashMedia Controller
06:04.4 SD Host controller: Texas Instruments PCI6411/6421/6611/6621/7411/7421/7611/7621 Secure Digital Controller
06:06.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)

To fix the problem run the following commands:
$ sudo apt-get install b43-fwcutter
$ wget http://mirror2.openwrt.org/sources/broadcom-wl-4.150.10.5.tar.bz2
$ tar xf broadcom-wl-4.150.10.5.tar.bz2
$ cd broadcom-wl-4.150.10.5/driver/
$ sudo b43-fwcutter -w /lib/firmware/ wl_apsta_mimo.o
$ sudo modprobe b43
$ sudo echo "b43" >> /etc/modules

With this we've installed the proper driver and added it at boot time.

Bottom line: there's so much a pretty GUI can do ;)

Tip: Fix Enemy Territory empty server list

Ever since my desktop's northbridge fan died I stopped playing Enemy Territory. Luckily I've finally replaced the fan so fired ET up and noticed that no server was listed.

It seems that as of late the Enemy Territory's masterlist is down. As a workaround edit the hosts file and add a new masterlist provided by etmaster.net.

In FreeBSD and Linux distributions, run the following command:
# echo "91.220.53.73 etmaster.idsoftware.com" >> /etc/hosts

Fire up ET as a new list of servers will be available.

Major thanks Paul at the Splash Damage forums for providing a solution ;)

HowTo: nForce2 sound on FreeBSD

I finally got around to replace the northbridge fan of my ABIT AN-7 powered desktop and with it boot its old FreeBSD 7.4-STABLE install. Though I have a Creative SoundBlaster Audigy 4 I wanted to make sure I could go by with just the motherboard's nForce2 integrated sound system, so bellow I'll explain how to enable the nForce2 sound on FreeBSD.

Let's check if FreeBSD recognized and assigned a sound driver to the device:
$ cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2007061600/i386)
Installed devices:

# dmesg | grep -i audio
pci0: at device 5.0 (no driver attached)
pci0: at device 6.0 (no driver attached)

# cd /usr/ports/sysutils/pciutils ; make install clean ; rehash

# lspci | grep -i audio
00:05.0 Multimedia audio controller: nVidia Corporation nForce Audio Processing Unit (rev a2)
00:06.0 Multimedia audio controller: nVidia Corporation nForce2 AC97 Audio Controler (MCP) (rev a1)

Ok. So no sound driver is attached to the device. To use the sound device load the proper driver which in this case is snd_ich according to FreeBSD 7 Relase Notes

Let's attach the driver to the device:

# kldload snd_ich

To be sure that the sound driver was correctly loaded run:

$ cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2007061600/i386)
Installed devices:
pcm0: at io 0xb400, 0xb800 irq 22 bufsz 16384 kld snd_ich [MPSAFE] (1p:1v/1r:1v channels duplex default)

To attach the appropriate driver at boot, we need to add it to loader.conf(5) like so:
# echo 'snd_ich_load="YES"' >> /boot/loader.conf

To setup sound output levels for various audio sources and frequency ranges you can use the FreeBSD mixer. To display the current mixer values do the following:

$ mixer
Mixer vol      is currently set to  75:75
Mixer pcm      is currently set to  75:75
Mixer speaker  is currently set to  75:75
Mixer line     is currently set to  75:75
Mixer mic      is currently set to   0:0
Mixer cd       is currently set to  75:75
Mixer rec      is currently set to   0:0
Mixer igain    is currently set to   0:0
Mixer ogain    is currently set to  50:50
Mixer line1    is currently set to  75:75
Mixer phin     is currently set to   0:0
Recording source: mic

To change mixer values you can type mixer followed by the name of the device and the desired level. If you wanted to change the CD output volume to 95 percent on left channel and 85 on the right channel:

$ mixer cd 95:85

And that's it. As a side note, though I mention FreeBSD 7.4-STABLE these instructions apply to recent versions of FreeBSD, namely FreeBSD 9.0-RELEASE.

For additional information consult sound(4) and snd_ich(4) man pages.

Thursday, January 26, 2012

HowTo: Mounting NTFS partition in write mode on FreeBSD

My brother's old laptop died and I got to keep its hard-drive. Being a Windows machine, it had a bunch of NTFS partitions. So this post explains how to identify a NTFS partition, mount it as read-only and finally learn how to mount it in write mode. I should mention that FreeBSD 7.4 was used but the same steps should apply to latter versions of the OS.

Physically attached the hard-drive (in my case I plugged an USB HDD) and have a look at /var/log/messages to identify the harddrive.
% su
# tail -n 20 /var/log/messages
Jan 26 21:40:03 flumen kernel: da0: Fixed Direct Access SCSI-4 device
Jan 26 21:40:03 flumen kernel: da0: 40.000MB/s transfers
Jan 26 21:40:03 flumen kernel: da0: 114473MB (234441648 512 byte sectors: 255H 63S/T 14593C)
Similar information can be collected from dmesg.
# dmesg
umass0: on uhub4
da0 at umass-sim0 bus 0 target 0 lun 0
da0: Fixed Direct Access SCSI-4 device
da0: 40.000MB/s transfers
da0: 114473MB (234441648 512 byte sectors: 255H 63S/T 14593C)
Let's find out which is the NTFS partition:
# fdisk /dev/da0
******* Working on device /dev/da0 *******
parameters extracted from in-core disklabel are:
cylinders=14593 heads=255 sectors/track=63 (16065 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=14593 heads=255 sectors/track=63 (16065 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:

The data for partition 1 is:
sysid 18 (0x12),(Compaq diagnostics)
start 63, size 16611147 (8110 Meg), flag 0
beg: cyl 0/ head 1/ sector 1;
end: cyl 1023/ head 254/ sector 63
The data for partition 2 is:
sysid 7 (0x07),(OS/2 HPFS, NTFS, QNX-2 (16 bit) or Advanced UNIX)
start 16611210, size 117194175 (57223 Meg), flag 80 (active)
beg: cyl 1023/ head 0/ sector 1;
end: cyl 1023/ head 254/ sector 63
The data for partition 3 is:
sysid 15 (0x0f),(Extended DOS (LBA))
start 133805385, size 100631160 (49136 Meg), flag 0
beg: cyl 1023/ head 0/ sector 1;
end: cyl 1023/ head 254/ sector 63
The data for partition 4 is:
Issuing the following command will mount a NTFS partition in read-only mode:
# mount -t ntfs /dev/da0s2 /mnt/
To be able to write into a NTFS partition it is required to install the sysutils/fuse-ntfs port:
# cd /usr/ports/sysutils/fusefs-ntfs/ && make install clean
If you use, as described in the man page, mount -t ntfs-3g an error will occurr:
# mount -t ntfs-3g /dev/da0s2 /mnt/
mount: /dev/da0s2 : Operation not supported by device
To mount the NTFS partition in write mode issue:
# ntfs-3g /dev/da0s2 /mnt/
Let's make sure that the partition is mounted:
#mount
/dev/ad4s1a on / (ufs, local)
devfs on /dev (devfs, local)
/dev/ad4s1e on /tmp (ufs, local, soft-updates)
/dev/ad4s1f on /usr (ufs, local, soft-updates)
/dev/ad4s1d on /var (ufs, local, soft-updates)
/dev/ad5s1d on /mnt/1 (ufs, local, soft-updates)
/dev/fuse0 on /mnt/2 (fusefs, local, synchronous)
man ntfs-3g contains some Linuxisms and as such read the man page with a grain of salt ;)

Saturday, July 9, 2011

Tip: Fixing Atheros L2 driver attachment on FreeBSD

My personal server, a low-powered system based on an integrated motherboard ASUS I220GC, is using a D-Link DGE-528 Ethernet PCI card which runs fine on FreeBSD 7.4. However while toying with the system I decided to active the integrated Atheros L2 10/100 Ethernet device that I had disabled a long time ago.

Upon enabling the device on the BIOS and booting the system I came across an odd situation: ae(4) which is Atheros L2 driver wasn't loading properly.
# dmesg | less
Jul 8 22:07:22 flumen kernel: pci2: on pcib2
Jul 8 22:07:22 flumen kernel: pci2: at device 0.0 (no driver attached)
# pciconf -lv
none2@pci0:2:0:0: class=0x020000 card=0x82331043 chip=0x20481969 rev=0xa0 hdr=0x00
vendor = 'Attansic (Now owned by Atheros)'
device = 'Fast Ethernet 10/100 Base-T Controller (Atheros L2)'
class = network
subclass = ethernet
To fix this ae(4) driver has to be loaded and then it will attach himself to the PCI device (pci2 in my system):
# kldload -v if_ae
ae0: mem 0xdffc0000-0xdfffffff irq 17 at device 0.0 on pci2
ae0: Using MSI messages.
miibus1: on ae0
atphy0: PHY 0 on miibus1
atphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
ae0: Ethernet address: 00:1f:c6:dd:15:72
ae0: [FILTER]
Loaded if_ae, id=5
By running pciconf(8) we can confirm that the driver is now successfully attached:
# pciconf -lv
ae0@pci0:2:0:0: class=0x020000 card=0x82331043 chip=0x20481969 rev=0xa0 hdr=0x00
vendor = 'Attansic (Now owned by Atheros)'
device = 'Fast Ethernet 10/100 Base-T Controller (Atheros L2)'
class = network
subclass = ethernet
To load the driver as a module at boot time loader.conf(5) needs to be edited.
# echo 'if_ae_load="YES"' >> /boot/loader.conf
Now that the driver attachment at boot is solved rc.conf(5) needs to be edited so that FreeBSD assigns an interface to Atheros L2 device at boot:
# vim /etc/rc.conf
ifconfig_ae0="inet 192.168.1.1 netmask 255.255.255.0"
The next time the system is booted the next settings are applied and Atheros L2 is properly working (make sure you use your own network settings namely netmask and inet).

Sources:
man ae
man ifconfig
man loader.conf
man pciconf
man rc.conf