Archive for the ‘Useful Commands’ Category

Solaris NTFS read saves the day

Wednesday, September 2nd, 2009

I recently had a NTFS volume go bad, so I thought easy to fix: Get the latest Knoppix, boot it from CD, and copy my shit off. Knoppix has had NTFS read support at least for quite some time.

Wrong.. gave me a hassle, errors, and couldn’t get the volume mounted. Then I decided I’ll update my SXCE to b121.. use some NTFS utilities on there. Had more progress (some NTFS utilities) but surprised that still no NTFS read support. So a quick search on blogs.sun.com for NTFS revealed these simple steps:


# wget http://www.belenix.org/binfiles/FSWpart.tar.gz
# wget http://www.belenix.org/binfiles/FSWfsmisc.tar.gz

Untar them, pkgadd them, and you are done. Then simply:


# mount -F ntfs /dev/dsk/c0d0pX /mnt

And nice command to view partitions:

# prtpart /dev/rdisk/c0d0p0 -ldevs

Solaris Boot Camp

Tuesday, January 31st, 2006

Well the Solaris Boot Camp came to Dallas and it was a very cool thing, and Bob is a cool guy and was nice to meet. Anyone that can cram that much information into that small amount of time deserves some respect. Some things I learned from Bob (and some I forgot about):

