Here is the deal, I have a Western Digital MyBook 1TB NAS. It runs a trimmed version of Linux, called BusyBox. For the past two weeks I’ve been busy hacking and customizing it.
Linux MyBookWorld 2.6.17.14 #1 PREEMPT Fri Jan 18 10:40:25 GMT 2008 armv5tejl GNU/Linux
Recently after upgrading to latest firmware version 2.00.18, I found that gcc was missing. I started following this guide to restore gcc. But, as darn Murphy would have it, I didn’t read the whole thing and just executedfind / -name *gcc*mv /lib/libgcc.* /tmp
which was a huge mistake.
The guide directed to delete files only in the /usr folder! But, I moved or deleted items from /lib!
Now, none of the commands were working, cp, mv, wget, ls, ln
.
I tried the following as a trial fix:
- PATH=$PATH:/tmp
- Tried setting various env variables
- Tried various combos of LD_PRELOAD with ldd
- ln -s /tmp/libgcc_s.so.1 /lib/libgcc_so.1 (ln didn’t execute)
- Final option was to remove the HDD from the enclosure and add it to a desktop running Linux and copy the two missing files back to the /lib directory. But, this option is a big PITA as it involves opening the very well made vibration resistant HDD enclosure setup. Another bit I read was that the disk may be encrypted and can’t be read on another system.
The Solution
Finally, I hit the pay dirt. The following fixed my cp
command and I was able to restore the missing files!
LD_LIBRARY_PATH=/tmpLD_PRELOAD=/tmp/libgcc_s.so.1
export LD_LIBRARY_PATH LD_PRELOAD
Just remember not to reboot the device once you did the screw up. Wait, sweat it out. I said to a colleague at office, “Its Linux, of course it can be FIXED without rebooting!”. Long live *nix!
PS: now, I am scared to reboot after fixing it, all hell might break loose!
Tags: CLI Linux NAS Tshoot