Monday, April 13, 2015

Getting old browser history for new PC

I just got a new PC.  I have a pretty complicated setup.  I run Linux and use KVM to run Windows 7 for Outlook and Powershell.  I run a lot of VMs.  And, whenever I get a new PC, I migrate the VMs from the old system to the new.  Before I do, I'm in a transition period where I just use virt-manager to run the old VMs off the old system and display on my new desktop (cuts down on monitors & keyboards.

So, I have my shiny new PC and I want to check on my BackupPC servers (I have 3 of them).  I usually just click on them in my quick-launch but the browser history is missing.  I decided to just look at the old history instead of launching the remote (old) version of FireFox for some reason.  And, besides, I need to move that info anyway.

My boss thinks my setup is nuts but he generously donated an extra 1TB drive for my VMs.  I create a VG for this disk and start carving off space.

# lvcreate -L 165G -n lv_oldol6 vg_tank
# mkfs.ext4 /dev/mapper/vg_tank-lv_oldol6

# mkdir /oldol6
# vi /etc/fstab   (add new file system)
# mount /oldol6

Now I have a place to store my data from my old system. So I mount the old system via SSH.

# yum install sshfs
# mkdir /ssh
# cd /ssh
# sshfs me@old.system.ip:/ /ssh/
# tar -cf - . | (cd /oldol6/ && tar -xf - )
# sync   (old sysadmin good luck command)
# updatdb
# locate places.sqlite   (I look for the one in the old place)
# sqlite3 /oldol6/.mozilla/firefox/umw8efgh.default/places.sqlite
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"

sqlite> .mode column
sqlite> .header on
sqlite> .schema
sqlite> select url FROM moz_places where title LIKE '%backuppc%';

Ta-dahhh!  That worked nicely.  I find the URL I'm looking for.

Monday, January 5, 2015

Booting Headless M3000 with XSCF and Wyse 55

The nice thing about Sun/Oracle Solaris Sparc systems is THEY JUST RUN!  It had been a while since I had rebooted the M3000 from a cold powered-off state.  We had some weird power issues over the holidays and lost some equipment and crashed others (despite UPS protection and generator backups).

The system was powered off - nothing but XSCF was on.  I couldn't remember the XSCF password.  I was trying root.  As it turns out, you are forbidden from creating an account called "root" on XSCF (it is one of the many reserved words).  I had to create a new user using the following procedure (thank you, Bikash!):

    login: default
Change the panel mode switch to Locked and press return…
Leave it in that position for at least 5 seconds. Change the panel mode switch to Service, and press return…

I did as directed...

 Create a user andrew

XSCF> adduser andrew
 Change the password for andrew

XSCF> password andrew
New XSCF password:
Retype new XSCF password:
 Grant andrew the following privileges, useradm, platadm, aplatop.

XSCF> setprivileges andrew useradm platadm platop
 After that, I was able to log in as my new user and view the errors.  There were none.

        XSCF> showlogs error 

Other options here: showlogs event, showlogs power, showlogs monitor, showlogs console and fmdump.

What I needed to do was boot.  Again, I struggled to remember the procedure for getting to the boot prompt.  I tried the T2 commands to start a console - no luck.  I tried simply console which got me close.  I needed a domain_id that I did not know.  Then I vaguely remembered something and tried this:

    XSCF>  console -d 0

I answered Y to "Do you really want to start console" and then it did nothing.  You need an extra ENTER here before the boot prompt showed up.  Then I typed "boot" and was finished.

It all seems so straight-forward and mnemonic now.  I don't know what my problem was this morning.  :-)

Thursday, December 18, 2014

EVEN MORE Fun with Server Core 2012 R2

And finally, to finish off my Windows Server Core 2012 R2, I install Cygwin!  Advice from the web says preemptively open port 22 for OpenSSHd.

netsh advfirewall firewall add rule name="SSHd" dir=in action=allow protocol=TCP localport=22

Now, download the Cygwin installer:

$client = new-object System.Net.WebClient
$client.DownloadFile( "","c:\windows\temp\setup-x86_64.exe" )

Now, run the installer:


Don't forget to configure OpenSShd (in Cygwin Bash):

$ ssh-host-config -y
$ cygrunsrv -S sshd
$ ssh-keygen -t rsa

Assuming you added lots of nice Cygwin utilities, you now have a very useful server.  ;-)


More Fun with Windows Server Core 2012 R2


In my earlier post on using SCONFIG, I mentioned needing to be able to do a few other things from the command line before I could stay immersed in Windows Server Core 2012 R2.  Namely, adding disks and formatting them.  I recently covered that here and here.  There's a couple of other things: Firewall Rules (viewing and setting), mapping network drives (turns out the old "net use" is by far the easiest way for that) and turning off IPv6.

