Moderator Control Panel ]

boot Ubuntu from SD-card / rootfs on USB SATA

boot Ubuntu from SD-card / rootfs on USB SATA

Postby hansiart » Sat Jul 12, 2014 6:46 pm

I managed to boot ubuntu (TBS-Matrix_ubuntu_12.04_V1.0.0.1) from an SD-card, USB-stick and SATA-SSD. The U-boot of this linaro-ubuntu-desktop is somewhat complicated. So I could nothing with the other post on this forum as to booting from SD so I started this new topic. You can also boot from emmc but have your rootfilesystem on sdcard, usbstick or sata.

The Idea was to do this in a save way by leaving the original variables in U-boot untouched. Only bootcmd is changed but this is not complicated. Thus we can easely go back to the original state. And there is little risk of doing something wrong.
I accomplished this by setting up some new environmentvariables in u-boot, derived from the originals that make it boot from emmc.

preparing SD-card:
Have a 16Gb SD plugged in. Open a terminal to your Matrix by connecting the serial port (see topic "serial Port and u-boot prompt" ). On your PC start putty, serial,speed 115200 en boot the matrix into Ubuntu.
type Login username passwd linaro linaro.
You can type sudo fdisk -l to see the disks. In my case mmcblk0 = the internal SD and mmcblk1=the external SD
Now type sudo dd if=/dev/mmcblk0 of=/dev/mmcblk1 to clone the internal sd to the external SD.
This can take a long time but you now should have bootable SD-card. Verify by typing sudo fdisk -l
You could do this also with an USB stick

Its conveniënt to make a directory on the emmc to identify what your rootfs is. When you make an empty directory called "emmc_ID_dir" then a ls / will show this when your rootfs resides on emmc. You can do a similar thing on your sd-card and USB-stick.

Now you need to get into the U-boot prompt. type sudo reboot, when you see "hit a key to stop autoboot", hit a key. Now you are in the U-boot prompt, in my case "MX6Q SABRESD U-Boot".
If this doesn't work: power off the Matrix, close and reopen the putty session and power on the Matrix, hit the key....
type printenv to see a list of variables
You will see a variable bootargs_mmc in which root is set to mmcblk0p1, this refers to the rootfilesystem
also there is a variable bootcmd_mmc in which you see mmc dev 3 , this refers to the bootdevice (emmc)

Now we setup some new variables for our needs, these are<br>
- bootargs_test (same as bootargs_mmc but we change root=/dev/mmcblk0p1 into ${rootfs}
- bootcmd_test (same as bootcmd_mmc but we change mmc dev 3 into ${bootdevice}
- bootdevice
- rootfs
Now when we boot with bootcmd_test we only have to change the value of bootdevice to boot from another device and/or rootfilesystem.

This is what you need to type:
setenv bootargs_test setenv 'bootargs ${bootargs} ${rootfs} rootwait video=mxcfb1:dev=ldb,LDB-XGA,if=RGB666 video=mxcfb0:dev=hdmi,1920x1080M@60 video-mxcfb1:off video=mxcfb2:off fbmem=28M consoleblank=0 quiet'
(the quotes are needed otherwise you get a "too many arguments")

setenv bootcmd_test run 'bootargs_base bootargs_test; ${bootdevice}; mmc read ${loadaddr} 0x800 0x4000; bootm'

type printenv bootargs_test and printenv bootargs_mmc to compare, (should be equal except for root=...)

you can type printenv bootcmd_test and printenv bootcmd_mmc to check this too

type setenv rootfs root=/dev/mmcblk1p1
type setenv bootdevice mmc dev 2

type saveenv to safe all

now type run bootcmd_test to see if it boots.
If you get a "card dit not respond to voltage change" error then you can experiment with the value of mmc dev # in bootdevice (try 0 or 1).

If it boots oke then you go back to the U-boot prompt and type
setenv bootcmd run bootcmd_test
Now it allways boots from SD

BTW booting from SD is slower so why would you?
Its easy to experiment, for instance you set rootfs to root=dev/mmcblk1p1 and bootdevice on mmc dev 3. Now it boots from emmc but the linuxfilesystem resides on the SD-card. Could we have the rootfs on USB or SATA this way? I tried this by setting rootfs to root=/dev/sda1 and yes, I have the rootfs of the USB-stick. If you plugg-in a SATA SSD then the SSD becomes SDA1 and the USB-stick SDB1, so now it boots from the SSD. You could change rootfs to root=dev/sdb1 in order to boot from the USB.

see also http://hansiart.ddns.net/techniek/ubuntu_boot_sd.html for more info
Last edited by hansiart on Fri Aug 08, 2014 6:11 am, edited 2 times in total.
hansiart
 
Posts: 3
Joined: Wed Jul 09, 2014 9:47 pm

Re: boot Ubuntu from SD-card / rootfs on USB SATA

Postby steven » Wed Jul 16, 2014 5:24 pm

Hi hansiart

Wo, it is great topic,and very useful for our user.
Thank you very much share this. :)

Thanks

Kind Regards

steven
steven
 
Posts: 2239
Joined: Fri Aug 06, 2010 3:23 pm

Re: boot Ubuntu from SD-card / rootfs on USB SATA

Postby elbandido » Mon Sep 01, 2014 11:23 am

This information has been very helpful to me because I needed a way to store Ubuntu after I had taken the time to set it up. It is nice to be able to load Android or another OS then be able to come back to a stored Ubuntu instead of starting from scratch.

It looks like I can restore a stored Ubuntu by using the "dd if=/dev/mmcblk1 of=/dev/mmcblk0" command?
Or is there a better way to copy the SD card back into the Matrix?

Thanks. EB
elbandido
 
Posts: 18
Joined: Mon May 05, 2014 11:25 am


Return to General discussion

Who is online

Users browsing this forum: No registered users and 16 guests