Tips, tricks and other useful bits and pieces for Solaris.
Contents
Changing Hostname
When you need to change the hostname of a Solaris box it's hard to remember all the files it stashes it's name away in, and if you miss some it can cause some odd problems. The trick is you have to make sure that the hostname is changed in all of these files:
- /etc/nodename
- /etc/inet/hosts
- /etc/hostname.*
- /etc/net/ticlts/hosts
- /etc/net/ticots/hosts
- /etc/net/ticotsord/hosts
- /etc/inet/ipnodes
Creating a Swap file
When you need more swap space and rebuilding the partition isn't a realistic alternative you need to create a swap file (also from Solaris 2.6 an on Sun claims that there is no performance difference between using a swap file and a swap partition). Here are the steps:
- Create the swap file (make sure there's enough room on the partition you create it):
# mkfile 1000m /SWAPFILE
- Add the file to the swap space:
# swap -a /SWAPFILE
- Check to make sure that everything worked as it should have:
# swap -l or # swap -s
If you want the addition to swap to persist after a reboot you need to add a line to /etc/vfstab like this:
/SWAPFILE - - swap - no -
Forcing Ethernet Duplex and Speed
In the below examples it's assumed that your ethernet interface is called hme0. Some newer suns you eri0 and older ones use le0 or bme0 as well (specialized cards can get you yet more names). Substitute your ethernet device name as appropriate.
Detect Current Settings
# ndd -get /dev/eri adv_autoneg_cap 0=off,1=on # ndd -get /dev/eri link_status 0=down,1=up # ndd -get /dev/eri link_speed 0=10,1=100 # ndd -get /dev/eri link_mode 0=half-duplex,1=full-duplex
You can also grep /var/adm/messages or /var/log/syslog, it'll log everytime it changes.There is also a
perl script that prints out all the information nice and pretty like.Force to 100Mb Full-Duplex On the command line:
# ndd -set /dev/eri instance 0 # ndd -set /dev/eri adv_100T4_cap 0 # ndd -set /dev/eri adv_100fdx_cap 1 # ndd -set /dev/eri adv_100hdx_cap 0 # ndd -set /dev/eri adv_10fdx_cap 0 # ndd -set /dev/eri adv_10hdx_cap 0 # ndd -set /dev/eri adv_autoneg_cap 0
In /etc/system (where they will take effect on every boot):set eri:adv_100T4_cap=0 set eri:adv_100hdx_cap=0 set eri:adv_10fdx_cap=0 set eri:adv_10hdx_cap=0 set eri:adv_100fdx_cap=1 set eri:adv_autoneg_cap=0
NFS Troubleshooting
Want to mount a share from a NetworkAppliance file server and guarentee that you are NFS version 3 and using TCP? Try this:
# mount -o rw,hard,intr,bg,vers=3,proto=tcp toaster:/vol/vol0/etc /mnt
Now want to know if your current NFS sessions are using TCP or UDP as the transport protocol?
# nfsstat -m
Look for errors on the interface:
# netstat -i
Building Packages
No real information here since all my documentation got lost last time if formatted my laptops hard drive (and discovered I'd backed up the wrong directory ... doh.). However here is a link that looks useful: