Sie sind auf Seite 1von 11

UNIX Tech Tips

1. Running Solaris in 32 or 64 bit mode Page 1 2. Removing ^M from Unix text files Page 2 3. Backup commands ufsdump , tar , cpio - Page 3 4. Setting up Ethernet card speed & duplex mode - Page 4 5. One Line scripts Page 4 1. Running Solaris in 32 or 64 Bit mode Finding the running mode ___________________ #isainfo -v 64-bit sparcv9 applications 32-bit sparc applications Booting in 32 bit mode _________________ ok> boot kernel/unix # eeprom boot-file=kernel/unix Booting in 64 bit mode __________________ OK>boot kernel/sparcv9/unix # eeprom boot-file=kernel/sparcv9/unix reboot the system Edit /platform/platform-name/boot.conf uncomment line with the variable named ALLOW_64BIT_KERNEL_ON_UltraSPARC_1_CPU set to the value true . ALLOW_64BIT_KERNEL_ON_UltraSPARC_1_CPU=true reboot the system . If diag switch is set to true following needs to be set _______________________________________

for 32 bit # /usr/sbin/eepromdiag-file= kernel/unix for 64 bit # /usr/sbin/eepromdiag-file= kernel/sparcv9/unix

2. Removing ^M from UNIX text files Using Perl : Following command will change the orginal file itself so keep a backup copy . perl -pi -e s:^V^M::g existing_file_name You won t see the Control V on typing but it is needed to generate control character ^M. Using sed : sed -e `s/^V^M//g` existing_file_name>new_file_name Using vi : Open file in vi and enter the following at : prompt in command mode . :%s/^V^M//g

3. Backup commands ufsdump , tar , cpio ufsdump 1. Used for complete file system backup . 2. It copies every thing from regular files in a file system to special character and block device files. 2. It can work on mounted or unmounted file systems. Tar: 1. Used for single or multiple files backup . 2. Can t backup special character & block device files . 3. Works only on mounted file system. Identifying the tape device dmesg | grepst Checking the status of the tape drive mt -f /dev/rmt/0 status

4. Backup file system using ufsdump ufsdump 0cvf /dev/rmt/0 /dev/rdsk/c0t0d0s0 or ufsdump 0cvf /dev/rmt/0 /usr To restore a dump with ufsrestore ufsrestorervf /dev/rmt/0 ufsrestore in interactive mode allowing selection of individual files and directories using add , ls , cd , pwd and extract commands . ufsrestore -i /dev/rmt/0 Making a copy of a disk slice using ufsdump ufsdump 0f /dev/rdsk/c0t0d0s7 |(cd /mnt/backup ;ufsrestorexf -) Backing up all files in a directory including subdirectories to a tape device (/dev/rmt/0), tar cvf /dev/rmt/0 * Viewing a tar backup on a tape tar tvf /dev/rmt/0 Extracting tar backup from the tape tar xvf /dev/rmt/0 (Restoration will go to present directory or original backup path depending on relative or absolute path names used for backup ) Backup using cpio find . -depth -print | cpio -ovcB> /dev/rmt/0 Viewing cpio files on a tape cpio -ivtB< /dev/rmt/0 Restoring a cpio backup cpio -ivcB< /dev/rmt/0 Compressing a file compress -v file_name gzip filename To uncompress a file uncompressfile_name.Z or gunzip filename

4. Setting up ethernet card speed , duplex mode in Solaris Command Line : Changes are lost on system reboots . - set the device instance (for multiport cards) ndd -set /dev/hme instance 0 this makes the next commands apply to hme0. - query parameters for the set instance: ndd -get /dev/hmelink_status 0 = link up, 1 = link down ndd -get /dev/hmelink_speed 0 = 10MBit, 1 = 100MBit ndd -get /dev/hmelink_mode 0 = half duplex, 1 = full duplex ndd -get /dev/hmeadv_autoneg_cap 0 = no autonegotiation, 1 = autoneg. enabled - set parameters, e.g. ndd -set /dev/hme instance 0 ndd -set /dev/hmeadv_autoneg_cap 1 to enable autonegotiation for hme0 2. PermanantChanges : changes are not lost on reboot. edit the /etc/system file and add these parameters .The sequence number matters. sethme:hme_adv_autoneg_cap=0 set hme:hme_adv_100T4_cap=0 set hme:hme_adv_100fdx_cap=1 set hme:hme_adv_100hdx_cap=0 set hme:hme_adv_10fdx_cap=0 set hme:hme_adv_10hdx_cap=0 Ehthernet mode setting in x86 is done in drivers .conf file. 100Mb Full Duplex on elxl0 in Solaris x86 __________________________________________ edit /kernel/drv/elxl.conf : #ident @(#)elxl.conf 1.3 98/02/23 SMI # # Copyright (c) 1998, by Sun Microsystems, Inc. # All rights reserved. # # Driver.conf file for the 3Com 3C90x # # To force full duplex operation, uncomment the following line:

