Archive for the ‘Linux OS’ Category

System is in Maintenance State – Boot Archives in Solairs 10

May 21st, 2023, posted in Solaris
Share

Boot archive in Solaris 10 is kernel module and configuration files which is needed for Solaris to start the system. It is a set of files. Its taken care by following two services :

 Svc:/system/boot-archive:default
 Svc:/system/boot-archive-update:default

Normally  Graceful shutdown or init 0 updates archive, but non-graceful or random shutdown leaves the archive files out of sync and after the system comes up it throws a warning that some of the files are different from boot-archive & system will be in maintenance state.

 The recommended action is to reboot to the failsafe archive to correct the above inconsistency. To accomplish this, on a GRUB-based platform, reboot and select the “Solaris failsafe” option from the boot menu.On an OBP-based platform, reboot then type “boot -F failsafe”. Then follow the prompts to update the boot archive. Alternately, to continue booting at your own risk, you may clear the service by running:

“svcadm clear system/boot-archive“

Nov 19 08:36:23 svc.startd[7]: svc:/system/boot-archive:default: Method “/lib/svc/method/boot-archive” failed with exit status 95.
Nov 19 08:36:23 svc.startd[7]: system/boot-archive:default failed fatally: transitioned to maintenance (see ‘svcs -xv’ for details)
Requesting System Maintenance Mode
(See /lib/svc/share/README for more information.)
Console login service(s) cannot run
Root password for system maintenance (control-d to bypass): Requesting System Maintenance Mode
(See /lib/svc/share/README for more information.)
Console login service(s) cannot run
Root password for system maintenance (control-d to bypass):

Now after logging in to the server with root password, if you check the services status, the boot-archive service will be in maintenance state & since all other services are depending this, those servers will be impacted.

bash-3.00# svcs -xv|more

svc:/system/boot-archive:default (check boot archive content)
 State: maintenance since Wed Nov 19 08:36:23 2014
Reason: Start method exited with $SMF_EXIT_ERR_FATAL.
   See: http://sun.com/msg/SMF-8000-KS
   See: /etc/svc/volatile/system-boot-archive:default.log
Impact: 65 dependent services are not running:
        svc:/system/filesystem/usr:default
        svc:/system/filesystem/minimal:default
        svc:/system/cryptosvc:default
        svc:/network/ipsec/ipsecalgs:default
        svc:/network/ipsec/policy:default
        svc:/milestone/single-user:default
        svc:/system/filesystem/local:default

Steps need to be followed is  you may need to clear boot archives :

#svcadm clear boot-archive

But recommended way is to reboot in fail safe mode and update it. If it gets corrupted , system can’t boot.

Recovery :
Boot solaris in fail safe mode. Solaris image will mount at /a . Then remove the previous record and create new boot archive.

Ok boot -F failsafe
#rm -f /a/platform/i86pc/boot_archive
#bootadm update-archive -R /a
#reboot

Share

Delete Files Older Than X days in Unix or Solaris

February 5th, 2023, posted in Solaris
Share

Delete Files Older Than X days in Unix or Solaris,Delete Files Older Than X days in Solaris,

 

Introduction :

In Production server, there is always a need to free up the disk space from time to time. The best way to achieve is to have a cron job or an autosys job which will delete the older log files from the directory.

In this simple tutorial, we’ll quickly look at the solution to this problem. In order to delete files older than X number of days, try using Unix find command. find command is more powerful than you can really imagine. It comes up with multiple options which when gets handy can help you cover a lot of functional requirements like moving files among directories, deleting old files, archiving files etc.

Recently I came across one such requirement of deleting files older than X days from a directory in Unix server and I thought of sharing the solution with you.


Solution :

Unix find command is used to achieve the desired result.

find /path/to/the/directory/ -type f -name '*' -mtime +30 -exec rm {} \;


Explanation :

Time to breakdown the find command mentioned above :

  1. /path/to/the/directory : Edit this portion of the code with the path of your target directory.
  2. -type f : It signifies that we are targeting all the ‘files’ in the specified directory.
  3. -name ‘*’ : We have used a general regex “*” to match all the file names. You can make it more specific if you need. For example , to delete only dat files use : -name "*.dat".
  4. -mtime +30 : This refers to all the files which are older than 30 days. mtime stands for Modification time in Unix.You can change the number based on your requirement.
  5. –exec rm {} \ : This is actually the execution command which calls for deletion of all the files filtered by all the above criteria. rm stands to remove in Unix.

Although it is a very simple command, still I want you understand the usage of mtime in find command in a little more detail.

The POSIX specification for find command states that :

-mtime n The primary shall evaluate as true if the file modification time subtracted from the initialization time, divided by 86400 (with any remainder discarded), is n.

In the descriptions, wherever n is used as a primary argument, it shall be interpreted as a decimal integer optionally preceded by a plus ( ‘+’ ) or minus-sign ( ‘-‘ ) sign, as follows: +n More than n. n Exactly n. -n Less than n.

