Booting from internal storage via chroot to /data

Linux development for the Acer A500/A501

Booting from internal storage via chroot to /data

Postby Skrilax_CZ » 30 May 2013, 00:01

I found some template for initramfs (taken from ubuntu 12.04 I think). In this stage it will boot from whatever is supplied as root (including nfs etc.), so you'd need to modify it a bit if you want it under say /data/linux or loop image (init is a shell script, I think modifying "rootmnt" variable after the FS is mounted is the easiest way).

After you patch, here are the steps to build:
1) Populate lib/modules with necessary kernel filesystem modules (only for nfs, ntfs etc., none are needed for ext4)
2) Build it:
Code: Select all
cd path_to_initramfs_root
find . | cpio -H newc -o | gzip > ../initramfs.gz

3) Build boot.img (normally as --ramdisk parameter) or use ext4fs boot on V9 bootloader to load

I won't be testing myself as I have my own setup.

EDIT: You can find ready ramdisk in here: viewtopic.php?f=43&t=1169&start=15#p38005
You do not have the required permissions to view the files attached to this post.
Last edited by Skrilax_CZ on 15 Aug 2013, 14:01, edited 1 time in total.
User avatar
Skrilax_CZ
Senior Owner
 
Posts: 181
Joined: 09 Feb 2012, 13:59
Reputation point: 272
Junior OwnerJunior OwnerJunior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby digetx » 30 May 2013, 12:10

Thanks :) It will be helpful.
User avatar
digetx
Dev Team
 
Posts: 4220
Joined: 06 Dec 2011, 00:56
Location: Moscow
Reputation point: 482
Junior OwnerJunior OwnerJunior OwnerJunior OwnerJunior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby sajunt4 » 30 May 2013, 20:37

Skrilax_CZ wrote:I found some template for initramfs (taken from ubuntu 12.04 I think). In this stage it will boot from whatever is supplied as root (including nfs etc.), so you'd need to modify it a bit if you want it under say /data/linux or loop image (init is a shell script, I think modifying "rootmnt" variable after the FS is mounted is the easiest way).

After you patch, here are the steps to build:
1) Populate lib/modules with necessary kernel filesystem modules (only for nfs, ntfs etc., none are needed for ext4)
2) Build it:
Code: Select all
cd path_to_initramfs_root
find . | cpio -H newc -o | gzip > ../initramfs.gz

3) Build boot.img (normally as --ramdisk parameter) or use ext4fs boot on V9 bootloader to load

I won't be testing myself as I have my own setup.


Thank you! I'll try!
User avatar
sajunt4
Junior Owner
 
Posts: 24
Joined: 03 Aug 2012, 00:46
Reputation point: 0
Junior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby blackthund3r » 14 Aug 2013, 22:38

Hey there :)

I'm very close to making this work, but I have a bit of an interesting paradox.....

  • I've pushed and extracted the lubuntu rootfs to /data/linux/*
  • I've modified the initramfs files so that in init it checks for another folder (/datapart) and if it does not exit it creates it
  • After mkdir /run/initramfs it does mount -t ext4 /dev/mmcblk0p8 /datapart
  • The rootmnt variable is set to /datapart/linux
  • After the variables are set I ls the contents of /dev and /, and get interesting results....

I had issues actually bootstrapping the initrd, so I did away with a ramdisk-based boot and instead extracted the lot to Flexrom (where menu.skrilax and the zImage are based). This works and the init script is called successfully.

Here's where the interesting issues begins. I have a paradox. /dev cannot be created and populated because it has to go in the rootfs (ie /datapart/linux), but I cannot mount mmcblk0p8 until I have a /dev folder, and so there is no way once init begins that I can actually mount any other partitions, at least not until it is too late to change roots...

Well, that's not strictly true. There is a /dev folder, but the only contents are console, null and pts. No partition list.

At what point in init can I mount /dev/mmcblk0p8 (not /dev/block it would seem...)?

The error I get that I think is most important is:
Code: Select all
Being: Running /scripts/init-bottom ... mount: mounting /dev on /datapart/linux/dev failed: No such file or directory


