Wednesday, 7 October 2015

Why is Windows constantly writing to disk?

I was wondering why a Windows 7 VM was doing so much write I/O and why my hourly snapshots were so large.

Running

perfmon /res

showed me that is was the system process (PID 4) that was doing the bulk of the writing. Searching for what that meant turned up all kinds of possibilities, but no way to tell concretely what file was being written to. I tried disabling automatic updates, security essentials, removing the virtual CD-ROM device, etc. No luck.

This morning I discovered by chance that within Resource Manager (opened using the command above) you can expand the 'Disk Activity' pane which is below the 'Processes with Disk Activity' pane and closed by default. This will allow you to see the file names being written and sort by Write I/O.

I don't know why this wasn't suggested in the dozens of pages/posts/KB articles I read, but there you go. Hopefully this will help someone out there.

Sunday, 23 August 2015

Minecraft automatic starting, saving, and stopping

Here is a linux (Ubuntu) init script for starting and stopping (including running a /save-all to autosave) a pair of minecraft servers. Watch out for any line wrapping in the code below. Blogger has lousy support for code blocks. I've tried to keep it narrow but who knows. It's HTML. :)


#! /bin/sh
### BEGIN INIT INFO
# Provides:          minecraft
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Minecraft initscript
# Description:       Start and Stop minecraft servers
### END INIT INFO

# Author: Amos Hayes <ahayes@polkaroo.net>
#

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Minecraft Servers"
NAME="minecraft"
SCRIPTNAME=/etc/init.d/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
   screen -d -m -S minecraft_MyFirstServer \
      su - minecraft -c 'cd MyFirstServer;java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui'
   screen -d -m -S minecraft_MySecondServer \
      su - minecraft -c 'cd MySecondServer;java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui'
}

#
# Function that stops the daemon/service
#
do_stop()
{
        screen -S minecraft_MyFirstServer -p 0 -X stuff "/save-all$(printf \\r)/stop$(printf \\r)"
        screen -S minecraft_MySecondServer -p 0 -X stuff "/save-all$(printf \\r)/stop$(printf \\r)"
}

case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  restart)
        #
        # If the "reload" option is implemented then remove the
        # 'force-reload' alias
        #
        log_daemon_msg "Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          0|1)
                do_start
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                esac
                ;;
          *)
                # Failed to stop
                log_end_msg 1
                ;;
        esac
        ;;
  *)
        #echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
        echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
        exit 3
        ;;
esac

:

Friday, 17 July 2015

Lossless rotation of MJPEG video

Write out the JPEG frames:

avconv -i WHOOPS.AVI -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg


Rotate them losslessly:

exiftran -i -2 frame*.jpg


Reassemble the frames and grab the audio from the original file to create a new complete file:

avconv -framerate 29.97 -i frame_%d.jpg -i WHOOPS.AVI -codec copy /
   -map 0:v -map 1:a ROTATED.AVI

 

Update: When this was originally written, Ubuntu was using the avconf fork of ffmpeg. These days, try replacing `avconv` in the commands above with `ffmpeg`.

Disconnect and power off USB peripheral from the Linux command line

I have a headless Proxmox PVE node that I sometimes need to mount USB storage to. When I'm done with it I can unmount the filesystem on ...