In the previous blog, I explained how I got to this point. Briefly, I have a new B+ RaspberryPi and a WD Labs PiDrive HDD. The aim is to end up with Jessie Lite booting off the PiDrive.
There are 2 key sources of information that I used. First is one from AdaFruit and the second a script from the EmonCMS scripts repository with some documentation here. They are largely the same.
I found the USB_HDD script in the EmonCMS repository worked well except that it fails first time. One solution suggested is to put a ‘wait’ in, but I found that simply running it a second time seems to solve the problem. No real idea why! I think it may be that the second time it is run, the folder is already created so it keeps going.
If I was doing it again, I would change the size of the partition so that it did not create one big partition, but rather a smaller one for the system and a larger one for data.
Failed SD and Recovering Booting off the HDD
I have just has a failure of an admittedly, recycled, SD card. The problem was I did not have a backup of the cmdline.txt file. If you have looked at the script, you will see it gathers some information about the HDD partition and then creates the cmdline.txt entry to boot off the SD Card.
After much fiddling I discovered the solution was quite simple (would have been simpler if I had backed up the file).
First thing is to get a new SD Card, and put the image of your choice on it. Personally a Jessie Lite fits on a 2Gb card so I go with that. Plug the HDD in and boot the Pi. It will of course boot into a bare system running off the SD Card. All you need to do, is change the cmdline.txt (simple eh?).
First you need to know what the drive is called. It is most likely to be sda1, so the command:
1 |
sudo blkid -o export /dev/sda1 |
will produce something like:
1 2 3 4 5 6 |
DEVNAME=/dev/sda1 LABEL=rootfs UUID=c1f02081-41ec-4ed0-8caa-9c0a4d76d144 TYPE=ext4 PARTLABEL=primary PARTUUID=e73d1bef-e989-4d28-805c-e14c9a931f1c |
What we are trying to do is get that value of PARTUUID into the cmdline.txt so it looks something like this;
1 |
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=E73D1BEF-E989-4D28-805C-E14C9A931F1A rootdelay=5 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait |
I had some fun getting it into the file. the only way I could find was to sudo -s to permanently be the super user, backup the existing file
1 |
cp cmdline.txt cmdline.working |
then pipe the value of PARTUUID into the file so;
1 |
blkid -o value -s PARTUUID /dev/sda1 >> /boot/cmdline.txt |
if you then edit the file nano /boot/cmdline.txt (or use your favourite editor) to get the line looking as above.
Once you have done that simply reboot check it all works then save the cmdline.txt file somewhere on the HDD. Once you have done that you will, of course, never need it.
On the off chance that this does not work, you can put the SD Card in another machine and copy the cmdline.txt back (so it boots off the SD Card) and then look into it further.
by