Any reason why you shouldn't do the switch to HDD before installing emoncms?

I guess this is a question to Paul...

Messing around with a new install and i wondered if there was any reason why if you plan to run from a USB HDD you shouldn't do the switch to the HDD from the SD card before doing all the install steps?

If so how would you do it? I've tried copying the usb_hdd file into the pi directory and using chmod but can't seem to get the system to see it as a valid executable file. I get 'command not found'.  This will absolutely be to do with my lack of linux skills   :-(

Paul, anyone, how would you do this?

Thanks for any help

Simon

pb66's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Hi Simon.

Assuming the file is accepting the executable status change (you can check using " ls -la ") are you prefixing your command to start the script with "./" if running from the same directory?

(the other) Paul

Bramco's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Hi Paul,

ls -ls gives

pi@HomePi-emoncms:~ $ ls -la
total 36
drwxr-xr-x 2 pi   pi   4096 Jan  3 15:58 .
drwxr-xr-x 3 root root 4096 Nov 21 20:32 ..
-rw------- 1 pi   pi   1088 Jan  3 15:56 .bash_history
-rw-r--r-- 1 pi   pi    220 Nov 21 20:32 .bash_logout
-rw-r--r-- 1 pi   pi   3512 Nov 21 20:32 .bashrc
-rw-r--r-- 1 pi   pi    675 Nov 21 20:32 .profile
-rwxr-xr-x 1 pi   pi   5178 Jan  3 15:04 usb_hdd
-rw------- 1 pi   pi     60 Jan  3 15:58 .Xauthority

then

pi@HomePi-emoncms:~ $ sudo ./usb_hdd -d /dev/sda
: No such file or directory

I've tried almost every other combo I can think of, e.g.:

pi@HomePi-emoncms:~ $ sudo usb_hdd -d /dev/sda
sudo: usb_hdd: command not found

I'm sure it's some arcane linux magic I'm not understanding....

Simon

PS I'm assuming by this that there is no real reason why you shouldn't do this first then do the install steps?

pb66's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

I see no reason you can't do it in that order, Ive not looked closely at the script to see if there are any pitfalls but it is a generic "move filesystem to hdd" script and not tied to emoncms.

I think the shebang forces the use of the bash command, try " sudo bash ./usb_hdd "

Paul 

Bramco's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Nah - then there's lots of errors:

pi@HomePi-emoncms:~ $ sudo bash ./usb_hdd -d /dev/sda
./usb_hdd: line 2: $'\r': command not found
./usb_hdd: line 8: $'\r': command not found
: invalid option9: set: -
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
./usb_hdd: line 10: $'\r': command not found
./usb_hdd: line 11: syntax error near unexpected token `$'{\r''
'/usb_hdd: line 11: `function print_version() {
p

I'm doing the install on Jessie Lite, so that might be the issue.

Never mind. I'd just thought it might be faster doing the install on the HDD rather than the SD card. Next time I'm messing with the full version of Jessie I'll try it out again.

pb66's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Could well be Jessie-lite, I had tried it on a full install of Jessie before I posted the "try bash" comment. although I was only checking for the script to start so I only called up the help text, I didn't enter any target details.

Paul

Paul Reed's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Hi Simon, the rationale in installing emoncms first, before moving root to a HDD, was simply to ensure that you got a basic 'working' system before doing anything further, so it would make troubleshooting easier. That's all.

How did you copy the script to your Pi - did you use a laptop/desktop?

If so, it may be that other than Unix line endings have been introduced ('\r' in your post above) and stopping the script from running. A way around this would be to git clone emoncms - so the script is downloaded direct to the pi, and try running it again - there's no need to set up emoncms - just run the script as per the guide.

Remember to check (as per the emoncms installation guide) is to make sure that your operating system only boots into the command line, and not Desktop. Because Desktop will mount your HDD when you connect it, and stop the script.

Paul

PS If you are using an external HDD, OS size shouldn't really be an issue, I just wondered why you chose Jessie Lite?

pb66's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

@Paul - well spotted, the "\r" could well be a OS line endings issue, I tested using "wget https://raw.githubusercontent.com/emoncms/emoncms/master/scripts/usb_hdd/usb_hdd" rather than cloning or trusting cut & paste.

Paul

 

Bramco's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Yep. Did the copy from windows, but.... I only copied the file, so not the content. The original worked though after the installation, so can't be any missing bits in Jessie lite.

As for Jessie lite, I only had a 4Gb SD lying around and the full Jessie is nearly 4Gb.

Paul Reed's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

...A way around this would be to git clone emoncms - so the script is downloaded direct to the pi, and try running it again

Did you try this?

Paul

Rhys's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Bramco,

I believe Paul is correct regarding the script having Windows line terminations.
The error lines you show above that have '\r' confirms it...

I'm not sure if the following will work, I'm still awaiting my first Pi so not sure of the device yet...
Paul's suggestion to download the script directly onto the Pi should work perfectly, but you can also try the following, if I'm correct about the Pi OS..
Execute
   sudo apt-get install dos2unix
if this installs
then try execute
   dos2unix usb_hdd
this should convert the file from Windows line terminations to LINUX line terminations.

Rhys

Paul Reed's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

...they can also be removed just by running the command below to strip out the offending line endings;

tr -d '\r' < input.file > output.file

Paul

Bramco's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Thanks guys,

It feels like back to the dark ages of 30 years ago with the DOS bs Unix line endings. I had blithely assumed that if I was moving a file round the systems wouldn't mess with it (especially as it doesn't have a type, e.g. .TXT) - how stupid can you be!!

I did do a git clone to my Windows machine and then used MobaXterm with the upload file button to get the file into the raspi, so I'm guessing it was the MobaXterm action that screwed it.

@Paul (Reed), I'm not sure I get the rationale of doing the install first, surely it doesn't matter if there are any issues either way. In fact you're minimally better off if it fails on an HDD because if the system is producing lots of log entries they are going to HDD not the SD so lengthening the life of the SD but I'm splitting hairs here of course.

@Rhys, I'm sure that would work but I think I'll wait until next time. Each re-install takes half a day as it is.

I think though in future I'll use the wget route Paul (pb) suggested.

Thanks for your help and insight guys.

Simon

Paul Reed's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

@Paul (Reed), I'm not sure I get the rationale of doing the install first...

I think that you've already proved my case!

If you had followed the installation guide you wouldn't have had this problem, because the guide tells you to git clone emoncms, which would give you a workable HDD script.

Paul

Bramco's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

I get your message Paul but my point was that it should be possible to do it either way. If I had another spare half day I'd try it HDD first to see if it is any faster.

Bramco's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Nothing ventured nothing gained - it's raining so can't/don't want to get out on the bike, so here's the results:

wget didn't work

pi@Homepi-emoncms:~ $ wget https://raw.githubusercontent.com/emoncms/emoncms/master/scripts/usb_hdd...
--2016-01-04 13:36:17--  https://raw.githubusercontent.com/emoncms/emoncms/master/scripts/usb_hdd/usb_hdd
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 62.252.172.241
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|62.252.172.241|:443... connected.
GnuTLS: A TLS fatal alert has been received.
GnuTLS: received alert [0]: Close notify
Unable to establish SSL connection.

   sudo apt-get install dos2unix   then   dos2unix usb_hdd worked of course.

Then doing the install up to the point where emoncms is installed which is the longest bit of the install, onto the SD card took 10% longer than onto the HDD, so no real gain there. In my case on a B it took about 30 minutes or so.

However - as I was doing this I realised the real reason why you would want to set up the SD card first is that you can make a copy of the image so you don't have to go through all the steps again.  

In fact it would be a good idea I think to add this to the instructions, especially now there is the button in Admin to back up the databases. This would enable anyone to quickly re-instate a system. So just after the sudo shutdown, add a note to the effect that at this point it's a good idea to make a copy of the SD card using Win 32 Disk Imager to do the read.

Simon

PS Still can't get this system to work but that's another story  :-(     More in another post  ;-)
 

 

pb66's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Simon - are you still using the lite Jessie?

The "wget" method should work without any issue, I've been using it as the "obvious tool for the job" for as long as I recall for fetching a very wide range of scripts from various targets very frequently and I never have any issues.

pi@raspberrypi:~ $ wget https://raw.githubusercontent.com/emoncms/emoncms/master/scripts/usb_hdd...
--2016-01-04 16:34:08--  https://raw.githubusercontent.com/emoncms/emoncms/master/scripts/usb_hdd/usb_hdd
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.31.19.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.31.19.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5029 (4.9K) [text/plain]
Saving to: ‘usb_hdd’

usb_hdd                           100%[==============================================================>]   4.91K  --.-KB/s   in 0s

2016-01-04 16:34:08 (20.0 MB/s) - ‘usb_hdd’ saved [5029/5029]

pi@raspberrypi:~ $

Is what you should get, that was just rechecked on a full Jessie install and it works just the same on wheezy. basically when browsing any code on github click on the "raw" button, copy the url into your ssh window with a "wget " prefix and job done no permission or cross platform line endings to worry about.

regards the "install order" it is best done in the order instructed, but ONLY because that's the order instructed, there are no major benefits to either route and comes down to personal preference, but if you follow the guide it will hopefully be a more well trodden path, tried'n'tested and therefore a good base to work from if things don't go quite to plan.

If you are looking for install speed then installing Raspbian direct to the hdd and editing the fstab and cmdline.txt files is the direct method. but the saving is still minimal and easily lost again if you don't get it right first time. 

If the basic "wget" isn't working I think you may well find other obstacles along the way too

Paul

EDIT - I just noticed the different IP's in your and my wget prints and noticed mine is the same every time I try it. if I navigate to just the ip used in my wget I find a github 404 page, but your wget ip is a blank page (for me) when doing a reverse lookup it is a virginmedia ip address, you may have dns issues.

Bramco's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Hi Paul,

I've had no other issues, only that the wget didn't work. I was doing this on Jessie Lite if you recall, so maybe that's the issue.

Simon

pb66's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

sorry, editing my post above while you where writing, see above.

Paul

Bramco's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

Hi Paul, thanks. Not a clue how to fix this. I can certainly get to the site from other machines. I'll have to have a play around tomorrow to see if I can work out what's wrong.

Lots of googling methinks....

Bramco's picture

Re: Any reason why you shouldn't do the switch to HDD before installing emoncms?

just a quick update. After posting on the RPi Forum and having a number of other Virgin Media users find that they wget works for them, I have to assume that the DNS server we get to use in our area is somehow out of step with others in the network.

There is a solution though.

Edit the file (sudo nano) /etc/resolvconf.conf

This is the config file for the resolv tool if I have things right. Gets a bit confused with names there.

Anyway, simply remove the # from the line name_servers=x.x.x.x  and replace the default with for example 8.8.8.8 for the google dns.

Shouldn't be necessary but it does work.

You can see the dns order in /etc/resolv.conf   (nearly the same name but this is the dymanic one managed by resolv - you shouldn't edit this.)  (There was another solution I tried which involved editing the dhclient file and adding the dns entry in there but this didn't seem to work for me.)

Simon

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.