Tuesday, April 17, 2012

Clone Arch root

This script will make a clone of my root directory onto a mounted partition. It is far from perfect!
It requires my root /etc/fstab plus a "clone-version" /etc/fstabClone (see below)
It requires folders /mnt/ssdRootClone on the original and /mnt/ssdRoot on the Clone.
I run it as root.

##############################################################################

#!/bin/bash
# fileinfo.sh
LOG="/var/log/cloneArch.log"
date=`date "+%a %b %e %H:%M:%S %Y"`
DESTINATION="/mnt/ssdRootClone"
#DESTINATION="/home/david/Clone"
FSTAB="/etc/fstab"
FSTABCLONE="/etc/fstabClone"


FILES="/bin
/boot
/dev
/etc
/lib
/lib64
/opt
/root
/run
/sbin
/srv
/tmp
/usr
/var"


FOLDERTOREMOVE="$DESTINATION/boot/grub/grub"


echo "$date : " >>$LOG
echo "$date : System is being cloned." >>$LOG
echo "$date : Clone mounted at $DESTINATION" >>$LOG
echo "$date : " >>$LOG


# Clear the variable directpries from the destination first
#rm -rf $DESTINATION/tmp
#rm -rf $DESTINATION/var


for file in $FILES
do
  
  if [ ! -e "$file" ]       # Check if file exists.
  then
    echo "$date : $file does not exist and has not been cloned." >>$LOG
  else


    # Clone the system here
    echo "$date : $file is next." >>$LOG
    # rsync options used
    #
    # -a, --archive
    # This is equivalent to -rlptgoD. It is a quick way of saying  you
    # want  recursion  and want to preserve almost everything (with -H
    # being a notable omission).  The  only  exception  to  the  above
    # equivalence  is when --files-from is specified, in which case -r
    # is not implied.
    #
    # Note that -a does not preserve hardlinks, because finding multiply
    # linked  files is expensive.  You must separately specify -H.
    #
    # -u, --update
    # This  forces rsync to skip any files which exist on the destination 
    # and have a modified time that  is  newer  than  the  source file.
    # (If an existing destination file has a modification time equal to
    # the source file's, it will be updated if the sizes  are different.)
    #
    # Note  that this does not affect the copying of symlinks or other
    # special files.  Also, a difference of file  format  between  the
    # sender  and receiver is always considered to be important enough
    # for an update, no matter what date is on the objects.  In  other
    # words, if the source has a directory where the destination has a
    # file, the transfer would occur regardless of the timestamps.
    #
    # This option is a transfer rule, not an exclude,  so  it  doesn't
    # affect  the  data  that  goes  into  the file-lists, and thus it
    # doesn't affect deletions.  It just limits  the  files  that  the
    # receiver requests to be transferred.
    #
    # -H, --hard-links
    # This tells rsync to look for hard-linked files in the source and
    # link together the corresponding files on the destination.  With-
    # out  this option, hard-linked files in the source are treated as
    # though they were separate files.
    #
    # This option does NOT necessarily ensure that the pattern of hard
    # links  on  the  destination  exactly matches that on the source.
    # Cases in which the destination may end up with extra hard  links
    # include the following:
    #
    #
    # o      If  the  destination contains extraneous hard-links (more
    #        linking than what is present in the  source  file  list),
    #        the  copying  algorithm  will  not break them explicitly.
    #        However, if one or more of the paths have content differ-
    #        ences,  the  normal  file-update process will break those
    #        extra links (unless you are using the --inplace  option).
    #
    # o      If you specify a --link-dest directory that contains hard
    #        links, the linking of the destination files  against  the
    #        --link-dest files can cause some paths in the destination
    #        to become linked together due to the --link-dest associa-
    #        tions.
    #
    #
    # Note  that  rsync  can only detect hard links between files that
    # are inside the transfer set.  If rsync updates a file  that  has
    # extra  hard-link connections to files outside the transfer, that
    # linkage will be broken.  If you are tempted to use the --inplace
    # option to avoid this breakage, be very careful that you know how
    # your files are being updated so that you  are  certain  that  no
    # unintended  changes  happen due to lingering hard links (and see
    # the --inplace option for more caveats).
    #
    # If incremental recursion is active (see --recursive), rsync  may
    # transfer a missing hard-linked file before it finds that another
    # link for that contents exists elsewhere in the hierarchy.   This
    # does  not  affect the accuracy of the transfer (i.e. which files
    # are hard-linked together), just its efficiency (i.e. copying the
    # data for a new, early copy of a hard-linked file that could have
    # been found later in  the  transfer  in  another  member  of  the
    # hard-linked  set  of files).  One way to avoid this inefficiency
    # is to disable incremental recursion using the --no-inc-recursive
    # option.
    rsync -aqHu --delete --stats --log-file=$LOG --log-file-format="%n" $file $DESTINATION
    # make use of "$ du" command
    # du -s $file | awk '{ print $2 "is " $1 }'
    echo "$date : $file successfully cloned." >>$LOG
  fi