My cmdline is:
Code: Select all
rootwait rw root=/dev/mmcblk0p6 init=/init rootfstype=ext4 noinitrd no_console_suspend=1 mem=1024M@0M video=tegrafb console=tty0 lp0_vec=8192@0x3d805000 tegra_fbmem=8197120@0x3d81c000 gpt


Thanks for any help you can provide!

The alternative, of course, is to mount much later and introduce a heck of a lot of symlinks which is far from ideal :P
~ @blackthund3r (Christopher)
Did I make myself useful? Feel free to rep!!

(reps make meh happeh)

http://acerhacks.com <----- A500 hacking FAQs (new link). Check there first! :)
Image

http://acerhacks.com/sbkcalc/ <--- Get that SBK!

-------------

Acer Iconia Tab A500 16GB
Skrilax v9 ICS bootloader
TegraOwners 4.2.2 Jellybean ROM
-----
Also runs Lubuntu 13.04 booting from /data/linux via the FlexROM :)
User avatar
blackthund3r
Guru Owner
 
Posts: 565
Joined: 21 Jan 2012, 15:00
Location: UK
Reputation point: 24
Junior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby Skrilax_CZ » 14 Aug 2013, 22:57

You have to make the node here manually, but the script already does that part for you.

Anyway, you have bad cmdline. In the cmdline, just swap mmcblk1p1 to mmcblk0p8, that's all. Second, I think this should be sufficient: open the init script, and find
Code: Select all
maybe_break mount
log_begin_msg "Mounting root file system"
. /scripts/${BOOT}
parse_numeric ${ROOT}
maybe_break mountroot
mountroot
log_end_msg


change it to

Code: Select all
maybe_break mount
log_begin_msg "Mounting root file system"
. /scripts/${BOOT}
parse_numeric ${ROOT}
maybe_break mountroot
mountroot
log_end_msg

export rootmnt=/root/linux
User avatar
Skrilax_CZ
Senior Owner
 
Posts: 181
Joined: 09 Feb 2012, 13:59
Reputation point: 272
Junior OwnerJunior OwnerJunior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby blackthund3r » 14 Aug 2013, 23:04

Skrilax_CZ » 14 Aug 2013, 21:57 wrote:You have to make the node here manually, but the script already does that part for you.

Anyway, you have bad cmdline. In the cmdline, just swap mmcblk1p1 to mmcblk0p8, that's all. Second, I think this should be sufficient: open the init script, and find
Code: Select all
maybe_break mount
log_begin_msg "Mounting root file system"
. /scripts/${BOOT}
parse_numeric ${ROOT}
maybe_break mountroot
mountroot
log_end_msg


change it to

Code: Select all
maybe_break mount
log_begin_msg "Mounting root file system"
. /scripts/${BOOT}
parse_numeric ${ROOT}
maybe_break mountroot
mountroot
log_end_msg

export rootmnt=/root/linux

Thank you so much for your swift reply! I'm just trying that now. I'm wondering though... how to I invoke the init script if the flexrom is not the root? Do I put the init script in /data/linux? If the root is the data partition should I copy the contents of the initramfs to /data? Will it then pick up the init script?

Many thanks!
~ @blackthund3r (Christopher)
Did I make myself useful? Feel free to rep!!

(reps make meh happeh)

http://acerhacks.com <----- A500 hacking FAQs (new link). Check there first! :)
Image

http://acerhacks.com/sbkcalc/ <--- Get that SBK!

-------------

Acer Iconia Tab A500 16GB
Skrilax v9 ICS bootloader
TegraOwners 4.2.2 Jellybean ROM
-----
Also runs Lubuntu 13.04 booting from /data/linux via the FlexROM :)
User avatar
blackthund3r
Guru Owner
 
Posts: 565
Joined: 21 Jan 2012, 15:00
Location: UK
Reputation point: 24
Junior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby Skrilax_CZ » 14 Aug 2013, 23:25

The init script is in the ramfs itself. Read the OP how to make initramfs. Then either make android image or use extfs boot with V9 bootloader (in the menu.skrilax file, add "ramdisk=path_to_ramdisk" in BL format).
User avatar
Skrilax_CZ
Senior Owner
 
Posts: 181
Joined: 09 Feb 2012, 13:59
Reputation point: 272
Junior OwnerJunior OwnerJunior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby blackthund3r » 14 Aug 2013, 23:28

