samedi 14 avril 2012

Notes about Chrome Tabs. Ctrl, Shift and multiple tabs selection.

Messing with too many opened tabs in Chrome, I'm missing Firefox Tab Groups / Panorama. Just to bitch about Chrome I start shift-clicking tabs .. when they actually start to move together.  


It actually does what you'd expect:
  • Maintain SHIFT, click on two tabs, they're now a selected tab interval.
  • Maintain CTRL, click on many tabs, they're now a selected tab set.
The selection can be moved around in the tab bar, onto another window, or out to a new one. If you fiddle with a sparse tab set, the tabs will group together. It lacks a bit of user feedback, but beside that it does what you'd expect.

note: I run Chrome '20.0.1100.0 canary' on Windows XP.

Can't find any documentation about it, don't know if it's new or not.. but it's sure cute.


Edit: Tab Selection is really thought through. Operations allowed also include : 

  • pinning
  • closing* selection
  • closing* all but selection

(*) close a group isn't directly undo-able, Ctrl-Shift-T will re-open one at a time. nothing too bad.


And it's actually one year old. 'multiple tabs selection' or 'multiselect tabs'. cf these :
http://exde601e.blogspot.fr/2011/03/multiple-tab-selection-in-google-chrome.html
http://lifehacker.com/5791787/select-multiple-chrome-tabs-by-domain-or-history
http://www.thechromesource.com/tag/multiselect-chrome-tabs/
http://src.chromium.org/viewvc/chrome?view=rev&revision=78884


There's more: you can also select by domain or by opener.

vendredi 13 avril 2012

LFS : hard drive partition as virtual vmdk drive in Virtual Box 4.1.12

I built LFS on a usb key, Kubuntu as a host. To run it I have to `halt` and then boot the usb key. I wanted to see how it runs on bare metal sort of. But now I want to tinker the system so I tried to see what virtualbox can offert. Turns out they support that (virtualbox do a lot of things, dhcp, port forward, you name it).

version used: 
Virtual Box, `VBoxManager --version` => 4.1.12r77245
Kubuntu 12.04b2 ~ 13/04/2012

1) create the vmdk file that represent your real partition:
VBoxManage internalcommands createrawvmdk -filename $path/$name.vmdk -rawdisk /dev/$disk -partitions $partition-number


for my needs it turned out like this:
VBoxManage internalcommands createrawvmdk -filename /home/foobar/VM/lfs.vmdk -rawdisk /dev/sdc -partitions 1


1.5) There's a permission issue, it seems that /dev/sda is only accessible for root, and forbids virtualbox to load the vmdk that points to /dev/sda2. For now run virtualbox as root. Maybe `chown` and `chmod` can correct the problem. I may try that later.


2) create a virtual machine, choose 'use an existing disk' and points to the vmdk. There might be another vmdk beside (name contains '-pt', partition tables ?? maybe), ignore it.


3) adjust the drives

When I boot the usb key on my laptop, remember:
- the lfs system is stored on partition 2 (counting from 1)
- For grub, the internal sata drives is hd0, the usb key is hd1 => grub run `linux (hd1,2)/boot/vmlinuz root=...`
- For linux kernel, the internal sata drives gets 'sda', the usb key gets 'sdb'. => we have to be sure to pass /dev/sdb2 as root for the kernel.

But in virtualbox, at first there's only one drive, the vmdk. So you need to create sata drives to match the configuration in the lfs partition. I added an old vdi virtual image drive, anyone will do, it's just a dummy placeholder that won't be used. Now I got 2 disks, vmdk and vdi. The vmdk being inserted first is plugged on sata port 0, the vdi on port 1. To swap this order, put the vmdk on 2, then the vdi on 0, then vmdk on 1. Now you're virtual boot time config is isomorphic to the real laptop system.


Now it should boot the kernel and reach init without issues. Right now my main problem is that the network interface isn't working. I suck at using `ip` but I got to fix this in order to build blfs.

mardi 10 avril 2012

LFS Success. Retrospective.

You have successfully registered!
ID: 23340
Name: agumonkey
First LFS Version: 20120409
© 1998-2012 Gerard Beekmans. Website design by Jeremy Huntwork & Matthew Burgess.
Finally I boot a LFS system.

I don't remember, it might be my 5th attempt ? development branch no less.
Never could go further than new system gcc/glibc.
Couldn't put my mind into solving.. too much noise. Weak mental.

Wasn't a walk in the park this time, what went wrong. Or what I should call
'The Overlook List' :

- choose a host
  last attempt was on a usb key 1Go for debian live, 6Go for the new lfs
  Failed early, stayed that way.
  last attempt started bad, I didn't pay attention and used lfslivecd which was obsolete.
  => realize that no special os needed, just a right set of tools
  now I thought to reuse the usb key and debian .. but I didn't want to boot another system.
  => realize that no special os needed, I run Kubuntu .. it's actually enough even for the latest SVN branch.