full-duplex=1; # # To force half duplex operation, uncomment the following line: #full-duplex=0; # # To force 10Mbps operation, uncomment the following line: #speed=10; # # To force 100Mbps operation, uncomment the following line: speed=100; #

5. One Line Scripts Finding out the memory information on a HP Unix system Total Memory : echo selclass qualifier memory;info;wait;infolog |cstm | grep Total Configured Memory All Memory Information , slots, modules etc. echo selclass qualifier memory;info;wait;infolog |cstm List highest diskspace users in /home directory sort -nr sorts the output in numerical reverse order giving highest at the top . du -k /home | sort -nr | pg *Find and list the core files in /app01 directory . Replace directory name(/app01 ) , file name (core) and command (ls -l ) to customize . Print option prints the output . 2>/dev/null is to supress the error messages in the output . find /app01 -name core -print -exec ls -l {} \; 2>/dev/null Removing core files : find /app01 -name core -print -exec rm -f {} \; 2>/dev/nul compressing Log files find /logdir -name *.log -print -exec gzip {} \; 2>/dev/null

List the partitions using more than 70% of disk partition space . $5 represants column number to be compared and 70 is the value to be compared . df -k | awk $5 > 70 Booting problems in Solaris Booting problems poses serious challenge to the system administrators as system is down and no one can use it . This article tries to cover some of the general booting problems and their possible solutions to enable understand the problem cause and bring the system up very quickly. Following are some of the booting issues ,error messages their meaning and possible solutions discussed in this article. 1) Booting in single user mode and mounting root disk 2) Making boot device alias 3) Timeout waiting for ARP/RARP packet ?error message 4) The file just loaded does not appear to be executable error message 5) bootblk: can t find the boot program error message 6) boot: cannot open kernel/unix error message 7) Error reading ELF header? error message Cannot open /etc/path_to_inst error message 9) Can t stat /dev/rdsk/c0t3d0s0 error message 1. Booting in single user mode and mounting root hard disk Most important step in diagnosing the booting problems is booting the system in single user mode and examining the hard disk for possible errors & work out the corrective measure. Single user mode can be achieved by any of the following methods :ok> boot -s ;from root disk ok> boot net -s ;from network ok>boot cdrom -s ;from cdrom Rebooting with command: cdrom -s Configuring the /devices directory Configuring the /dev directory | INIT: SINGLE USER MODE # # fsck /dev/rdsk/c0t3d0s0 # mount /dev/dsk/c0t3d0s0 /mnt Perform the required operation on mounted disk , now accessible through /mnt ,&unmount the hard disk after you are done ; # umount /mnt # reboot

2.Making boot device alias In case system can not boot from primary disk and it is needed to make another boot disk to access the data , nvalias command is used . nvalias command makes the device alias and assigns an alternate name to a physical disk. Physical address of target disk is required which can be had by show-disk command on ok>. ok>nvalias disk7 /iommu@f,e0000000/sbus@f,e0001000/dma@3,81000/esp@3,80000/sd2,0 The new aliased disk can be named as boot disk or can be used for booting by refering its name . ok>setenv boot-device disk7 ok>reset or ok> boot disk7 3. Timeout waiting for ARP/RARP packet ? At ok> type printenv and look for these parameters . boot-device disk mfg-switch? false diag-switch? false if you see boot-device net or true value for the other two parameter change it to the values above. In case you wants to boot from network make sure your client is properly configured in boot server and network connections & configuration are proper. 4. The file just loaded does not appear to be executable Boot block on the hard disk is corrupted .Boot the system in single user mode with cdrom and reinstall boot block . #installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t3d0s0 5. bootblk: can t find the boot program boot block can not find the boot programe ufsboot in Solaris .Either ufsboot is missing or corrupted . In such cases it can be restored from the cdrom after booting from cdrom& mounting the hard disk # cp /platform/`uname -i`/ufsboot /mnt/platform/`uname -i` 6. boot: cannot open kernel/unix Kernel directory or unix kernel file in this directory is not found .Probably deleted during fsck or deleted by mistake. Copy it from the cdrom or restore from the backup tape. # cp /platform/`uname -i`/kernel/unix /mnt/platform/`uname -i`/kernel 7. Error reading ELF header ? Kernel directory or unix kernel file in this directory is corrupted.Copy it from the cdrom or restore from the backup tape. # cp /platform/`uname -i`/kernel/unix /mnt/platform/`uname -i`/kernel

8. Cannot open /etc/path_to_inst System can not find the /etc/path_to_install file .It might be missing or corrupted and needs to be rebuild. To rebuild this file boot the system with -ar option : ok>boot -ar Press enter to select default values for the questions asked during booting and select yes to rebuild /etc/path_to_install The /etc/path_to_inst on your system does not exist or is empty. Do you want to rebuild this file [n]? y system will continue booting after rebuilding the file. 9. Can t stat /dev/rdsk/c0t3d0s0 When booted from cdrom and done fsck the root partition comes out to be fine but on booting from root disk this error occurs. The device name for / is missing from /dev/dsk directory and to resolve the issue /dev& /devices directories has to be restored from root backup tapes .

