Welcome! Log In Create A New Profile

Advanced

Booting Using Seperate boot AND rootfs Partitions

Posted by DonCharisma 
Booting Using Seperate boot AND rootfs Partitions
January 11, 2015 01:08PM
It's my understanding that uboot is limited in the filesystems it will boot from. Older uboot ext2 and ext3, and later ones will boot direct into ext4, I think - so don't quote me on that !

The new f2fs, and RAID can't be directly booted from a single boot/rootfs partition, because of the limitations in uboot - so you'll need a separate boot partition to boot into those filesystems.

Today I've successfully booted a basic 3 partition USB Drive, eg :

/dev/sda1/ boot ext2 (or ext3) ~ approx 200Mb (type 83)
/dev/sda2/ rootfs ext3 ~ 1GB (type 83)
/dev/sdb3 swap ~ 1GB (type 82)

First build the flash drive's partitions, preferably on a linux machine using fdisk /dev/sdx

I then built on /dev/sdb2 the rootfs following bodhi's instruction for 3.17.0 rootfs - Debian-3.17.0-kirkwood-tld-1 - here - http://forum.doozan.com/read.php?2,12096

Then it's just a "mv" command to move the /boot folder from /dev/sdb2 to /dev/sdb1

Don't forget to update the kernel to your specific device (as per bodhi's instructions, with the dtb file)

How uboot works with regard to the boot and rootfs partitions

Basically your uboot will search for the boot files (the kernel and intramfs files /boot/uImage and /boot/uInitrd) in the FIRST partition of any attached USB drives, it'll run with the first one it finds. THIS IS HOW THE KERNEL AND CRITICAL FILES ARE LOADED BY UBOOT.

When the kernel is ACTUALLY started, it is given 'bootargs'. This is the way we tell the kernel where the rootfs partition is - using the bootargs. In particular in my setup the relevant uboot variables :

usb_bootcmd=run usb_init; setenv usb_root LABEL=rootfs; run usb_set_bootargs; run usb_boot
usb_root=LABEL=rootfs
usb_rootdelay=10
usb_set_bootargs=setenv bootargs console=$console root=$usb_root rootdelay=$usb_rootdelay rootfstype=$usb_rootfstype $mtdparts $usb_custom_params

Basically the kernel is told that the rootfs partition has a label of "rootfs" (usb_root=LABEL=rootfs) and there's a delay to wait for the partition to mount of 10 (seconds ?) (usb_rootdelay=10)

So that you can see all of my uboot envs (fw_printenv) on a working setup, I've included the whole list :