- headfirst style
  Created a local lfs user. Used $HOME/lfs as target for $LFS.
  I went through the book simply. This time not writing commands, I now understand sed enough
  so I can just copy/paste, and avoid time-wasting typos.
  By the time I reach the chapter 7 I wonder how I'm gonna boot this local folder.
  So I skip the beat, erase the usb key 2nd partition. cp -R $HOME/lfs /media/usb
  and try to finish there.

- lfs-bootscript, wrong sudo : host corrupted
  In a hurry I try to trick make to install bootscripts using DESTDIR variable.
  Except, I think, that sudo doesn't inherit the environment, thus letting make
  do its job using the host /.
  Luckily, Kubuntu init.d wasn't too corrupted, network setup takes 2 minutes
  now but it still boots. At first I thought I was good for a full setup.

- can't compile kernel (predefs.h not found)
  Not caring much about Kubuntu, I reach the kernel compilation step.
  To my surprise I made something wrong. Someone in the toolchain complains about
  about 'predefs.h' and 'bits.h' not being found. Seems related to kernel headers.
  Problem : too complex, Brain : too weak.

- redo & build an env
  Frustrated by the bare naked, information overload, and fragility. I try to improve a bit
  the process. I recreate the lfs user, add a .bash.d with :
  - extract function
  - lfs specific variable setup
  - a little login message to remind me of what variables are set or not.
  Nothing fancy at all, but it's already easier.
  I also time and log everything:
  `time make $cmd 2>&1 | tee $logs/$chapter/$(basename $(pwd))-$cmd.log` ; echo ">>> $?"

  I can leverage history key bindings almost blindly. Almost.

- grub road bump
  Things are smooth, no more `sudo` havoc, kernel compiles. I'm anxious about the
  grub process but anyway.
  Grub stops, saying he can't do shit, but even grub1 is nice enough to let you poke
  around live. The usb key is hd0, so I prepend the vmlinuz path with (hd0,2).
  F10 to run. 'Decompressing Kernel...' followed by kernel panic.

- IRC saves the day again
  Can't count how much knowledge I got on IRC channels.
  @Ratrophy tell me to add rootdelay=n[seconds] to avoid mounting before the usb key is
  fully setup.
  Works fine, now the kernel only panics, but for a totally different reason.

- FS drivers !
  It's been a long time since I've compiled a kernel, the menu organisation changed a bit.
  I didn't see EXT4 because it's written Extended Fileblahblahblah-long-wording Version 4.
  Okay, since I kept linux source in their compiled state, I can rebuild it quick with ext4 module.
  ...
  Seems that it needs to be builtin. Oh yeah there's no initrd .. I don't understand it all but
  someone has to have ext4 builtin.
  Now it .. panics. Saying /dev/sda can't be mounted. My kernel parameters mention /dev/sdb
  so Y U NO bOOT ?!?

- fstab ...
  Ah I copied the fstab from the book taking a bet on the device name, thinking the usb key would
  get sda since I boot on it. Wrong. Let's go vimcorrect that.
  Now I reach init ! and then I see a horrifying error message talking about forced halt.

- Stubbornness => single mode peeping.
  So :
  - the bootloader is fine
  - the kernel is fine
  - the filesystem is fine
  - the userspace is fine ( as in, program runs when chrooted in the host )

  This can't be serious. I poke in grub, making the FS rw.. No progress.
  Some setups drop the kernel into a shell. I wish I could.. I can only try single user mode.
  Rewrite grub.cfg `linux (hd0,2)/boot/vmlinuz-xxx root=/dev/sdb2 ro single init=/bin/bash`
  Boot, and here it is, the glorious shell. First time I type in that state.
  Can't do shit since the FS is ro, but I understand that only 10 minutes later.

- devtmpfs investigation
  I try running the bootscripts by hand, line by line.
  `mount -t -o procfs none /proc`
  Now ps works ... nice but not what I want.
  I mount everything until I realize /dev is quite empty. What is udev waiting for ??
  `mount -t devtmpfs .. /dev` => error, unknown fs type devtmpfs. WAT
  What is devtmpfs anyway ? isn't it devfs ?
  Then my eyes catch the huge NOTE saying not to forget to activate 'devtmpfs' ...
  Okay, reboot Kubuntu, recompile (the whole) kernel.

- Register
  Yep it boots, grub >= kernel >= init >= login.
  60MB used, 38 for cache. Not bad Linus.

- BLFS ? Not so fast
  - the network is not setup right
  - I got a static IP
  - no route to my internet gateway
  - there's no ssh, no wget. only ftp is on the system