done  


# After cloning, fstab is going to mount the wrong partition
# Use the fstabClone for the corrected mounts.
if [ ! -e "$FSTABCLONE" ]       # Check if file exists.
then
  echo "$date : $FSTABCLONE does not exist and has not been copied." >>$LOG
else
  rm $DESTINATION$FSTAB
  cp -Rp $FSTABCLONE "$DESTINATION$FSTAB"
  echo "$date : /etc/fstab corrected for the clone." >>$LOG
fi


# After cloning ac opy of grub needs to be removed
rm -rf $FOLDERTOREMOVE
echo "$date : grub has been cleaned up for the clone." >>$LOG
echo "$date : " >>$LOG


echo "$date : System cloning is complete." >>$LOG
echo "$date : " >>$LOG


exit 0


##############################################################################


Here are the /etc/fstab and /etc/fstabClone files, respectively.


##############################################################################


# /etc/fstab: static file system information
#
# <file system> <dir> <type> <options> <dump> <pass>
tmpfs /tmp tmpfs nodev,nosuid 0 0
#
LABEL=htpcHome /home ext4 defaults 0 1
LABEL=ssdRoot / ext4 defaults 0 1
LABEL=ssdRootClone /mnt/ssdRootClone ext4 defaults 0 1
LABEL=slackRoot /mnt/slackware ext4 defaults 0 1
LABEL=grubPartition /boot/grub ext4 defaults 0 1
#LABEL=ssdSwap swap swap defaults 0 0
/dev/sda2 swap swap defaults 0 0
LABEL=mythGlenelg /home/david/MythTV/Glenelg xfs defaults,noatime,nodiratime,nosuid,nodev,allocsize=64m 0 1
LABEL=mythSturt /home/david/MythTV/Sturt xfs defaults,noatime,nodiratime,nosuid,nodev,allocsize=64m 0 1
# NFS client
#david-desktop:/ /mnt nfs4 rw,hard,intr,bg 0 0
#david-desktop:/music /home/david/Music nfs4 rw,hard,intr,bg 0 0
#david-desktop:/movies /home/david/Movies nfs4 rw,hard,intr,bg 0 0
# Samba
//david-desktop/movies /home/david/Movies cifs noatime,nodiratime,bg,username=david,password=david 0 0
//david-desktop/music /home/david/Music cifs noatime,nodiratime,bg,username=david,password=david 0 0
//david-desktop/tvseries        /home/david/TVseries    cifs    noatime,nodiratime,bg,username=david,password=david        0 0
##############################################################################

and 

##############################################################################

# /etc/fstab: static file system information
#
# <file system> <dir> <type> <options> <dump> <pass>
tmpfs /tmp tmpfs nodev,nosuid 0 0
#
LABEL=htpcHome /home ext4 defaults 0 1
LABEL=ssdRoot /mnt/ssdRoot ext4 defaults 0 1
LABEL=ssdRootClone / ext4 defaults 0 1
LABEL=slackRoot         /mnt/slackware  ext4    defaults        0 1
LABEL=grubPartition /boot/grub ext4 defaults 0 1
#LABEL=ssdSwap swap swap defaults 0 0
/dev/sda2 swap swap defaults 0 0
LABEL=mythGlenelg /home/david/MythTV/Glenelg xfs defaults 0 1
LABEL=mythSturt /home/david/MythTV/Sturt xfs defaults 0 1
# NFS client
#david-desktop:/ /mnt nfs4 rw,hard,intr,bg 0 0
#david-desktop:/music /home/david/Music nfs4 rw,hard,intr,bg 0 0
#david-desktop:/movies /home/david/Movies nfs4 rw,hard,intr,bg 0 0
# Samba
//david-desktop/movies /home/david/Movies cifs noatime,bg,username=david,password=david 0 0
//david-desktop/music /home/david/Music cifs noatime,bg,username=david,password=david 0 0
//david-desktop/tvseries        /home/david/TVseries    cifs    noatime,bg,username=david,password=david        0 0
##############################################################################