Skrilax_CZ » 14 Aug 2013, 22:25 wrote:The init script is in the ramfs itself. Just read the OP how to create it.

Does it need to be launched from a ramdisk? Can it not be launched directly? oooooops :P

Once I create the initramfs.gz file, where do I copy it to? /data or /flex?

EDIT: I'm putting it in both. Here we go!

EDIT 2: It didn't like it. I'm going to have to add rootfstype=ext4 to the cmdline, and possibly provide initrd=/initramfs.gz

EDIT 3: Didn't see the ramdisk= bit. Sorry!
Last edited by blackthund3r on 14 Aug 2013, 23:41, edited 1 time in total.
~ @blackthund3r (Christopher)
Did I make myself useful? Feel free to rep!!

(reps make meh happeh)

http://acerhacks.com <----- A500 hacking FAQs (new link). Check there first! :)
Image

http://acerhacks.com/sbkcalc/ <--- Get that SBK!

-------------

Acer Iconia Tab A500 16GB
Skrilax v9 ICS bootloader
TegraOwners 4.2.2 Jellybean ROM
-----
Also runs Lubuntu 13.04 booting from /data/linux via the FlexROM :)
User avatar
blackthund3r
Guru Owner
 
Posts: 565
Joined: 21 Jan 2012, 15:00
Location: UK
Reputation point: 24
Junior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby Skrilax_CZ » 14 Aug 2013, 23:41

Oh man :doh:

Have I ever mentioned flexrom, lol? We're using ramdisk to chroot to the /data/linux. Read the OP .... it says all that is needed.
User avatar
Skrilax_CZ
Senior Owner
 
Posts: 181
Joined: 09 Feb 2012, 13:59
Reputation point: 272
Junior OwnerJunior OwnerJunior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby blackthund3r » 14 Aug 2013, 23:55

Skrilax_CZ » 14 Aug 2013, 22:41 wrote:Oh man :doh:

Have I ever mentioned flexrom, lol? We're using ramdisk to chroot to the /data/linux. Read the OP .... it says all that is needed.

Sorry I'm so dopey!

The flexrom is where I put my menu.skrilax file, along with zImage which is why it is relevant.

I used the default cmdline that you provided with the root changed to mmcblk0p8, and added ramdisk=FLX:/initramfs.gz to menu.skrilax and it doesn't mount the file system and kernel panics. If I set the rootfstype to ext4 it gets further thn still kernel panics :( I'm using an initramfs which has been built as you described with that one line added to init.

I think something else is missing but I can't think what.....
~ @blackthund3r (Christopher)
Did I make myself useful? Feel free to rep!!

(reps make meh happeh)

http://acerhacks.com <----- A500 hacking FAQs (new link). Check there first! :)
Image

http://acerhacks.com/sbkcalc/ <--- Get that SBK!

-------------

Acer Iconia Tab A500 16GB
Skrilax v9 ICS bootloader
TegraOwners 4.2.2 Jellybean ROM
-----
Also runs Lubuntu 13.04 booting from /data/linux via the FlexROM :)
User avatar
blackthund3r
Guru Owner
 
Posts: 565
Joined: 21 Jan 2012, 15:00
Location: UK
Reputation point: 24
Junior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby Skrilax_CZ » 15 Aug 2013, 01:08

Well I have just guessed that looking at the init script. To make sure that the ramdisk is booting, bootloader should say "Loading ramdisk from filesystem ... OK" in the status. Otherwise output of the init script is seen in dmesg, so examine it.

EDIT: Just tried to use it w/o changes to anything (rootfs @ flexrom). Worked fine.
User avatar
Skrilax_CZ
Senior Owner
 
Posts: 181
Joined: 09 Feb 2012, 13:59
Reputation point: 272
Junior OwnerJunior OwnerJunior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby blackthund3r » 15 Aug 2013, 11:05

Skrilax_CZ » 15 Aug 2013, 00:08 wrote:Well I have just guessed that looking at the init script. To make sure that the ramdisk is booting, bootloader should say "Loading ramdisk from filesystem ... OK" in the status. Otherwise output of the init script is seen in dmesg, so examine it.

EDIT: Just tried to use it w/o changes to anything (rootfs @ flexrom). Worked fine.