Solaris SPARC Boot Sequence The following represents a summary of the boot process for a Solaris 2.x system on Sparc hardware. Power On: Depending on the system involved, you may see some output on a serial terminal immediately after power on. This may take the form of a Hardware Power ON message on a large Enterprise server, or a "'" or "," in the case of an older Ultra system. These indications will not be present on a monitor connected directly to the server. POST: If the PROM diag-switch? parameter is set to true, output from the POST (Power On Self Test) will be viewable on a serial terminal. The PROMdiaglevel parameter determines the extent of the POST tests. (See theHardware Diagnostics page for more information on these settings.) If a serial terminal is not connected, a prtdiag -v will show the results of the POST once the system has booted. If a keyboard is connected, it will beep and the keyboard lights will flash during POST. If the POST fails, an error indication may be displayed following the failure. Init System: The "Init System" process can be broken down into several discrete parts:

y y

y y

y y

OBP: If diag-switch? is set, an Entering OBP message will be seen on a serial terminal. The MMU (memory management unit) is enabled. NVRAM: If use-nvramrc? is set to true, read the NVRAMRC. This may contain information about boot devices, especially where the boot disk has been encapsulated with VxVM or DiskSuite. Probe All: This includes checking for SCSI or other disk drives and devices. Install Console: At this point, a directly connected monitor and keyboard will become active, or the serial port will become the system console access. If a keyboard is connected to the system, the lights will flash again during this step. Banner: The PROM banner will be displayed. This banner includes a logo, system type, PROM revision level, the ethernet address, and the hostid. Create Device Tree: The hardware device tree will be built. This device tree can be explored using PROM monitor commands at the ok> prompt, or by using prtconf once the system has been booted.

Extended Diagnostics: If diag-switch? and diag-level are set, additional diagnostics will appear on the system console.
auto-boot?:

If the auto-boot? PROM parameter is set, the boot process will begin. Otherwise, the system will drop to the ok> PROM monitor prompt, or (ifsunmoncompat? and security-mode are set) the > security prompt. The boot process will use the boot-device and boot-file PROM parameters unless diag-switch? is set. In this case, the boot process will use the diagdevice and diag-file. bootblk: The OBP (Open Boot PROM) program loads the bootblk primary boot program from the boot-device (or diag-device, if diag-switch? is set). If the bootblk is not present or needs to be regenerated, it can be installed by running the installboot command after booting from a CDROM or the network. A copy of the bootblk is available at /usr/platform/`arch -k`/lib/fs/ufs/bootblk ufsboot: The secondary boot program, /platform/`arch -k`/ufsboot is run. This program loads the kernel core image files. If this file is corrupted or missing, abootblk: can't find the boot program or similar error message will be returned. kernel: The kernel is loaded and run. For 32-bit Solaris systems, the relevant files are:
y y /platform/`arch -k`/kernel/unix /kernel/genunix

For 64-bit Solaris systems, the files are:

y y

/platform/`arch -k`/kernel/sparcV9/unix /kernel/genunix

As part of the kernel loading process, the kernel banner is displayed to the screen. This includes the kernel version number (including patch level, if appropriate) and the copyright notice. The kernel initializes itself and begins loading modules, reading the files with theufsboot program until it has loaded enough modules to mount the root filesystem itself. At that point, ufsboot is unmapped and the kernel uses its own drivers. If the system complains about not being able to write to the root filesystem, it is stuck in this part of the boot process. The boot -a command singlesteps through this portion of the boot process. This can be a useful diagnostic procedure if the kernel is not loading properly.
/etc/system:

The /etc/system file is read by the kernel, and the system parameters are

set. The following types of customization are available in the /etc/system file:
y y y y y y

moddir: Changes path of kernel modules. forceload: Forces loading of a kernel module. exclude: Excludes a particular kernel module. rootfs: Specify the system type for the root file system. (ufs is the default.) rootdev: Specify the physical device path for root. set: Set the value of a tuneable system parameter.

If the /etc/system file is edited, it is strongly recommended that a copy of the working file be made to a well-known location. In the event that the new/etc/system file renders the system unbootable, it might be possible to bring the system up with a boot -a command that specifies the old file. If this has not been done, the system may need to be booted from CD or network so that the file can be mounted and edited. kernel initialized: The kernel creates PID 0 ( sched). The sched process is sometimes called the "swapper." init: The kernel starts PID 1 (init).
init:

The init process reads the /etc/inittab and /etc/default/init and follows the instructions in those files. Some of the entries in the /etc/inittab are:

y y y

fs: sysinit (usually /etc/rcS) is: default init level (usually 3, sometimes 2) s#: script associated with a run level (usually /sbin/rc#)

rc scripts: The rc scripts execute the files in the /etc/rc#.d directories. They are run by the /sbin/rc# scripts, each of which corresponds to a run level. Debugging can often be done on these scripts by adding echo lines to a script to print either a "I got this far" message or to print out the value of a problematic variable.

Das könnte Ihnen auch gefallen