Firewall rules definitely rates its own post.  Mapping drives is trivial as long as they allow you to use the old "net use"command.  Slightly less trivial with Powershell.  Honestly, I would only use the PS way if i was programming something (or it MS took away "net use"command in a future release).  So that leaves IPv6 for this post.  Here's how to disable that: First you have to find the name (alias) of your Ethernet card.  After that, you can display it's settings.

PS C:\Windows\system32> Get-NetAdapter

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
Ethernet 5                Citrix PV Network Adapter #2                 20 Up           BE-EF-B0-1D-FA-CE         1 Gbps
Ethernet 8                Citrix PV Network Adapter #0                 23 Up           FE-ED-BA-5E-BA-11         1 Gbps

PS C:\Windows\system32> Get-NetAdapterBinding -InterfaceAlias "Ethernet 8" | Select-Object Name,DisplayName,ComponentID

Name                                    DisplayName                             ComponentID
----                                    -----------                             -----------
Ethernet 8                              Link-Layer Topology Discovery Responder ms_rspndr
Ethernet 8                              Link-Layer Topology Discovery Mapper... ms_lltdio
Ethernet 8                              Microsoft Network Adapter Multiplexo... ms_implat
Ethernet 8                              Client for Microsoft Networks           ms_msclient
Ethernet 8                              QoS Packet Scheduler                    ms_pacer
Ethernet 8                              File and Printer Sharing for Microso... ms_server
Ethernet 8                              Internet Protocol Version 6 (TCP/IPv6)  ms_tcpip6
Ethernet 8                              Internet Protocol Version 4 (TCP/IPv4)  ms_tcpip 
Now, just disable IPv6...

PS C:\Windows\system32> Disable-NetAdapterBinding -InterfaceAlias "Ethernet 8" -ComponentID ms_tcpip6
And -  TA-DAHH!  That's it.

iSCSI with Powershell and Hyper-V on Windows Core 2012 R2

I found a great link for working with iSCSI drives from Powershell.  The first thing you have to do is turn on iSCSI:

PS C:\Windows\system32> Set-Service -Name MSiSCSI -StartupType Automatic
PS C:\Windows\system32> Start-Service MsiSCSI

Next, tell Windows Server Core where your SAN resides:

PS C:\Windows\system32> New-IscsiTargetPortal -TargetPortalAddress
InitiatorInstanceName  :
InitiatorPortalAddress :
IsDataDigest           : False
IsHeaderDigest         : False
TargetPortalAddress    :
TargetPortalPortNumber : 3260
PSComputerName         :

I would have thought at this point it would know the iSCSI share but it did not.  Had to run this command:

PS C:\Windows\system32> $target = Get-IscsiTarget
PS C:\Windows\system32> print $target.NodeAddress
Can't find file

PS C:\Windows\system32> Connect-IscsiTarget -NodeAddress $target.NodeAddress

You just need the above TWO commands in black.  I ran the line in red to see what it was looking at (making certain of the IQN before proceeding).  The Connect-IscsiTarget command responds with this:

AuthenticationType      : NONE
InitiatorInstanceName   : ROOT\ISCSIPRT\0000_0
InitiatorNodeAddress    :
InitiatorPortalAddress  :
InitiatorSideIdentifier : 412341375678
IsConnected             : True
IsDataDigest            : False
IsDiscovered            : True
IsHeaderDigest          : False
IsPersistent            : False
NumberOfConnections     : 1
SessionIdentifier       : ffffe000cd87c020-4012313700056702
TargetNodeAddress       :                      TargetSideIdentifier    : 4f00
PSComputerName          :

Testing the iSCSI session...

PS C:\Windows\system32> Get-IscsiConnection

ConnectionIdentifier : feffe060cd87c029-1
InitiatorAddress     :
InitiatorPortNumber  : 15552
TargetAddress        :
TargetPortNumber     : 3260
PSComputerName       :

