Category: Machine

Technology stream. IT and other technical aritcles.

  • So, CM7 it is! (My “almost” pure OSS android)

    After some struggling and readjustment I have finally embraced CM7 as my main OS giving up on Edge* games (too fast :-S). I have found quite a few replacements for missing apps, camera is fully functional, and my phone is filled with OSS goodness from OS up thanks to Cyanogen and FDroid crowds.

    • I have started off with Unofficial Nightlies
    • Then I built my own
    • Then I’ve added user apps:
      • Added Alarm Klock as my alarm clock
        • Downloaded alarm-specific music instead of default rings
      • “Stopwatch” + “StopWatch & Timer”
      • Vanilla Music
      • Zirco browser

    For now it’s nightlies for me until final 7.2 comes out.

  • Working towards using CM7/CM9 on SGS2

    Considering my last mis-adventure with CM7 I figured it’s time to take proactive steps. Either take an app that has “close” functionality and tweak it, or just get used to it.

    What I’m going to do is pile some resources to use as a launchpad… here we go:

    2012-03-16

    Got a bootloop today trying out GingerMod ugh…Flashed 0.8 fine… found that things were missing largely (it’s even more spartan then CM7 IMO), bumped to 0.8.5 – and kaboom! Thank $DIETY for CWM (DIETY=chainfire?)! Restored back without having to resort to “[READ THIS] Got a Boot Loop? Don’t post a New Thread!”

    CM7 is still a no-go due to massive deficiencies in the categories I do care about (Camera being one of them). I really want to get CM7 to work though…

     

  • CM7 on SGS2

    My SGS2 decided to test my patience and alertness all at the same time – 2 days ago it decided to “lose” some of the data on the internal storage (WTF?) followed by wiping contents of SD card. That has happened just as I was trying to download some files *from* the device, and upload some back. I have received messages about I/O errors etc which were not very promising.

    Now, I’ve been using Cognition-1.5.1 for quite some time now (which is stock ROM with some tweaks really) however in my situation I was looking for more control over the device and desire to run fsck against internal storage etc. Considering I’ve lost most of my data (by a lucky stike of luck I did have a backup that is 2 weeks old) I decided to bite the bulet and go for Cyanogen. Long research and questioning of my motives resulted in CM7 being installed on my SGS2.

    Things I liked

    • WiFi drivers: I’ve got solid WiFi performance with CM7 unlike stock ROM I speeds were amaizing
    • Number of tweaks and presence of “profiles”
    • UI is nice and clean. Looks like ADWLauncher settings are better polished than what I have in Cognition…
    • very spartan ROM. Bare minimum to get by, as it should be, except…

    Things I miss/didn’t like

    immediately after I’ve booted into CM7 I have noticed that I’m attached to certain things:

    • Clock: I really use that Samsung stock clock to it’s fullest – Alarm, Timer, Stopwatch, etc. CM7 stock clock pales in comparison… pitty
    • Video playback: I had to show movies to some people that day and all “recommended” players from Market would stutter after a minute or two of playback which was embarasing…
      • I couldn’t find the list of supported formats/codecs for CM7 to convert to that my videos… ugh…
    • Default system font change – I’m too used to my current font in Cognition and would like to keep it
    • SMS application looked rather “dull”. Not sure if it’s not just a different interface but it felt like it was missing features
    • It CRASHED on me while using Market… saw something in MIUI forums about insufficient disk space for larger applications – maybe that’s the cause?

    Things I should try/may be able to fix

    • clock: Lightning Bug, Alarm Droid could probably replace Stock Alarm clock… haven’t found the rest yet
    • sounds like some Video players can switch between HW/SW decoding so switching to SW decode may help my problem with stuttering. May also try different format/codec combination
    • MIUI is a custom ROM atop of CM it sounds
    • CM9 may be able to bring some goodness as well
    • AOSP-based ROMS
    • INDEX – Galaxy S II Original Android Development [ 5 March ]

     Where I’m at

    At the moment I have returned to Congition-1.5.1 (sigh..) I am looking at CM9 now, except it’s an “alpha” and hoping that imminent release of ICS for SGS2 by Samsung will yield source code dump which may speed up CM9 development (or not).

  • Installing VMs from USB iso with SELinux

    Today I’ve attempted installing Fedora VM from the image on USB and got some unpleasant messages in virt-install:

    2012-02-24 20:24:06.582+0000: 1329: error : qemuProcessReadLogOutput:969 : internal error Process exited while reading console log output: char device redirected to /dev/pts/4
    qemu-kvm: -drive file=/media/3D2B-FFC6/iso/Fedora-16-x86_64-netinst.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw: could not open disk image /media/3D2B-FFC6/iso/Fedora-16-x86_64-netinst.iso: Permission denied

    Digging for the truth took me a while. In the meantime I have attempted “logical” solution:

    mount -o context=system_u:object_r:virt_image_t:s0 /dev/sdb1 /var/lib/libvirt/images

    Which turned out to be wrong as installer would still fail, this time leaving message in /var/log/messages:

    Feb 24 13:46:18 dimon2 kernel: [87065.769543] type=1400 audit(1330116378.901:4): avc: denied { read } for pid=1287 3 comm=”qemu-kvm” name=”Fedora-16-x86_64-netinst.iso” dev=sdb1 ino=116 scontext=system_u:system_r:svirt_t:s0:c130,c52 7 tcontext=system_u:object_r:virt_image_t:s0 tclass=file

    So I came across a bug in RH bugzilla that helped with the solution:

    mount -o context=system_u:object_r:svirt_image_t:s0 /dev/sdb1 /var/lib/libvirt/images

    Note the tiny difference – using “svirt_image_t” vs “virt_image_t”. Unpleasant but I can live with that… It also means I have to mount USB devices manually to be able to use them as a source for VM images… but that is OK.

  • Remote Backups with rsync

    Having sites hosted externally with limited access I still needed backups. And I wanted them to be as secure as I can possibly make them. And that’s where “Using Rsync and SSH” came in handy. This is the approach I used previously, prior to my Firewall crashing. It allows me to lock down backup account so that all it does is backup, via the validation script on “backup host” and using SSH key pair on both “backup host” and “backup slave”.

  • Building Linux Home Theater box

    Hardware

    First Note: this build was not about “cheap”. This is all about “building my own”, “small” and “quiet”, “cheap” comes as a last criteria.

    SilentPCReview gave me some really valuable information on how to get things together with this case. Most importantly – to get 120mm case fan. I experimented with 80mm and got temperatures inside the case dropping from ~80C down to ~60C which prompted me to go that extra mile and get 120mm fan – Noctua NF-S12B turned out to be one valuable addition – with varied settings 1200/900/600 RPM it allowed me to be the judge of what’s acceptable, and I ended up using 900RPM setting as it was much quieter than 1200RPM yet provided plenty of airflow. I ended up pointing it outward (i.e. sucking air out of the case vs sucking it in). Such positioning allows you to suck cool air directly towards CPU drawing hot air towards PSU fan and the Case Fan allowing for better temperature management as far as I can tell. Temperatures seem to be in comfortable ~50C zone so no unpleasant noise so far (well, we’ll wait for movies to warm things up).

    My plan B includes underclocking CPU and GPU if temperatures get too high. Core i3 is more than enough for movie-watching/internet browsing so I’m not too worried about effects of underclocking.

    Software

    Pre-building in VM

    This one needs to be quiet and not to burn holes in SSD and be fairly minimalistic, so I’m building it from Fedora 16 Install DVD starting with “minimal” setup and building up to something I can accept. After building the box as a VM (with Spice graphics) – image of an SSD that we’re about to use, and installing base OS first tweak is to get rid of all unnecessary writes via noatime, and tmpfs:

    # cat /etc/fstab
    /dev/sda1  /                       ext4    discard,noatime,data=writeback        1 1
    none /tmp tmpfs defaults 0 0

    Now we need some packages for X Windows:

    # yum groupinstall “X Window System” LXDE

    That should give us nice base. However if you try to launch graphical interface:

    # systemctl start graphical.target

    you get no fonts and lots of squares on the screen. I fixed that with a “hammer”:

    # yum install xorg-x11-fonts\*
    # yum install liberation\*

    after that we can start up Xorg – no problem.

    Now some apps and more convenience:

    # rpm -Uvh http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm
    # rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
    # yum install flash-plugin
    # yum install libdvdread libdvdnav lsdvd
    # yum install mplayer mplayer-gui smplayer
    # rpm -Uvh http://rpm.livna.org/livna-release.rpm
    # yum install libdvdcss
    # yum install vlc
    # yum install xine-lib xine-lib-extras xine-lib-extras-freeworld xine-ui xine-ui-skins gxine minitube
    # yum install firefox

    And all this goodness in 1.5G – not bad. We’ve got Flash, Firefox, XBMC, Mplayer, VLC and Xine – almost ready to bust some movies 🙂

    All we need now is to boot into XBMC by default to avoid all the complexities of a “typical boot” on this over-simplified machine:

    # useradd -m -g users -G audio,video -s /bin/bash xbmc
    # passwd xbmc
    # cat > /etc/lxdm/lxdm.conf
    [base]
    session=/usr/bin/xbmc-standalone
    greeter=/usr/libexec/lxdm-greeter-gtk
    autologin=xbmc

    [server]
    arg=/usr/bin/X -background vt1

    [display]
    gtk_theme=Clearlooks
    bg=/usr/share/backgrounds/default.png
    bottom_pane=1
    lang=1
    theme=Industrial

    [input]

    [userlist]
    disable=0
    white=
    black=
    ^D

    Notes on above: we’ve created xbmc user, set his password. And made default action for lxdm to login xbmc user using xbmc-standalone shell. Almost there…
    Now some graphical goodness for package management in case we need it:

    # yum install yumex

    After that VM can be shut down and we’re transfering our image over to CompactFlash card connected via CardReader:

    homePC # virsh shutdown htpc
    homePC # dd if=htpc.img of=/dev/sdf

    Note that above is done from my “normal PC” rather than from within VM itself.

    Tuning of the real thing

    Now whenever I plug My CF-to-SATA kit into Zotac H-55 I’m getting system that hangs for a while, and then… doesn’t see new disk. Bummer. Fall-back – 4G USB stick.

    now I’ve got USB stick ready and found out I’m missing NetworkManager, d’oh!

    First thing that hit me – difference in size of CF and USB stick. F16 uses GPT, and bitterly complains about broken FS etc. etc. etc. so… fixing is possible only via parted:

    htpc # parted
    (parted) print all
    …

    after which it asks you whether you want to fix various issues and the answer is “yes”

    # yum install NetworkManager NetworkManager-gtk NetworkManager-gnome

    However after that I’ve got the unpleasant

    $ nm-connection-editor

    ** (nm-connection-editor:10500): WARNING **: Icon nm-device-wired missing: Icon ‘nm-device-wired’ not present in theme

    ** (nm-connection-editor:10500): WARNING **: Failed to initialize the UI, exiting…

    which was fixed by

    # yum install gnome-icon-theme-legacy

    but even then I’ve got:

    ** (nm-connection-editor:10500): WARNING **: Icon nm-device-wwan missing: Icon ‘nm-device-wwan’ not present in theme

    I have resorted to a hack – symlinked some instances of nm-device-wired.png to nm-device-wwan.png and even that didn’t help!

    # yum install lxde-icon-theme

    while that made LXDE look less “rough” it didn’t fix the issue. Argh!
    Final attempt was to install whatever pieces of NetworkManager missing:

    # yum install NetworkManager-{openconnect,openvpn,openswan,pptp,vpnc}

    and that has finally resolved the issues of missing icons, g’ah!

    Things to do

    • add Autofs mounting of NAS shares with pictures/movies

     

  • On SSD-based builds

    As I was making my way through FreeBSD reinstall on CF I was also working on Linux-based Home Media Centre with as few moving parts as possible, yes and it includes SSD. So I started snooping around to get similar tweaks to FreeBSD ones, and surprisingly those are the same – use “noatime” and mount needed partitions as tmpfs:

    # grep tmpfs /etc/fstab
    none /tmp tmpfs defaults 0 0

    As I will be making my way through that build I’ll try to document it bit better.

  • On usefulness of backups, crashing Soekris boxes and other FreeBSD curiosities

    Just to get this out of the way: I am my worst enemy, and there’s no excuse why I didn’t set up backups of my FreeBSD firewall long time ago.

    My firewall crashed in the most hurtful way – HDD (Seagate Momentus – I really hate them now, it’s a second one out of two to die in my possession) and I had to scramble trying to recover from this. Luckily I had my previous firewall incarnation laying around (old PC) with some PF rules and other gadgetry on it, so at least I haven’t had to start from scratch.

    Considering that I had problems on the Soekris box[es] for a while now: using HDD I could not compile anything on that machine getting Signal 11 crashes mid-air. This time I decided to get CF build going, esp. considering that I did have one Soekris box functioning as a bridge in my living room and running off CF with no problems whatsoever. What did I do? I dusted off that box, took that same CF, and installed brand-new FreeBSD-9 on it.

    First iteration

    I have almost infinite number of ageing PC’s laying around, so I just downloaded FreeBSD CD, plugged it into the diskless PC with CF plugged via card reader and installed FreeBSD “the normal way”. Then configured all of the Console goodness required for Soekris access:

    # cat /boot/loader.conf
    comconsole_speed=”9600″
    console=”comconsole”
    # grep ttyu0 /etc/ttys
    ttyu0   “/usr/libexec/getty std.9600”   vt100   on secure

    added some CF-specific tweaks (like md-based /var/log and /tmp):

    # grep mfs /etc/fstab
    md              /tmp            mfs     rw,-s32M,noatime        0       0
    md              /var/log        mfs     rw,-s64M,noatime       0       0

    and mounting the rest with “noatime” I was ready to enjoy life… when box crashed again. It just went into the neverending boot loop – it would boot up to the WiFi card initialization and reboot itself. After letting it “cool down” for 30-40min it’s bootable again, but not for long, thus suspicion that we’re dealing with overheating someplace.

    OK, so I have some DOM’s laying around.

    Second iteration

    Installing on DOM was not as convenient as CF since I had no header on the MotherBoard to hook it into, thus I was left with the only option of PXE booting, for which I lost all the tools and didn’t feel like building them up again. So I bootstrapped myself from already created CF. After cooling system down enough I booted it up with both CF and DOM installed. Then I had to partition and populate DOM, and that’s what almost killed this project – I couldn’t boot from DOM as I wasn’t initializing that disk properly. So I have done some more reading and got to this:

    #fdisk -BI da1 #Initialize your new disk
    #bsdlabel -B -w da1s1 auto #Label it.
    #bsdlabel -e da1s1 # Edit the bsdlabel just created and add any partitions.

    where “fdisk -B da1” and “bsdlable -B da1s1” are instrumental in achieving any level of success. Now my DOM boots… sort of.

    Future plan

    I may get tired of all this and just go with pfSense instead as it could be my doing that is breaking things…

    Some links

     

  • Fedora 16 renaming mdraid disks and grub2 woes

    Dealing with constant mdraid device renames that F16 DVD (just like F15 did before it) performs and bugs and oddities of grub2 I’ve decided to rename md devices back to what I created and documented them as. While mdadm docs are quite terse, fellow sysadmin came to the rescue:

    # mdadm –assemble /dev/md3  /dev/sd[abcdefghijk]3

    given how old my mdraid devices were I had to resort to the oldest syntax possible to get things going.

    In the meantime Grub2 decided to go crazy on me (boy, it does remind me LILO in it’s old days). So here’s quick problem-solution combo.

    Problem

    Since I’ve installed F16 rescue mode renamed /dev/md* devices several times. ugh! Apparently grub2 capability to boot from mdraid devices is not mature enough (or the ways Fedora scripts using it are immature…) to get initial setup. Well, /boot/grub2/grub.cfg can be made to have no reference to real devices – no problem, BUT! Apparently Grub2 stashes someplace /boot’s device name when you perform grub2 install!

    Solution

    solution is to boot into Fedora DVD’s rescue mode and before allowing it to locate all the disks switch to console 2 (Alt-F2) and:

    1. rename all md* devices to what they should be via above trick:

    # mdadm –stop /dev/md123
    # mdadm –assemble /dev/md2 /dev/sd[ac]2

    note how we shut down renamed device md123 and bring it back up as md2 – further inspection via

     # mdadm –examine /dev/sda2 | grep Minor
    Preferred Minor : 2

    confirms that now stored minor has changed.

    2. switch back to Fedora’s rescue screen on console 1 (Alt-F1) and let it look for the installed instance.

    3. Now select instance and get into the shell.

    4. do the advised:

    # chroot /mnt/system

    5. make darn sure you record your new MD numbers in /etc/mdadm.conf, one way is to walk through the member devices and do:

    # mdadm –examine –scan /dev/sda2 >> /etc/mdadm.conf

    6. massage /etc/mdadm.conf into something like:

    MAILADDR root
    # AUTO +imsm +1.x -all
    DEVICE /dev/sda*
    DEVICE /dev/sdc*

    ARRAY /dev/md2 level=raid1 num-devices=2 UUID=xxxf82e4:6xxxxa0d0:44xxx7c0xxxxa021

    7. now we need to firm this up and cut initramfs for it (this will include our new /etc/mdadm.conf). Make sure  /etc/dracut.conf has line with  mdadmconf=”yes” uncommented, then run:

    # dracut -f /boot/initramfs-$(uname -r).img $(uname -r)

    8. finally we need to make sure grub2 is on board for this:

    # grub2-install /dev/sdc

    # grub2-install /dev/sda

    9. just to be sure re-generate grub.cfg:

    grub2-mkconfig -o /boot/grub2/grub.cfg

    10. we’re done.

  • Easy way to mount CIFS in (Fedora) linux via autofs

    after struggling with HOWTO Forge’s recipe and Fedora’s modification of the same recipe, CentOS provides some helpful info on how to set things up the easy way:

    # yum install autofs cifs-utils
    # mkdir /mnt/smb

    Add this line to /etc/auto.master:

     

    /mnt/smb /etc/auto.smb.top

    Create /etc/auto.smb.top as:

     

    * -fstype=autofs,-Dhost=& file:/etc/auto.smb.sub

    Create /etc/auto.smb.sub as (adjust as needed):

     

    * -fstype=cifs,credentials=/root/secret.txt,uid=500,gid=100 ://${host}/&

    Now you can access by simply typing:

     

    # cd /mnt/smb/winbox/getme