Thursday, April 12, 2012

Post about getting MythTV backend to wake for recordings

Thanks, Lester_Burnham for this post!

Simple test to wake the machine 5 minutes from now (if this works, you're pretty much set)

sudo sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm"
sudo sh -c "echo `date '+%s' -d '+ 5 minutes'` > /sys/class/rtc/rtc0/wakealarm"
cat /sys/class/rtc/rtc0/wakealarm
 
Check

cat /proc/driver/rtc
 
This should return a list of parameters. Check the alrm_time is 5 minutes into the future and the alrm_date is today. Shutdown your computer and see if it comes back up in ~5 min.

sudo shutdown -h now
 
If the alarm is set then you should see something like this. If so then shutdown and see if it wakes up at the alarm date/time.

rtc_time : 13:40:26
rtc_date : 2008-12-21
alrm_time : 10:45:00
alrm_date : 2008-12-22
alarm_IRQ : yes
alrm_pending : no
24hr  : yes
periodic_IRQ : no
update_IRQ : no
HPET_emulated : no
DST_enable : no
periodic_freq : 1024
batt_status : okay

Wednesday, April 11, 2012

.lircrc file and .lirc folder

This is the ~/.lircrc file.


#Custom lircrc generated via mythbuntu-lirc-generator
#All application specific lircrc files are within ~/.lirc
include ~/.lirc/mythtv 
include ~/.lirc/irexec
include ~/.lirc/mplayer 
include ~/.lirc/xine 
include ~/.lirc/vlc 
include ~/.lirc/xmame 
include ~/.lirc/xmess 
include ~/.lirc/totem 
include ~/.lirc/elisa 


This is the ~/.lirc/mythtv file



# LIRCRC Auto Generated by Mythbuntu Lirc Generator
# Author(s): Mario Limonciello, Nick Fox
# Created for use with Mythbuntu

begin
    remote = mceusb
    prog = mythtv
    button = RecTV
    config = R
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Guide
    config = S
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Back
    config = Escape
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = OK
    config = Return
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Right
    config = Right
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Left
    config = Left
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Down
    config = Down
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Up
    config = Up
    repeat = 0
    delay = 0 
end


begin
    remote = mceusb
    prog = mythtv
    button = Hash
    config = D
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Clear
    config = Q
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Enter
    config = Z
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Stop
    config = Escape
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Pause
    config = P
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Record
    config = R
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Play
    config = P
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Rewind
    config = <
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Forward
    config = >
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = ChanDown
    config = Down
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = ChanUp
    config = Up
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = VolDown
    config = [
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = VolUp
    config = ]
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = More
    config = I
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Mute
    config = |
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Home
    config = M
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Skip
    config = Right
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Replay
    config = Left
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Nine
    config = 9
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Eight
    config = 8
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Seven
    config = 7
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Six
    config = 6
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Five
    config = 5
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Four
    config = 4
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Three
    config = 3
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Two
    config = 2
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = One
    config = 1
    repeat = 0
    delay = 0
end


begin
    remote = mceusb
    prog = mythtv
    button = Zero
    config = 0
    repeat = 0
    delay = 0
end




The folder (and in fact this file) can be found at this post of Arkays.


A good post from rileyp about making custom ~/.lirc/irexec is located here.


My original forum post on getting mceusb remote (logitech harmony 525) working for MythTV in Arch Linux is here.

lircd.conf in /etc/lirc folder

#


# brand:                        HP 


# model no. of remote control:  TSGH-IR01


# devices being controlled by this remote: HP Slimline S3100y


#


# RC-6 config file


#


# source: http://home.hccnet.nl/m.majoor/projects_remote_control.htm


#         http://home.hccnet.nl/m.majoor/pronto.pdf


#


# used by: Philips


#


#########


#


# Philips Media Center Edition remote control


# For use with the USB MCE ir receiver


#


# Dan Conti  dconti|acm.wwu.edu


#


# Updated with codes for MCE 2005 Remote additional buttons


# *, #, Teletext, Red, Green, Yellow & Blue Buttons


# Note: TV power button transmits no code until programmed.


# Updated 12th September 2005


# Graham Auld - mce|graham.auld.me.uk


#


# Radio, Print, RecTV are only available on the HP Media Center remote control


#


#


# Updated with codes for MCE 2007 Remote additional buttons


# Visualization, Aspect, SlideShow, Eject


# Note: 


# Renamed some buttons: DVD->DVDMenu, More->MoreInfo, Star->Asterisk, Hash->Pound


# Note: 


# Blue, Yellow, Green, Red, and Teletext buttons do not exist on the HP remote






begin remote






  name        mceusb


  bits                 16


  flags  RC6|CONST_LENGTH


  eps                  30


  aeps                100






  header       2667   889


  one           444   444


  zero          444   444


  pre_data_bits        21


  pre_data        0x37FF0


  gap              105000


  toggle_bit           22


  rc6_mask    0x100000000










      begin codes






#seen on HP Pavilion dv3t remote  --Tim Mann, 3 Nov 2009


Media         0x00007b7f


PlayPause     0x00007b91










#unused by HP remote


Blue      0x00007ba1


Yellow      0x00007ba2


Green      0x00007ba3


Red      0x00007ba4


Teletext      0x00007ba5






#ba6 - bae unused 


        BA6           0x00007ba6


        BA7           0x00007ba7


        BA8           0x00007ba8


        BA9           0x00007ba9


        BAA           0x00007baa


        BAB           0x00007bab


        BAC           0x00007bac


        BAD           0x00007bad


        BAE           0x00007bae






        Radio         0x00007baf


        Print         0x00007bb1






#bb2 - bb4 unused  


        BB2           0x00007bb2


        BB3           0x00007bb3


        BB4           0x00007bb4






        Videos        0x00007bb5


        Pictures      0x00007bb6


        RecTV         0x00007bb7


        Music         0x00007bb8


        TV            0x00007bb9






#bba - bbf unused 


        BBA           0x00007bba


        BBB           0x00007bbb


        BBC           0x00007bbc


        BBD           0x00007bbd


        BBE           0x00007bbe


        BBF           0x00007bbf


#bc1 - bca unused 


        BC1           0x00007bc1


        BC2           0x00007bc2


        BC3           0x00007bc3


        BC4           0x00007bc4


        BC5           0x00007bc5


        BC6           0x00007bc6


        BC7           0x00007bc7


        BC8           0x00007bc8


        BC9           0x00007bc9


        BCA           0x00007bca






        Eject         0x00007bcb


        SlideShow     0x00007bcc


        Visualization 0x00007bcd






#bce - bcf unused 


        BCE           0x00007bce


        BCF           0x00007bcf


#bd1 - bd7 unused 


        BD1           0x00007bd1


        BD2           0x00007bd2


        BD3           0x00007bd3


        BD4           0x00007bd4


        BD5           0x00007bd5


        BD6           0x00007bd6


        BD7           0x00007bd7






        Aspect        0x00007bd8


        Guide         0x00007bd9


        LiveTV        0x00007bda


        DVD           0x00007bdb


#NoGap


        Back          0x00007bdc


        OK            0x00007bdd


        Right         0x00007bde


        Left          0x00007bdf


        Down          0x00007be0


        Up            0x00007be1


#NoGap


        Star          0x00007be2


        Hash          0x00007be3


#NoGap


        Replay        0x00007be4


        Skip          0x00007be5


        Stop          0x00007be6


        Pause         0x00007be7


        Record        0x00007be8


        Play          0x00007be9


        Rewind        0x00007bea


        Forward       0x00007beb


#NoGap


        ChanDown      0x00007bec


        ChanUp        0x00007bed


        VolDown       0x00007bee


        VolUp         0x00007bef


#NoGap


        More          0x00007bf0


        Mute          0x00007bf1


        Home          0x00007bf2


        Power         0x00007bf3


#NoGap


        Enter         0x00007bf4


        Clear         0x00007bf5


#NoGap


        Nine          0x00007bf6


        Eight         0x00007bf7


        Seven         0x00007bf8


        Six           0x00007bf9


        Five          0x00007bfa


        Four          0x00007bfb


        Three         0x00007bfc


        Two           0x00007bfd


        One           0x00007bfe


        Zero          0x00007bff


      end codes






end remote

Monday, April 9, 2012

Farmerdave's htpc components

Gigabyte ga-ma78gm-s2h
AMD Athlon X2 4850e
2GB DDR2 800MHz ram
MSI RX2600XT GPU (needed for the component TV-out – older tv) - removed

Asus GeForce GT430 Silent
Leadtek DTV2000H Tuner