Saturday, October 01, 2011

Persistent USB mount locations on Pogoplug (and other Linux devices)

In a previous post, I talked about how I set up rsync on my Pogoplug Biz for church. I had mentioned a Couple of “Gotchas”, such as the way USB drives may be a different device name upon reboot. This makes it hard to find the Optware drive consistently. Here is my solution.

Basically, you want to get the e2fs libraries and programs, then use blkid and findfs to locate the drive. As of Oct 2011, the links below are correct, but be sure to check http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/ and replace the file names as necessary.

The commands below will download and copy the necessary libraries and e2fs utilities for mounting your flash drive in the same location. I am assuming you are going to use the device UUID instead of the drive lable to locate the drive, but both are possible. I also assume that you want to modify the NAND (the Pogoplug internal flash drive) as little as possible. I am ONLY copying the files necessary for this task of finding and mounting specific USB drives to specific locations upon reboot.

Getting the e2fs libraries and utilities


cd /tmp
wget http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/e2fslibs_1.41.14-1_arm.ipk
tar xvzf e2fslibs_1.41.14-1_arm.ipk
tar xvzf data.tar.gz


wget http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/e2fsprogs_1.41.14-1_arm.ipk
tar xvzf e2fsprogs_1.41.14-1_arm.ipk
tar xvzf data.tar.gz


Copying the e2fs files to the internal flash memory
The following command makes it possible to change the Pogoplug flash memory, so be careful from here on out! Also, I am assuming that /usr/sbin is on your PATH.


mount / -o remount,rw,noatime


cd /tmp/opt/lib
mv libb* /usr/lib
mv libc* /usr/lib
mv libe* /usr/lib
mv libu* /usr/lib


cd /tmp/opt/sbin
mv blkid /usr/sbin
mv findfs /usr/sbin


OK, this puts the files on the NAND and I can use blkid to locate the optware flash drive by UUID, and use findfs use in /etc/init.d/rcS to mount it to /opt. Next I need to locate the actual device UUID for the startup script. Run blkid to get the UUID, and write this down.

blkid
/dev/sda1: UUID="2CB9-87AD" TYPE="vfat" LABEL="LeeJones"
/dev/sdb1: UUID="fc640330-9e49" TYPE="ext3" LABEL="OPTWARE"

NOTE: the UUID and LABEL are case sensitive.

In this case, my Optware drive has a UUID of fc640330-9349. Now we should be able to locate the Optware USB drive (or any particular drive) with the findfs command:


findfs UUID="fc640330-9e49"

This returns the result of /dev/sdb1


Editing the startup /etc/init.d/rcS script

Using your favorite text editor, add the following line to /etc/init.d/rcS before anything calls /opt

mount `findfs UUID="fc640330-9e49"` /opt

