Updating Arch Linux — filesystem drama

Today I updated Arch Linux on a VM that I haven’t used in a while. When I first did this I received a mes­sage like:

:: Pro­ceed with instal­la­tion? [Y/n] y
(73/73) check­ing keys in keyring                     [######################] 100%
(73/73) check­ing pack­age integrity                   [######################] 100%
(73/73) load­ing pack­age files                        [######################] 100%
(73/73) check­ing for file con­flicts                  [######################] 100%
error: failed to com­mit trans­ac­tion (con­flict­ing files)
filesys­tem: /bin exists in filesys­tem
filesys­tem: /sbin exists in filesys­tem
filesys­tem: /usr/sbin exists in filesys­tem
Errors occurred, no pack­ages were upgraded.

Puz­zling… Every­one that’s writ­ten a script knows to call #!/bin/bash on the first line. How could /bin exist­ing be a problem?

I googled a bit and came across this won­der­ful post to get a list of pack­ages that owns files in /bin, /sbin, and /usr/sbin: https://bbs.archlinux.org/viewtopic.php?pid=1280576#p1280576

So I ran the command:

grep ‘^s\?bin/\|usr/sbin’ /var/lib/pacman/local/*/files | cut –d “:” –f 1 | uniq | cut –d “/” –f 6

The result was a list­ing of 20 some pack­ages. I then upgraded each them, one at a time, with pac­man –S , leav­ing filesys­tem to the end, along with bash and glibc.

So far so good. I updated bash. No prob­lems. Then I updated glibc…

/usr/bin/locale-gen: /bin/sh: bad interpreter

That isn’t promis­ing. So I tried to run /bin/sh, and it wasn’t there. Not only was /bin/sh gone, but the entire /bin direc­tory was gone. I poked around and found bash, sh, and the other usual sus­pects in /usr/bin. I cre­ated a sys­link for /bin -> /usr/bin with: ln –s /usr/bin /bin

Then I ran pac­man –S glibc and it worked. Next up filesys­tem. Same error as before, except this time it was just on /bin. I removed the sym­link, updated filesys­tem, and every­thing was in har­mony once again. The filesys­tem pack­age will actu­ally cre­ate /bin -> /usr/bin and /sbin -> /usr/bin so that all of your scripts will con­tinue to func­tion when you call #!/bin/bash at the top.

True to form, I didn’t come across this post by Arch Linux until after I’d writ­ten this blog entry. Take a look for another method of solv­ing the problem.

Binding Media Keys in i3 on Arch Linux to Control MPD

My Log­itech key­board has sev­eral but­tons at the top that I wanted to use to con­trol mpd (man|arch). They were Prev, Play/Pause, Next, and Mute/Unmute.

I knew that my win­dow man­ager i3 (man|arch) was able to bind key com­bi­na­tions to per­form func­tions such as exe­cut­ing a pro­gram, switch­ing the vis­i­ble work­space, or mov­ing a win­dow. The for­mat of the .i3/config file to launch a pro­gram on a cer­tain key com­bi­na­tion is:

bindsym <key com­bi­na­tion> exec <com­mand to execute>

With that known, we need to know how the sys­tem refers to those media keys. This is where xev (man|arch) is use­ful. Xev is a pro­gram that will print out data about mouse move­ments, key press events, and key release events. When the key is unbound you’ll get a Key­Press event like the below:

Key­Press event, ser­ial 32, syn­thetic NO, win­dow 0x4800001,
    root 0x28e, subw 0x0, time 654012911, (-169,-224), root:(1755,327),
    state 0x10, key­code 20 (keysym 0x2d, minus), same_screen YES,
    XLookup­String gives 1 bytes: (2d) “-“
    XmbLookup­String gives 1 bytes: (2d) “-“
    XFil­terEvent returns: False

Notice the sec­tion on the 2nd line, “(keysym 0x2d, minus)”, in this exam­ple, I had pressed the “-” key and found that the sys­tem refers to it as “minus”. I did this for each of the media keys and found their names to be:
Prev: XF86AudioPrev
Next: XF86AudioNext
Play/Pause: XF86AudioPlay
Mute/Unmute: XF86AudioMute

We can now fill in the key com­bi­na­tion sec­tion of the .i3/config:

bindsym XF86AudioPrev exec <com­mand to exe­cute>
bindsym XF86AudioNext exec <com­mand to exe­cute>
bindsym XF86AudioPlay exec <com­mand to exe­cute>
bindsym XF86AudioMute exec <com­mand to execute>

By read­ing the man page of mpc(man|arch), we know that it can per­form the fol­low­ing func­tions given the cor­re­spond­ing com­mand:
Prev: mpc prev
Next: mpc next
Play: mpc play
Pause: mpc pause

This makes two of the key bind­ings straight for­ward, but leaves us need­ing a tog­gle for Play/Pause, as we have one but­ton that must send one of two com­mands depend­ing on the cur­rent state of mpd. Here’s a bash script that will per­form just such a tog­gle: https://github.com/rarmknecht/utilities/blob/master/mpc_toggle

With the mpc_toggle script copied to /usr/local/bin our .i3/config now looks like:

bindsym XF86AudioPrev exec mpc prev
bindsym XF86AudioNext exec mpc next
bindsym XF86AudioPlay exec mpc_toggle
bindsym XF86AudioMute exec <com­mand to execute>

Next up, Mute/Unmute. Because I’m using the ALSA sound dri­vers I can use the tool amixer (man|arch) to con­trol the Mas­ter out­put. Again, here’s a bash script that allows for a tog­gle by read­ing the state of Mas­ter before set­ting it: https://github.com/rarmknecht/utilities/blob/master/my_mute

And that’s it once we drop the script in /usr/bin/local and update the i3 con­fig­u­ra­tion file. We can now play/pause, mute/unmute, go back a song, or skip to the next from the keyboard.

Final .i3/config snippet:

bindsym XF86AudioPrev exec mpc prev
bindsym XF86AudioNext exec mpc next
bindsym XF86AudioPlay exec mpc_toggle
bindsym XF86AudioMute exec my_mute

Rebuilt the Workstation

Today I decided to rebuild my per­sonal work­sta­tion again. I’d had Win­dows 7 installed since Novem­ber 2011 as I had started play­ing games like Skyrim, Dia­blo 3, and Guild Wars 2. I’ve real­ized that I haven’t really played a game in many months and have no spe­cific need for the Win­dows OS.

I’ve went with my old friend Arch and tried out a new win­dow man­ager (i3).

randr is now fully sup­ported within the nvidia binary dri­vers, so i3 had no trou­ble rec­og­niz­ing the mul­ti­ple mon­i­tors. Both .i3status.conf and .i3/config were straight-forward to edit to my liking.

So far so good!

Xorg.conf for nVidia Geforce 9400 — Dual Screen

# Below is a work­ing xorg.conf file from my sys­tem as of the date noted two lines below.
# Posted for per­sonal ref­er­ence.
# nvidia-settings: X con­fig­u­ra­tion file gen­er­ated by nvidia-settings
# nvidia-settings:  ver­sion 1.0  ([email protected])  Tue Nov  4 14:08:09 PST 2008

Sec­tion “Server­Lay­out“

Iden­ti­fier     “DUAL“
Screen      0  “Screen0” 1280 0
Screen      1  “Screen1” LeftOf “Screen0“
Input­De­vice    “Keyboard0” “CoreKey­board“
Input­De­vice    “Mouse0” “Core­Pointer“
End­Sec­tion

Sec­tion “Files“
End­Sec­tion

Sec­tion “Mod­ule“
Load           “dbe“
Load           “extmod“
Load           “type1“
Load           “freetype“
Load           “glx“
End­Sec­tion

Sec­tion “Server­Flags“
Option         “Xin­erama” “1”
End­Sec­tion

Sec­tion “Input­De­vice“

# gen­er­ated from default
Iden­ti­fier     “Mouse0“
Dri­ver         “mouse“
Option         “Pro­to­col” “auto“
Option         “Device” “/dev/psaux“
Option         “Emulate3Buttons” “no“
Option         “ZAx­isMap­ping” “4 5″
End­Sec­tion

Sec­tion “Input­De­vice“

# gen­er­ated from default
Iden­ti­fier     “Keyboard0“
Dri­ver         “kbd“
End­Sec­tion

Sec­tion “Mon­i­tor“
Iden­ti­fier     “Monitor0“
Ven­dor­Name     “Unknown“
Mod­el­Name      “DELL 1703FP“
Horiz­Sync       30.0 — 80.0
VertRe­fresh     56.0 — 76.0
Option         “DPMS“
End­Sec­tion

Sec­tion “Mon­i­tor“
Iden­ti­fier     “Monitor1“
Ven­dor­Name     “Unknown“
Mod­el­Name      “hp L1730“
Horiz­Sync       30.0 — 83.0
VertRe­fresh     56.0 — 76.0
Option         “DPMS“
End­Sec­tion

Sec­tion “Device“
Iden­ti­fier     “Device0“
Dri­ver         “nvidia“
Ven­dor­Name     “NVIDIA Cor­po­ra­tion“
Board­Name      “GeForce 9400 GT“
BusID          “PCI:2:0:0″
Screen          0
End­Sec­tion

Sec­tion “Device“
Iden­ti­fier     “Device1“
Dri­ver         “nvidia“
Ven­dor­Name     “NVIDIA Cor­po­ra­tion“
Board­Name      “GeForce 9400 GT“
BusID          “PCI:2:0:0″
Screen          1
End­Sec­tion

Sec­tion “Screen“
Iden­ti­fier     “Screen0“
Device         “Device0“
Mon­i­tor        “Monitor0“
Default­Depth    24
Option         “Twin­View” “0”
Option         “meta­modes” “DFP-0: nvidia-auto-select +0+0″
Sub­Sec­tion     “Dis­play“
Depth       24
End­Sub­Sec­tion
End­Sec­tion

Sec­tion “Screen“
Iden­ti­fier     “Screen1“
Device         “Device1“
Mon­i­tor        “Monitor1“
Default­Depth    24
Option         “Twin­View” “0”
Option         “meta­modes” “DFP-1: nvidia-auto-select +0+0″
Sub­Sec­tion     “Dis­play“
Depth       24
End­Sub­Sec­tion
EndSection

Customizing bash and vim

Post­ing here for my ref­er­ence the next time I need to con­fig­ure my prompt and vim. I cur­rently do all of my school­work on a CLI only linux box and even though I don’t need a GUI, I do enjoy some color dur­ing my ses­sions. The prompt and vim con­fig pro­vide just that. If you’d like to make your own prompt sim­ply replace the quoted char­ac­ters of PS1 with what you would like using this and this as ref­er­ences.

[email protected]: [~]: uname –a
Linux suse 2.6.18.8–0.5-default #1 SMP Fri Jun 22 12:17:53 UTC 2007 i686 athlon i386 GNU/Linux
[email protected]: [~]: tail –n 2 .bashrc
alias ls=‘ls –color’
export PS1=”\[\033[1;33m\]\u\[\033[0m\]@\h: \[\033[36m\][\w]:\[\033[0m\] “
[email protected]: [~]:

This is a fan­tas­tic .vimrc posted by some­one that knows more about vim con­fig­u­ra­tion than I care to. The main thing I enjoy is the fixed back­space key (it actu­ally works), the col­or­ing, and the 4 spaces inserted for a TAB. I also very much appre­ci­ate that the file is thor­oughly com­mented so that any­one who wants to understand/modify it can. I for instance changed his set­ting of 2 spaces per TAB to 4 spaces per TAB. Thanks for the great infor­ma­tion Stripey!