Tuesday 30 November 2010

Backing up Entire Drives with [dd]

If you want to backup a partition use, [partimage]. It is excellent, and will happily achieve the task.

If, on the other hand, you want to backup the whole disk, there does not seem to me to be an OS alternative other than [dd].

To backup the [i]nput [f]ile (because in linux EVERYTHING is a file) [dev]ice [sda] in chunks with a [s]ize of 1 [M]ega[b]yte, [|] piping all data to the [bzip2] program set at the highest encryption setting [-9] to [>] the file [disk_image.301110.img.bz2] on the share [backup/reception] on the cifs server [readynasduo.local] from a live [ubuntu] user's account (having first browsed to the CIFS share, run this command:

sudo dd if=/dev/sda bs=1M | bzip2 -9 >'/home/ubuntu/.gvfs/backup on readynasduo.local/reception/disk_image.301110.img.bz2'

LFS - Powertop & acpi

Powertop is a system which is supposed to help you save battery life on a portable PC by identifying areas to optimise. Powertop requires lspci (optional) which in turn wants 'which', so:

wget ftp://ftp.gnu.org/gnu/which/which-2.20.tar.gz
tar -xzvf which-2.20.tar.gz
cd which-2.20
./configure --prefix=/usr &&
make
make install
cd ..
rm -rvf which-2.20

wget http://www.kernel.org/pub/software/utils/pciutils/pciutils-3.1.7.tar.bz2
tar -xjvf pciutils-3.1.7.tar.bz2
cd pciutils-3.1.7
make PREFIX=/usr ZLIB=no
make PREFIX=/usr install
make PREFIX=/usr install-lib
update-pciids
cd ..
rm -rvf pciutils-3.1.7

wget http://www.lesswatts.org/projects/powertop/download/powertop-1.13.tar.gz
tar -xzvf powertop-1.13.tar.gz
cd powertop-1.13
make
make install
cd ..
rm -rvf powertop-1.13.tar.gz

Just leave it running for 5+ minutes and you will get an estimate of usage.

Another useful power tool is acpi for getting battery information, and you install as follows:

wget http://sourceforge.net/projects/acpiclient/files/acpiclient/1.5/acpi-1.5.tar.gz/download
tar -xzvf acpi-1.5.tar.gz
cd acpi-1.5
./configure --prefix=/usr
make
make install
cd ..
rm -rvf acpi-1.5

Friday 26 November 2010

Extra Openbox Menu Items

Some items to add to the Openbox menu:

Here is an entry for Firefox 4 beta:

<item label="firefox"><action name="Execute"><execute>/opt/firefox4/bin/firefox</execute></action></item>

Here is an entry to Suspend the machine to RAM. I cannot get this actual command to run, so I have to pop the command in a script and then run the script. There has to be a better way of doing this.

<item label="Suspend to RAM"><action name="Execute"><command>~/str.sh</command></action></item>

cat > ~/str.sh << "EOF"
echo mem > /sys/power/state
EOF

The next two items would be good in the system section - Powertop for useful battery information, and top for system process information.

<item label="Powertop"><action name="Execute"><command>xterm -e /usr/bin/powertop</command></action></item>

<item label="Top"><action name="Execute"><command>xterm -e /usr/bin/top -i</command></action></item>

Friday 19 November 2010

LFS - Fonts

The standard font that X comes with is, bluntly, shit. So lets install some new fonts to brighten everything up.

Firstly, setup the directory to store the downloaded files in:

mkdir /sources/fonts
cd /sources/fonts

Next download a bog standard, and nice looking, free font, Dejavu. The commands basically 1. make a folder in /usr/share/fonts 2. copies all ttf files into that directory 3. runs the program fc-cache to load the ttf files.

wget http://sourceforge.net/projects/dejavu/files/dejavu/2.32/dejavu-fonts-ttf-2.32.tar.bz2/download
tar -jxvf dejavu-fonts-ttf-2.32.tar.bz2
cd dejavu-fonts-ttf-2.32/ttf
install -v -d -m755 /usr/share/fonts/dejavu &&
install -v -m644 *.ttf /usr/share/fonts/dejavu &&
fc-cache -v /usr/share/fonts/dejavu
cd ../../
rm -rf dejavu-fonts-ttf-2.32

Next we are going to install some Microsoft fonts - which are freely licensed. To do this we are going to need a bit of software to unpack the Microsoft archive:

wget http://www.cabextract.org.uk/cabextract-1.2.tar.gz
tar -xzvf cabextract-1.2.tar.gz
cd cabextract-1.2
./configure --prefix=/usr &&
make
make install
cd ..
rm -rf cabextract-1.2

