Move root file system to usb drive?
#1
Question 
I've spent a while searching but haven't found anything yet. I'd like to use a usb flash drive to run the board from and not an sd card.
I had a quick look at the boot partition, but nothing jumped out as to how to achieve this.

Anyone done this yet?

Thanks.
  Reply
#2
Like any Linux system, the kernel is reading at some point the /etc/fstab file.
If you change it so that root mount point is mounting your usb flash, the root file system will be switched.
  Reply
#3
Big Grin 
It wasn't as simple as changing /etc/fstab as the root file system is already loaded. It actually turned out to be relatively simple though. Interesting journey to get there.

  1. So, I formatted my usb drive and copied the file system over using rsync.
  2. Then, to tell the boot process where the root file system is, you can edit uEnv.txt (in the FAT partition on the SD Card. I added the two lines below:
Code:
root=/dev/sda2
bootdelay=20

The journey to get here started with looking at initrd. I ended up extracting that and finding the script that loads the root file system and starting the boot process from there. I realized passing parameters to that would change the root fs, but couldn't work that out. I thought I could change the default, however I believe the script is always called with parameters so that doesn't help.
I then learnt some about u-boot. In the end one useful resource was this document. I had tried changing the uEnv.txt originally, but some of the online documents I found led me astray. After digging into longsleep's repository a little I came upon boot.scr. I first thought this was a simple text file for custom commands. Not quite. It is a compiled file from mkimage. However, within that I could add commands to override the root parameter used for setting the root file system. After getting that working, I realized that I could do the same thing more simply in uEnv.txt! A final note: it seemed that if I used the reboot command, it would hang with a hard lock on the cpu. Generally removing the power and doing a cold reboot worked. Adding the 'bootdelay' seems to have fixed both cases.
  Reply
#4
(05-23-2016, 09:02 AM)monty Wrote: It wasn't as simple as changing /etc/fstab as the root file system is already loaded. It actually turned out to be relatively simple though. Interesting journey to get there.

  1. So, I formatted my usb drive and copied the file system over using rsync.
  2. Then, to tell the boot process where the root file system is, you can edit uEnv.txt (in the FAT partition on the SD Card. I added the two lines below:
Code:
root=/dev/sda2
bootdelay=20

The journey to get here started with looking at initrd. I ended up extracting that and finding the script that loads the root file system and starting the boot process from there. I realized passing parameters to that would change the root fs, but couldn't work that out. I thought I could change the default, however I believe the script is always called with parameters so that doesn't help.
I then learnt some about u-boot. In the end one useful resource was this document. I had tried changing the uEnv.txt originally, but some of the online documents I found led me astray. After digging into longsleep's repository a little I came upon boot.scr. I first thought this was a simple text file for custom commands. Not quite. It is a compiled file from mkimage. However, within that I could add commands to override the root parameter used for setting the root file system. After getting that working, I realized that I could do the same thing more simply in uEnv.txt! A final note: it seemed that if I used the reboot command, it would hang with a hard lock on the cpu. Generally removing the power and doing a cold reboot worked. Adding the 'bootdelay' seems to have fixed both cases.

The best place to seek on this answer is Sunxi IRC. They recently have new developments on boot process such as EFI on SPI Flash, and may lead to your quest.
  Reply
#5
Hi,

i have root fs on external usb drive but sd card is still needed to boot (u-boot etc.)

Steps:
Usefull links:
https://github.com/longsleep/build-pine64-image/pull/13
https://github.com/longsleep/build-pine64-image/pull/17
http://forum.pine64.org/showthread.php?t...89#pid9289
  Reply
#6
(05-23-2016, 03:25 PM)jozzy Wrote: Hi,

i have root fs on external usb drive but sd card is still needed to boot (u-boot etc.)

Steps:
Usefull links:
https://github.com/longsleep/build-pine64-image/pull/13
https://github.com/longsleep/build-pine64-image/pull/17
http://forum.pine64.org/showthread.php?t...89#pid9289

Neat. Hows the performance?
You can find me on IRC, Discord and Twitter


  Reply
#7
(05-23-2016, 03:45 PM)Luke Wrote:
(05-23-2016, 03:25 PM)jozzy Wrote: Hi,

i have root fs on external usb drive but sd card is still needed to boot (u-boot etc.)

Steps:
Usefull links:
https://github.com/longsleep/build-pine64-image/pull/13
https://github.com/longsleep/build-pine64-image/pull/17
http://forum.pine64.org/showthread.php?t...89#pid9289

Neat. Hows the performance?

Much better. Maybe i give U some numbers:
SD card (ext4):
  • reading: max 16MB/s
  • writing: max 10MB/s

External usb<->sata disk (ext4):
  • reading: max 37MB/s
  • writing: max 34MB/s 
  Reply
#8
(05-23-2016, 04:10 PM)jozzy Wrote:
(05-23-2016, 03:45 PM)Luke Wrote:
(05-23-2016, 03:25 PM)jozzy Wrote: Hi,

i have root fs on external usb drive but sd card is still needed to boot (u-boot etc.)

Steps:
Usefull links:
https://github.com/longsleep/build-pine64-image/pull/13
https://github.com/longsleep/build-pine64-image/pull/17
http://forum.pine64.org/showthread.php?t...89#pid9289

Neat. Hows the performance?

Much better. Maybe i give U some numbers:
SD card (ext4):
  • reading: max 16MB/s
  • writing: max 10MB/s

External usb<->sata disk (ext4):
  • reading: max 37MB/s
  • writing: max 34MB/s 

Wow, pretty good stuff. That effectively doubled/ tippled the performance. Oh, and thank you for the instructions!
You can find me on IRC, Discord and Twitter


  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Rockpro64 NFS root mount (kernel 4.20) - ethernet help? tenspd137 0 448 12-06-2018, 01:14 AM
Last Post: tenspd137
  Boot issues: What todo when you muck up your FSTAB file Dagremote 1 765 04-16-2017, 10:28 PM
Last Post: pfeerick

Forum Jump:


Users browsing this thread: 1 Guest(s)