Looks good so you permanently register it (you don't want your iSCSI volumes disappearing after a reboot after all this).

PS C:\Windows\system32> Get-IscsiSession | Register-IscsiSession

Now, check to see if you have a iSCSI session:

PS C:\Windows\system32> get-IscsiSession

AuthenticationType      : NONE
InitiatorInstanceName   : ROOT\ISCSIPRT\0000_0
InitiatorNodeAddress    :
InitiatorPortalAddress  :
InitiatorSideIdentifier : 400301370020
IsConnected             : True
IsDataDigest            : False
IsDiscovered            : True
IsHeaderDigest          : False
IsPersistent            : True
NumberOfConnections     : 1
SessionIdentifier       : bfbfe030cd87c020-400201370020d002
TargetNodeAddress       :
TargetSideIdentifier    : 4f00
PSComputerName          :

Looking good.  Now check your drives again:

PS C:\Windows\system32> get-disk

Number Friendly Name                            Operationa Total Size Partition
                                                lStatus                Style
------ -------------                            ---------- ---------- ---------
0      XENSRC PVDISK SCSI Disk Device           Online          88 GB MBR
1      XENSRC PVDISK SCSI Disk Device           Online          40 GB MBR
2      EQLOGIC 100E-00 SCSI Disk Device         Online       77.01 GB RAW

You can see the Dell Equalogic SAN volume has been added as disk number 2.
Now you just need to format the disk and give it a drive letter:

PS C:\Windows\system32> Get-Disk | Where partitionstyle -eq 'raw' | Initialize-D
isk -PartitionStyle MBR -PassThru | New-Partition -AssignDriveLetter -UseMaximum
Size | Format-Volume -FileSystem NTFS -NewFileSystemLabel "iDisk3" -Confirm:$fal

DriveLetter FileSystemL FileSystem  DriveType  HealthStat SizeRemain       Size
            abel                               us                ing
----------- ----------- ----------  ---------  ---------- ----------       ----
F           iDisk3      NTFS        Fixed      Healthy      76.91 GB      77 GB

Remember: Get-Disk | Where partitionstyle -eq 'raw' is CRUCIAL if you do not want to initialize a disk with data on it already.

That's it.  You've added an iSCSI drive from the command line.

Wednesday, December 17, 2014

Hard Disks with PowerShell

The other day, I needed to extend a Hyper-V iSCSI disk store (after increasing the size on the SAN).  I didn't know how.  One of our consultants used DISKPART - oh yeah - forgot that from NT 3.51 (or perhaps earlier).  I was using PowerShell's Get-Disk but wasn't able to go much further.  So I mocked up a VM to play with.  I added a drive and formatted it (after looking at the Hey, Scripting Guy! blog).
  PS  C:\Windows\system32> Get-Disk | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle MBR -PassThru |New-Partition -AssignDriveLetter -UseMaximumSize |Format-Volume -FileSystem NTFS -NewFileSystemLabel "disk2" -Confirm:$false

You can run most of the commandlets between the pipes as individual commands (not sure that makes it any easier).

Anyway, once I had my test drive, it was time to expand it.  I halted the system and then made the changes in Citrix XenCenter.  After restarting, I checked to see that the drive was now 40GB instead of 25GB.  HOWEVER, this is misleading.  Although the DRIVE is now 40GB, the partition being used is still only 25GB.

PS C:\Windows\system32> Get-Partition -DiskNumber 1
Disk Number: 1

PartitionNumber DriveLetter  Offset       Size Type
--------------- -----------  ---------    ---- ----
1               E            1048576     25 GB IFS

To expand the disk, I had hoped there was a simple "MaxSize" but instead I found this:

PS C:\> $size = (Get-PartitionSupportedSize –DiskNumber 1 –PartitionNumber 1)

PS C:\> Resize-Partition -DiskNumber 1 –PartitionNumber 1 -Size $size.SizeMax

Ta-dahh!  Sadly, DISKPART is easier.  But, for the PowerShell purists, running Windows Core 2012 R2, this does the trick.


Friday, September 12, 2014

When your VM gets stuck in suspended mode in Red Hat KVM...

I needed to re-do my network interfaces in KVM - make more bridged Ethernet connection for the VMs to use.  I totally forgot that I had a guest VM running as I began my reboot.  "Suspending SSB2" it says as I panic suddenly realizing what I had done.  It's ok - I've done this before I quickly remember.  It does a great job of automatically suspending and resuming UNLESS YOU JUST HAPPEN TO CHOSE THAT REBOOT TO SCREW UP THE NETWORK CONFIGURATION.

So, it reboots and networking is goofed.  I quickly see what I did, fix and reboot again.  This time it's ok but the SSB2 VM does not start.  I try to start it manually and get the message:

libvirtError: error creating macvtap type of interface: Device or resource busy

Whatever that means.  (It actually means I tried to un-suspend but couldn't talk to the iSCSI network so we're leaving it in limbo).  I google and google and find a lot of folks in the same boat.  They came up with some very iffy and convoluted solutions involving editing multiple XML files, etc.  I follow the threads to the bottom of each.  None of them seem quite right.

New to KVM, I try clonging the non-startable SSB2 and succeed.  It boots and works (requires a lot of network changes, but oh well).

Still not satisfied I see mention of "/var/lib/libvirt/qemu/save/"  (it's in my case).  Again some very complicated procedures involving editing multiple XML files, etc. with no guaranteed results by the author.

Since I have a working clone, I figure "What the heck!  I'll just delete "/var/lib/libvirt/qemu/save/" and try starting.  It worked!  -Except for one snag - I already had an exact doppleganger running.  It locked up my virt-manager and the server hard.  After, rebooting all was well.

This worked for me.  On a TEST system.  Use at your own risk.