Boot spoofing?

Has anyone produced a hardware spoof to make a hard disk appear as an SD card, for booting and the main storage?

Ideally, this would drive one of the stand-alone USB hard disks.

Reply to
Guy Tomsson
Loading thread data ...

Unlikely - emulating the SD card in hardware to the level that the Pi drives it, and then having a full USB stack to drive a HDD, would be painful.

However, what is possible is having a kernel image on an SD card that kexecs another kernel stored on a USB device. The Pi firmware still lives on the SD card, but everything from kernel downwards can live on the USB storage.

It's not too complex - you just need to build a Pi kernel (to live on the SD) with kexec support, and then call kexec with a new USB-based kernel filename and boot command line.

Theo

Reply to
Theo Markettos

That still is needlessly complex.

I'm booting from a SD card with a nearly unmodified raspbian image. My root filesystem is on an usb hard disk and I mount the first partition of the SD card as /boot.

root@raspberrypi:~# cat /etc/fstab proc /proc proc defaults 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 2 /dev/sda5 / ext4 defaults 0 1 /dev/sda6 /var ext4 defaults 0 1 /dev/sda7 /home ext4 defaults 0 1 /dev/sda2 swap swap defaults 0 0

I prepared the hard disk on a separate (i386) linux system that had a SD card reader (needed to access the SD card). In the text below I refer to the partitions on the drive as /dev/sdx5, /dev/sdx6, etc., where "sdx" represents the name of the drive as known on the linux system where I prepared the drive. On the raspberrypi the drive will be known as /dev/sda so that name needs to be used in etc/fstab as quoted above.

My preparation of the hard disk was:

-- partition the drive

-- create filesystems for /, /var and /home on /dev/sdx5, /dev/sdx6 and /dev/sdx7.

-- Mount /dev/sdx5 somewhere on a temporary mount point and create mountpoints for var, home and boot on this newly mounted filesystem.

-- Mount /dev/sdx6 on the mountpoint created above for "var" and mount /dev/sdx7 on the mountpoint for "home"

-- Mount the second partition of the SD card on another temporary mount point and copy its whole contents to the place where /dev/sdx5 was mounted. Make sure to preserve file permissions and ownerships.

-- Adjust /etc/fstab as quoted above.

-- mkswap /dev/sdx2

That is the whole preparation of the hard disk. Note that till now I didn't change anything on the SD card - I just copied stuff from the SD card to the hard disk.

The only change I made to the SD card was adjusting the "root=..." field in /boot/cmdline.txt. This can be done on a live raspberrypi booted from the SD, or on a separate system where you mount the first partition of the SD card.

root@raspberrypi:~# cat /boot/cmdline.txt dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda5 rootfstype=ext4 elevator=deadline rootwait

You might need to adjust the "rootfstype=..." field too if you want to switch from ext4 to something else.

After this connecting the HD to the raspberrypi and a reboot from the slightly modified SD card should be sufficient to boot with the root filesystem on the hard disk.

Regards,

Kees.

--
Kees Theunissen.
Reply to
Kees Theunissen

As ever, it depends what you want to do.

If you are content to keep your root FS on HDD and the kernel on the SD card, this will work. If you also want to keep your kernel on the HDD, you need some other way to call it.

But a simpler solution than kexec would be a bootloader like u-boot, where you can tell it where it should find the kernel to boot. I've not kept up with that project's current state, however.

Theo

Reply to
Theo Markettos

no idea if the raspberry can boot from USB, but you can put the /boot partition on a small SD card and then the / on the USB drive. I did a similar thing with a Alix board and it works well.

Bye Jack

--
Yoda of Borg am I! Assimilated shall you be! Futile resistance is, hmm?
Reply to
Jack

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.