When the WD Mybook Live 3TB NAS was released, I went out and bought one and promptly put all my stuff on it. I have never kept anything *really* important on there as I didn’t have anything to back up all that data on to. Anyway, the NAS was destroyed in a thunderstorm one day but fortunately the hard disk still worked. Unfortunately the way WD formats these NAS hard disks is very strange indeed. Normal means of recovering data from them don’t work. Scouring google for tips on how to get your data back results in nothing useful.
I tried various hard disk enclosures.. these have no chance as they all pretty much only support up to 2TB disks. I tried various ext2/ext3 windows drivers.. no good. I tried linux machines with custom built kernels.. also no good.
There are basically three problems:
- The hard disk is big, USB enclosures hate that
- The hard disk uses a (new) GTP partitioning scheme, older versions of Linux will struggle.
- The hard disk ext4 partition (the one with all your data on) is formatted using 64kb sectors. This is the biggest hurdle as your PC running linux will not be able to mount it!
To recover your data:
A rough understanding of Linux is useful. In short you’re going to need to get the hard disk out of the NAS enclosure, stick it into a PC running a recent(ish) version of Linux and mount the partition using fuseext2. The trick to being able to mount the 64k sector disk is to avoid directly mounting it using the most excellent fuseext2 package. You’ll also need somewhere to put the recovered files – maybe another WD NAS? Maybe not
Step by step:
- I recommend getting an old PC (with sata ports inside) and an old hard disk for installing Xubuntu (no need for ‘heavy’ Ubuntu) on. Don’t plug in your WD hard disk yet, you don’t want to accidentally format it!
- Once you’ve installed xubuntu or whatever you’re using, turn off the machine and plug in the WD hard disk. Boot it back up again.
- Start a terminal and type:
sudo apt-get install fuseext2 parted
sudo parted -l
- The parted -l command will show you hard disks and partitions labelled /dev/sd.. something. You will see both the hard disk you installed linux on and the WD hard disk. The WD one will have a label such as: Model: ATA WDC WD30EZRS-11J (scsi), have a look down the list of partitions for the big ext4 one, like this:
4 4624MB 3001GB 2996GB ext4 primary
Make a note of the disk (/dev/sdb) displayed underneath the hard disk model, and the partition number (in my case number 4). The path to the partiton for me is /dev/sdb4 (it may be different for you).
- Now you’re ready to mount the disk. To make life easier for you non-terminal types, I’ve provided instructions on mounting it in your home directory:
sudo mkdir -p ~/WD
sudo fuseext2 -o ro -o sync_read /dev/sdb4 ~/WD
You may hit various hurdles along the way. I’m not entirely sure if older PCs can support really big hard disks. If you’re using an earlier mybook world or something I believe they used XFS and software raid partitions which this blog post isn’t really about.
Remember, always back up anything you care about!
Please let me know if you found this useful, and link to it so it helps others stuck in the same situation!!
More info: Mounting filesystems > 4Kb block sizes on Linux
No doubt many others have thought of this already, but today I had a brainwave..
You have forms that use the dreaded captcha, which just sucks. Better forms use a honey pot trap but it’s still a bit weird. What if we checked to see how long a user had spent filling out a form – a bot will take (not much time) to complete the form where as a human being will take slightly longer, say anything over 5s.
Surely if we just check to make sure the form hasn’t been completed at in-human speeds we know if it’s a bot? If the form is somehow completed very quickly we can fall back to captcha, but for Pete’s sake – let’s stop using captcha by default.
Several years ago a new framework called CakePHP was released and I was quick to jump on the band wagon. The promise of having base code that does 90% of the work for you was too tempting and we quickly got burned trying to perform more complex SQL queries – hitting the boundaries of what was possible and having to hack our way around it. Ugh.
Still, when you go back to writing an MVC style web app from the ground up you quickly realise that life would be much easier with a framework. A year or so after CakePHP I had a go with CodeIgniter and found it’s less strict Model paradigm easier to work with as you could just pass straight SQL to your database. Sure it lacked some features but it was easy to work with and easy to pick up.
Then I became freelance and did a bunch of work with WordPress, which I really like but it’s not a framework (though I do think it’s under-used and underrated).
So, as of August last year I started a new job where we use Zend Framework. My first impression was ‘wow, this is cool – very professional!’ 6 months in, and though I’ve not used it lots I think I can safely say it’s nothing like Cake or CI – it’s far more complicated, there are no walk through guides – you must invest good time learning it (something which there wasn’t time for me to do..)
I now know enough about ZF1 to get by, but last night I had a look at zend framework 2.. it appears as though a whole new level of complexity has been added. I spent a couple of hours trying to figure out what the hell was going on and (for the time being) gave up!
I concluded a few things:
- Zend Framework is a ‘nuts and bolts’ framework.. it feels much more like a bunch of helper classes to help you make your own framework. This is flexible, but complicated and time consuming.
- Things that are complicated are more easy to break.
- Zend Framework is nothing like the other frameworks out there. It takes a long time to develop good things.
- The learning curve is steep. Steep enough to make you wonder if it makes any sense for a business to pursue it..imagine if all your future employees need to spend 2 months learning something before they can begin work?
- Following on from 4 – if other companies/startups etc. aren’t using zend framework because it’s too time consuming for creating websites compared to other frameworks then does it make me valuable as someone who knows ZF? I guess you could look at this one in two lights really. In some ways it could make me more valuable!
- One worrying thing about working with ZF1 was that different people on the team approached similar work in very different ways because of the flexibility ZF offers.. one person used Zend_Db_Table where another might use something else.. one person may have written a wrapper for something, put something in a library, a service or a base controller – things can quickly get out of hand.
Food for thought, but it’s becoming apparent that investing your time in one framework is a very serious thing to do.. everyone knows PHP, but when the frameworks become almost as complex as the language itself it becomes a serious investment of time for a web programmer.
I’d very much appreciate people’s comments on this
Please note: I’ll be revisiting this post on and off as I gain more experience with both ZF1 and ZF2 and I’ll be looking into other frameworks such as Yii and Symfony over the coming months.
Just a quick update.. I assure you this site is still active I’m currently extremely busy but I have lots of cool things coming up.. arduino based notification system with REST service, technical project management ideas, gitflow, and mindful programming technique.. nice.
It’s by no means perfect (will allow 0000001, 000, 1.0000, 0.0), but it’s not bad for general purpose.
I’ve often had issues with character sets getting muddled up.. generally from my clients pasting ISO-8859-1 special chars into my sites that are UTF-8. Today I discovered the super-handy iconv() function that’ll convert character sets.. in this case I needed to drop down to ascii for generating pdfs with dompdf:
$output = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
This always ends up being a bit tricky, and some guides I’ve found on the net differ slightly from what I’ve got here. This seems to work pretty well for me on Debian.
Enter the following into /etc/sshd/config to allow sftp and to lock a user into a specific chroot’ed directory:
Subsystem sftp /usr/lib/openssh/sftp-server
For each user you want to lock down, you’ll first need to add the user, set the shell to false so they can’t log in via ssh and then set their home directory to where you want them chroot’ed:
usermod -s /bin/false joebloggs
usermod -d /srv/www/somehome/ joebloggs
Now just add a few details for the user to /etc/sshd/config:
Match User joebloggs
The users home directory must be owned by root and only writable by root – bit weird, but you get odd auth messages and it doesn’t work otherwise. There’s probably a work-around for this, but for me it doesn’t really matter. If or when I do need a work around I’ll post it here. Feel free to leave comments with tips/suggestions!
A lot of sites will tell you to do this:
CREATE TABLE t2 SELECT * FROM t1;
Problem is that you’ll lost your auto_increment, primary key and any other indexes you have (and any other extra meta data like that.)
This might not be the best solution, but hey it worked for me:
CREATE TABLE t2 LIKE t1;
INSERT INTO t2 SELECT * FROM t1;
Hope that helps somebody.. I only noticed I’d lost all my primary keys after copying a load of tables using the old method.
For about a year I noticed that very infrequently my VPS would run out of memory.. at first I thought it was probably just a wordpress plugin, but after a while I discovered it was actually saslauthd. This is a known bug (not known very well though..) with saslauthd on Debian. Anyway, here’s the fix – I’m not totally sure of the implications, so if you run a busy mail server I’d recommend you look into it a bit more before doing it:
I changed this line:
Update the file: /etc/default/saslauthd
OPTIONS=”-c -m /var/run/saslauthd”
OPTIONS=”-c -m /var/spool/postfix/var/run/saslauthd -r”
I think this basically disables threading and enables forking of the process (or something like that) which is what was responsible for the memory leak.
So if you’re running out memory on your server, maybe give this a try
[Thanks to Djamu: http://www.howtoforge.com/forums/archive/index.php/t-52750.html ]
I’ve just started to learn a bit of ActionScript for a new project I’m working on. The first thing I needed to do was integrate a message from the source html (and eventually a php file.) Turns out there’s pretty much no clear documentation out there on the web, so I decided to write this.
First thing’s first, create a text object in your flash file and set the instance name to something you can easily remember, in this example I set it to message. Once you’ve done that, on the keyframe for the layer in which that peice of text is, right click it and click on actions, then add the following:
this.message.text = LoaderInfo(this.root.loaderInfo).parameters.mymessage;
<param name="movie" value="test.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="test.swf?mymessage=workingok" quality="high" bgcolor="#ffffff"
width="600" height="450" name="test" align="middle" allowScriptAccess="sameDomain"
That’s basically where you set the variables you want to pass to flash. You have to urlencode each parameter. If you don’t know what that means, google it.