• Rsync How to

    Rsync is a very very useful command with a whole bunch of options. However most of the time if you run rsync on the command line you only need to know a few.

    #rsync -avz foo:src/bar /data/tmp

    This would recursively transfer all files from the directory src/bar
    on the machine foo into the /data/tmp/bar directory on the local machine.

    The files are transferred in “archive” mode, which ensures that symbolic links,
    devices, attributes, permissions, ownerships etc are preserved in the transfer.
    Additionally, compression will be used to reduce the size of data portions of the transfer.

    #rsync -avz foo:src/bar/ /data/tmp

    A trailing slash on the source changes this behavior to transfer all files
    from the directory src/bar on the machine foo into the /data/tmp/.

    A trailing / on a source name means “copy the contents of this directory”.
    Without a trailing slash it means “copy the directory”.

    This difference becomes particularly important when using the –delete option.

    Below are a few of the options that I find useful.

    What to Copy:
    -r recursive

    How to Copy:
    -n dry run
    -g preserve group

    Destination Options:
    -a archive
    -b backup

    Syntax Examples:
    rsync [OPTION]… SRC [SRC]… [USER@]HOST:DEST
    rsync [OPTION]… [USER@]HOST:SRC DEST
    rsync [OPTION]… SRC [SRC]… DEST
    rsync [OPTION]… [USER@]HOST::SRC [DEST]
    rsync [OPTION]… SRC [SRC]… [USER@]HOST::DEST
    rsync [OPTION]… rsync://[USER@]HOST[:PORT]/SRC [DEST]
    rsync [OPTION]… SRC [SRC]… rsync://[USER@]HOST[:PORT]/DEST

  • Changing a Solaris Server’s IP Address

    The following steps may be used to change the IP address of a
    Solaris system.

    1. Change the host’s IP in /etc/hosts for the change to take effect
    after reboot. If you are using Solaris 10, you must also change the host’s IP in /etc/inet/ipnodes for the change to take effect after reboot.

    2. Run ifconfig interface ip_address netmask broadcast_address for the
    IP address change to take effect immediately. The netmask and broadcast_address should be specified if you are using variable length subnet masks (VLSM), but may be omitted otherwise.


    3. If you are using variable length subnet masks (VLSM), add the host’s network number and subnet mask to /etc/netmasks.

    <

    p style=”font-family:Arial”>If the new IP address places the system on a different network:

    4. Place the host’s new default gateway in /etc/defaultrouter, place new netmask in /etc/netmasks

    5. Run route add default new_gateway for the new default gateway to take effect immediately.

    6. Run route delete default old_gateway to delete the old default gateway from the routing table.

  • Using Filesystem Labels in Linux

    Ist2_3533724_yellow_sticky_note When rebooting a RHEL box with a whole bunch of SAN luns I ran into an issue where the system was failing when trying to mount a device ( /dev/sdm). When I logged into the box in single user mode this device did not even exist. However, it was brought to my attention that a few luns where removed from this box recently, so apparently when I rebooted the box generated a new device list, and my renamed /devd/sdm to something different.

    Apparently this is common.As the simple act such as adding or removing a
    LUN can cause Linux to remap your /dev/sd entries, causing what used to
    be /dev/sde1 to become /dev/sdd1. This problem can be solved by using filesystem labels, which are entries in the ext3 filesystem header.

    have found 2 ways of doing this.

    First is with e2label, Usage: e2label device [newlabel]

    You can also show your label as below. In this instance my label is 'storage'

    root@kubuntu:~/downloads# e2label /dev/sdb1
    storage

    Or you can use tune2fs

    L argument to set, l to show a whole bunch of stuff

    tune2fs -L storage /dev/sdb1

    root@kubuntu:~/downloads# tune2fs -l /dev/sdb1
    tune2fs 1.40.8 (13-Mar-2008)
    Filesystem volume name:   storage
    Last mounted on:          <not available>
    Filesystem UUID:          1cc16930-8891-4307-97fb-e267117dead1
    Filesystem magic number:  0xEF53
    Filesystem revision #:    1 (dynamic)
    Filesystem features:      ext_attr resize_inode dir_index filetype sparse_super large_file
    Filesystem flags:         signed_directory_hash
    Default mount options:    (none)
    [truncated]

    Then make your changes to the fstab, both entries below are same, just one uses the newly assigned label.

    #/dev/sdb1      /mnt            auto    rw,user,noauto,exec     0       3
    LABEL=storage   /mnt            auto    rw,user,noauto,exec     0       3

  • Verify Solaris 10 Multipathing/Configure SAN Disk

    Fibre

    I was attempting to troubleshoot issues as a user was complaining about slow performance on a SAN disk. First thing that I did was check to ensure that there were not any performance issues on any disks that might have been causing this users issues

    A quick iostat verified that everything was looking fine
    iostat -cxzn 1

     

    This box is running Veritas so lets check out the disks. Vxdisk list shows one Sun6140 disk.

    # vxdisk list
    DEVICE       TYPE            DISK         GROUP        STATUS
    Disk_0       auto:none       –            –            online invalid
    Disk_1       auto:none       –            –            online invalid
    SUN6140_0_1  auto:cdsdisk    diskname_dg02  diskname_dg online nohotuse

    Luxadm is an utility, which discovers FC devices (luxadm probe), shut
    downs devives (luxadm shutown_device …) runs a firmware upgrade
    (luxadm download_firmware …) and many other things. In this instance I use luxadm to get the true device name for my disk


    # luxadm probe
    No Network Array enclosures found in /dev/es

    Found Fibre Channel device(s):
    Node WWN:200600a0b829a7a0  Device Type:Disk device
    Logical Path:/dev/rdsk/c4t600A0B800029A7A000000DC747A8168Ad0s2

    I then run a luxadm on the device. Below you can see that I do indeed have two paths to the device.
    1 controller = one path, 2 controllers = 2 paths

    # luxadm display /dev/rdsk/c4t600A0B800029A7A000000DC747A8168Ad0s2
    DEVICE PROPERTIES for disk: /dev/rdsk/c4t600A0B800029A7A000000DC747A8168Ad0s2
    Vendor:               SUN
    Product ID:           CSM200_R
    Revision:             0619
    Serial Num:           SG71009283
    Unformatted capacity: 12288.000 MBytes
    Write Cache:          Enabled
    Read Cache:           Enabled
    Minimum prefetch:   0x1
    Maximum prefetch:   0x1
    Device Type:          Disk device
    Path(s):

    /dev/rdsk/c4t600A0B800029A7A000000DC747A8168Ad0s2
    /devices/scsi_vhci/ssd@g600a0b800029a7a000000dc747a8168a:c,raw
    Controller           /devices/pci@1f,4000/SUNW,qlc@5,1/fp@0,0
    Device Address              203700a0b829a7a0,1
    Host controller port WWN    210100e08bb370ab
    Class                       secondary
    State                       STANDBY
    Controller           /devices/pci@1f,4000/SUNW,qlc@5/fp@0,0
    Device Address              203600a0b829a7a0,1
    Host controller port WWN    210000e08b9370ab
    Class                       primary
    State                       ONLINE

    Had I only had one path I would have run cfgadm. I would have seen that one of the fc-fabric devices would have been unconfigured. I then could have used cfgadm to configure it and enable my mulitpathing

    # cfgadm
    Ap_Id                          Type         Receptacle   Occupant     Condition
    c0                             scsi-bus     connected    configured   unknown
    c1                             scsi-bus     connected    unconfigured unknown
    c2                             fc-fabric    connected    configured   unknown
    c3                             fc-fabric    connected    configured   unknown

    MPXIO Primer

    Solaris I/O multipathing gives you the ability to set up multiple
    redundant paths to a storage system and gives you the benefits of load
    balancing and failover.

    Need to enable MPXIO

    Solaris 10 is the easier, because the mpxio capability is
    built-in. You just need to turn it on!

    To enable it, edit the file /kernel/drv/fp.conf
    file. At the end it should say:

    mpxio-disable="yes";

    Just change yes to no and it will be enabled:

    mpxio-disable="no";

    Before multipathing, you should see two copies of each disk in
    format. Afterwards, you’ll just see the one copy.

    It assigns the next available controller ID, and makes up some
    horrendously long target number. For example:

    Filesystem kbytes used avail capacity Mounted on
    /dev/dsk/c6t600C0FF000000000086AB238B2AF0600d0s5
    697942398 20825341 670137634 4% /test

  • How to Change Root’s Ilom Password

    ILOM is the system Service Processor Sun includes with Sun x64 systems.ILOM, can also be accessed via an integrated HTTPS server, meaning that a user friendly graphical user interface is available. Currently the server models below use ILOM.
    Sun Fire[TM]  X4100

    Sun Fire[TM]  X4200

    Sun Fire[TM]  X4500

    Sun Fire[TM]  X4600

    Sun Fire[TM]  X4100 M2

    Sun Fire[TM]  X4200 M2

    Sun Fire[TM]  X4600 M2

    Sun Blade[TM] 6000

    Sun Blade[TM] 8000

    Sun Netra[TM] X4200 M2

    Sun SPARC[TM] Enterprise T5120

    Sun SPARC[TM] Enterprise T5220

    The default root password for the ILOM is changeme. This is a Sun default and you should make sure that you modify this when you are setting up your new server.

    Below I have outlined the procedure that you need to follow

    1. Connect and Login to your Serial Management port.
    2. cd /SP/users
    3. type “set /SP/users/root password”, and voila

    Changing password for user /SP/users/root…
    Enter new password: ********
    Enter new password again: ********
    New password was successfully set for user /SP/users/root

  • Veritas Volume Manager Upgrade Solaris 8

    Symantec_Storage_Foundation_Basic_5_Linux
    I’ve been told by some that this process is overkill, and have been told by others that this process is the cleanest way to go. Please procede at your own risk.

    QuickNotes: vxlicrep -e will allow you view your veritas license along with lot of additional information.

    Backup any file systems that are part of rootdg

    This particular system is running Veritas 3.5 which requires a rootdg. This system has 3 file systems that are part of this dg. They are seen below. Comment any rootdg entries out of the /etc/vfstab.

    /dev/vx/dsk/rootdg/home
    1048576 35232 950055 4% <mountpoint>

    /dev/vx/dsk/rootdg/disk
    1048576 467462 544827 47% <mountpoint>

    /dev/vx/dsk/rootdg/disk
    1048576 55289 932147 6% <mountpoint>

    These systems are located on this disk slice.

    7
    unassigned wm 5566 – 14086 41.35GB (8521/0/0)
    86709696

    First step is to back these 3 file systems up locally whereever there is room or over NFS mount.

    Export & Unmount

    Unmount any veritas filesystems and export and disk groups.

    Break Mirrors

    At this point I need to break the submirrors off that are on the second system disk. In this case c1t1d0.

    Use the format below

    metadetach mirror submirror

    for example:

    metattach d1 d21

    Keep Veritas from Starting up on Reboot.

    Touch /etc/vx/reconfig.d/state.d/install-db to prevent Veritas from starting up with the box.

    Reboot in Single User mode, Verify that you are booting of off the primary disk. Init 0, boot -s

    Remove the current Veritas packages in the order listed below. (You may encounter addition packages not listed here. If this occurs add these packages to the removal order after VRTSvcsvr and before VRTSvxfs)

      1. VRTSvmdoc
      2. VRTSfsdoc
      3. VRTSvmman
      4. VRTSvrdoc
      5. VRTSvrw
      6. VRTSweb
      7. VRTSobgui
      8. VRTSvmpro
      9. VRTSfspro
      10. VRTSob
      11. VRTSspc
      12. VRTSvcsvr
      13. VRTSordoc (Should
        be Database Edition Only)
      14. VRTSorgui (Should
        be Database Edition Only)
      15. VRTSdbed (Should
        be Database Edition Only)
      16. VRTSvxmsa
      17. VRTSvxfs
      18. VRTSvxvm
      19. VRTSvxlic

    Install San Foundation kit

    (Sol8), make sure that you reconfigure reboot in single user mode

    Step 8: devfsadm -Cv, change to runlevel 2 before next step.

    Step 9: Install new veritas and patch with maint pack 2, then reboot again.

    Step 10: Upgrade disk groups and file systems.

    Upgrading Disk Groups:

    To determine what DG version you are running, you can use the following command

    vxdg -q list <my-dg> | grep version.

    Import your disk groups, and run the following command on each DG, the -T is optional.

    vxdg [ -T version ] upgrade diskgroup.

    Upgrading File Systems:

    To determine what FS version you are running, you can use the command below.

    fstyp -v /dev/vx/dsk/dev/device

    Mount your filesystems and then run the following command

     vxupgrade -n 6 /mountpoint

    Use the format command to create new slices (on disk0) for the 3 file systems listed in step one. Basically split the 41.35gb contained in Slice 7 across Slice 5-7.

    5 unassigned wm 0
    0 (0/0/0) 0

    6 unassigned wm 0
    0 (0/0/0) 0

    7 unassigned wm 5566 – 14086
    41.35GB (8521/0/0) 86709696

    Mount the new slices and copy data from the original mount points to the new mounts.

    Load the partition table from disk one onto disk two.

    Reattach Mirrors.

  • Solaris: How to Resize a Swap Partition….on a disk without any free slices

    First lets detach the swap partition (submirror) on the secondary disk. Where d1 is the metadevice and d21 is the submirror

    #metadetach d1 d21
    d1: submirror d21 is detached
    
    metaclear d21
    d21: Concat/Stripe is cleared
    

    Now lets format Secondary Disk (c1t1d1 in this example)

    Below is the partition table of the disk that I am working with. Slice one will be resized using unallocated disk space. Add 1 to the last cylinder of slice 7 to determine your starting cylinder. In this case my new starting cylinder is 2691.

    Total disk cylinders available: 14087 + 2 (reserved cylinders)
    Part Tag Flag Cylinders Size Blocks
    0 root wm 0 - 824 4.00GB (825/0/0) 8395200
    1 swap wu 825 - 1031 1.00GB (207/0/0) 2106432
    2 backup wm 0 - 14086 68.35GB (14087/0/0) 143349312
    3 unassigned wm 1032 - 1038 34.78MB (7/0/0) 71232
    4 var wm 1039 - 1657 3.00GB (619/0/0) 6298944
    5 home wm 1658 - 2070 2.00GB (413/0/0) 4202688
    6 stand wm 2071 - 2277 1.00GB (207/0/0) 2106432
    7 stand wm 2278 - 2690 2.00GB (413/0/0) 4202688
    

    Now resize the partition
    In this case I am going to use the rest of the disk, which according to the information for partition two, ends @ cylinder 14087. Subtract 2691 from 14087, to determine how many cylinders your slice is going to be.

    Enter partition id tag[swap]:
    Enter partition permission flags[wu]:
    Enter new starting cyl[825]: 2691
    Enter partition size[2106432b, 207c, 1028.53mb, 1.00gb]: 11396c
    

    Now save this new partition scheme

    Enter table name (remember quotes): my_table
    

    Then label your disk. As you can see below, my swap partition is now huge.

    Part Tag Flag Cylinders Size Blocks
    0 root wm 0 - 824 4.00GB (825/0/0) 8395200
    1 swap wu 2691 - 14086 55.30GB (11396/0/0) 115965696
    2 backup wm 0 - 14086 68.35GB (14087/0/0) 143349312
    3 unassigned wm 1032 - 1038 34.78MB (7/0/0) 71232
    4 var wm 1039 - 1657 3.00GB (619/0/0) 6298944
    5 home wm 1658 - 2070 2.00GB (413/0/0) 4202688
    6 stand wm 2071 - 2277 1.00GB (207/0/0) 2106432
    7 stand wm 2278 - 2690 2.00GB (413/0/0) 4202688
    Now lets Swap the Swap
    
    
    First, reinitialize swap submirror.
    metainit d21
    d21: Concat/Stripe is setup
    

    Add swap to new submirror

    \swap -a /dev/md/dsk/d21
    

    View swap

    swap -l
    swapfile dev swaplo blocks free
    /dev/md/dsk/d1 85,1 16 2106416 2106416
    /dev/md/dsk/d21 85,21 16 115965680 115965680
    

    Remove the metadevice from swap

    swap -d /dev/md/dsk/d1
    

    Verify that previous step worked

    swap -l
    swapfile dev swaplo blocks free
    /dev/md/dsk/d21 85,21 16 115965680 115965680
    

    Clear Metadevice/Mirror

    metaclear d1
    Mirror is cleared
    Clear Metadevice/submirror
    metaclear d11
    d11: Concat/Stripe is cleared
    

    Format Primary Disk (c1t1d0 in this example)

    Select a predefined table

    partition> select
    0. original
    1. my_table
    Specify table (enter its number)[0]: 1
    View the partition table, and make sure it looks right.
    
    Total disk cylinders available: 14087 + 2 (reserved cylinders)
    
    Part Tag Flag Cylinders Size Blocks
    0 root wm 0 - 824 4.00GB (825/0/0) 8395200
    1 swap wu 2691 - 14086 55.30GB (11396/0/0) 115965696
    2 backup wm 0 - 14086 68.35GB (14087/0/0) 143349312
    3 unassigned wm 1032 - 1038 34.78MB (7/0/0) 71232
    4 var wm 1039 - 1657 3.00GB (619/0/0) 6298944
    5 home wm 1658 - 2070 2.00GB (413/0/0) 4202688
    6 stand wm 2071 - 2277 1.00GB (207/0/0) 2106432
    7 stand wm 2278 - 2690 2.00GB (413/0/0) 4202688
    
    Label disk
    partition> label
    Ready to label disk, continue? y
    

    Put things back the way they were.

    Reinitialize the swap submirror on the primary disk

    metainit d11
    d11: Concat/Stripe is setup
    

    Reinitialize Metadevice Mirror

    metainit d1
    d1: Mirror is setup
    
    Add the metadevice to swap
    swap -a /dev/md/dsk/d1
    

    … and verify that it took

    swap -l
    swapfile dev swaplo blocks free
    /dev/md/dsk/d21 85,21 16 115965680 115965680
    /dev/md/dsk/d1 85,1 16 115965680 115965680
    

    Remove the submirror that you added to swap in the step above

    swap -d /dev/md/dsk/d21
    

    Reattach Submirror d21 to Mirror d1

    metattach d1 d21
    d1: submirror d21 is attached
    

    Redefine dump device

    dumpadm -d swap
    Dump content: kernel pages
    Dump device: /dev/md/dsk/d1 (swap)
    Savecore directory: /var/crash/blahblah
    Savecore enabled: yes
    

    Related articles

    SwapFaq’s
    Repartitioning a Linux Cloud Server
    HomeLab: Cisco Switch Boot Alternate IOS Image
    Solaris 9 Scan for New SAN Luns & and Vertias Volume Manager Quick Start