User avatar
solar3000
Posts: 1051
Joined: Sat May 18, 2013 12:14 am

/=ext HDD; /boot=SD, from rasp.img file

Tue Jul 02, 2013 6:02 pm

Raspbian fully on external hard disk drive
I was able to get raspbian / to be fully on an external (powered/desktop) hard drive. /boot remains on the SD in vfat.
It works and I need people to look at what I did and tell me if I did anything wrong or that you would do it differently and why.

* I made a copy of 2013...raspbian_file.img -- I'll call it raspian.img
* mount -o loop,offset=$((122880*512)) raspbian.img /mnt/src
why is there no space between the comma and offset?
* mount /dev/sda1 /mnt/dest
* mv /mnt/src/* /mnt/dest
everything is moved over except lost+found, it errored and got skipped because sda1 already has one
* edit /boot/cmdline....to use sda1
* rebooted and the hard drive started flapping around and after a few minutes my pi is alive with a new install
Antikythera

User avatar
rpdom
Posts: 15450
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: /=ext HDD; /boot=SD, from rasp.img file

Tue Jul 02, 2013 6:22 pm

solar3000 wrote:* mount -o loop,offset=$((122880*512)) raspbian.img /mnt/src
why is there no space between the comma and offset?
Because they are both part of the parameters to the "-o" option. If you had a space between them the "loop," would be taken as the parameter and the "offset=$((12880*512))" would be taken as the next option which should be the device/file name.
solar3000 wrote:mv /mnt/src/* /mnt/dest
Possibly better to use a cp or rsync command here. "mv" will move the contents from the source location to the destination - effectively deleting everything from your original image file. Which would make the file useless if you wanted to do the same for another Pi or disk.

User avatar
solar3000
Posts: 1051
Joined: Sat May 18, 2013 12:14 am

Re: /=ext HDD; /boot=SD, from rasp.img file

Tue Jul 02, 2013 6:51 pm

rpdom wrote:
Possibly better to use a cp or rsync command here. "mv" will move the contents from the source location to the destination - effectively deleting everything from your original image file. Which would make the file useless if you wanted to do the same for another Pi or disk.
I made a copy of the downloaded .img file, so I would delete the now empty .img file anyway.
Antikythera

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: /=ext HDD; /boot=SD, from rasp.img file

Wed Jul 03, 2013 1:14 am

I actually used dd to image off the 2 separate partitions within the image file.
that way I could again use dd to dd the separate partitions onto the SD card and USB drive.

Your way works though :)
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
solar3000
Posts: 1051
Joined: Sat May 18, 2013 12:14 am

Re: /=ext HDD; /boot=SD, from rasp.img file

Wed Jul 03, 2013 7:36 am

and what were the dd parameters you used to do so?
Antikythera

SteveSpencer
Posts: 351
Joined: Thu Mar 28, 2013 9:19 am
Location: Nottingham, UK

Re: /=ext HDD; /boot=SD, from rasp.img file

Wed Jul 03, 2013 8:27 am

Something that puzzles me. I understand the whole process of mounting, copying, and then altering the cmdline options on the boot partition.
However, I can't help wondering if you would need to change the contents of /etc/fstab on the HDD copy afterwards so it doesn't read:
  • /dev/mmcblk0p2 / ext4 defaults,noatime 0 1
but instead reads
  • /dev/sda1 / ext4 defaults,noatime 0 1
or am I missing something?
It also occurred to me that rebooting with the HDD attached is fine, but if you put in another USB storage device, how could you guarantee that the right one ended up as /dev/sda1?

(Never had this issue with UN*X when I was a lad - we used to install from 9 track magtape or those fancy new QIC tapes, and if we wanted driver support for new-fangled things, we had to write it)

Steve
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...

User avatar
rpdom
Posts: 15450
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: /=ext HDD; /boot=SD, from rasp.img file

Wed Jul 03, 2013 9:32 am

SteveSpencer wrote:Something that puzzles me. I understand the whole process of mounting, copying, and then altering the cmdline options on the boot partition.
However, I can't help wondering if you would need to change the contents of /etc/fstab on the HDD copy afterwards so it doesn't read:
  • /dev/mmcblk0p2 / ext4 defaults,noatime 0 1
but instead reads
  • /dev/sda1 / ext4 defaults,noatime 0 1
or am I missing something?
It also occurred to me that rebooting with the HDD attached is fine, but if you put in another USB storage device, how could you guarantee that the right one ended up as /dev/sda1?

(Never had this issue with UN*X when I was a lad - we used to install from 9 track magtape or those fancy new QIC tapes, and if we wanted driver support for new-fangled things, we had to write it)

Steve
Well, the / partition is mounted by the kernel using the command line parameters. It can't access the fstab file before then, so it doesn't use it. You can change the entry if you want, or comment it out - everything will still work.

As to having two devices connected at boot time - no, you can't guarantee that the correct one will be called /dev/sda. This is why many Linux systems use disk labels or UUIDs for the boot disk and root partition. The Pi doesn't support those in cmdline.txt, so the answer is not to plug in any other storage devices until the boot is well under way.

(I used to boot my Unix system from floppy on occasions, then use the QIC-60 tapes to install or restore the system)

SteveSpencer
Posts: 351
Joined: Thu Mar 28, 2013 9:19 am
Location: Nottingham, UK

Re: /=ext HDD; /boot=SD, from rasp.img file

Wed Jul 03, 2013 10:10 am

Right, that answers my questions nicely.
I understand about fstab not being available, but wondered if there was a knock-on effect if / needed to be remounted, and thinking more about it, probably not, but as you say, I can change it post-boot.

The additional media thing is a bit of a pain, if I suffered an unintentional reboot, but then, if I have my root FS on an external HDD, my SD card is less likely to be corrupted. Since I'll be running the HDD from a powered USB hub, connecting/disconnecting additional storage shouldn't be too painful either.

Thanks
Steve
(and the boot from floppy and restore from QIC reminds me of my much later SCO days... sigh!)
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...

SteveSpencer
Posts: 351
Joined: Thu Mar 28, 2013 9:19 am
Location: Nottingham, UK

Re: /=ext HDD; /boot=SD, from rasp.img file

Wed Jul 03, 2013 11:13 am

Curses!

It turns out that the HDD enclosure I am using requires a 'ums-cypress' module loaded before the drive is accessible. Is there a way to make this available on the boot partition, or will I have to find one that doesn't use the same USB/SATA bridge?

Without it, the system boots and sees the USB/SATA bridge, but then knows nothing about the drive beyond it, of course. :(
Steve
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...

RediJedi
Posts: 45
Joined: Sun Apr 21, 2013 9:56 am

Re: /=ext HDD; /boot=SD, from rasp.img file

Wed Jul 03, 2013 11:17 am

There was a post showing how you can make sure you mount the proper partitions using PARTUUID in cmdline.txt. I can't find it to link it but basicly:

Install gdisk, and use it to find the "partition unique GUID" for the linux filesytem copy it some where.

then open tune2fs and get the "filesystem UUID" copy it down.

open cmdline.txt and replace root=/dev/mmcblk0p2 with root=PARTUUID=<your part unique guid here>

then open /etc/fstab and replace /dev/mmcblk0p2 with UUID=<your filesystem UUID>

that should stop any problems when mounting and your filesystem can be on any free usb slot not just /dev/sda1

this is by no means a guide, just the basic steps I used. I will try to link to the original post if I can find it.

SteveSpencer
Posts: 351
Joined: Thu Mar 28, 2013 9:19 am
Location: Nottingham, UK

Re: /=ext HDD; /boot=SD, from rasp.img file

Wed Jul 03, 2013 3:04 pm

Hmm, as to my issue, I'm guessing not, having read through https://github.com/raspberrypi/linux/issues/75

Can anyone point me in the direction of a USB/SATA case (2.5") that uses a chipset that does work with only built-in modules?

I don't really want to have to build a custom kernel just to use an external HDD as a root FS...

Steve

User avatar
RaTTuS
Posts: 10493
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: /=ext HDD; /boot=SD, from rasp.img file

Wed Jul 03, 2013 3:07 pm

http://www.sendspace.com/file/uxxpiv
is a recent kernel with the module built in...
I use them on one of my setups
you could also add your request there ....
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: /=ext HDD; /boot=SD, from rasp.img file

Wed Jul 03, 2013 3:10 pm

solar3000 wrote:and what were the dd parameters you used to do so?
Don't quite remember, I'll have to dig them up.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
jackokring
Posts: 816
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: /=ext HDD; /boot=SD, from rasp.img file

Wed Jul 03, 2013 3:37 pm

The top USB port seems to be enumerated first (ID 4). The /etc/fstab does need to be altered as if you get a filesystem error need to mount read-only check, then your in a reboot loop. EDIT: Although why remounting at the same location would trust a filesystem with errors is perhaps a strange one. :D
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

SteveSpencer
Posts: 351
Joined: Thu Mar 28, 2013 9:19 am
Location: Nottingham, UK

Re: /=ext HDD; /boot=SD, from rasp.img file

Fri Jul 05, 2013 1:17 pm

From my experiments, the "top" first does seem to hold true.
I decided against using the custom kernel for now, at least until I have a cross-compiling environment available, and can do it for myself.
I've also discovered that the Touro 1TB external drives, although USB3, will, when plugged into a powered USB2 hub, work as a root FS, which gives me a lot of room. My next issue will be that of finding a USB/SATA bridge that does work out of the box (the Pi box) when I want to use an SSD instead because the real-life environment isn't conducive to using something with moving parts.

Given the state of the roads due to potholes and speed bumps (or sleeping policemen, if you prefer), mounting a spinning hard disk in a car doesn't seem like it will be without potential problems.
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...

User avatar
RaTTuS
Posts: 10493
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: /=ext HDD; /boot=SD, from rasp.img file

Fri Jul 05, 2013 1:28 pm

my car cam version runs fine....
RPI + camera + SSd + hub all powered from a lipo battery pack
the rootfs is on the ssd
[it is a cypress hub but I use my compiled kernel]
I need to re-do it all so I can switch it on and off auto magically but that will eb when I have some time...
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Return to “Advanced users”