Now we need to get the fonts:

wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/andale32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/arial32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/arialb32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/comic32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/courie32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/georgi32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/impact32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/times32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/trebuc32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/verdan32.exe/download
wget http://sourceforge.net/projects/corefonts/files/the%20fonts/final/webdin32.exe/download

We then install the fonts using a bit of a script to automate the repetitive commands. Apart from the cabextract command basically we are doing the same as the Dejavu commands above.

for msfont in andale32 arial32 arialb32 comic32 courie32 georgi32 impact32 times32 trebuc32 verdan32 webdin32
do
mkdir $msfont
cabextract $msfont.exe -d $msfont
cd $msfont
install -v -d -m755 /usr/share/fonts/$msfont
install -v -m644 *.TTF /usr/share/fonts/$msfont
install -v -m644 *.ttf /usr/share/fonts/$msfont
fc-cache -v /usr/share/fonts/$msfont
cd ..
rm -rf $msfont
done

I am not entirely sure if this last step actually does anything, but it is supposed to make a config file which anti aliases the fonts.

cat > ~/.fonts.conf << "EOF"
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <match target="font">
   <edit name="autohint" mode="assign">
     <bool>true</bool>
   </edit>
 </match>
</fontconfig>
EOF

Friday 12 November 2010

Command Line F1 Live Timing

Live Timing is pretty much essential for any self respecting F1 fan. It lets you follow what is going on for every car, so you are not restricted to what ever the (usually braindead) director chooses to show you from time to time.

Bad news. It needs Java to work. This is unfortunate if you want it to run on an inexpensive Netbook which struggles with Java. Also, it crashes from time to time, and restarting a browser and reloading a Java page is not much fun.

Helpfully some chap has written a command line client for live timing, and you can get it here:

wget http://launchpad.net/live-f1/0.2/0.2.10/+download/live-f1-0.2.10.tar.gz

You install it as follows:

tar -xzvf live-f1-0.2.10.tar.gz
cd live-f1_0.2.10
./configure
make

The software will now be available in the [./src] directory, and you can run it by typing:

./src/live-f1

You need to set up your user/password file in [~] as follows:

cat > ~/.f1rc << "EOF"
email YOUR_EMAIL_ADDRESS
password YOUR_PASSWORD
EOF

OBVIOUSLY you change the YOUR_X bits to match your log on details from the Live Timing's website.

Friday 5 November 2010

Wireless Networking on Maverick

Once I shifted to Maverick Meercat, I found that the drivers became obstinate. Helpfully the Broadcom folks have uploaded a couple of patches which sorts this out. These are then, updated instructions on how to get the fucking thing to work.

cd /media/2G
wget http://www.broadcom.com/docs/linux_sta/hybrid-portsrc-x86_32-v5.60.48.36.tar.gz 
wget http://www.broadcom.com/docs/linux_sta/sta_5.60.48.36_2.6.33_kernel_patch.zip
wget http://www.broadcom.com/docs/linux_sta/sta_5.60.48.36_2.6.34_multicast_kernel_patch.zip

My USB Stick is called [2G] so Ubuntu automounts it into a directory with the same name in [/media]. The next command downloads the latest version of the hybrid driver. I am not sure what a hybrid driver is, but if I had to guess I would say it is a driver AND firmware contained in the same package. Incidentally, you could just use the same URL in windows and save the file to the USB Key. You then reboot to the USB Key and run the following commands (ideally from a script):

cd /tmp
cp /cdrom/hybrid-portsrc-x86_32-v5.60.48.36.tar.gz .
mkdir hybrid_wl 
cd hybrid_wl 
tar -xzvf ../hybrid-portsrc-x86_32-v5.60.48.36.tar.gz
unzip /cdrom/sta_5.60.48.36_2.6.33_kernel_patch.zip
patch -p0 < patch
unzip /cdrom/linux_sta/sta_5.60.48.36_2.6.34_multicast_kernel_patch.zip
patch -p0 < patch_hybrid_multicast
make clean
make
sudo rmmod b43 
sudo rmmod b44 
sudo rmmod b43legacy
sudo rmmod wl
sudo rmmod ssb 
sudo rmmod ndiswrapper 
sudo rmmod lib80211
sudo modprobe lib80211
sudo insmod wl.ko

The [cp] commands [c]o[p]ys the file we downloaded into the current [.] directory, which is [/tmp] because we just moved into it. The patch commands change the source code files in terms of the instructions contained in the special patch files.

There are lots of [r]e[m]ove [mod]ules commands, because there are so many modules which potentially interfere with the [wl] driver. Again, once this script has finished, the interface should be up and running. This one will take a little longer to run because it is building the module from source code each time.