- Ending notes
   Even though I've had a lot of criticizing in my head about LFS, it's a wonderful tutorial.
   Thanks a lot to their team.

lundi 9 avril 2012

LFS random discovery : time bash builtin and /usr/bin/time

I'm trying to instrument a bit LFS commands. I often wrap `make` into time + tee.
Exit status is often 0 even if make reports errors. Does time report it's exit status ? or the parameter command's one ? .. well it seems that make or the Makefile was design to return 0 even on 'unexpected FAIL' so time says everything is OK. Meanwhile I googled a bit to investigate and stumbled upon that : http://stackoverflow.com/questions/9715570/gnu-time-and-formatting-output

Ahh noobery strikes again.

samedi 7 avril 2012

bash_it color generator cost me 8 seconds at login



  • trying bash_it
  • sluggish login time
  • need : bash debug using -x, set PS4
  • trace -> inspect under vim
  • discover fancy color name generator
  • perlishly lispy thing
  • large set of nested, args eating, function aggregating bits of term code on the output
  • very DSL
  • followed by a cute 30-something calls to generate a set of {,bold,underline,blah}color variables.

I may be wrong, it seems this stacking of functions is not very cheap, at least not on my VM on a core duo. When I trace the login, thousands of calls, 90% are color related, mostly identical. I feel like looking at the naive recursive Fibonacci function.

Anyway disabling colors made bash-it invisible (sic) again.

cheat url summary :

- PS4 string to see stack >>> http://wiki.bash-hackers.org/scripting/debuggingtips
- Trace, tee log a script >>> http://www.commandlinefu.com/commands/view/3310/run-a-bash-script-in-debug-mode-show-output-and-save-it-on-a-file
- Mass comment in vim >>> http://vim.wikia.com/wiki/Commenting_out_a_range_of_lines

and the original project :

- bash-it >>> https://github.com/revans/bash-it

lundi 2 avril 2012

nano-hack : wrt54g v2 plus ddwrt plus ssh


$ ps
PID USER       VSZ STAT COMMAND
    1 root      1464 S    /sbin/init noinitrd 
    2 root         0 SW   [keventd]
    3 root         0 SWN  [ksoftirqd_CPU0]
    4 root         0 SW   [kswapd]
    5 root         0 SW   [bdflush]
    6 root         0 SW   [kupdated]
    9 root         0 SW   [mtdblockd]
   13 root      1500 S    watchdog 
   91 root      1460 S    resetbutton 
  141 root      1100 S    telnetd 
  160 root       808 S    dnsmasq --conf-file=/tmp/dnsmasq.conf 
  164 root      1456 S    wland 
  168 root       692 S    udhcpc -i vlan1 -p /var/run/udhcpc.pid -s /tmp/udhcpc
  172 root       692 S    cron 
  179 root      1424 S    ttraff 
  200 root      2140 S    httpd -p 80 
  381 root      1536 S    dropbear -b /tmp/loginprompt -r /tmp/root/.ssh/ssh_ho
  419 root      1456 S    process_monitor 
  572 root      1104 S    sh -c alias ping='ping -c 3'; eval "ps" > /tmp/ping.l
  573 root      1104 R    ps 
  574 root      1104 S    sh -c /sbin/ledtool 1 
  575 root      1104 R    sh -c /sbin/ledtool 1


$ uname -a
Linux DD-WRT 2.4.35 #3392 Mon Nov 2 13:19:34 CET 2009 mips unknown

That, is the output of commands using ddwrt on a wrt54g v2.

Finally tried to upgrade this old device. It uses 192.168.1.1 which collides with my actual internet gateway so I had to think (far too long) to connect to the wrt54g without stopping the gateway. Stopping my laptop's wifi and using ethernet wire between both gave me a functionning network, ping 192.168.1.1 was responding. 
I forgot that I set up https on the linksys webadmin. After uploading an almost random firmware found on ddwrt page I saw a 'upload success' but something failed. Rebooting it twice didn't bring the webadmin page back (http nor https). I could ping to the box so I tried to upload another firmware using tftp. First to attempts failed, the third printed a message saying it was cleaning nvram flash then exited. The process was a bit too quick to feel right. I consider resetting using the back button, hoping to reinitiate an upload, then I saw a webpage .. but it was ddwrt webadmin. Somehow it works now, so I fiddled with it, enabled ssh. And that's about it, what's next ?

- Adding usb ports. Nice if you use the device as a server
- Better antennas
- Heatsink
- More recent software. ddwrt last firmware uses linux 2.4 and busybox. Running 3.3 kernel and such might be fun, for the sake of it.

ps: A+ on the hackability of this thing. The case has no screw, just stiff surface bumps that hold the board into a two part case. Really nice.