NOTE: The character before findfs is a back quote (`) not an apostrophe ('). Look for the back quote on the tilde key (~) next to your number 1 key.

Once you have saved the changes to rcS, reboot:

mount / -o remount,ro

sync
sync
reboot

Extra Credit

Personally, I want to minimize the changes to my copy of /etc/init.d/rcS, so mine is the factory default one plus the following two extra lines at the end:

mount `findfs UUID="fc640330-9e49"` /opt # mounts Optware USB
/opt/etc/init.d/optrun.sh # runs additional software

The contents of /opt/etc/init.d/optrun.sh are as follows:

#!/bin/sh
# runs optware startups in sort order
cd /opt/etc/init.d
for i in `ls S* | sort`
do
  ./$i start
done

This allows me to make minimal changes to /etc/init.d/rcS, just enough to find and properly mount Optware to /opt every single reboot. The optrun.sh command starts any additional things I want, such as rsync. Anything file in /opt/etc/init.d that is both executable and begins with a capital S will be ran at boot time.

Also, if I screw up on one on of my additions (been there) and disable my device, all I have to do is power off the Pogoplug, pull out the Optware USB drive and reboot. After a normal boot, I plug the drive back in and fix my mistake.

46 comments:

  1. I really have to admit it’s quite a novelty to arrive at a relatively ‘different’ blog like this, great job. I expect I’ll be coming back fairly soon and I look forward to reading your next post when I do.
    panerai replica

    ReplyDelete
  2. I have search your site through google.Thanks for sharing a beautiful and high quality informaton.i have a medical transcription
    company
    .again thanks...

    ReplyDelete
  3. very interesting post,i have bookmarked it,i have a list of cheap driving school in Alexandria,i wiill revist your blog.thanks...

    ReplyDelete
  4. Its Very Informative and useful blog! plz contact us for high quality work of seo services provider

    ReplyDelete
  5. wao very impressive blog.i have search it through yahoo.its very amazing.i have online toys store for your kids.c u again

    ReplyDelete
  6. Thanks, Can the same be done for the other drives as well so that they always mount with the same mnt_sd?# location?

    ReplyDelete
  7. Thanks for your sharing .I just wonder how you manage to collect so many great articles in a week. You are so hardworking to read so many articles. Is PayPal good enough to be used? I love this article

    ReplyDelete
  8. One thing that will really help you out with your spring cleaning is to invest in the right tools for organizing your home. If you don?t already have closet organizers, files for different documents and enough shelving, then spring is a good time to ma…

    ReplyDelete
  9. very nice blog and thanks for info

    thanks very much for sharing

    betty and friends

    ReplyDelete
  10. i have search your blog from google its very amazing i have bookmark it for revisit,here is a mango exporters from pakistancompany,mango is a delcious fruit.

    ReplyDelete
  11. I just found your blog and want to say thank you! What an enjoyable time looking
    through so many sites. Thanks for sharing and keep up the good work till the end.
    lawyer web design

    ReplyDelete
  12. What a cool post i have not seen anywhere thanks for share and keep up the good work.
    Travel to Vietnam in Luxury Way

    ReplyDelete
  13. Really informative post thanks for share and keep up the good work.
    Challenge Coins

    ReplyDelete
  14. It is superb and outstanding post thank you very much for share.
    Commercial Real Estate Software

    ReplyDelete
  15. I have search your site from bing, its very up to dated and a good soucrce of information.i am Custom Lapel Pins Maker

    ReplyDelete
  16. I have this same question.

    "Thanks, Can the same be done for the other drives as well so that they always mount with the same mnt_sd?# location?"

    ReplyDelete
  17. Its very nice site to visit, I like your content style its Excellent effort for updating site. i really find unique content in your site.Lapel Pins

    ReplyDelete
  18. Word Count

    I am spammer, but I am really happy to have participate in this discussion! Cheers.

    ReplyDelete
  19. A very well-written post. I read and liked the post and have also bookmarked you. All the best for future endeavors.
    Solar water Heater

    ReplyDelete
  20. The post is very informative. It is a pleasure reading it. I have also bookmarked you for checking out new posts. Solar panels

    ReplyDelete
  21. The post is handsomely written. I have bookmarked you for keeping abreast with your new posts.
    Solar panel cost

    ReplyDelete
  22. The post is very informative. It is a pleasure reading it. I have also bookmarked you for checking out new posts.
    Solar Panels for Home

    ReplyDelete
  23. Thanks for showing up such fabulous information. I have bookmarked you and will remain in line with your new posts. I like this post, keep writing and give informative post...!
    Solar battery charger

    ReplyDelete
  24. Good efforts. All the best for future posts. I have bookmarked you. Well done. I read and like this post. Thanks.
    Energy solar panels

    ReplyDelete
  25. It is a pleasure going through your post. I have bookmarked you to check out new stuff from your side.
    Commercial solar power

    ReplyDelete
  26. There are a number of points however which I believe would do better if you went into a little bit further detail than you have done. just my opinion, along with I’m not trying to be critical at all. If you do follow this up then I would be interested. Thanks.
    buy youtube comments

    ReplyDelete
  27. Stock Tips
    Stock market tips are suggested to the investors in the Indian Stock market to provide them to gain healthy profit.

    ReplyDelete
  28. Online Share Trading
    There are many blogs and sites which give stock tips and analysis about stock market, traders can take advice form these sites & blogs

    ReplyDelete
  29. Your writing in your blog is so creative..it brings us a smile as we read it. Thank you...
    Dubai Audit

    ReplyDelete
  30. I absolutely love your blog and find most of your post’s to be exactly I’m looking for. Again, awesome weblog!
    dubai offshore company incorporation

    ReplyDelete
  31. You seem to have a lot of confidence in the things you do. Nice post also! .
    Essay Help service

    ReplyDelete
  32. It’s good site, I was looking for something like this
    Cheap essay papers

    ReplyDelete
  33. Perfect piece of work you have done, this internet site is really cool with superb info .
    Online custom essay writing service

    ReplyDelete
  34. Good work done by the blogger, Keep up the work going………….
    paper writing service

    ReplyDelete
  35. Interesting blog post and very good website design, just bookmarked you. Thanks for sharing!
    essay writing services

    ReplyDelete
  36. Thanks for the information and for sharing your knowledge.
    company registration dubai

    ReplyDelete
  37. Lord Krishna Packers Movers offers services like Packing and Moving household goods and office goods in Delhi and to all India. packers and movers delhi is a best site for transportations of packers and mover in delhi.

    ReplyDelete
  38. I like your idea, its different from a lot of other sites. Nice blog too.
    Dubai Auditors

    ReplyDelete
  39. It's Very informative and trustworthy post,keep posting as well as great work.

    ReplyDelete
  40. Great post and thanks for sharing. It is really useful and helpful for me. Thank u…
    Dubai Auditors

    ReplyDelete
  41. Wohh just what I was looking for, regards for posting .
    Academic Writing Service

    ReplyDelete
  42. Incredible points. Sound arguments. Keep up the great work.
    essay writing

    ReplyDelete