Saturday, February 16, 2013

UEFI on Gentoo w/ grub2 and GPT

I did this on a new build (new hard drive) on a current slave system. So you can adapt the techniques a bit if you're doing this off a livecd or just migrating a current system.

First you'll want to download a UEFI compatible livecd ( or make your own ). I recommend SysRecueCD http://www.sysresccd.org/Download based on Gentoo. Just download the iso and burn it to a cd, then  set it aside.

You'll want to build a EFI partition either using parted or gdisk (assuming this is a clean disk, add your other partitions into this string of commands like normal):

Add this line to your make.conf (or modify for your arch needs) :


Then emerge efi/grub2:


Create the filesystem (has to be fat):

If you want to have a legacy  boot loader on this drive then I'd recommend using a directory inside of /boot ( like /boot/efi ) for the efi partition. Otherwise you can use /boot.

You'll probably want the following options enabled in your kenerl :

Compile your new kernel, then copy over your vmlinuz/bzimage to /boot :
NOTE: kernels must be in the following format for grub2 to autodetect "kernel-(version)" or "vmlinuz-(version)"

Make the config file with grub2 :


Now if you're currently booted off a UEFI medium, then great. Otherwise you need to use the sysrescuecd linked above or another medium. Reboot and check your BIOS settings. I am running a Sabertooth 990fx r2.0 and changed:

That forced the board to only boot of UEFI so I knew that the livecd wouldn't be booted in legacy/mbr mode. After you're booted off a uefi medium you can verify by looking for the directory `/sys/firmware/efi` .

If it exists you should be good. If it doesn't then you either :
A) Aren't booted right off the UEFI medium - check bios settings
B) Check livecd you're using to make sure it supports efi bootmgr and the kernel
C) modprobe efivars - if the kernel built it in as a module

You shouldn't have to worry about B or C if using the sysrescd.

Get back in your new build environment if you had to reboot

Finally install the EFI grub bootmgr :

It should tell you if it was successful. If so - reboot off your new UEFI grub2 disk!

You may want to go back into your BIOS if you enabled UEFI only mode, and put it into mix mode in case you ever want to boot off a non-uefi medium.


Saturday, February 9, 2013

mrebuild.sh - rebuild modules after a kernel update

This script is used to rebuild all third party modules after a kernel update. modules-rebuild doesn't  always pull in all the packages you need, so this gives an easy config file to specify additional modules, packages, and commands. Making the rebuild of everything necessary after a kernel update a one-liner.

  • download mrebuild.sh and put in /usr/local/bin
  • download mrebuild.conf and put in /etc/conf.d
  • view and modify mrebuild.conf if necessary
  • `mrebuild.sh --go` will kick off the rebuild process

This script can also be downloaded http://pastebin.com/BBsZGZxV

mrebuild.sh



This config file can also be downloaded http://pastebin.com/iPs7hz1e

mrebuild.conf

killwindows.sh - simple wine/windows process terminator

If you run wine apps, or do any development with it, you'll undoubtedly have the need for this. Frequently a wine process will get hung up in the background, and may prevent you from doing what you need to.


  • Download the script and put it in a bin directory. 
  • view and modify blacklist and whitelist variables ( pipe delimited )
  • killwindows.sh --list     (will show you what processes are alive, and "would be" killed)
  • killwindows.sh --kill     (will show the what processes are alive then `kill` them)


You can also download the script here : http://pastebin.com/u2a3sG55




Friday, February 8, 2013

updateworld.sh - a simple way to manage world updates

This script manages and performs world updates for the Gentoo distro. It can perform the usual sync, emerge world, revdep, etc-update, plus options to add in whatever custom commands you want. It is maintained by a central .conf file to make it easy. The goal is to either give an end-user a simple, customized, and either quiet or verbose world update experience. On top of that it can be set to run autonomously, if you have many deployed Gentoo machines and have approved a branch to update to, pushing out this one line script should make it simple. This script has bash color logging, the default location is in `/var/log/portage`.

To view the made package page : http://code.google.com/p/updateworld
You can find the latest revision of the script on the page : https://code.google.com/p/updateworld/downloads/list

You will also find a basic wiki documentation highlighting the possible features.

The tar has these two important files:

To install :
  • copy updateworld.sh to /usr/local/bin
  • copy updateworld.conf to /etc/conf.d/
  • edit updateworld.conf - should read all the notes and options available

To run a quiet full update :
  • `updateworld.sh --full`

To run a verbose update adding in keep-going and force-sync :
  • `updateworld.sh --go --verbose --keep-going --force-sync`

You can also use the --help flag if you're looking for proper syntax and options.

g13lcd.sh - a simple app to load text or images on a g13

This script gives you a simple one-liner way to display specific text or images on the g13 LCD screen.
This relies on:
    ecraven's g13 https://github.com/ecraven/g13
    netpbm http://netpbm.sourceforge.net/
    imagemagick http://www.imagemagick.org/


netpbm and imagemagick are both in Portage for Gentoo.

  • emerge -av netpbm imagemagick
  • download and `make` g13 : `git clone https://github.com/ecraven/g13`
  • copy pbm2lpbm to a bin directory like `/usr/local/bin` 

