Raspberry Pi Remote Root Access

Now some of you will write in no doubt and say how easy this is – how could I possibly not know this. Well, I didn’t. I found out two other things this week – so here’s the lot in one go.

SD Card Cloning

But before I start, here’s something else I just cleared up – cloning of microSD cards. I was SURE I read there was an issue cloning the Pi SD cards. So having set up my Pi2 the way I wanted it with just about everything but the kitchen sink in it, I decided to start the second Pi2 from scratch – well that didn’t work out because about 2.3rds the way through setting up the many programs, the think ground just about to a halt – I mean like 5 minutes to power up. Was it the microSD?, was it the Pi? was it the setup?  I decided I had nothing to lose by cloning the microSD with Windows 8.1 using Win32DiskManager.

So that I did and sure enough – I now have two fully functioning Pi2 boards, one on and the other on – oh and that includes WIFI – I just plugged an identical WIFI module into the second Pi, powered it up and it just worked.

SD Card Lifetime

Something ELSE I just discovered. So I was getting worried about the lifetime of the microSD given that I’m using mySQL for example which surely must hammer the disk. WELL, it turns out that as well as looking for memory cards with SPEED you need to consider automatic levelling. EH? Don’t worry you don’t have to do anything. So imagine the Pi is writing to the card over and over in the same spot. Well, you only get 10s of thousands of writes and depending what you’re doing that could be wrapped up in weeks never mind years. It turns out that SD cards with automatic levelling (Samsung Ultra comes to mind as against cheap unbranded crap) actually have a controller in there that monitor usage and move stuff around for you!! The downside is that there’s always the possibility you finish what you’re doing, shut off and.. lose some data – so – shut the Pi down properly and use some kind of uninterruptable supply. SOME phone chargers will act like an uninterruptable, some won’t… you’ll have to take pot luck on that, I have 4 different battery packs (JuiceBar etc) and only two of them make reliable uninterruptable power supplies.

Remote Access to Pi Files

and so finally onto remote access…. up to now I’m using WinSCP on the PC talking to TightVNCServer on the Pi2 boards.. but could never get past user pi level access – in other words it I typed in root and a password, no matter what password it would not work. I could have SWORN I had typed in a root password.. however, obviously not.

So off I went to the web to find out how to fix  that, most of the instructions said “just enable a root access password and you can then log in using WinSCP as root”. HAH, all very nice but how the hell do you do THAT?

Turns out it’s easy… open a terminal in the Pi (unless you’re already in command line mode) – and type…

sudo passwd root

at which point you get asked for a password twice and Bob’s your uncle!! So now I can access the Pi files from my PC from either device – as Pi or Root as easy as clicking a couple of buttons.



5 thoughts on “Raspberry Pi Remote Root Access

  1. In the server-admin world, it's considered bad form to allow remote access as root; the normal practice is that a remote user is granted sudo access to do root-y things when required.

    Not a problem if you're only drinking with Windows guys. 😉

  2. SD Card Lifetime - "automatic levelling"

    Every branded manufacture like Samsung, Sandisk, Toshiba ect. has here own patents for virtual mapping, dynamic and static wear-leveling, and automatic block management to ensure high data reliability and maximize flash life expectancy.

    So if your work is important for you by from a known company 🙂

    1. So here's a question - we can run any old memory test program to get the SPEED of SD - but is there a freeby out there for PCs that will test whether or not wear levelling is implemented and any other related info??? Amazing what you think of once you're aware of something 🙂

  3. SD Card Cloning:

    Hi Pete, you can run into a problem with Win32DiskManager if the source card is slightly larger than the destination, even by a small amount; just a few 512 byte blocks difference is enough. If you hit the issue, the app flags a mismatch and won't write back the image. This can even happen between the same make and model of card - as I found out recently with a pair of 8GB Sandisk micro SD cards. There seem to be two easy fixes for this:

    Firstly, you can track down a 'V1.0' version of Win32DiskManager - it's mentioned in the Pi forums somewhere but I have lost the link - this version (which isn't on the official site, which also makes me a bit uncomfortable using it) apparently does not check the card size before writing the image, so you may end up with a truncated partition than needs to be manually resized (and hopefully no data has fallen off the end!). This seem a little hit and miss for me, so I went for Plan B:

    'BillW' has written a bash script that runs on the Pi and backs-up the live system to a second microSD card in a USB adaptor. The script copes with mismatched card sizes and seems to work very well - although there is the caveat that it's best if the Pi is 'quiesced' during the backup operation so that databases and important log files remain consistent. Considering that the alternative is to completely shut down the Pi2 to clone the card, using the script with some pre and post processing to stop database activity and/or do a database dump isn't too much hassle. It took about 9 minutes to backup a Kingston 8GB card to a class 10 8GB Sandisk. The script is on Github and there's a good readme with more info. Worth a look:


Comments are closed.