If you wanna resize a partition with gparted…

…you gotta manually compile the latest version of e2fsck.


OK, it’s not that difficult, but you would think the error messages for such a common operation would have been more helpful. I’m just trying to extend the Raspberry Pi image I just flashed so it takes up the whole SD card.

Here’s how to do the thing.

For the record, e2fsck is the ext-filesystem-specific component of the fsck filesystem utility. I have just this week been using it to check ext filesystems for errors like so:

e2fsck /dev/sdb5 (or whatever)

Make sure the drive is unmounted first:
umount /dev/sdb

Be careful; that’s umount, not unmount. I can’t tell you how many times that used to throw me off!


Additional issues! For some reason I could mount the filesystem once, but not again after that. Apparently I should have just resized the filesystem manually instead of using gparted to begin with. I resolved the issue thanks to the info found in this thread and the following commands:

(make sure partition is unmounted)
e2fsck -f /dev/sdX
resize2fs /dev/sdX

Locked Out in Windows Safe Mode

A smiling dog sits at a table surrounded by fire saying, "This is fine."

So I was fiddling with my desktop system the other day trying to fix a problem, and I set my system boot options to reboot into safe mode. Unfortunately, I accidentally selected Safe Mode WITHOUT Networking, which meant I could no longer use the network to connect with Microsoft/Live account, which meant I couldn’t log in to my admin account at all! It just wouldn’t accept my password, and there was no option for a PIN. No matter what I tried, I couldn’t get out of safe mode or turn on networking because I couldn’t log in! Microsoft, per usual, was absolutely no help. I found many others with this same problem, but no solutions.

I had a small moment of calm panic. Had I just completely locked myself out of my system? Was I going to have to reinstall the operating system? Continue reading “Locked Out in Windows Safe Mode”

Running ctypes in Python 3

Ball python, Photo credit: Micheal McConville

I’ve been teaching myself Python lately and I’m working through a few different books to do so. One of them is Gray Hat Python by Justin Seitz. I feared it might be a little dated, but it looked like a fun way to learn.

From the very first, “Hello World!” I was already unable to get my code to run. Here’s the example:

from ctypes import *

msvcrt = cdll.msvcrt
message_string = "Hello world!\n"
msvcrt.printf("Testing: %s", message_string)

All my console printed was:



It didn’t work in Eclipse, and it didn’t work with the command line (I’m on my Windows 10 machine). There were no errors thrown, and the correct function was clearly being accessed, but something was causing the function to stop after the first character. Some quality time with Google led me to several other people with this problem, people who were obviously following the same book I was and equally stumped. Unfortunately all the answers given either didn’t work for me or they were just too far over my head for me to practically sort out.

Well after banging my head against this for hours, I finally found a solution! As always seems to be the case, the problem was simple: printf in this instance works with Python 2.x and it expects strings to be encoded as bytes. By contrast, in Python 3, the version I have installed, literal strings are in unicode. I needed to find a way to get the string and the function to to speak the same encoding language. But the code solution given in the post in which I learned this discrepancy still didn’t work, nor did a few others I tried. Frustrated, and at this point having wasted 2 or 3 hours, I decided to do once last round of searches before calling it a night. That’s when I stumbled upon this post in a Python mailing list archive. Simply changing printf() to wprintf() fixed my problem! I now have a couple of different ways to get around this issue in the future!

So, for anyone else working through Gray Hat Python with Python 3, the final working solution is:

from ctypes import *

msvcrt = cdll.msvcrt
message_string = "Hello world!\n"
msvcrt.wprintf("Testing: %s", message_string)

Happy coding!