Next download and copy this `g13lcd.sh` script to a bin directory. You can also find it: http://pastebin.com/NA9xzpaH





You will need to start the g13 daemon before being able to output to the LCD. Either use the `g13` command or see previous entry about the `g13.sh` script I wrote.

Afterwards you can execute this script by either:
`g13lcd.sh --text2lcd TEXT GOES HERE` or
`g13lcd.sh --image2lcd /somedirectory/someimage.jpg`

It should be able to convert most image types to display on the screen. But it's (as of yet) a very basic script, it ignores all aspect ratio, doesn't do specific padding, etc. You'll want to make sure the image you're converting is about the  same size pretty much.

g13.sh - using a g13 daemon and load presets

Getting g13 to work on Linux is more challenging then it should be. Unfortunately I've yet to get the g15daemon to fully work on the g13 pad (key binding issues). This way relies on ecraven's g13 app: https://github.com/ecraven/g13


  1. Download it by: `git clone https://github.com/ecraven/g13`
  2. Go into the downloaded directory and `make`
  3. Copy the g13, pbm2lpbm, clock.sh (if you desire) to a bin directory like `/usr/local/bin`

You should now be able to run `g13` and get the default functionality.

You can use the following `g13.sh` script to make a nice start up script for this g13 app and have all your saved features. It can change the RGB led color of the text, the led color of the MR buttons, apply bindings, and display a startup lcd image.  You can also download it : http://pastebin.com/prrCSAbY




This script relies on two config files.

/etc/conf.d/g13.conf (http://pastebin.com/AG66eDJ5)


/etc/conf.d/g13-binder.conf (http://pastebin.com/NGtMTRqA)


Follow the notes and modify the files as you see fit. The g13-binder.conf is optional - there is a default binding in the g13 daemon, this is just if you want to customize any key mapping.

Afterwards a simple `g13.sh --start` and `g13.sh --stop` should give you the desired results.

Note: If you copied over the clock.sh, running it will keep a somewhat accurate running clock on the lcd screen, much like the default for g15daemon.

Another neat g13 app on Linux is : http://code.google.com/p/linux-g13-driver/
It certainly makes the bindings easy with a Java UI and I believe uses the same ecraven g13 daemon. However it doesn't have the other functionality easily accessible - at least I haven't played around with it enough to discover.

Check out the g13lcd.sh script, gives a simplistic way to output text or images  to the g13 lcd screen. http://customlinux.blogspot.com/2013/02/g13lcdsh-simple-app-to-load-text-or.html

Thursday, February 7, 2013

pavolume.sh - control the active sink volume for pulseaudio

If you have multiple audio output devices, and you use keyboard bindings to control the master volume -> your system may get confused which master volume you want and select the first one by default. This script finds the current default active sink and changes the volume with it.

Copy it to a bin dir like `/usr/local/bin` execute with :
  • pavolume.sh --up
  • pavolume.sh --down
  • pavolume.sh --togmute  (this will change the mute status to the opposite of what it is currently - useful for a single key that does both)
  • pavolume.sh --sync   (this will sync all of your current apps using the current active/default output to the same volume level)

In the beggining of the script you'll see four useful settings/variables :
  1. The 'osd' variable. If you want to display an OSD message when changing volume set to yes. It's setup for kde and the KOSD package - so you might have to install that.
  2. The 'inc' variable. This is the increment that each volume up/down request will preform. 5 is default.
  3. The 'capvol' variable. This will cap the max volume to 100% (since pulseaudio by default allows you to go over this limit). Defaults to 'yes'.
  4. The 'maxvol' variable. This will cap the maximum volume to another percent (capvol overrides this if set to yes). Pulse will keep increasing the volume to several thousand percent, so here you can set a much more respectable number. Defaults to '200'.
  5. The 'autosync' variable. This will automatically sync all your sink-inputs (apps) with the current volume of your output (speakers) whenever you change the volume. This is useful if you manage multiple outputs and have issues with the app volumes becoming out of sync with the output (they should move up/down together). If you like keeping apps at different volumes then you should change this to no, and maybe bind a keystroke for manual sync if you so desire.

If you wish to use kosd it's in portage for Gentoo:
  • emerge -av kosd
  • After installation you have to restart kde to get it to load. 

If you wish to remove the volume cap (IE - have your max volume over 100%) you will need to apply the following patch to kosd. If you're using Gentoo (and you probably should be), all you need to do is put this patch in the `/etc/portage/patches/kde-misc/kosd/` directory.

You can also download the maxvol.patch here : http://pastebin.com/yCgVtmUZ




  • Afterwards go to systemsettings -> Shortcuts and Gestures -> Custom Shortcuts -> Add new shortcuts bound to the commands listed above.

You can also download the script here : http://pastebin.com/ZqWt3A5q

switchaudio.sh - switching pulseaudio output

A script if you use multiple audio output devices and Pulseaudio. For instance USB  headphones and a regular internal sound card. This script makes it easy to switch between the different cards, and update any current applications to use the new output device. 

To execute just copy to a bin directory like `/usr/local/bin` and run `switchaudio.sh --next`.

You can bind this script to a key shortcut in KDE : systemsettings -> Shortcuts and Gestures

You can also find it: http://pastebin.com/a6T3ezFs