Modifying uRamdisk & bootutil

Search This thread

Renate

Inactive Recognized Developer / Recognized Contrib
Feb 3, 2012
2,805
1,261
193
Boston
Nexus 7 (2013)
Moto E5
There's a lot of fine-tuning you can do by modifying init.rc that is packed into uRamdisk in the boot partition.

In the Unix world to modify init.rc inside uRamdisk you would need to:
  1. Use dd to strip the image header
  2. Use gzip to expand the contents
  3. Use cpio to separate it into files
  4. Edit what you want in init.rc
  5. Use cpio to combine the files
  6. Use gzip to compress the contents
  7. Use mkimage to wrap the contents
In the Windows world a command line utility simplifies this:
Code:
bootutil /v /x uRamdisk init.rc
Edit init.rc
Code:
bootutil /v /r uRamdisk init.rc
As always, be careful and make a backup.
Making a Clockwork Recovery update to restore the original uRamdisk might be a good idea.
Download bootutil.exe in the signature.
 

ApokrifX

Senior Member
May 23, 2011
468
50
0
There's a lot of fine-tuning you can do by modifying init.rc that is packed into uRamdisk in the boot partition.

In the Unix world to modify init.rc inside uRamdisk you would need to:
  1. Use dd to strip the image header
  2. Use gzip to expand the contents
  3. Use cpio to separate it into files
  4. Edit what you want in init.rc
  5. Use cpio to combine the files
  6. Use gzip to compress the contents
  7. Use mkimage to wrap the contents
In the Windows world a command line utility simplifies this:
Code:
bootutil /v /x uRamdisk init.rc
Edit init.rc
Code:
bootutil /v /r uRamdisk init.rc
As always, be careful and make a backup.
Making a Clockwork Recovery update to restore the original uRamdisk might be a good idea.
Download bootutil.exe in the signature.
Cool!
Now we will see real hard core modding! :highfive:
 

Renate

Inactive Recognized Developer / Recognized Contrib
Feb 3, 2012
2,805
1,261
193
Boston
Nexus 7 (2013)
Moto E5
Here's some ideas of what you can do with bootutil.

Install adbd in /system/bin and chmod 755 it.
Delete both sbin and sbin/adbd from uRamdisk.
Change the start of adbd in init.rc from /sbin/adbd to /system/bin/adbd

Trim the cruft from PATH in init.rc and make it only /system/bin

Delete the whole secton in init.rc for the /data/media/B&N Downloads

Add a mount point for USB drives right before the root gets ro in init.rc

Delete all that stuff for /sys/devices/platform/omapdss
Where/when/what did that ever exist?
 
  • Like
Reactions: siniy

siniy