ethact=egiga0
bootdelay=3
baudrate=115200
mainlineLinux=yes
console=ttyS0,115200
led_init=green blinking
led_exit=green off
led_error=orange blinking
mtdparts=mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)
mtdids=nand0=orion_nand
partition=nand0,2
stdin=serial
stdout=serial
stderr=serial
rescue_set_bootargs=setenv bootargs console=$console ubi.mtd=2 root=ubi0:rootfs
ro rootfstype=ubifs $mtdparts $rescue_custom_params
rescue_bootcmd=if test $rescue_installed -eq 1; then run rescue_set_bootargs; na
nd read.e 0x800000 0x100000 0x400000; bootm 0x800000; else run pogo_bootcmd; fi
pogo_bootcmd=if fsload uboot-original-mtd0.kwb; then go 0x800200; fi
force_rescue=0
force_rescue_bootcmd=if test $force_rescue -eq 1 || ext2load usb 0:1 0x1700000 /
rescueme 1 || fatload usb 0:1 0x1700000 /rescueme.txt 1; then run rescue_bootcmd
; fi
ubifs_mtd=3
ubifs_set_bootargs=setenv bootargs console=$console ubi.mtd=$ubifs_mtd root=ubi0
:rootfs rootfstype=ubifs $mtdparts $ubifs_custom_params
ubifs_bootcmd=run ubifs_set_bootargs; if ubi part data && ubifsmount rootfs && u
bifsload 0x800000 /boot/uImage && ubifsload 0x1100000 /boot/uInitrd; then bootm
0x800000 0x1100000; fi
usb_scan=usb_scan_done=0;for scan in $usb_scan_list; do run usb_scan_$scan; if t
est $usb_scan_done -eq 0 && ext2load usb $usb 0x800000 /boot/uImage 1; then usb_
scan_done=1; echo "Found bootable drive on usb $usb"; setenv usb_device $usb; se
tenv usb_root /dev/$dev; fi; done
usb_scan_list=1 2 3 4
usb_scan_1=usb=0:1 dev=sda1
usb_scan_2=usb=1:1 dev=sdb1
usb_scan_3=usb=2:1 dev=sdc1
usb_scan_4=usb=3:1 dev=sdd1
usb_init=run usb_scan
usb_device=0:1
usb_rootdelay=10
usb_set_bootargs=setenv bootargs console=$console root=$usb_root rootdelay=$usb_
rootdelay rootfstype=$usb_rootfstype $mtdparts $usb_custom_params
usb_boot=mw 0x800000 0 1; ext2load usb $usb_device 0x800000 /boot/uImage; if ext
2load usb $usb_device 0x1100000 /boot/uInitrd; then bootm 0x800000 0x1100000; el
se bootm 0x800000; fi
ethaddr=[Don Charisma redacted]
arcNumber=3089
if_netconsole=ping $serverip
start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; se
tenv stdout nc; setenv stderr nc; version;
preboot=run if_netconsole start_netconsole
rescue_installed=1
sata_boot=ide reset; mw 0x800000 0 1; ext2load ide 0:1 0x800000 /boot/uImage; if
 ext2load ide 0:1 0x1100000 /boot/uInitrd; then bootm 0x800000 0x1100000; else b
ootm 0x800000; fi
sata_bootcmd=run usb_set_bootargs; run sata_boot
bootcmd=usb start; run force_rescue_bootcmd; run ubifs_bootcmd; run usb_bootcmd;
 usb stop; run sata_bootcmd; run rescue_bootcmd; run pogo_bootcmd; reset
usb_bootcmd=run usb_init; setenv usb_root LABEL=rootfs; run usb_set_bootargs; ru
n usb_boot
ipaddr=192.168.1.232
serverip=192.168.1.203
usb_root=LABEL=rootfs

YOU WILL ALSO NEED TO ... update your /etc/fstab on /dev/sdb2 ... mine looks like this :
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/root      /               ext3    noatime,errors=remount-ro 0 1
LABEL=boot      /media/boot             ext2    noatime 1 2
/media/boot/boot        /boot           none    bind
tmpfs          /tmp            tmpfs   defaults          0       0

Note the double mount of the boot partition. I had to do it this way because there's actually a folder on /dev/sdb1 called /boot ... so a single direct mount to /boot ends up with the boot files in /boot/boot

Also note you'll need to create the folder in media, in order to mount /dev/sda1
mkdir /media/boot

Don't forget to add your swap into fstab, that's one of my favourite mistakes !

If anyone knows the additional steps to boot from RAID - I'd be interested to know what they are :)

Cheers

Don Charisma ... because anything is possible with Charisma

My blog - http://DonCharisma.org
Our commercial site - http://DonCharisma.com
Re: Booting Using Seperate boot AND rootfs Partitions
January 11, 2015 05:21PM
Fantastic share there Don - looks like you have cracked this one.!
Re: Booting Using Seperate boot AND rootfs Partitions
January 12, 2015 10:36AM
@Gravelrash - thanks dude ... pretty much cracked the dual partition boot ... f2fs ... another story !

Cheers

Don Charisma ... because anything is possible with Charisma

My blog - http://DonCharisma.org
Our commercial site - http://DonCharisma.com
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: