Wednesday, July 29, 2015

hp c3000 risc workstation beeping

 knock it the eff off already.  
 yes, i know you are a workstation and don't want to be a headless server. kthx.  
   
 error message: Run F21F?  
   
 That means CDE desktop is trying to find a display for dtlogin. As root:  
   
 /sbin/init.d/dtlogin.rc stop_msg  
 /sbin/init.d/dtlogin.rc stop  
 ch_rc -a -pDESKTOP=none /etc/rc.config.d/desktop  

Thursday, July 9, 2015

list full last modification time

 ls -l --time-style=+%Y%m%d%H%M%S   
 ls -l --time-style=+%Y%m%d%H%M%S | awk '{print $6 " " $7}'  
 stat is nice, too.  

locations of ip information for centos & windows

this is a followup to the "problem"
 centos:  
 IP  
 cat /etc/sysconfig/network-scripts/ifcfg* |grep IPADDR  
   
 Name  
 cat /etc/sysconfig/network  
   
 Mac  
 cat /sys/class/net/eth*/address  
   
 ubuntu:  
 IP  
 cat /etc/network/interfaces  
   
 Name  
 cat /etc/hostname  
   
 Mac  
 cat /etc/udev/rules.d/70-persistent-net.rules  
   
   
 windows  
   
 IP  
 \ControlSet001\services\Tcpip\Parameters\Interfaces   
 between brackets...  
 IPAddress, SubnetMask, DefaultGateway, NameServer  
   
 Name  
 \ControlSet001\Control\ComputerName\ComputerName  
 ComputerName  
   
 Mac  
 \ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}  
 0000-?...  
 NetworkAddress  

Tuesday, July 7, 2015

virsh script to enumerate all disks

and this is useful.
 #!/bin/bash  
   
 for name in `virsh list --all | grep -i -e running -e shut |  
 awk '{ print $2 }'`  
   
 do  
  virsh dumpxml $name | grep -i -e "source file" -e "source dev" |  
  grep -v .iso |  
  sed -e 's/source file=//g' |  
  sed -e 's/source dev=//g' |  
  sed -e "s/'//g" |  
  sed -e "s/<//g" | sed -e "s/\/>//g" | while read -r result; do  
  echo $name $result  
  done  
 done  
   

Monday, July 6, 2015

find kvm vm system name on their raw disks

 I have a problem.  
   
 Someone not me installed a bunch of Linux KVM Servers and didn't bother to name the VMs something sane. That someone also didn't bother to keep note of VM to canonical DNS name or even IP.  
 What a drag.  
   
 virsh isn't much use.  
   
 I need to access the raw disks and grep around.  
   
 Did I mention these were Linux and Windows KVM VMs? Yeah. My KVM server farm is all CentOS 6 x86_64.  
   
 Install guestfish  
   
 [root@kvmserver ~]# yum install guestfish  
 [root@kvmserver ~]# yum install libguestfs-winsupport  
   
 Yay.  
   
 Let's find the vms on the system.  
   
 [root@kvmserver ~]# virsh list --all  
   
  Id  Name              State  
 ----------------------------------------------------  
  1   poc19          running     <--- windows
  -   poc20          shut off    <--- linux
   
 Let's find the VMs disk.  
   
 [root@kvmserver ~]# virsh dumpxml poc20 | grep 'source file'  
    <source file='/home/vm-disk/poc20.img'/>  
   
 Let's create a place to mount the disk and where we're going to do our work:  
   
 [root@kvmserver ~]# mkdir /mnt/poc20  
 [root@kvmserver ~]# guestmount -a /home/vm-disk/poc20.img -i --ro /mnt/poc20/  
 [root@kvmserver ~]# ls /mnt/poc20/  
   
 bin boot dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var  
   
 cat /mnt/poc20/etc/sysconfig/network  
   
 poc20  
   
 Now, let's umount the work directory. to unmount you'd figure you'd use guestumount /mountpoint  
   
 [root@kvmserver ~]# guestunmount   
   
 -bash: guestunmount: command not found  
   
 nope. bad man bad bad.  
   
 try:  
   
 [root@kvmserver ~]# fusermount -u /tmp/mount  
   
 [root@kvmserver ~]# cd /mnt/poc20/  
 [root@kvmserver poc20]# ls  
   
 <tumbleweeds>  
   
 Super.   
   
 For the Windows system (poc19) you may do the same disk mount procedure. And you can walk around the filesystem no problem.  
 And yes, you may do this on a live, running VM.  
   
 I want that hostname. And you know and I know that Windows 7 has its hostname here:  
 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName  
   
 We already yum install libguestfs-winsupport  
   
 Now, get chntpw (a Linux-based Windows registry editor)  
 per: http://pkgs.org/download/chntpw do stuff for your distro.  
   
 [root@kvmserver ~]# cd /usr/local/src  
 [root@kvmserver src]# wget http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm  
 [root@kvmserver src]# rpm -Uvh nux-dextop-release*rpm  
 [root@kvmserver src]# yum install chntpw  
   
 Do the whole mount thing. Then run chntpw.  
   
 [root@kvmserver ~]# cd /mnt/poc19/Windows/System32/config  
   
 [root@kvmserver config]# chntpw SYSTEM  
 chntpw version 0.99.6 110511 , (c) Petter N Hagen  
 openHive(SYSTEM) failed: Read-only file system, trying read-only  
 Hive <SYSTEM> name (from header): <SYSTEM>  
 ROOT KEY at offset: 0x001020 * Subkey indexing type is: 686c <lh>  
 File size 10223616 [9c0000] bytes, containing 2166 pages (+ 1 headerpage)  
 Used for data: 150888/9612696 blocks/bytes, unused: 4820/177064 blocks/bytes.  
   
 Simple registry editor. ? for help.  
   
 > ls          
 Node has 8 subkeys and 0 values  
  key name  
  <ControlSet001>  
  <ControlSet002>  
  <MountedDevices>  
  <RNG>  
  <Select>  
  <Setup>  
  <Software>  
  <WPA>  
   
 > cd ControlSet001\Control\ComputerName\ComputerName  
   
 (...)\Control\ComputerName\ComputerName> cat ComputerName  
 Value <ComputerName> of type REG_SZ, data length 20 [0x14]  
 POC19  
   
   
 (...)\Control\ComputerName\ComputerName> q  
   
 Yay. We have a name.