Expanding a raw image file

On one of my customer’s devices, the backup software requires that the
backups go to a separate partition (or drive).  However, the customer
only has one raid array and the bulk of the space is in /home.   To work
around this limitation, I created a raw image file called backup.img,
which gets mounted as /backup.   After the software performs its local
backup, I use duplicity to backup /backup remotely to a backup server at
my location (with encryption).

Today I got an alert that /backup was running low on space.  It was an
80GB image and 61GB was in use, leaving only 15GB free.  Now, this
amount of free space should last quite a while.  However, the software
(cPanel)  has a known issue for years that the 80% limit is hardcoded
into the program.  I can change this, but every time cPanel updates, it
overwrites that change.

So to be proactive, I decided to go ahead and increase the image size.

In order to increase the size of an image, you simply unmount your raw
image and use the dd command.

# Increase by ~20GB
dd if=/dev/zero bs=1M count=20480 >> backup.img
# 20,480 is 20,480 MB or ~20GB

# check the filesystem
/sbin/e2fsck -f backup.img
# resize the filesystem
/sbin/resize2fs backup.img
# check the filesystem again
e2fsck -f backup.img               

Learning Python

I am reasonably familiar with Perl and PHP languages.  Recently though,
I have taken it upon myself to learn Python.  I’ve played with Python a
few times, and it seems to be very powerful with lots of useful
functionality under the hood.

For some basic practice, I recommend Learn Python The Hard Way,
which is free book by a reputable Python author, Zed Shaw.  He makes the
book itself available for free as a PDF download or you can purchase it
directly.  The book walks you through a number of examples, each one
building upon what you learned in the previous exercise.  You are
required to enter each exercise in by hand.  This uses the principle
that if you learn better by writing things down, you’ll learn better by
typing it in.  Copying and pasting completely bypasses that manual entry
learning process, so if you want to learn, I suggest you follow Shaw’s
instructions.  I found the book rather insightful, but I often felt that
certain aspects were not being properly explained to me.  To be fair,
I’m only up to exercise 15 in a 52 exercise book.

However, I also came across another way to learn Python.  Google has had
instructor Nick Parlante teach Python in a classroom setting.  The
class was video taped and put online along with the associated
learning aids (primarily a group of python files).  The class was taught
in 7 segments over 2 days.  So if you go to the class website, you can download the learning aids, and then follow along with
the lecture videos. 

I like this method better than following the static book.  Since it was
taught in an interactive classroom, it goes at a pace where you can keep
up with it from your own computer.  Also, students in the class were
able to ask questions, which allows the information to be represented in
a different way.  Finally, at the end of each segment, there are some
sample files you can open up in your editor.  Each file has a skeleton
template.  In comments, it tells you what a segment is supposed to do,
and you have to implement it in code based on what you learned while
watching the video.  The sample file also includes some bare bones “unit
tests” that call your functions, passing it input data and comparing it
to an expected output.  These unit tests will show what they received
from your function and what they expected.  If the two matched, you have

I like these practice samples mainly because it immediately forces you
to apply the knowledge you learned.  You do have to think about it and
do some back and forth troubleshooting on your own code.  Since they
provided the unit tests, you can get instant feedback on if you’re doing
it correctly or not.

If you want to learn Python and can dedicate an hour on any given day to
it, I recommend the Google course.  If you want to go in smaller 10-20
minute blocks, try using Learn Python The Hard Way.  Of course, you can
pause the videos and come back to them, but I think it’s much better to
go through the entire video, following along on your own system as you