29 August 2016

Mac: Move iTunes Library

Moving the iTunes Media folder is easy enough, but if you want to move the library files as well you have to work a little harder

  1. Close iTunes
  2. Copy the "iTunes" folder to a new location
    NB "iTunes Media" is a sub folder.
  3. Delete the original (it'll still be in trash)
  4. Create a new iTunes folder in the same location. iTunes requires it to be:
    Users/<user>/Music/iTunes
  5. Create links from the new location back to the old location:
    1. cd Users/<user>/Music/iTunes
    2. Using Terminal create links here to the new location:
      sudo ln "/<some location>/iTunes/iTunes Library Extras.itdb"
      sudo ln "/<some location>/iTunes/iTunes Library Genius.itdb"
      sudo ln "/<some location>/iTunes/iTunes Library.itl"
      sudo ln "/<some location>/iTunes/iTunes Music Library.xml"

28 August 2016

XenServer: Re-attach Existing or Create Local Storage


To re-attach exxisting storage e.g. when you've done a destructive upgrade of XenServer and have the OS on one drive and some VMs on another one, or when you need to create it

These are my notes from other posts here and here.

To Create a Repository

  1. List the paritions:
    cat /proc/partitions
  2. List the disks by id and match your parition to the scsi-<some UUID>
    ll /dev/disk/by-id
  3. Create the storage repository
    1. Get the host id
      xe host-list
    2. Create the SR:
      xe sr-create uuid=<VG Name UUID> type=lvm name-label="Local storage 2" content-type=user
      xe sr-create content-type=user device-config:device=/dev/disk/by-id/<scsi...> host-uuid=<host-uuid> name-label=”Local Storage 2” shared=false type=lvm

To Connect a Storage Repository

  1. Find the state of the physical drives:
    pvdisplay
    or: cat /proc/partitions
  2. Use the returned 'VG Name' to introduce it to XenServer:
    xe sr-introduce uuid=<VG Name UUID> type=lvm name-label="Local storage 2" content-type=user
  3. Connect the physical block device (PBD) with the SR:
    1. Get the host's UUID
      xe host-list
    2. Get the device name:
      ls -l /dev/disk/by-id
      You need one ending -part1,2 etc
    3. Connect the device:
      xe pbd-create host-uuid=<host UUID> sr-uuid=<VG Name UUID> \ device-config:device=/dev/disk/by-id/<device name>
    4. Plug in the new disk
      xe pbd-plug uuid=<UUID>

To Remove a Repository

  1. Find the UUID
    xe pdb-list
  2. Remove it
    xe pbd-unplug uuid=<device UUID>
  3. Remove it:
    xe sr-forget uuid=<sr-UUID>
    NB: this is the sr-uuid not the uuid

21 August 2016

Linux: Setup SSH Keys Authentication

Setup a Client Key

  1. Setup key pair on client computer:
    ssh-keygen -t rsa
    1. Optionally create a passphrase (that needs to be entered each time)
  2. Copy the key to the destination server:
    ssh-copy-id <user>@<destination ip>
    or
    cat ~/.ssh/id_rsa.pub | ssh <user>@<destination ip> "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"

Disable password login for SSH

    1. Create a backup of the settings:
      sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.factory-defaults
      sudo chmod a-w /etc/ssh/sshd_config.factory-defaults
    2. Edit the config file:
      sudo vi /etc/ssh/sshd_config
    3. Find PasswordAuthentication yes (/PasswordAuthentication in vi)
      Change to: PasswordAuthentication no
    4. Optionally disable root login with password also:
      PermitRootLogin without-password
    5. Restart ssh:
      reload ssh
      or
      service sshd restart

To Remove an Authorised Host

vi /root/.ssh/authorized_keys
Delete the line for your client

19 August 2016

Android: Amazon Video on Android

I think it's a shame I feel the need to write this post, but anyway, to run Amazon Prime Video on Android you need to jump through a few hoops:

  1. Install Amazon App on Play Store
  2. Install Amazon Underground from: http://www.amazon.com/apps
    NB: You'll need to allow apps from unknown sources to do this
  3. Use Amazon Underground to search for and install Amazon Video

16 August 2016

XenServer: Increase the Memory of VM


  1. Shutdown the VM either by logging in and shutting down or force using xe (not recommended):
    xe vm-list (to get the UUID of the machine)
    xe vm-shutdown uuid=<VM UUID> force=true
  2. Find the VM name:
    xe vm-list
  3. Check the existing memory:
    xe vm-list name-label=<VM name> params=all |grep memory
  4. Use xe vm-memory-limits-set to set the memory:
    xe vm-memory-limits-set dynamic-max=<dynamic max> dynamic-min=<dynamic min> static-max=<static max> static-min=<static min> name-label=<VM name>
    NB: If you're setting statics then all are the same except static min which is 536870912 on my machine
  5. Restart the VM:
    xe vm-start vm=<VM name>
  6. Once it's restarted, ensure it has the correct memory e.g. on Ubuntu this is:
    free

Linux: Free Up Disk Space

See where space is being used
df -h
sudo du -xm / | sort -rn

Ubuntu

On ubuntu you can free up space by clearing old app caches:

apt-get clean all
apt-get update
apt-get -f install
apt-get autoremove

Freeing up Disk Space


  • Delete log files in tmp
    cd /tmp/
    rm -rf *.log
  • Delete archived log files in tmp:
    rm -rf /var/log/*gz
    or to do this recursively:
    To see what it will delete:
    find . -name "*log*.gz" -type f
    find . -name "*log*.gz" -type f -delete

Log Rotate

Amend /etc/logrotate.conf e.g. using a guide like this one on thegeekstuff.com
e.g. reduce the amount you keep by

# keep 1 weeks worth of backlogs
rotate 1

06 August 2016

Ubuntu Reconnect After Network Fail

I recently had an Ubuntu system upgrade fail part way through with the result that it would not longer connect tot he net. I resolved it by carrying out the following. Your situation may be different.

If you run ifconfig -a you should get information about your ethernet adapters, but if this is not the case these steps might help.
  1. /etc/resolv.conf was missing so I recreated the link: ln -s /run/resolvconf/resolv.conf
  2. Then reconfigured it: dpkg-reconfigure resolvconf
  3. Add a route: ip route add default via 192.168.0.1 dev eth0
Then I was able to run apt-get update and all was good after a reboot