FMA features like fmadm, fmstat

  • boot -m milestone=milestone allows you to boot to a specific milestone
  • boot -m milestone=all boots all milestones
  • boot -m milestone=none which is useful in reparing a system that have problems booting early
  • boot -m verbose will print a line of information at boot when every service is started

    Change your default run level:
    (To change to another run-level just skip the -d part)

  • svcadm milestone -d milestone/single-user:default
  • svc:/milestone/single-user:default is runlevel S
  • svc:/milestone/multi-user:default is runlevel 2
  • svc:/milestone/multi-user-server:default is runlevel 3

    If you look at an FMRI entry:
    svc://localhost/network/login:rlogin
    notice the localhost part.. the word is eventually we’ll be able to use svc://someotherhost/network/login:rlogin

  • SMF service “unintialized” means that it didn’t start due to incomplete initialization (check sysidconfig, zlogin -C, NFS question)
  • SMF service “offline” means its tried to start but its dependencies weren’t met.
  • SMF service “disabled” means its off.
  • SMF service “maintenance” means error must be resolved by admin. check log.
  • SMF service “degraded” means its running at limited capacity in comparison to normal operation.

    Cool presentation Bob, and let me know when the Sun Developers Day comes.

  • Using TIP on Solaris

    Monday, January 2nd, 2006

    At my work, I regularly deal with Cisco switches, so I need to use console cables quite frequently. One of the first things I did was configure tip to work through a console cable. This was my first experience with tip and very simple to get working which suprised me because of all the horror stories I’ve heard about using tip. The laptop they bought for me is a Dell Latitude 810 and of course I run Solaris 10 on it (and it runs quite well on it I might add). I’m going to go over some basics of how to get tip working and some neat things I found out about it.

    Tips main configuration file is /etc/remote. This file contains all the entries for where you want to connect. If you look at this file there is already pre-defined entries and settings for certain instances:

    hardwire::dv=/dev/term/b:br#9600:el=^C^S^Q^U^D:ie=%S:oe=^D

    hardwire = profile name
    dv = the device
    br = baud rate
    el = EOL marks
    ie = input EOF marks
    oe = output EOF string
    More options are all explained in the /etc/remote file at the bottom

    This shows for the entry “hardware” we want to use the device /dev/term/b which is serial port B, baud rate of 9600, and EOL and EOF marks as shown. On my laptop there is no second serial port so this line is useless. Check your available serial ports in /dev/term. You then connect to this by typing:

    # tip hardwire

    This is all very simple stuff. So to connect through a console cable to my Cisco switches I used something like:

    cisco::dv=/dev/ttya:br#9600:el=^C^S^Q^U^D:ie=%$:oe=^D:

    This tells to use the first serial port (COM1) with a baud rate of 9600. I could of also used /dev/term/a instead of /dev/ttya, they are all the same thing.

    # tip cisco
    connected
    Catalyst 1900 Management Console
    Copyright (c) Cisco Systems, Inc. 1993-1998
    All rights reserved.
    Enterprise Edition Software
    Ethernet Address: 00-10-14-07-37-80
    Model Number: WS-C1924C-A
    -------------------------------------------------

    1 user(s) now active on Management Console.

    User Interface Menu

    [M] Menus
    [K] Command Line
    [I] IP Configuration

    If you enter ~? it will tell you the list of available commands you can do through the term.

    Enter Selection: ~?
    ~! shell
    ~< receive file from remote host
    ~> send file to remote host
    ~t take file from remote UNIX
    ~p put file to remote UNIX
    ~| pipe remote file
    ~C connect program to remote host
    ~c change directory
    ~. exit from tip
    ~^D exit from tip
    ~$ pipe local command to remote host
    ~^Y suspend tip (local only)
    ~^Z suspend tip (local+remote)
    ~s set variable
    ~? get this summary
    ~# send break
    ~
    [EOT]

    Some of these are mainly for when connecting to other UNIX machines but for switches, one that is really cool is ~! which allows you to exit from the tip, and drops you to the shell, then when you exit the shell it puts you back to tip. Another one I like is the ~> which allows me to put a list of switch commands in a file and then send that file to the terminal which then will execute those commands one by one.

    ZFS Cheatsheet

    Friday, November 4th, 2005

    For those of us outside of Sun:

    With ZFS on the way, I thought I’d gather up from some of my resources and create a ZFS cheatsheet so you can get ready for whats to come:

    There are two main commands for ZFS, “zfs” and “zpool”

    "zpool list" - Show current usage on zfs pools
    "zpool iostat 5" - Display I/O stats for zfs pools
    "zpool vdevs" - Shows current mirror/pool device properties
    "zpool create pool c0t3d0 c1t1d0 c4t4d0 c5t2d0" - Creates a pool consisting of c0t3d0 c1t1d0, c4t4d0, c5t2d0
    "zpool create -fv pool slice1 slice2" - Creates a pool consisting of slice1 and slice2
    "zpool create pool mirror c1t0d0 c2t0d0" - Creates a mirror consisting of c2t0d0 and c2t0d0
    "zpool add -f pool mirror c0t1d0s3 c0t1d0s4" - Adds mirror to pool

    "zfs list" - Show current zfs filesystems
    "zfs create pool/filesystem" - Creates filesystem under pool
    "zfs create pool/filesystem /mountpoint" - Creates filesystem under pool and mounts it to mountpoint
    "zfs snapshot pool/filesystem@snapshotname" - Takes snapshot of filesystem
    "zfs mount pool/filesystem /mountpoint" - Mounts a zfs filesystem to mountpoint
    "zfs destroy pool/filesystem" - Deletes filesystem from pool
    "zfs destroy pool" - Deletes pool

    Notes on ZFS:
    (From what I’ve gathered, may not be correct)

  • Package Name: SUNWzfs
  • You can’t convert a UFS filesystem to a ZFS filesystem as of yet, this means if you want ZFS you will have to install Solaris 10 Express from scratch.
  • If upgrading, ZFS can be used on new disks but not on existing UFS disks.
  • If there is a bad checksum on a disk, ZFS will grab the good checksum from another disk in the mirror and self heal.
  • You can use part of a pool for additional swap space.
  • Other operating systems can’t mount ZFS volumes as of yet.
  • There is never a need to fsck a ZFS filesystem.
  • Measure interface speed

    Friday, July 29th, 2005

    If you ever want to measure the input/output speed of your interfaces you can use ifstat. This is a really cool utility and I just installed it and had it running in less than 3 minutes. Grab it, untar it, and make sure /usr/sfw/bin and /usr/ccs/bin are in your PATH. ./configure; make; make install

    Once you run it, it automatically starts logging in/out KB/sec on your interface.
    Here’s me transferring a 600MB file from my solaris machine to linux machine:

    KB/s in KB/s out
    0.00 0.00
    0.20 0.13
    0.00 0.00
    514.66 20853.94
    514.25 21564.71
    814.88 33671.18
    787.98 32942.04
    778.22 32055.16
    820.35 34272.25
    805.25 34045.20
    807.75 33977.55
    822.91 34546.12
    799.83 33339.39
    832.44 34547.16
    797.99 33147.15
    840.15 34767.95
    840.07 34464.00
    841.79 34524.27
    784.47 32330.31
    639.21 26542.30
    694.19 28859.22
    800.51 33386.52
    562.46 23486.51

    Here’s what Solaris FTP reported after it was sent:

    615586930 bytes sent in 20 seconds (30495.36 Kbytes/s)

    Seems about right.

    fstyp command

    Monday, July 11th, 2005

    You can use the fstyp command to find out what filesystem a device is.

    # fstyp /dev/rdsk/c0d0s0
    ufs

    You could also use a shell script like so to determine all devices in the /dev/rdsk directory:

    for i in /dev/rdsk/*; do echo “$i = $(fstyp $i 2>/dev/null)”; done

    Solaris 11 GRUB

    Friday, July 8th, 2005

    If you’ve ever played with trying to dual boot the latest Solaris using the Solaris GRUB then you’ll probably use this information. To rewrite the MBR with the Solaris GRUB use the installgrub command like so:

    # /sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0d0s0

    I still haven’t got my triple boot working exactly how I want it, but I will.

    How to create a boot floppy in Solaris

    Thursday, June 2nd, 2005

    This might come in handy for someone new to Solaris.
    Here’s how to create a bootable floppy in Solaris:

    Put in Solaris 10 CD2 and a floppy, run ‘volcheck’ to check for new media if it doesn’t pick them up right away. Then:

    This formats the floppy
    # fdformat -d -U

    Goto the dir on the drive where the image is
    # cd /cdrom/cdrom0/Solaris_10/Tools

    This copys the image to the disk
    # dd if=d1_image of=/vol/dev/aliases/floppy0 bs=36k

    Run this and then manually eject the floppy
    # eject floppy

    To eject cdrom
    # eject cdrom0

    Solaris 10 and USB key

    Monday, May 23rd, 2005

    Solaris 10 with a USB key doesn’t get any more simple. I was messing around and found if you type cfgadm it will show dynamically reconfigurable hardware devices: (This was all done on my x86 machine)

    root@solaris# cfgadm
    Ap_Id Type Receptacle Occupant Condition
    c2 scsi-bus connected configured unknown
    usb0/1 usb-hub connected configured ok
    usb0/1.1 usb-storage empty configured unusable
    usb0/1.2 unknown empty unconfigured ok
    usb0/1.3 unknown empty unconfigured ok
    usb0/1.4 unknown empty unconfigured ok
    usb0/2 unknown empty unconfigured ok

    I saw that it was showing my USB status so then I plugged in my USB key and executed the command again:

    root@solaris# cfgadm
    Ap_Id Type Receptacle Occupant Condition
    c2 scsi-bus connected configured unknown
    usb0/1 usb-hub connected configured ok
    usb0/1.1 usb-storage connected configured ok
    usb0/1.2 unknown empty unconfigured ok
    usb0/1.3 unknown empty unconfigured ok
    usb0/1.4 unknown empty unconfigured ok
    usb0/2 unknown empty unconfigured ok

    Notice on USB0/1.1 it now says connected, it recognized when I plugged it in. Then I found out all you have to do is create the directory /rmdisk and restart the vold (Volume Management Daemon) and vold will now pickup your USB key under /rmdisk/rmdisk0. It’s that simple.

    root@solaris# mkdir /rmdisk
    root@solaris# pkill -HUP vold
    root@solaris# ls /rmdisk/rmdisk0
    AVG AntiVirus Gaim Resumes
    Adaware Mirc Spybot
    Benchmark Utils Netstat Live Thunderbird
    CiscoVPNClient PUTTY.EXE WinSCP3.lnk
    Codes R33838.EXE WinXP Support Tools
    CuteFTP.Pro.3.0.w.crack.rar RealVNC
    Firefox Registry Mechanic

    Useful Command

    Friday, May 20th, 2005

    Want to see what processes are taking up the most memory?
    try:

    ps -efo vsz,pid,comm | sort -rn