Important point to note in the above statement is that the fractional part is always ignored. So, when you specify -mtime +1 , it looks for files older more than 1 day. Rather to explain it further, it simply says to match files modified two or more days ago.

If you want to delete files older than 1 day, you can try using -mtime +0 or -mtime 1 or -mmin $((60*24)).

Would suggest you to try playing with the combinations on your own to deepen the understanding.
Still in case you have more questions, please feel free to get in touch with me.

 

Share

Commonly used ILOM commands

December 27th, 2022, posted in Oracle, Solaris
Share

Integrated Lights-out Manager (ILOM) helps to manage and troubleshoot the complete hardware of a server. With the help of ILOM we can remotely manage a server. We can power on and power off it remotely. Let us see some of the most commonly used commands in the ILOM shell.

 

Login related commands

-> start /SP/console        -- start the SP-console
-> show /SP/sessions        -- see the currently active sessions
-> stop /SP/console         -- to stop any user session

Start and stop system

-> start /SYS                            (start system)  
-> stop [-force] /SYS                    (stop system)
-> show /SYS                             (shows the power status)
-> reset /SYS                            (reset host)
-> reset /SP                             (reset ILOM SP)
-> set /HOST send_break_action=break     (send break signal to the OS)
-> reset /CMM                            (to reset CMM on a blade Chassis)

 

Locator commands

To set the locator on or off

-> set /SYS LOCATE=on
-> set /SYS LOCATE=off

Networking Commands

To see the current network configuration of ILOM

-> show /SP/network

To set an IP address for ILOM

-> set pendingipdiscovery=static 
-> set pendingipaddress=10.10.10.10
-> set pendingipnetmask=255.255.255.0
-> set pendingipgateway=10.10.10.1
-> set commitpending=true

To show SP MAC address

show /SP/network macaddress

If on a Blade chassis, to check the CMM IP :

-> show /CMM/network

User administration

-> show /SP/users                  (Display all the ILOM users)
-> show /SP/user/admin             (Display configuration settings of a specific user)
-> create /SP/users/user_name password=PWD role=[administrator|operator]    (create new user)
-> delete /SP/users/username       (Delete a user)
-> set /SP/users/admin01 role=administrator           (set the role of a user)
-> set /SP/users/admin01           (set or change password of user)

Monitoring and logs

-> show /SP/logs/event/list     (ILOM event log)
-> show -level all -output table /SP/faultmgmt     (List all hardware faults)
-> show -level all -output table /SYS type==Temperature value       (List all temperature sensor readings)

Hardware info

-> show -level all -output table /SYS type==DIMM                (show DIMMS)
-> show -level all -output table /SYS type=='Host Processor'    (show CPUs)
-> show -l all /SYS type=='Hard Disk'                           (show disks)

 

Share

VNC Server On Solaris

November 6th, 2022, posted in Solaris
Share
for S11_u10:
pkg publisher -P
pkg install solaris-desktop


Path should be :

PATH=$PATH:/usr/X11/bin
PATH=$PATH:/usr/openwin/bin
export PATH
Share

Find And Delete Files Older Than Some Particular Time Period In Linux

October 9th, 2022, posted in Solaris
Share

Searching By File Timestamp

Unix/Linux filesystems have three types of timestamp on each file. They are as follows:

  1. Access time (-atime): The timestamp when the file was last accessed.
  2. Modification time (-mtime): The timestamp when the file was last modified.
  3. Change time (-ctime): The timestamp when the metadata for a file (such as permissions or ownership) was last modified.

 

Search and delete file older than 7 days

Lets take an example, wherein we will find and delete file older than 7 days. We will be using the option “-mtime” of the find command for this.

1. Get a list of files using find command as follows:

# find /path_to_directory -mtime +7 -type f -exec ls {}\;

2. If the filenames start with any particular pattern, filter using that as follows:

# find /path_to_directory -name 'filenamepattern*' -mtime +7 -type f -exec ls {}\;

3. After checking and confirming the output, go for removal script(It is very IMPORTANT), otherwise there will be irrecoverable data loss.

# find /path_to_directory -name 'filenamepattern*' -mtime +7 -type f -exec rm -fv {}\;

# find . -name “*.pdf” -atime +7 -exec rm {} \;

4. If this needs to be done on a remote server through cron job and log the filenames of deleted files, use the following command

# ssh user@remote_ip "find /path_to_directory -name 'filenamepattern*' -mtime +7 -type f -exec rm -fv {} \; >> /tmp/backup_deletion`date +%Y%m%d`.log 2>&1"

 

Conclusion

The -mtime parameter will search for files based on the modification time; -ctime searches based on the change time. The -atime, -mtime, and -ctime use time measured in days. The find command also supports options that measure in minutes. These are as follows:

  1. -amin (access time)
  2. -mmin (modification time)
  3. -cmin (change time)

For example, to print all the files that have an access time older than seven minutes, use the following command:

# find . -type f -amin +7 -print

-newer option

The -newer option specifies a reference file with a modification time that will be used to select files modified more recently than the reference file.

Find all the files that were modified more recently than file.txt file:

# find . -type f -newer file.txt -print
Share