Member
Nov 27, 2008
7
4
0
Renate, Thank you very much for your tool. I've been looking for a way to change mount point from /sdcard to /mnt/sdcard for a long time. With bootutil it's much easier.
How I did it:
1. Flash noogie.img to sdcard.
2. Boot from sdcard and connect NST to PC.
3. In partition manager assign letter to boot partition.(ex. MiniTool Partition Wizard)
4. Update mount points in init.rc at E:\uRamdisk with bootutil.(Don't forget to mkdir your mount points)
5. Remove letter from boot partition with partition manager.
6. Reboot NST.
7. Update mount points /system/etc/vold.conf
 

Renate

Inactive Recognized Developer / Recognized Contrib
Feb 3, 2012
2,805
1,261
193
Boston
Nexus 7 (2013)
Moto E5
I've added more stuff and more flags to bootutil.exe
It won't make a lot of difference for modifying just init.rc,
but it will allow you to make your own ramdisks and insert files and symlinks.

Code:
usage:  bootutil [flags] image file [file...]
/d  delete files
/g  group id
/i  insert before
/l  list files
/m  file mode
/n  new archive (name)
/r  replace files
/s  symlink (path)
/x  extract files
/u  user id
/v  verbose

[b]# create 3 symlinks to busybox[/b]
bootutil /v uRamdisk /i /sbusybox date ls ps

[b]# insert adbd before stuff with chmod 755[/b]
bootutil /v uRamdisk /istuff system/bin/adbd /m755
 
  • Like
Reactions: dnordquest

dnordquest

Member
Dec 3, 2012
30
0
0
Error Messages

Many thanks for bootutil! I'm trying to modify the init in uRamdisk and am getting the following errors messages:

GZip signature not found OR

Image signature not found.

Any suggestions?

Thanks!
 

Renate

Inactive Recognized Developer / Recognized Contrib
Feb 3, 2012
2,805
1,261
193
Boston
Nexus 7 (2013)
Moto E5
Any suggestions?

Are you sure that what you have is a uRamdisk?
Try this:
Code:
C:\>bootutil /l /v uRamdisk
Read image, 11 files
drwxrwx--x                              data
-rw-r--r--        89  2013-02-08 08:54  default.prop
drwxr-xr-x                              dev
-rw-r--r--       324                    env.txt
-rwxr-x---    107344  2012-02-03 09:13  init
-rwxr-x---      1677                    init.goldfish.rc
-rwxr-x---     19131  2013-02-08 08:54  init.rc
-rwxr-x---     40205                    initlogo.rle
drwxr-xr-x                              proc
drwxr-xr-x                              sys
drwxr-xr-x                              system
Then try:
Code:
C:\>bootutil /x /v uRamdisk init
 

dnordquest

Member
Dec 3, 2012
30
0
0
"Are you sure that what you have is a uRamdisk?"

When I try bootutil.exe on the uRamdisk from my boot directory, I get "Gzip signature not found."
When I try it on the uRamdisk from the binaries.zip file you linked to as a source for a good init, I get what you say I should get. The uRamdisk from my 1.2.1 updated, rooted NST is 182K. The uRamdisk that works is 168k. Should I look for another?

Thanks.
 

Renate

Inactive Recognized Developer / Recognized Contrib
Feb 3, 2012
2,805
1,261
193
Boston
Nexus 7 (2013)
Moto E5
I do have version 1.1, 1.1.2, 1.1.5, 1.2, 1.2.1 of the uRamdisk and they all work fine with bootutil.
Maybe whoever did your rooted uRamdisk did a sloppy job?
Get that file to me and I'll take a look.
Code:
E:\>bootutil /v /l E:\Nook11\ramdisk.img
Read image, 13 files
drwxrwx--x            data
-rw-r--r--       118  default.prop
drwxr-xr-x            dev
-rw-r--r--       324  env.txt
-rwxr-x---    127964  init
-rwxr-x---      1677  init.goldfish.rc
-rwxr-x---     18728  init.rc
-rwxr-x---     40205  initlogo.rle
drwxr-xr-x            proc
drwxr-x---            sbin
-rwxr-x---    134136  sbin/adbd
drwxr-xr-x            sys
drwxr-xr-x            system

E:\>bootutil /v /l E:\Nook112\ramdisk.img
Read image, 13 files
drwxrwx--x            data
-rw-r--r--       118  default.prop
drwxr-xr-x            dev
-rw-r--r--       324  env.txt
-rwxr-x---    127964  init
-rwxr-x---      1677  init.goldfish.rc
-rwxr-x---     18728  init.rc
-rwxr-x---     40205  initlogo.rle
drwxr-xr-x            proc
drwxr-x---            sbin
-rwxr-x---    134136  sbin/adbd
drwxr-xr-x            sys
drwxr-xr-x            system

E:\>bootutil /v /l E:\Nook115\ramdisk.img
Read image, 13 files
drwxrwx--x            data
-rw-r--r--       118  default.prop
drwxr-xr-x            dev
-rw-r--r--       324  env.txt
-rwxr-x---    127964  init
-rwxr-x---      1677  init.goldfish.rc
-rwxr-x---     19067  init.rc
-rwxr-x---     40205  initlogo.rle
drwxr-xr-x            proc
drwxr-x---            sbin
-rwxr-x---    134136  sbin/adbd
drwxr-xr-x            sys
drwxr-xr-x            system

E:\>bootutil /v /l E:\Nook12\ramdisk.img
Read image, 13 files
drwxrwx--x            data
-rw-r--r--       118  default.prop
drwxr-xr-x            dev
-rw-r--r--       324  env.txt
-rwxr-x---    128000  init
-rwxr-x---      1677  init.goldfish.rc
-rwxr-x---     19259  init.rc
-rwxr-x---     40205  initlogo.rle
drwxr-xr-x            proc
drwxr-x---            sbin
-rwxr-x---    134136  sbin/adbd
drwxr-xr-x            sys
drwxr-xr-x            system

E:\>bootutil /v /l E:\Nook121\ramdisk.img
Read image, 13 files
drwxrwx--x            data
-rw-r--r--       118  default.prop
drwxr-xr-x            dev
-rw-r--r--       324  env.txt
-rwxr-x---    128000  init
-rwxr-x---      1677  init.goldfish.rc
-rwxr-x---     19259  init.rc
-rwxr-x---     40205  initlogo.rle
drwxr-xr-x            proc
drwxr-x---            sbin
-rwxr-x---    134136  sbin/adbd
drwxr-xr-x            sys
drwxr-xr-x            system
 
  • Like
Reactions: dnordquest

batchaesir

New member
Sep 10, 2007
2
0
0
Dear Renate NST,

I used bootutil to modify uRamdisk , but i got "Image data CRC error".
 

Attachments

  • ramdisk.7z
    247.3 KB · Views: 19
Last edited:

Renate

Inactive Recognized Developer / Recognized Contrib
Feb 3, 2012
2,805
1,261
193
Boston
Nexus 7 (2013)
Moto E5
i got "Image data CRC error".
The problem is that the CRC for the image data is wrong. :p

I don't know what tool made this file, but it's wrong.
The problem is that the "guts" of the file are 1/4 Meg but it's padded out to 1 Meg with zeroes.

Take your file and truncate it to 0x3d339 (250,681) in length.

There's a new bootutil.exe in the signature with less ambiguous error reporting.
Code:
C:\>bootutil /l ramdisk.uimg
Image data size error
C:\>modfile /t ramdisk.uimg 3d339
C:\>bootutil /l ramdisk.uimg
drwxrwx--x            data
-rw-r--r--       118  default.prop
...
 
Last edited:

stephangm

New member
Nov 9, 2015
3
0
0
imgutil usage

There's a lot of fine-tuning you can do by modifying init.rc that is packed into uRamdisk in the boot partition.

In the Unix world to modify init.rc inside uRamdisk you would need to:
  1. Use dd to strip the image header
  2. Use gzip to expand the contents
  3. Use cpio to separate it into files
  4. Edit what you want in init.rc
  5. Use cpio to combine the files
  6. Use gzip to compress the contents
  7. Use mkimage to wrap the contents
In the Windows world a command line utility simplifies this:
Code:
bootutil /v /x uRamdisk init.rc
Edit init.rc
Code:
bootutil /v /r uRamdisk init.rc
As always, be careful and make a backup.
Making a Clockwork Recovery update to restore the original uRamdisk might be a good idea.
Download bootutil.exe in the signature.

Hi Renate,

I was just wondering about the usage of imgutil commands.
In the command Usage: imgutil [flags] image [file...], I would like to modify init.rc on uRamdisk. Do I simply type uRamdisk like above? Or is there a path I need to specify?
On my system under /proc/partitions I have:
179 16 1024 mmcblk0boot1
179 8 1024 mmcblk0boot0
and under /proc/mtd I have nothing
Will this be a problem?

Cheers,
Stephan
 

Renate

Inactive Recognized Developer / Recognized Contrib
Feb 3, 2012
2,805
1,261
193
Boston
Nexus 7 (2013)
Moto E5
First: As general information, this is now called imgutil, uses (mostly?) the same arguments and is available in the signature below.
It has had improvements to make it more robust and it can deal with images with garbage on the end.
It also supports DTB, the device tree blob used on some newer devices.
I use this on many non-B&N devices, including Marshmallow.
@stephangm
You first have to get the raw image.
Depending on your device, it might be a file in a partition or a raw partition.
A file always has an explicit size, a partition has an explicit size too, but it's usually bigger than the actual image.

For instance, the NST uses a uRamdisk file inside the FAT partiton mmcblk0p1

The Glow Plus uses a combined kernel/ramdisk that's in the raw (emmc) partition mmcblk0p1
To get this, you might do something like:
Code:
C:\> adb shell
# cat /dev/block/mmcblk0p1 > /sdcard/p1.img
# ^D
C:\> adb pull /sdcard/p1.img
C:\> dir p1.img
--- 12 Megs or something
C:\> imgutil /v /x p1.img init.rc
C:\> myeditor init.rc
C:\> imgutil /v /r p1.img init.rc
C:\> dir p1.img
--- 7 Megs or something
C:\> adb push p1.img /sdcard
C:\> adb shell
# cat /sdcard/p1.img > /dev/block/mmcblk0p1
Note that when you first copy the file it will be the full size of the partition, that is, the image plus useless stuff at the end.
Once imgutil has modified it, it will be truncated to the useful size.

As far as figuring out which partition the boot one is, there are multiple ways, including fdisk, /proc, by-name or in the sysfs uevent.
 

gsms

Senior Member
Sep 6, 2014
96
7
0
When i tried to use this command with imgutil (the new name for bootutil from Renate NST) on NST
"imgutil /l /v uRamdisk"
i received this message : Could not open uRamdisk ???

Secondly, copying this row of code :
"adb shell
# cat /dev/block/mmcblk0p1 > /sdcard/p1.img"
i get this answer:
"cannot create /sdcard/p1.img, read-only file system"

Why these commands don't work as intended ???
 

Renate

Inactive Recognized Developer / Recognized Contrib
Feb 3, 2012
2,805
1,261
193
Boston
Nexus 7 (2013)
Moto E5
I received this message : Could not open uRamdisk ???
Probably because the file does not exist.

Secondly, copying this row of code :
"adb shell
# cat /dev/block/mmcblk0p1 > /sdcard/p1.img"
i get this answer:
"cannot create /sdcard/p1.img, read-only file system"
Those instruction were for the Glow Plus.
Since you haven't even copied over the uRamdisk from the NST, it makes the first part above even less sensible.
The NST has the uRamdisk as a file on the vfat on mmcblk0p1
 

Renate

Inactive Recognized Developer / Recognized Contrib
Feb 3, 2012
2,805
1,261
193
Boston
Nexus 7 (2013)
Moto E5
There's a new version of imgutil.exe available in the signature.

The changes include the addition of the /a (append) flag and different behavior for the /i (insert) flag.
It no longer is necessary (or legal) to supply an argument to the /i flag.

/a puts all the files at the end of the archive in the order that they appear on the command line.
Code:
imgutil /a /v boot.img bats zebras cats
At the end of the archive would be bats, zebras, cats.

Code:
imgutil /i /v boot.img bats zebras cats
The three files would be inserted at the sorted position.

From a previous update, the /c flag allows you to change the command line that is fed to the kernel.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 6
    There's a lot of fine-tuning you can do by modifying init.rc that is packed into uRamdisk in the boot partition.

    In the Unix world to modify init.rc inside uRamdisk you would need to:
    1. Use dd to strip the image header
    2. Use gzip to expand the contents
    3. Use cpio to separate it into files
    4. Edit what you want in init.rc
    5. Use cpio to combine the files
    6. Use gzip to compress the contents
    7. Use mkimage to wrap the contents
    In the Windows world a command line utility simplifies this:
    Code:
    bootutil /v /x uRamdisk init.rc
    Edit init.rc
    Code:
    bootutil /v /r uRamdisk init.rc
    As always, be careful and make a backup.
    Making a Clockwork Recovery update to restore the original uRamdisk might be a good idea.
    Download bootutil.exe in the signature.
    2
    I've added delete to the operations of bootutil:
    Code:
    usage:  bootutil image file [...]
    /d  delete files
    /l  list files
    /r  replace files
    /x  extract files
    /v  verbose
    2
    There's a new version of imgutil.exe available in the signature.

    The changes include the addition of the /a (append) flag and different behavior for the /i (insert) flag.
    It no longer is necessary (or legal) to supply an argument to the /i flag.

    /a puts all the files at the end of the archive in the order that they appear on the command line.
    Code:
    imgutil /a /v boot.img bats zebras cats
    At the end of the archive would be bats, zebras, cats.

    Code:
    imgutil /i /v boot.img bats zebras cats
    The three files would be inserted at the sorted position.

    From a previous update, the /c flag allows you to change the command line that is fed to the kernel.
    2
    First: As general information, this is now called imgutil, uses (mostly?) the same arguments and is available in the signature below.
    It has had improvements to make it more robust and it can deal with images with garbage on the end.
    It also supports DTB, the device tree blob used on some newer devices.
    I use this on many non-B&N devices, including Marshmallow.
    @stephangm
    You first have to get the raw image.
    Depending on your device, it might be a file in a partition or a raw partition.
    A file always has an explicit size, a partition has an explicit size too, but it's usually bigger than the actual image.

    For instance, the NST uses a uRamdisk file inside the FAT partiton mmcblk0p1

    The Glow Plus uses a combined kernel/ramdisk that's in the raw (emmc) partition mmcblk0p1
    To get this, you might do something like:
    Code:
    C:\> adb shell
    # cat /dev/block/mmcblk0p1 > /sdcard/p1.img
    # ^D
    C:\> adb pull /sdcard/p1.img
    C:\> dir p1.img
    --- 12 Megs or something
    C:\> imgutil /v /x p1.img init.rc
    C:\> myeditor init.rc
    C:\> imgutil /v /r p1.img init.rc
    C:\> dir p1.img
    --- 7 Megs or something
    C:\> adb push p1.img /sdcard
    C:\> adb shell
    # cat /sdcard/p1.img > /dev/block/mmcblk0p1
    Note that when you first copy the file it will be the full size of the partition, that is, the image plus useless stuff at the end.
    Once imgutil has modified it, it will be truncated to the useful size.

    As far as figuring out which partition the boot one is, there are multiple ways, including fdisk, /proc, by-name or in the sysfs uevent.
    2
    i got "Image data CRC error".
    The problem is that the CRC for the image data is wrong. :p

    I don't know what tool made this file, but it's wrong.
    The problem is that the "guts" of the file are 1/4 Meg but it's padded out to 1 Meg with zeroes.

    Take your file and truncate it to 0x3d339 (250,681) in length.

    There's a new bootutil.exe in the signature with less ambiguous error reporting.
    Code:
    C:\>bootutil /l ramdisk.uimg
    Image data size error
    C:\>modfile /t ramdisk.uimg 3d339
    C:\>bootutil /l ramdisk.uimg
    drwxrwx--x            data
    -rw-r--r--       118  default.prop
    ...
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone