Difference between revisions of "Solaris tricks"

From WTFwiki
Jump to navigation Jump to search
(Added xmodmap for fixing arrow keys)
Line 84: Line 84:
 
  Name=Openbox
 
  Name=Openbox
 
  Comment=Openbox
 
  Comment=Openbox
  Exec=/usr/pkg/bin/openbox
+
  Exec=/usr/pkg/bin/openbox-session
 
  Icon=
 
  Icon=
 
  Type=Application
 
  Type=Application

Revision as of 15:31, 16 December 2008

Page containing various magical things that we've learned about Solaris and OpenSolaris.

Writing a Sun disk label to a hard drive

The solaris installer will crash and burn if the disks you're installing to don't have a valid sun disk label. To ensure you have one, get to a command prompt from the solaris installer (right click the desktop in the graphical installer and select program->terminal).

# format -e

Pick the disk you want to label, it will ask you if you want to label it. Say 'y'. This should fix things. Select any additional disks with the 'disk' command, then 'quit'.

Sometimes this isn't enough, though! For some reason there are two types of labels, SMI and EFI, and other operating systems sometimes use EFI which Solaris pretends to understand but doesn't. So before quitting, type "label" again, whether or not it made a label automatically, and choose the SMI label. Default through any follow-up questions.

Setting a Static IP

This is way more cumbersome than you'd expect:

  • Edit /etc/nodename and /etc/hostname.<mymaininterfacename> (probably hme0) and put the hostname in the file
  • Delete /etc/dhcp.<mymaininterfacename> if it exists
  • Edit /etc/hosts and /etc/inet/ipnodes and put in the IP address and the hostname
  • Edit /etc/defaultdomain and add your FQDN
  • If you're not using a normal subnet, edit /etc/inet/netmasks and add your own custom one
  • Set your default route in /etc/defaultrouter
  • Reboot (I have no idea how to restart the appropriate services)
  • Fume at the ridiculousness of solaris

Making Alt-Tab (and other mod1 related bindings) work

I use x2x to send keyboard input to my opensolaris box. It's an Ultra 80 with a Sun Type 4 keyboard. However, the machine I x2x from is a PC with an IBM Type-M keyboard. By default, any shortcuts using the alt key don't work. However, if on the PC you run the following command:

 xmodmap -e "keysym Alt_L = Meta_L Alt_L"

It should fix the issues with shortcuts using alt. This works better than using xmodmap on the sun machine. I'm not sure why but I'm not gonna argue.

Using the xterm-color terminfo file

The xterm that comes with solaris, like so many of the bundled applications, sucks. I've installed a better version from pkgsrc. To get solaris to find the terminfo file for xterm-color I've added the following to my ~/.zshrclocal (a file I use for per-machine shell configuration/overrides):

 export TERMINFO=/usr/pkg/share/lib/terminfo
if [ $TERM = xterm ]; then export TERM=xterm-color fi

PATH, MANPATH, man(1), etc

Change pager to GNU less (comes with Solaris in /usr/sfw/bin, or install from pkgsrc), and:

alias more=less
PAGER=less

Suggestion for MANPATH:

MANPATH=/opt/SUNWspro/man:/usr/share/man:/usr/local/man:/usr/perl5/man:\
        /usr/local/share/man:/opt/csw/share/man:/usr/pkg/man

Suggestion for PATH, as Solaris puts things in a bazillion different places you'll be lost without something like this:

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/etc:/usr/ucb:/usr/sfw/bin:\
     /usr/ccs/bin:/usr/dt/bin:/opt/SUNWspro/bin:/usr/openwin/bin:\
     /usr/perl5/bin:/usr/local/bin:/opt/csw/bin:$HOME/bin

export PAGER MANPATH PATH

Getting a locate command on the system

Install sysutils/findutils. Edit root's crontab (sudo crontab -e root or whatever)

 1 3 * * * /usr/pkg/bin/gupdatedb

Then:

 alias locate=glocate

Either wait for 3am to roll around or run that gupdatedb command as root. It runs as the daemon user by default for security purposes (it won't index your 0600 chmodded pr0n).

Top alternative

prstat

Cleaning up a default Solaris install

Uninstalling unnecessary software

Use pkginfo to list all the installed packages and pkgrm to remove them. Be careful in removing things though as I don't think the solaris package manager does dependancy tracking.

Disabling services

Use svcs to list the services enabled on the machine. To disable a service do svcadm disable <service>. To list all services, even disabled ones; svcs -a.

Running a non-standard window manager

Reconfiguring dtlogin is a fool's errand, so disable it and enable gdm instead:

svcadm disable cde-login
svcadm enable gdm2-login

Now, create a .desktop file in /usr/share/xsessions. Here's my openbox.desktop file:

[Desktop Entry]
Encoding=UTF-8
Name=Openbox
Comment=Openbox
Exec=/usr/pkg/bin/openbox-session
Icon=
Type=Application

Now, simply log out and the new session will appear in gdm.

Compiling gcc 4.3.x

Here's some random notes on making gcc 4.3.x build on solaris. I used a gcc 3.4.3 compiler I built from pkgsrc, but in theory sunpro or the sfw gcc should work too.

  • compile and install gmp and mpfr to somewhere like /opt/gcc43
  • create a directory thats *NOT* a subdirectory (eg ~/gccbuild)
  • export CONFIG_SHELL=/bin/ksh
  • ../gcc-4.3.2/configure --prefix=/opt/gcc43 --with-gnu-as --with-as=/usr/sfw/bin/gas --without-gnu-ld --with-ld=/usr/ccs/bin/ld --enable-languages=c,c++ --with-gmp=/opt/gcc34 --with-mpfr=/opt/gcc43 --disable-multilib
  • gmake; gmake install

Partly stolen from here

Compiling firefox 3

  • ~/.mozconfig
ac_add_options --disable-tests
ac_add_options --disable-debug
ac_add_options --disable-crashreporter
ac_add_options --disable-jemalloc
ac_add_options --enable-optimize
ac_add_options --enable-application=browser
. $topsrcdir/browser/config/mozconfig
  • export LDFLAGS="-L/usr/pkg/lib -R/usr/pkg/lib"
  • Edit configure and change -rpath-link in MOZ_FIX_LINK_PATHS to -R
  • gmake -f client.mk

See also here and here. There's a possible fix for jemalloc in this mozilla bug.

Fixing the braindead x86 keymap

I was having issues with openbox not recognizing my arrow keys when navigating root menus and resizing windows. This is *really* annoying if you rely on the keyboard for things like that. The problem turned out to be the broken solaris keymap which mapped, for example, Down to both keycode 104 (Down) and 88 (Keypad Down).

The solution lies with rusty old friend xmodmap:

~/.Xmodmap

keycode 80 = KP_Up KP_8 F28
keycode 83 = KP_Left KP_4 F30
keycode 85 = KP_Right KP_6 F32
keycode 88 = KP_Down KP_2 F34

I think there's other stupidity lurking in the keymap, but I haven't had it cause me any difficulty so far so I'm ignoring it.