Nifty tidbits and random thoughts on technology and anything else that catches my fancy
Tag Archives: Linux
I finally got my nettop – AMD E-350 based barebones system. Installed 4G of RAM and the plan was to set it up with XBMCBuntu or XBMC-XvBA. Instead of installing the XBMC-XvBA version directly, I figured that I could start with XBMCBuntu, see how it does and then if necessary move to the XvBA enabled builds.
I don’t have a hard drive for the nettop – the plan was to have the system run off a 8Gig pen drive.
Basic Installation – XBMCBuntu
What you need
- The nettop with RAM installed.
- 2 USB pendrives – One for installation (2GB) and another which is going to act as your HDD (8G)
- Download UNetBootin for windows and the XBMCBuntu iso image
- Create a Live USB using UNetBootin: Once you have UNetBootin installed, stick in a flash drive in the usb, start UNetBootin and selec the XBMCBuntu iso image as the source distribution iso and the flash drive as the destination.
- Boot the nettop using the USB drive: You might have to play around with boot devices and priorities in the BIOS settings to get it to boot from the USB drive. To keep things simple, stick the pendrive into one of the USB2 ports (avoid the USB3)
- ON the UNetBootin boot menu, you can just try out XBMCBuntu live image. I did so and things seemed to work well enough for me to do the full install to another USB drive plugged into the system. Note that if you’re not able to find the target drive, then just reboot with both the USB drives plugged in – sometimes, newly inserted devices aren’t detected.
- Install, go through the menus and wait for it to complete.
- As you go through the menus, keep in mind to choose a custom partitioning scheme. In my case, I had 4G of RAM and there’s no sense in having a swap drive on the pen drive. If you plan on having hibernation support, then use a 2G swap partition (50% of RAM) – else you can skip the swap altogether.
- Once done, pull out the installation pen drive and reboot. You should be able to reboot off the USB pendrive that you installed into. The installation pendrive is pretty much done – you won’t need it any longer.
At this point, I had XBMCBuntu up and running however, there were a few problems:
- On idle, CPU utilization was very high (~ 60 – 70%) and the unit was running hot.
- Display resolution proved troublesome – my LCD’s native resolution is 1366×768 but that wasn’t available over HDMI.
- I was able to get 1360×768 on DVI/D-Sub – but that meant using a separate cable for audio out.
Of these, the high CPU utilization was the biggest worry – so there’s a few steps available to try
- Within XBMC – set sync to display refresh – always.
- Turn off RSS feeds
<advancedsettings> <useddsfanart>true</useddsfanart> <cputempcommand>cputemp</cputempcommand> <samba> <clienttimeout>30</clienttimeout> </samba> <network> <disableipv6>true</disableipv6> </network> <loglevel hide="false">1</loglevel> <gui> <algorithmdirtyregions>1</algorithmdirtyregions> <visualizedirtyregions>false</visualizedirtyregions> <nofliptimeout>0</nofliptimeout> </gui> <measurerefreshrate>true</measurerefreshrate> <videoextensions> <add>.dat|.DAT</add> </videoextensions> <tvshowmatching append="yes"> <!-- matches title 01/04 episode title and similar.--> <regexp>[s]?([0-9]+)[/._ ][e]?([0-9]+)</regexp> </tvshowmatching> <gputempcommand>/usr/bin/aticonfig --od-gettemperature | grep Temperature | cut -f 2 -d "-" | cut -f 1 -d "." | sed -e "s, ,," | sed 's/$/ C/'</gputempcommand> </advancedsettings>
Did those and while they dropped the CPU utilization to about 25% which was quite good. However, during videos, the CPU was still high – and that’s because even though XBMCBuntu official uses hardware acceleration through VAAPI, it still is spotty.
I went over to the XBMC-XvBA installation thread and followed the directions in the first post to add the XBMC-XvBA ppas. The download took some time and XvBA build got installed. Started XBMC and things were much, much better.
sudo apt-add-repository ppa:wsnipex/xbmc-xvba sudo apt-get update sudo apt-get install xbmc xbmc-bin
There are other tweaks that are listed on the XBMC-XvBA installation thread which I also went ahead and applied.
Optimizing Linux for a flash/pen drive installation
Installing on a pen drive /usb flash drive has its pain points. My boot time was around painfully slow (~3.5 minutes). Opening Chromium took forever and even page loads were slow (it would be stuck with the status bar on ‘checking cache’…). Also, the incessant writing to disk is probably killing off my pen drive much much faster. I ended up doing the following:
- Use the
nodiratimeflags for the USB drive
# /etc/fstab UUID=39f52ccf-363b-4b6e-abdd-927809618d83 / ext4 noatime,nodiratime,errors=remount-ro 0 1
- Use tmpfs – In memory, reduces writes to disk and is faster. With 4G of RAM, this is a no-brainer.
# /etc/fstab tmpfs /tmp tmpfs defaults,noatime,nodiratime,mode=1777 0 0
- Browsers – use profile-sync-daemon for Ubuntu from Arch Linux – will automatically move your browser profile directory from your home folder to /tmpfs
.xbmcto NAS/External drive along with your media. Makes a lot more sense to keep your .xbmc folder with your media on a external hdd.
- Change to
# Assuming sda is your USB drive sudo echo noop > /sys/block/sda/queue/scheduler
- Change system swappiness. We don’t want the OS to use swap drive at all.
# /etc/sysctl.conf vm.swappiness=1
Getting suspend/hibernate to work
I had greatest trouble here – but was able to get
pm-utils working eventually.
pm-utils is a framework of shell scripts around suspend/hibernation/wakeup that provides hooks to execute scripts before standby/hibernation and when the computer resumes from sleep/shutdown.
First test if basic suspend/hibernate works
# check suspend methods supported cat /sys/power/state # S3 sudo sh -c "echo mem > /sys/power/state"
If your system goes into standby, then things are good. But its just a good start. In my case, system would go into standby only the first time after boot. After that, it would go into standby but then resume immediately. Its been asked enough times on Google and I’ve probably tried all the fixes. The first one is to update a kernel param
# /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_enforce_resources=lax"
After that, make sure to run
In my case, the magic incantation above failed (your mileage might vary). Nothing bad happened so I kept it on. Anyway, so I rebooted, then suspended and resumed the first time (which works) and took a dump of
dmesg > dmesg.1.log. After that again tried to suspend and when it came back immediately, I could get a dmesg output and scan the entries after the first run. Turned out that the log had entries related to xhci_hcd – so decided to unload it first and then try to suspend:
sudo modprobe -r xhci_hcd sudo sh -c "echo mem > /sys/power/state"
After this, the system was able to standby each and every time. Now it was time to get pm-utils working. Out of the box, pm-utils came with a config that had a bunch of things that I didn’t understand (and I doubt they applied to this machine). If standby was working directly, then it should have worked through pm-utils. However, it needed some amount of pushing around before that comes around to a functional state.
pm-utils to play nice
So now that I had confirmed suspend working, it was time to see why
pm-utils was being so bad. First off, time to clean up the default configuration. So copied
/etc/pm/config.d/config and then start editing it
SLEEP_MODULE="kernel" # These variables will be handled specially when we load files in # /etc/pm/config.d. # Multiple declarations of these environment variables will result in # their contents being concatenated instead of being overwritten. # If you need to unload any modules to suspend/resume, add them here. SUSPEND_MODULES="xhci_hcd" # If you want to keep hooks from running, add their names here. HOOK_BLACKLIST="99_fglrx 99lirc-resume novatel_3g_suspend"
Waking up with the keyboard
if you’d like wake up with a usb device (usb keybd), then you need to find out the usb port where your device is connected. The easiest way might be to check dmesg output which would usually print this out. In my case, my wireless keyboard/trackball are connected on USB3
echo USB3 > /sys/proc/acpi echo enabled > /sys/proc/devices/usb3/power/wakeup
After that, the HTPC could be woken up with a keypress. Now I haven’t been able to find a way to do the same thing with only the keyboard (so that the system doesn’t wake up anytime anyone picks up the keyboard – so for now, have turned this off). The above change won’t persist over a reboot – so to make it persistent, put the two lines above to
/etc/rc.local before the
fglrx annoyances (ATI binary driver)
Not much point of a HTPC if the video isn’t top quality. And there are a lot of variables involved there – your computer hardware, software, drivers, type of connection (HDMI/DVI) and the telly itself. Also, video driver support on Linux for ATI leaves quite a bit to be desired. One of the reasons of going with XBMCBuntu was knowing that there’ll be large community support available on ubuntuforums.
Right off the bat, things started at the mildly irritating level. Catalyst control center in root mode won’t start even though there’s a big fat menu item there. Quick google and it says that the easiest way out is to use
gksu amdcccle in the run dialog (ALT-F2).
Full HD resolution
My telly (Panasonic 32″) came with a native resolution of 1360×768 – was pleasantly surprised when I found that with a HDMI connection it would let me go up to 1920×1080. Interestingly, even the telly on screen menu reports full HD resolution – so I’m not really sure if they did put a full HD panel and report it as 720p normally. In any case, I’m not complaining and Full HD videos do look better
So where does all this get us
After all this, it makes a sea change in the overall experience:
- XBMC idles at 15 – 20% cpu utilization. During video playback, stil stays at a comfy 40% – 50% while playing 720p/1080p videos
- Browsers (Chrome and FF) open near instantly; browsing experience is better than my desktop and page loads, tab switches etc feel much nimbler than on my desktop (AMD 6 core, 12G monster running Win 7×64)
- Total cost – USD 180
More to come
- Hibernation support
- Scheduled wake up from shutdown/hibernate/suspend state
So this is a continuation to my last post on my effort to upgrade the media center at home. While I wait for hardware to come, I’ve been reading up through forums and blogs online and am finding it real hard to get some good advice. So, thought it might help to list down concisely the situation as it stands currently, in the hope that it will server other folks who’re trying to find similar answers.
So what’s the fuss all about?
Getting XBMC on Linux with AMD fusion APUs to work nicely and render hardware accelerated video. Also, while we’re at it, also do it by booting off a pendrive (ie hdd less system)
To get hardware accelerated video on ATI/AMD hardware on Linux, currently, there are two choices
- XvBA – this is AMD’s graphic APIs (similar to VDPAU on nVidia). Not very well supported.
- VAAPI – this is intels APIs. XBMC Eden is said to work well with VAAPI.
- Open source Linux drivers for ATI chips lag behind the closed source ATI proprietary drivers. For HD video, you’re pretty much limited to using ATI’s proprietary drivers. So, let’s emphasize – from now on, driver means ATI Catalyst for Linux
OpenElec is covered in the earlier post – but essentially you have a Fusion optimized micro builds that can run off an SD card/flash drive. From a video perspective, this should be identical to XBMCBuntu. The upside is that everything is pre-configured while the downside is that it’s pretty limited.
Also covered in my previous post – lightweight Ubuntu based distro/LiveCD. XBMC Eden implements VAAPI and Catalyst Fusion APUs drivers can be used asa backend with these and provide hardware accelerated video. There are some cases where this bridging doesn’t/may not work well. On the other hand, since this is the officially supported method, its going to be around and improved upon, and likely to have more info available in public domain etc.
XBMC-XvBA PVR builds
So this is an unofficial build by the community. THe promise is that instead of going the VAAPI route, this has direct support for XvBA api so, offes better performance. The forum thread tracking this is available here. While the build is supposed to be quite usable, from the thread activity, it seems its also heavily under development.The goal is to merge this back to the mainline once it stabilizes.
I plan to go the path of least resistance – OpenElec, then XBMC-XvBA and finally settle on XBMCBuntu – but things might change once I actually get down to it.
Time for the big fat disclaimer – Nothing in this post is guaranteed to be correct. this is my read of stuff on the net and it could be wrong. You’re welcome to correct it in the comments and I’d be more than happy to fix the post.
So my last weekend project had been to compile Android ICS from source. Given that the size of the repo itself is in excess of 6Gigs, just getting it down itself took the better part of Friday night and Saturday night. When I got down to running make on it, it was Sunday afternoon.
Needless to say, things didn’t work too well. I’m running this on a 32 bit Ubuntu 10.04 Virtualbox with a piddly 1GB RAM. When
make failed the first time, realized that swap was a measly 300Mb. First steps first, went on to increase memory to 2GB (that’s all I can spare) and increased swap to 2Gs.
Compilation next round started and that failed too – ran out of disk space – and this was Sunday night. Things kind of stayed there and finally this evening, resized the disk in virtualbox to 50Gigs. Again started the compilation and this time ran into linker errors when building webcore. One more round of troubleshooting involved deleting the previously built static library and then running make again. Surprisingly, this time make completed successfully – to the point where I wasn’t sure if it had succeeded or just failed silently on something else.
The next step was to run the emulator to see if it really would boot up. Over at source.android.com, they oversimplify it when they say that you just run
emulator from the android root folder. That didn’t work for me – and this time it was because I hadn’t sourced the envSetup.sh file… this thread http://groups.google.com/group/android-platform/browse_thread/thread/91ff18e034acf951 helped in tracking that one down.
So finally, after all that trouble, I have my very own ICS build running!!!!
For now, its onward ahoy to setting up Eclipse and starting with a fix I’ve been mulling about for sometime now..
Signing off from cloud nine
For machines to be accessible on the internet, usually you need a static IP that’s leased from your ISP so that when someone types in your IP address, so that packets can be routed over to your machine. However, getting a static ip is costly and for the most part, internet users have dynamic IP address that the ISP allocates each time an end user connects to the internet. Since the ip address keeps changing on each connection, there’s no straightforward way to connect to the machine without knowing the IP address that’s been allocated – or so it was at least till Dynamic DNS came along (it isnt new – has been around for ages, but for some reason isn’t that well known)
Typically, when you type in http://www.google.com in your browser, your machine performs a DNS (Domain name service) lookup with the DNS servers from your ISP to find out the IP address corresponding to http://www.google.com. With DDNS (dynamic DNS) this is made to work with your dynamically allocated IP address also. Here’s how it works
- Register with a DDNS service provider. Service provider provide free accounts for personal use – go to www.dyndns.org
- Once you’ve created your account, go ahead and set up your hostname. DDNS service providers will have some domains that you can choose from and you get to choose the host part. For a fee, you can also use a domain name of your choice.
- If your set up has a router at your end, check your router administration page if it supports dynamic DNS. If it does, you need to enter the hostname, account and password. Everytime your router connects to the internet, it sends an update notification to the DDNS service notifying the new IP obtained from your ISP. The DDNS service takes care of sending update notifications to routers on the internet.
- If you dont have a router, then download the DDNS client software from the service provider. Most DDNS providers have windows, mac and linux clients. These run on your machine and do the same thing – notify the DDNS service provider of your new IP whenever you establish a connection with your ISP.
- If you’ve got all this set up, then you can reach your machine from the net – try ping <your host name>
If you’re running Linux/Ubuntu, make sure your’re running SSH service and try ssh <your host name>. If you have a router setup, then you will need an additional step – basically the DDNS name refers to your router IP – and not the machine behind the router that you wish to reach. You will also need to make sure that your machine has a static IP from your router. To set up your router, go to your router administration page.
- Go to the LAN section and give a range of IPs outside of the static IP. Most routers have lan addresses like 192.168.x.y – 192.168.x.z. If you want your host to have an IP address of 192.168.1.100, then give a LAN range that does not include this IP – say 192.168.1.110 – 192.168.1.200.
- Save and reboot your router.
- Now go to your network settings and enter your static IP (192.168.1.100), netmask 255.255.255.255, gateway (usually 192.168.1.1).
- Go to your router administration page and look for a section like virtual server – your router will allow you to forward packets received on a particular port to a host and port within your LAN. You will have to enter the external port (we’ll use 22), the internal machine to forward (192.168.1.100) and the port to forward to (22). With this in place, any packets received on port 22 (ssh) on your router will be forwarded to the 192.168.1.100 machine on the ssh port.
- Save and reboot your router.
- Give it a spin.
From a different machine (or from the same one -doesnt matter), try out ssh <your host> and you should be able to login to your machine – via the internet.