Posts Tagged tips

how to fix ‘who -r’ shows nothing

OS: Solaris 9.
Issue: who -r won’t give you the running level. so the pkgadd won’t work.
myhost1:~ root # who -r # shows no output

Solution:
check the /var/adm/utmpx, maybe the file has been corrupted
myhost1:~ root # cd /var/adm
myhost1:adm root # vi u1.log
# paste the following content.
system boot 0 2 0000 0000 1315335814 0 0 0 Tue Sep 6 20:03:34 2011
run-level 3 0 1 0063 0123 1315335839 0 0 0 Tue Sep 6 20:03:59 2011
rc2 s2 1262 8 0000 0000 1315335885 0 0 0 Tue Sep 6 20:04:45 2011
rc3 s3 3938 8 0000 0000 1315335915 0 0 0 Tue Sep 6 20:05:15 2011
Read the rest of this entry »

,

No Comments

Cygwin telnet tips etc

Install Telnet Using Cygwin On Windows 7
telnet for Cygwin is in inetutils, install the package to gain telnet

Crontab issue:
pam_access(crond:account): access denied
crond[9985]: CRON (someuser) ERROR: failed to open PAM security session: Success
crond[9985]: CRON (someuser) ERROR: cannot set security context

* if has /etc/cron.allow – add users to this file
* /etc/security/access.conf – comment out

# All other users should be denied to get access from all sources.
#- : ALL : ALL
# -:ALL EXCEPT root:LOCAL

No Comments

/var/adm/wtmpx too big

How to safely clean the /var/adm/wtmpx

Solution 1 (clean everything):
# cd /var/adm
# gzip -c wtmpx > wtmpx.backup.gz
# > wtmpx

Solution 2(keep last 1000 logs):
# cd /var/adm
# /usr/lib/acct/fwtmp < wtmpx | tail -1000 > wtmpx.ascii
# /usr/lib/acct/fwtmp -ic < wtmpx.ascii > wtmpx
# rm wtmpx.ascii
The commands makes convert info from binary to ascii from wtmpx, save last 1000 lines into wtmpx.ascii file, convert the info in wtmpx.ascii to binary again, and save it into wtmpx. Finally no-needed wtmpx.ascii is removed.

No Comments

Converting a virtual disk image: VDI to VMDK to a raw loopback file you can mount

By default, VirtualBox creates virtual disk images in a special format called VDI, which is unique to VirtualBox. Disk images are stored in $HOME/.VirtualBox/HardDisks.

You’ll need to convert VDI into another format if you want to run a VirtualBox VM on another virtualization platform, such as VMWare or KVM.

The VMDK virtual disk format is a good choice because even though it originated with VMWare it is supported by other virtualization platforms including VirtualBox and KVM.

VirtualBox enables the conversion using the low-level “VBoxManage clonehd” command:

VBoxManage list hdds # prints a list of disk image UUIDs
VBoxManage clonehd -o converted.vmdk format VMDK
cd ~/.VirtualBox/HardDisks/
ls -la converted.vmdk

Once you have converted to VMDK you can use qemu-img, a tool bundled with qemu (KVM’s virtualization backend) to further convert VMDK to other formats.

A particularly useful format to convert to is ‘raw’ which you can then mount as a loopback device:

apt-get install qemu
qemu-img convert -f vmdk converted.vmdk -O raw converted.raw
mount -o loop converted.raw /mnt

,

No Comments

Changing password inside a script

In an ideal world you’d never need to change the password associated with a user account without using passwd, but there are times when it is helpful to script such things.

The naive attempts to automate the use of passwd will fail, so the standard advice has always been to use a tool like expect to interactively call the passwd binary.

But there is an alternative approach which is more sensible which is to use the usermod command to change a password.

Assume you have a user account called guest upon your system and you wish to set the user’s password to openaccess you can do this by running:

# hash=$(echo openaccess | openssl passwd -1 -stdin)
# usermod –pass=”$hash” guest

If you wish you could combine that into a single line:

# usermod -p $(echo openaccess | openssl passwd -1 -stdin) guest

If a local user can see the commands you’re running in the output of “ps”, “top”, or similar then this is insecure – but if you generate the hash remotely you should probably be safe enough.

No Comments

Solaris: Boot archive error or corrupt

Boot archive error or corrupt

A few weeks ago, I got a little problem with my solaris box, namely solaris won’t boot because the boot archive was corrupt, *sigh*. Anyway the boot archive in solaris 10 was contain kernel module and configuration file was needed for solaris to startup the system.

Error:

module /platform/i86pc/boot_archive error 3 bad or corrupt data while decompressing file

Workaround:

Boot up your solaris in “solaris failsafe mode”, next solaris image will mount with writeable mode on “/a” mount point

rm -f /a/platform/i86pc/boot_archive
bootadm update-archive -R /a
reboot

,

No Comments

Solaris: get global zone name from non-global zone

run the netstat -p from non-global zone, get the ip information.
check the ip. one of the ip should be global zone’s ip.

there is any commands to check ? No.
so we’d better keep a good record, like motd. or cmdb.

,

No Comments

short scripts: convert squid timestamp

cat > /var/convert.pl
#!/usr/bin/perl -p
s/^\d+\.\d+/localtime $&/e;

Ctrl+D
. /var/convert.pl /var/squid/log/access.log |more

No Comments

readonly issue on disk

We have one server became readonly after update DMX.

Error logs:
Buffer I/O error on device dm-1, logical block 1545
lost page write due to I/O error on dm-1
ext3_abort called.
EXT3-fs error (device dm-1): ext3_journal_start_sb: Detected aborted journal
Remounting filesystem read-only
qla2xxx 0000:0d:00.0: scsi(0:0:0): Abort command issued — 1 11299f0 2002.
qla2xxx 0000:0d:00.1: scsi(1:0:0): Abort command issued — 1 113a04c 2002.
……
qla2xxx 0000:0d:00.0: Unable to read SFP data (102/a0/0).
process `sysctl’ is using deprecated sysctl (syscall) net.ipv6.neigh.eth3.base_reachable_time; Use net.ipv6.neigh.eth3.base_reachable_time_ms instead.
ext3_abort called.
EXT3-fs error (device dm-1): ext3_remount: Abort forced by user
ext3_abort called.

mount -o remount,rw /apps
mount: block device /dev/mapper/xxxx is write-protected, mounting read-only

Solution: reboot the server, all fixed :(

No Comments

Network / TCP / UDP Tuning

This is a very basic step by step description of how to improve the performance networking (TCP & UDP) on Linux 2.4+ for high-bandwidth applications. These settings are especially important for GigE links.

Quick Step
Cut and paste the following into a linux shell with root privleges:
sysctl -w net.core.rmem_max=8388608
sysctl -w net.core.wmem_max=8388608
sysctl -w net.core.rmem_default=65536
sysctl -w net.core.wmem_default=65536
sysctl -w net.ipv4.tcp_rmem=’4096 87380 8388608′
sysctl -w net.ipv4.tcp_wmem=’4096 65536 8388608′
sysctl -w net.ipv4.tcp_mem=’8388608 8388608 8388608′
sysctl -w net.ipv4.route.flush=1

Details:
Read the rest of this entry »

No Comments