YESSSSSSSSSSSS! IT WORKS!

Thank you so much for your patience!

Here's what I did to make it work:
1) The ramdisk was loading from menu.skrilax as you told me to
2) The patch to init that you suggested was switching roots _BUT_ there is a requirement in switch_root that the folder you are switching root to is on a different filesystem. As my root was set to mmcblk0p8, and the root was in /root/linux, it was failing to switch roots and execute the new init. In turn this meant that the kernel ran out of things to execute and panicked.
3) To make the switch worked I modified the "Chain to real filesystem section" so it reads:
Code: Select all
# Chain to real filesystem
if command -v switch_root >/dev/null 2>&1; then
   mkdir /newroot
   mount --bind ${rootmnt} /newroot
   exec switch_root /newroot ${init} "$@" </newroot/dev/console >/newroot/dev/console

This gets me to the welcome screen.

Thanks so much for your perseverance once again, and I hope this helps somebody! This also means I can put the initramfs.gz file anywhere, and use AKB, FLX or UDA for the kernel if I really want to as it will always get to /data/linux.
~ @blackthund3r (Christopher)
Did I make myself useful? Feel free to rep!!

(reps make meh happeh)

http://acerhacks.com <----- A500 hacking FAQs (new link). Check there first! :)
Image

http://acerhacks.com/sbkcalc/ <--- Get that SBK!

-------------

Acer Iconia Tab A500 16GB
Skrilax v9 ICS bootloader
TegraOwners 4.2.2 Jellybean ROM
-----
Also runs Lubuntu 13.04 booting from /data/linux via the FlexROM :)
User avatar
blackthund3r
Guru Owner
 
Posts: 565
Joined: 21 Jan 2012, 15:00
Location: UK
Reputation point: 24
Junior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby Skrilax_CZ » 15 Aug 2013, 11:17

Good. Oh maybe upload it if sbdy else would want to use it.
User avatar
Skrilax_CZ
Senior Owner
 
Posts: 181
Joined: 09 Feb 2012, 13:59
Reputation point: 272
Junior OwnerJunior OwnerJunior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby blackthund3r » 15 Aug 2013, 12:09

Skrilax_CZ wrote:Good. Oh maybe upload it if sbdy else would want to use it.

Will do :)

Sent from my Nexus 4 using Tapatalk 4
~ @blackthund3r (Christopher)
Did I make myself useful? Feel free to rep!!

(reps make meh happeh)

http://acerhacks.com <----- A500 hacking FAQs (new link). Check there first! :)
Image

http://acerhacks.com/sbkcalc/ <--- Get that SBK!

-------------

Acer Iconia Tab A500 16GB
Skrilax v9 ICS bootloader
TegraOwners 4.2.2 Jellybean ROM
-----
Also runs Lubuntu 13.04 booting from /data/linux via the FlexROM :)
User avatar
blackthund3r
Guru Owner
 
Posts: 565
Joined: 21 Jan 2012, 15:00
Location: UK
Reputation point: 24
Junior Owner

Re: [WIP] Booting from internal storage via chroot to /data

Postby blackthund3r » 15 Aug 2013, 12:28

I think the touch screen buffer has a few glitches. Tried playing an HTML5 YouTube video and this happened.....

(What you see behind is my Nova launcher screen :P)

Sent from my Nexus 4 using Tapatalk 4
You do not have the required permissions to view the files attached to this post.
~ @blackthund3r (Christopher)
Did I make myself useful? Feel free to rep!!

(reps make meh happeh)

http://acerhacks.com <----- A500 hacking FAQs (new link). Check there first! :)
Image

http://acerhacks.com/sbkcalc/ <--- Get that SBK!

-------------

Acer Iconia Tab A500 16GB
Skrilax v9 ICS bootloader
TegraOwners 4.2.2 Jellybean ROM
-----
Also runs Lubuntu 13.04 booting from /data/linux via the FlexROM :)
User avatar
blackthund3r
Guru Owner
 
Posts: 565
Joined: 21 Jan 2012, 15:00
Location: UK
Reputation point: 24
Junior Owner

Next

Return to Acer A500/A501 Linux

Who is online

Users browsing this forum: No registered users and 1 guest

x

#{title}

#{text}