unpack boot.img lzma - Android Q&A, Help & Troubleshooting

How to unpack this boot.img
boot.img: u-boot legacy uImage, V2.0.0-67-g215089c-dirty(20120828.165942),
Linux/ARM, OS Kernel Image (lzma), 4220825 bytes, Tue Aug 28 11:59:55 2012, Load Address: 0x80008000, Entry Point: 0x80008000, Header CRC: 0x0830866D, Data CRC: 0x11
475B66,
TV Box Nano2 ATV500B

Simply, you don't. The u-boot differs from the Android boot process. Therefore your image has a different data structure than a regular Android boot image.
Sent from my Xperia Arc via Tapatalk 2

unpack and repack
Code:
### uImage original size: 3593374 ###
### Binwalk ouput for original uImage ##
DECIMAL HEX DESCRIPTION
-------------------------------------------------------------------------------------------------------
0 0x0 uImage header, header size: 64 bytes, header CRC: 0x534C30CF, created: Tue Nov 8 06:05:02 2011, image size: 3593310 bytes, Data Address: 0xFFFFFFFF, Entry Point: 0x0, data CRC: 0x672C70AA, OS: Linux, CPU: ARM, image type: Firmware Image, compression type: none, image name: LK:ZT280_H1_2n
64 0x40 uImage header, header size: 64 bytes, header CRC: 0xC6DD4500, created: Tue Nov 8 06:05:02 2011, image size: 3593246 bytes, Data Address: 0x80008000, Entry Point: 0x80008000, data CRC: 0x58A04739, OS: Linux, CPU: ARM, image type: OS Kernel Image, compression type: lzma, image name: Linux-2.6.34
128 0x80 LZMA compressed data, properties: 0x5D, dictionary size: 8388608 bytes, uncompressed size: 9980736 bytes
### Remove 2 uImage headers ###
dd if=uImage of=zImage-lzma bs=1 skip=128
### Uncompress lzma kernel ###
### Compressed size: 3593246 ###
### Uncompressed size: 9980736 ###
dd if=zImage-lzma bs=1 | lzcat > zImage
### Find start of cpio ###
grep -a -b -m 1 --only-matching '070701' zImage
167936:070701
168052:070701
### Find end of cpio ###
grep -a -b -m 1 --only-matching 'TRAILER!!!' zImage
1765826:TRAILER!!!
### Add 11 to the above # to include trailer and extract cpio from kernel ###
dd if=zImage bs=1 skip=167936 count=1765837 of=initramfs_orig.cpio
### Explode the cpio ###
mkdir cpio_orig
cd cpio_orig/
cpio -v -i --no-absolute-filenames < ../initramfs_orig.cpio
### Make changes to initramfs ###
### Create new cpio ###
(cd cpio_orig; find . | cpio -o -H newc | gzip) > ../initramfs.cpio
### Write beginning of original zImage up to start of cpio to a new file ###
dd if=zImage bs=1 count=167936 of=/tmp/zImage
### Add new cpio/initramfs to the new file ###
dd if=initramfs.cpio bs=1 seek=167936 of=/tmp/zImage
### Write ending of original zImage to new file ###
### Seek below should be size of first part (167936) + size of original initramfs (1765837) ###
dd if=zImage bs=1 seek=1933773 skip=1765826 of=/tmp/zImage
### lzma compress the new zImage ###
### Uncompressed size: 9026566 ###
### Compressed size: 3808279 (larger than original zImage compressed size!?) ###
lzma -9 /tmp/zImage
### Add uImage headers to new file ###
### or should this be replaced by using the mkimage command? ###
dd if=uImage of=/tmp/uImage bs=1 count=128
### Add compressed zimage to new uImage ###
### New uImage size: 3808407 ###
dd if=/tmp/zImage.lzma bs=1 seek=128 of=/tmp/uImage
### binwalk output for new uImage ###
DECIMAL HEX DESCRIPTION
-------------------------------------------------------------------------------------------------------
0 0x0 uImage header, header size: 64 bytes, header CRC: 0x534C30CF, created: Tue Nov 8
06:05:02 2011, image size: 3593310 bytes, Data Address: 0xFFFFFFFF, Entry Point: 0x0, data CRC: 0x672C70AA, OS:
Linux, CPU: ARM, image type: Firmware Image, compression type: none, image name: LK:ZT280_H1_2n
64 0x40 uImage header, header size: 64 bytes, header CRC: 0xC6DD4500, created: Tue Nov 8
06:05:02 2011, image size: 3593246 bytes, Data Address: 0x80008000, Entry Point: 0x80008000, data CRC: 0x58A0473
9, OS: Linux, CPU: ARM, image type: OS Kernel Image, compression type: lzma, image name: Linux-2.6.34
128 0x80 LZMA compressed data, properties: 0x5D, dictionary size: 33554432 bytes, uncompre
ssed size: 9026566 bytes
248589 0x3CB0D gzip compressed data, was "\255\344\016\015!\232|.\333\017s\250\3577\366{\241\240
\005`v\321\324\2238\307DX\241l&\003k\330\203b\030\230!\245x\366\021?\211s\214\254\253\327w\354\222C\230\015\303=
64\2126", has comment, from Z-System, comment, encrypted, last modified: Sun Jan 14 00:12:51 2024

Thank you!
andrewavp said:
Code:
### uImage original size: 3593374 ###
### Binwalk ouput for original uImage ##
DECIMAL HEX DESCRIPTION
-------------------------------------------------------------------------------------------------------
0 0x0 uImage header, header size: 64 bytes, header CRC: 0x534C30CF, created: Tue Nov 8 06:05:02 2011, image size: 3593310 bytes, Data Address: 0xFFFFFFFF, Entry Point: 0x0, data CRC: 0x672C70AA, OS: Linux, CPU: ARM, image type: Firmware Image, compression type: none, image name: LK:ZT280_H1_2n
64 0x40 uImage header, header size: 64 bytes, header CRC: 0xC6DD4500, created: Tue Nov 8 06:05:02 2011, image size: 3593246 bytes, Data Address: 0x80008000, Entry Point: 0x80008000, data CRC: 0x58A04739, OS: Linux, CPU: ARM, image type: OS Kernel Image, compression type: lzma, image name: Linux-2.6.34
128 0x80 LZMA compressed data, properties: 0x5D, dictionary size: 8388608 bytes, uncompressed size: 9980736 bytes
### Remove 2 uImage headers ###
dd if=uImage of=zImage-lzma bs=1 skip=128
### Uncompress lzma kernel ###
### Compressed size: 3593246 ###
### Uncompressed size: 9980736 ###
dd if=zImage-lzma bs=1 | lzcat > zImage
### Find start of cpio ###
grep -a -b -m 1 --only-matching '070701' zImage
167936:070701
168052:070701
### Find end of cpio ###
grep -a -b -m 1 --only-matching 'TRAILER!!!' zImage
1765826:TRAILER!!!
### Add 11 to the above # to include trailer and extract cpio from kernel ###
dd if=zImage bs=1 skip=167936 count=1765837 of=initramfs_orig.cpio
### Explode the cpio ###
mkdir cpio_orig
cd cpio_orig/
cpio -v -i --no-absolute-filenames < ../initramfs_orig.cpio
### Make changes to initramfs ###
### Create new cpio ###
(cd cpio_orig; find . | cpio -o -H newc | gzip) > ../initramfs.cpio
### Write beginning of original zImage up to start of cpio to a new file ###
dd if=zImage bs=1 count=167936 of=/tmp/zImage
### Add new cpio/initramfs to the new file ###
dd if=initramfs.cpio bs=1 seek=167936 of=/tmp/zImage
### Write ending of original zImage to new file ###
### Seek below should be size of first part (167936) + size of original initramfs (1765837) ###
dd if=zImage bs=1 seek=1933773 skip=1765826 of=/tmp/zImage
### lzma compress the new zImage ###
### Uncompressed size: 9026566 ###
### Compressed size: 3808279 (larger than original zImage compressed size!?) ###
lzma -9 /tmp/zImage
### Add uImage headers to new file ###
### or should this be replaced by using the mkimage command? ###
dd if=uImage of=/tmp/uImage bs=1 count=128
### Add compressed zimage to new uImage ###
### New uImage size: 3808407 ###
dd if=/tmp/zImage.lzma bs=1 seek=128 of=/tmp/uImage
### binwalk output for new uImage ###
DECIMAL HEX DESCRIPTION
-------------------------------------------------------------------------------------------------------
0 0x0 uImage header, header size: 64 bytes, header CRC: 0x534C30CF, created: Tue Nov 8
06:05:02 2011, image size: 3593310 bytes, Data Address: 0xFFFFFFFF, Entry Point: 0x0, data CRC: 0x672C70AA, OS:
Linux, CPU: ARM, image type: Firmware Image, compression type: none, image name: LK:ZT280_H1_2n
64 0x40 uImage header, header size: 64 bytes, header CRC: 0xC6DD4500, created: Tue Nov 8
06:05:02 2011, image size: 3593246 bytes, Data Address: 0x80008000, Entry Point: 0x80008000, data CRC: 0x58A0473
9, OS: Linux, CPU: ARM, image type: OS Kernel Image, compression type: lzma, image name: Linux-2.6.34
128 0x80 LZMA compressed data, properties: 0x5D, dictionary size: 33554432 bytes, uncompre
ssed size: 9026566 bytes
248589 0x3CB0D gzip compressed data, was "\255\344\016\015!\232|.\333\017s\250\3577\366{\241\240
\005`v\321\324\2238\307DX\241l&\003k\330\203b\030\230!\245x\366\021?\211s\214\254\253\327w\354\222C\230\015\303=
64\2126", has comment, from Z-System, comment, encrypted, last modified: Sun Jan 14 00:12:51 2024
Click to expand...
Click to collapse
I know this was posted almost a year ago, but thank you! I've been trying to figure out the finer details concerning this style of uImage by examining files in a hex editor and reading scripts that only output the initramfs portion. The comments and commands posted here told me exactly what I needed to know.
ShaunMT

shaunmt said:
Title: Thank you!
Click to expand...
Click to collapse
I was taught to say thanks by clicking on the icon:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
THANKS
.

shaunmt said:
I know this was posted almost a year ago, but thank you! I've been trying to figure out the finer details concerning this style of uImage by examining files in a hex editor and reading scripts that only output the initramfs portion. The comments and commands posted here told me exactly what I needed to know.
ShaunMT
Click to expand...
Click to collapse
Did you by any chance found a way to pack back the boot.img? the "packing" part of this does not seem to work for me

niabi said:
Did you by any chance found a way to pack back the boot.img? the "packing" part of this does not seem to work for me
Click to expand...
Click to collapse
I don't remember if this was the exact format of the devices that I've been supporting, but I use some scripts created by CXZ at slatedroid for the Ainol series. You should be able to find them in the threads there.
ShaunMT

shaunmt said:
I don't remember if this was the exact format of the devices that I've been supporting, but I use some scripts created by CXZ at slatedroid for the Ainol series. You should be able to find them in the threads there.
ShaunMT
Click to expand...
Click to collapse
Thanks I was just coming to say that Finless was kind enough to share his script, and I am now able to pack it back up

How To Add LZMA Files
Hi,
There is a lot of great information here. Maybe someone here can help me. Is there a way to add LZMA files? You have your uImage; you extract the kernel and then decompress it and run binwalk on it to get this (example):
Code:
DECIMAL HEX DESCRIPTION
-------------------------------------------------------------------------------------------------------
184564 0x2D0F4 ASCII cpio archive (SVR4 with no CRC), file name: "dev"
184680 0x2D168 ASCII cpio archive (SVR4 with no CRC), file name: "dev/console"
184804 0x2D1E4 ASCII cpio archive (SVR4 with no CRC), file name: "root"
184920 0x2D258 ASCII cpio archive (SVR4 with no CRC), file name: "TRAILER!!!"
5797868 0x5877EC Linux kernel version "3.0.35-06433-g8e02e5d-dirty ([email protected]) (gcc version [email protected]) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)ogle 20120106 (prerelease) (GCC) ) #6 SMP PREEMPT Fri May 30 03) ) #6 SMP PREEMPT Fri May 30 03:07:36 MST 2014"
5811760 0x58AE30 LZMA compressed data, properties: 0x02, dictionary size: 16777216 bytes, uncompressed size: 50331648 bytes
5813168 0x58B3B0 gzip compressed data, from Unix, NULL date: Wed Dec 31 17:00:00 1969, max compression
5831784 0x58FC68 LZMA compressed data, properties: 0x01, dictionary size: 33554432 bytes, uncompressed size: 50331648 bytes
5888826 0x59DB3A LZMA compressed data, properties: 0x02, dictionary size: 33554432 bytes, uncompressed size: 133128 bytes
5935896 0x5A9318 LZMA compressed data, properties: 0x48, dictionary size: 33554432 bytes, uncompressed size: 50331648 bytes
Now say I wanted to add an LZMA file to the end of this; Decimal 5935896, or say somewhere else; between Decimals 5813168 and 5831784. How would I do that using the DD Utility?

Related

[Q] Terminal not showing .img files when trying to replace .img files

When trying to push new files to my LG G3 to fix the issue outlined here:
http://forum.xda-developers.com/showthread.php?t=2582142&page=178
Basically, can't get to recovery, or download and won't boot.
Terminal returns this instead of list of .img files:
ls /dev/sd *
TERMINAL RESPONSE: / dev / sda / dev / sda1 / dev / sda2 / dev / sda3
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present
************************************************** *****************************************
Found invalid GPT and MBR valid; Converting MBR to GPT format in memory.
************************************************** *****************************************
Disk /dev/sda: 625142448 sectors, 298.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 4746570D-B91E-4A91-917C-D94BCEBD34F3
Partitions table holds up to 128 entries
First usable sector in 34, last usable sector is 625142414
Partitions will be aligned on 2048-sector boundaries
Total free space is 310512237 sectors (148.1 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 52430847 25.0 GiB 0700 Linux data
2 52430848 314632191 125.0 GiB 0700 Linux data
^^^^ here is where the list of img files and their respective locations should be according to the guide. However, it does not show.
Any ideas?

Make Cyanogenmod ROM zip without creating the .img files

hey guys,
For the past few days I've tried building Cyanogenmod 12 for my device. The build process seems to finish but my build is stuck at 'creating system.img' file. my terminal output is:
Code:
Install: /home/ishtiaque/CM12/android/system/out/target/product/codina/system/app/Email/Email.apk
build/tools/generate-notice-files.py /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/NOTICE.txt /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/NOTICE.html "Notices for files contained in the filesystem images in this directory:" /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/NOTICE_FILES/src
Combining NOTICE files into HTML
Combining NOTICE files into text
Installed file list: /home/ishtiaque/CM12/android/system/out/target/product/codina/installed-files.txt
Target system fs image: /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/PACKAGING/systemimage_intermediates/system.img
Running: mkuserimg.sh -s /home/ishtiaque/CM12/android/system/out/target/product/codina/system /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/PACKAGING/systemimage_intermediates/system.img ext4 system 641728512 /home/ishtiaque/CM12/android/system/out/target/product/codina/root/file_contexts
make_ext4fs -s -T -1 -S /home/ishtiaque/CM12/android/system/out/target/product/codina/root/file_contexts -l 641728512 -a system /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/PACKAGING/systemimage_intermediates/system.img /home/ishtiaque/CM12/android/system/out/target/product/codina/system
Creating filesystem with parameters:
Size: 641728512
Block size: 4096
Blocks per group: 32768
Inodes per group: 7840
Inode size: 256
Journal blocks: 2448
Label:
Blocks: 156672
Block groups: 5
Reserved block group size: 39
Created filesystem with 2570/39200 inodes and 106418/156672 blocks
now I've tried re-downloading the sources and building again after waiting overnight at this step but it just doesn't finish.
So my question is: can I skip the creation of these .img files and proceed to making the flashable zip in any way? I don't have fastboot option for my device afterall so its quite unnecessary to create these image files (it seems to me)
Thanks
Edit: according to the above output, a system.img file is actually produced in the systemimage_intermediates but it doesn't ge tcopied in the /product/codina folder
ishtiaque9 said:
hey guys,
Code:
Install: /home/ishtiaque/CM12/android/system/out/target/product/codina/system/app/Email/Email.apk
build/tools/generate-notice-files.py /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/NOTICE.txt /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/NOTICE.html "Notices for files contained in the filesystem images in this directory:" /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/NOTICE_FILES/src
Combining NOTICE files into HTML
Combining NOTICE files into text
Installed file list: /home/ishtiaque/CM12/android/system/out/target/product/codina/installed-files.txt
Target system fs image: /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/PACKAGING/systemimage_intermediates/system.img
Running: mkuserimg.sh -s /home/ishtiaque/CM12/android/system/out/target/product/codina/system /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/PACKAGING/systemimage_intermediates/system.img ext4 system 641728512 /home/ishtiaque/CM12/android/system/out/target/product/codina/root/file_contexts
make_ext4fs -s -T -1 -S /home/ishtiaque/CM12/android/system/out/target/product/codina/root/file_contexts -l 641728512 -a system /home/ishtiaque/CM12/android/system/out/target/product/codina/obj/PACKAGING/systemimage_intermediates/system.img /home/ishtiaque/CM12/android/system/out/target/product/codina/system
Creating filesystem with parameters:
Size: 641728512
Block size: 4096
Blocks per group: 32768
Inodes per group: 7840
Inode size: 256
Journal blocks: 2448
Label:
Blocks: 156672
Block groups: 5
Reserved block group size: 39
Created filesystem with 2570/39200 inodes and 106418/156672 blocks
Click to expand...
Click to collapse
I'm having same problem, do you know how to fix?
hastalafiesta said:
I'm having same problem, do you know how to fix?
Click to expand...
Click to collapse
hey hastalafiesta,
apparently I managed to get past this point. there are several files you need to edit:
1. build/core/Makefile: here you have to enter several lines which allow you to skip recovery_from_boot.p file (which wasn't created on Cyanogenmod 11 idk why)
Code:
# The system partition needs room for the recovery image as well. We
# now store the recovery image as a binary patch using the boot image
# as the source (since they are very similar). Generate the patch so
# we can see how big it's going to be, and include that in the system
# image size check calculation.
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
ifndef BOARD_CUSTOM_BOOTIMG_MK
ifeq ($(CM_BUILD),)
RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
else
RECOVERY_FROM_BOOT_PATCH :=
endif
else
RECOVERY_FROM_BOOT_PATCH :=
endif
$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \
$(INSTALLED_BOOTIMAGE_TARGET) \
$(HOST_OUT_EXECUTABLES)/imgdiff \
$(HOST_OUT_EXECUTABLES)/bsdiff
@echo -e ${CL_CYN}"Construct recovery from boot"${CL_RST}
mkdir -p $(dir [email protected])
PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) [email protected]
endif
$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
@echo -e ${CL_CYN}"Install system fs image: [email protected]"${CL_RST}
$(copy-file-to-target)
$(hide) $(call assert-max-image-size,[email protected] $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
systemimage: $(INSTALLED_SYSTEMIMAGE)
.PHONY: systemimage-nodeps snod
systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
| $(INTERNAL_USERIMAGES_DEPS)
@echo "make [email protected]: ignoring dependencies"
$(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
$(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
ifeq (true,$(WITH_DEXPREOPT))
$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
endif
endif
#######
## system tarball
match the first and last comment to find the relevant sections in the file, then replace.
2. build/tools/post_process_props.py: add the lines that start with '+'
Code:
def mangle_default_prop(prop):
# If ro.debuggable is 1, then enable adb on USB by default
# (this is for userdebug builds)
+ prop.put("ro.secure", "0")
+ prop.put("ro.adb.secure", "0")
if prop.get("ro.debuggable") == "1":
val = prop.get("persist.sys.usb.config")
if val == "":
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 7908b70..732c8c1 100755
3. build/tools/releasetools/common.py: same as post_process_props
Code:
def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img,
info_dict=None):
+ pass
+
+def MakeRecoveryPatch2(input_dir, output_sink, recovery_img, boot_img,
+ info_dict=None):
"""Generate a binary patch that creates the recovery image starting
with the boot image. (Most of the space in these images is just the
kernel, which is identical for the two, so the resulting patch
and voila! your build will finish and a zip will form. try flashing it :good:
credits for the edits: @nieltg
~ishtiaque
ishtiaque9 said:
Code:
def mangle_default_prop(prop):
# If ro.debuggable is 1, then enable adb on USB by default
# (this is for userdebug builds)
+ prop.put("ro.secure", "0")
+ prop.put("ro.adb.secure", "0")
if prop.get("ro.debuggable") == "1":
val = prop.get("persist.sys.usb.config")
if val == "":
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 7908b70..732c8c1 100755
Click to expand...
Click to collapse
Actually, I use this part of code to force-enable ADB debugging in my build..
So, this part of code isn't mandatory.. Sorry!
nieltg said:
Actually, I use this part of code to force-enable ADB debugging in my build..
So, this part of code isn't mandatory.. Sorry!
Click to expand...
Click to collapse
any developer needs ADB

Can't edit cache.img file using simg2img and img2simg

I tried on both windows and ubuntu.
First I try to flash the original cache.img
Code:
heimdall flash --CACHE cache.img
Works, no errors and everything goes fine. Now when I do...
Code:
>file cache.img
cache.img: Android sparse image, version: 1.0, Total of 16384 4096-byte output blocks in 14 input chunks.
>simg2img cache.img cache.raw
>img2simg cache.raw cache2.img
>file cache2.img
cache2.img: Android sparse image, version: 1.0, Total of 16384 4096-byte output blocks in 74 input chunks.
Without changing (or even mounting) the raw file at all! I just converted it to raw and back.
Then I tried to flash the new file again, fails. And as you can see they are obviously very different, even though I did absolutely no changes!
I verified the block size, the default one (4096) is the correct one.
Also, the original cache.img is 49.4 MB, the cache2.img file is 39.6 MB
The output when trying to flash the new cache.img file:
Code:
Uploading CACHE
100%
ERROR: Failed to confirm end of file transfer sequence!
ERROR: CACHE upload failed!
It should be the same file, but isn't. What am I doing wrong?
Edit:
Instead of using img2simg, I used mkuserimg.sh which created a file that's NEARLY identical to my original file:
Code:
>sudo ./mkuserimg.sh -s ./cache ./cache2.img ext4 cache 64M
in mkuserimg.sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
make_ext4fs -s -l 64M -a cache ./cache2.img ./cache
Creating filesystem with parameters:
Size: 67108864
Block size: 4096
Blocks per group: 32768
Inodes per group: 4096
Inode size: 256
Journal blocks: 1024
Label:
Blocks: 16384
Block groups: 1
Reserved block group size: 7
Created filesystem with 15/4096 inodes and 12062/16384 blocks
>file *.img
cache2.img: Android sparse image, version: 1.0, Total of 16384 4096-byte output blocks in 14 input chunks.
cache.img: Android sparse image, version: 1.0, Total of 16384 4096-byte output blocks in 14 input chunks.
>ls -l *.img
-rw-r--r-- 1 root root 49406148 Aug 20 13:19 cache2.img
-rwxrw-rw- 1 ae ae 49406208 May 19 09:24 cache.img
As you see they slightly differ now, but flashing still fails. Adding --verbose to heimdall adds this:
Code:
ERROR: Failed to unpack received packet.
Edit 2:
I'm using a Samsung device (Galaxy S7)
Fixed it in the end using manually compiled and modified binaries of the sim2img and img2sim. The original source is obtained from
github .com/ASdev/android_img_repack_tools/tree/android-6.0.1
and then apply this patch
gist. github .com/jedld/4f388496bda03b349f5744f367749a67
(had to add spaces because i'm a new user, but wanted to put this here in case someone else has this problem)
then build it, and it flashes now properly. (using simg2img and img2simg)

Ubuntu, Arch Linux, Tails on Acer Chromebook C720P & Asus CS10 Chromebook stick

placeholder
I will try & summarise all my works to install Linux distros on USB's or using crouton on Chromebooks...
Make sure you are in developer mode...
1. crouton
Download crouton in ~/Downloads
Useful command in Chrome/Chromium OS to install crouton Linux distro ubuntu xenial with xfce & xiwi in Acer Chromebook C720P
in a ctrl-alt-t shell -
shell
sudo sh ~/Downloads/crouton -r xenial -t xfce,xiwi,touch,extension
After running the command, one should get the following message (generally)
Here's some tips:
Audio from the chroot will now be forwarded to CRAS (Chromium OS audio server),
through an ALSA plugin.
Future Chromium OS upgrades may break compatibility with the installed version
of CRAS. Should this happen, simply update your chroot.
You already have the Chromium OS extension installed, so you're good to go!
You can open your running chroot desktops by clicking on the extension icon.
Once in a crouton window, press fullscreen or the "switch window" key to switch
back to Chromium OS.
You can launch individual apps in crouton windows by using the "xiwi" command
in the chroot shell. Use startxiwi to launch directly from the host shell.
Use the startxiwi parameter -b to run in the background.
Example: sudo startxiwi -b xterm
You can start Xfce via the startxfce4 host command: sudo startxfce4
Unmounting /mnt/stateful_partition/crouton/chroots/xenial...
Sending SIGTERM to processes under /mnt/stateful_partition/crouton/chroots/xenial...
Done! You can enter the chroot using enter-chroot.
( to use xiwi, you need to install the crouton extension from the Google Web Store).
Not re-inventing the wheel, head on for further info to:
Complete Crouton Installation Guide (Linux on any Chromebook):
https://www.codedonut.com/chromebook/install-crouton-chromebook/
& the dev's crouton's github:
https://github.com/dnschneid/crouton
In case the crouton chroot is already installed without xiwi,
To update an installation with xiwi, apply:
sudo sh ~/Downloads/crouton -n xenial -t xfce,xiwi,touch,extension -u
Notes:
cons -
with crouton one is stuck with the Chrome OS host Linux Kernel , which for Acer CB C720P is Kernel v3.8
it is a chroot environment, so new Ubunture features such as snap packaging cannot be used.
pros -
xiwi allows running Linux apps in separate windows
share of the clipboard & ~/Downloads folder between host & guest
one does not leave the Chrome OS environment
it is like the new crostini feature they are pushing on Kernel 3.18 & above
I think crostini is crouton in Italian
Chromebrew
All I have to say about skycocker's chromebrew -
For a full arsenal of Linux commands at your fingertips in a crosh shell, install Chromebrew package manager on Chromebook or Chrome OS -
requisites: developer mode enabled.
https://github.com/skycocker/chromebrew …
curl -Ls http://git.io/vddgY | bash
crew <command> [-k|--keep] <package1> ...]
Note -
sad but true, I installed chromebrew to get access to the nano text editor - as I have never made the effort to master vi/vim despite using Linux since 1995...
Tails Linux distro with Tor privacy
Tails is an operating system based on Linux & the Tor anonymity project.
It's easy to install on a USB, & very portable as it can boot off MBR & EFI partitions.
It's only available for x86 & x86_64 computers, though they are looking into porting it to Arm.
I got it on a USB following instructions in the developers website: https://tails.boum.org/
Tor browser on any computer, Linux, Mac, Windows, Android.
1. relevant to Chromebooks or hacked with Android & Play Store - Orbot / Orfox:
Tor anonymising solution is now available on Play Store - the Tor proxy is called Orbot & a web browser was compiled to run with it based on mozilla firefox called Orfox.
The set Orbot / Orfox are available to download for free from the Play Store -
I won't describe any of it -
Initially before it was on Play Store, it could be downloaded from the devs group who ported it to Android it: https://guardianproject.info/apps/orbot/
It was also made available through an open source Android Store: F-Droid - https://guardianproject.info/fdroid/
F-Droid is a great source for free open source alternative Android software - it works seamlessly through the Android platform or within proprietary Android based like Amazon Fire.
2. For other x86 platforms like Windows, Linux, Mac...
all is in here: https://www.torproject.org/
F-Droid - a great open source software repository for Android applications
Great way to complement Amazon Appstore, or Android Play Store is F-Droid -
a software repository for Android applications, similar to Google Play store.
The main repository, hosted by the project, contains only apps that are free and open-source software.
https://f-droid.org/en/
https://twitter.com/inabster/status/956226183477317633
F-Droid have a repository for a Tor powered solution on Android platform worthy to those concerned about privacy Orbot is the open source app, & Orfox is the associated Tor Mozilla based (Firefox fork) browser - https://guardianproject.info/apps/orbot/ https://guardianproject.info/apps/orfox/
https://twitter.com/inabster/status/956229034169520130
Ubuntu on Chromebook from USB.
Seabios emulates an mbr boot, so allows booting to mbr using Ctrl-L
Ubuntu then installs as normal to mbr using a Ubuntu livecd.
It might be possible to install Ubuntu so it boots using Ctrl-U. I did not look into it.
Arch Linux on Chromebook & Asus Chromebit CS10
Arch Linux on Asus Chromebit CS10 -
Full instructions here:
https://archlinuxarm.org/platforms/armv7/rockchip/asus-chromebit-cs10
Mainline Kernel
The installation above will use the ChromeOS 3.14 kernel. The mainline kernel can be used instead, though some hardware may not be working yet. Two options are available to switch to the mainline kernel:
Replace kernel packages after installation
Install linux-armv7 packages, replacing the linux-veyron package, and the firmware-veyron package:
pacman -S linux-armv7 linux-armv7-chromebook firmware-veyron
Type y and hit enter when prompted to flash the kernel to the kernel partition.
Remove the veyron-libgl and xf86-video-armsoc-rockchip packages. Mali is not supported in mainline.
pacman -R veyron-libgl xf86-video-armsoc-rockchip
Reboot.
Perform a new installation with the above steps using the armv7-chromebook tarball:
http://os.archlinuxarm.org/os/ArchLinuxARM-armv7-chromebook-latest.tar.gz
Install the firmware-veyron package, or copy it to the drive for later installation for wifi support.
pacman -S firmware-veyron
Arch Linux on Chromebook -
Easiest instructions to install Arch Linux on a USB of Chromebook in BIOS legacy mode here:
https://gist.github.com/alphazo/3285090
https://twitter.com/inabster/status/692098848391610372
General consideration on Linux installs with uefi - notes to self
These are notes to myself to link up to - I have posted them on @twitter - but nice to have them ready for copy & paste.
Not related to Chromebooks generally, unless one uses Ctrl-U which is an uefi boot... I did not dabble in it...
Two important config files to get a successful Arch Linux or Ubuntu boot are:
grub.cfg
fstab
fstab is in /etc/
/etc/fstab
& tells the OS where relevant partitions are
... TBC
Linux Kernel related building commands for reference...
Build Ubuntu Kernel
sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc
clone git kernel for source in home user folder ~/kernel
cd kernel
cp /boot/config-$(uname -r) .config
make menuconfig
sudo make -j 4 && sudo make modules_install -j 4 && sudo make install -j 4
sudo update-initramfs -c -k 4.xx.xx
sudo update-grub .../...
also
build kernel headers from source with: (at root of kernel directory) -
sudo make headers_install INSTALL_HDR_PATH=/usr/include
Arch Linux 4.19-LTS & 5.0.8 nasty bug
Testing Arch Linux on Chromebook
Arch Linux 4.19-LTS & 5.0.8 nasty bug
but for those using Arch Linux, avoid kernel 4.19-LTS & 5.0.8 like the plague,
both damage Arch Linux by disabling usb input devices, trackpad, mouse, keybooard, touch...
I had to put my rant somewhere, it damaged a 3 year Arch Linux USB stick for me
Since I am here, might as well post for reference my experience with getting a new USB loaded with Arch Linux
not doing it from scratch, too much effort...
found this - quite good too, Live USB persistent -
Arch Linux USB OS https://sourceforge.net/projects/arch-linux-usb-os/ …
It saves the trouble of building Arch Linux OS from scratch.
Uses Kernel 5.0.5 -
Linux robot 5.0.5-arch1-1-ARCH #1 SMP PREEMPT Wed Mar 27 17:53:10 UTC 2019 x86_64 GNU/Linux
if allowed to upgrade to 5.0.8 will bork the input, so only upgrade to 5.0.7 maximum (linux-rt), which I built through aur.
upgrading through aur to linux-rt 5.0.7
$ uname -a
Linux robot 5.0.7-rt5-1-rt #1 SMP PREEMPT RT Mon Apr 22 14:42:29 CEST 2019 x86_64 GNU/Linux
to get to boot with this kernel needs to replace linux with linux-rt in loader settings.
to stop kernel from upgrading -
ArchLinux is updated to the newest version with the command:
pacman -Syu
To stop it from updating the kernel (until they get their **** together) add
IgnorePkg = linux linux-headers
into /etc/pacman.conf
stuff / thingies
[email protected] ~ $ cd /run/archiso/bootmnt
[email protected] bootmnt $ ls
arch EFI loader
[email protected] bootmnt $ ls arch/boot
amd-ucode.img grub intel-ucode.img intel_ucode.LICENSE x86_64
[email protected] bootmnt $ ls arch/boot/x86_64/
initramfs-linux.img initramfs-linux-rt.img vmlinuz-linux vmlinuz-linux-rt
notes -
original shipped linux version is 5.0.5
upgraded linux version though aur is linux-rt 5.0.7
so needed to copy vmlinuz-linux-rt & initramfs-linux-rt.img to /run/archiso/bootmnt/arch/boot/x86_64/
cannot be done from a running instance, so had to boot from another live usb to copy it over from
[email protected] bootmnt $ ls /boot
amd-ucode.img initramfs-linux-rt-fallback.img syslinux
grub initramfs-linux-rt.img vmlinuz-linux
initramfs-linux.img intel-ucode.img vmlinuz-linux-rt
to automate replace loading linux with linux-rt, modify
/run/archiso/bootmnt/loader/entries/
[email protected] entries $ ls
Archlinux.conf Archlinux-terminal.conf uefi-shell-v2-x86_64.conf
Archlinux-copytoram.conf uefi-shell-v1-x86_64.conf
example
Archlinux.conf original
title Arch Linux UEFI
linux /arch/boot/x86_64/vmlinuz-linux
initrd /arch/boot/intel-ucode.img
initrd /arch/boot/amd-ucode.img
initrd /arch/boot/x86_64/initramfs-linux.img
options archisobasedir=arch archisolabel=USB-BOOT cow_label=usb-save loglevel=3
change to:
title Arch Linux UEFI
linux /arch/boot/x86_64/vmlinuz-linux-rt
initrd /arch/boot/intel-ucode.img
initrd /arch/boot/amd-ucode.img
initrd /arch/boot/x86_64/initramfs-linux-rt.img
options archisobasedir=arch archisolabel=USB-BOOT cow_label=usb-save loglevel=3
to be able to modify bootloader files
do above from a separate linux usb (mine is Ubuntu 18.04)
$ mkdir efi
$ sudo mount /dev/sdb1 efi
$ cd efi
$ ls
arch EFI loader
... etc as above.
News - Arch Linux released Kernel 5.0.9 - still has the nasty bug - do not upgrade, if you did, downgrade by installing the downgrade script from aur...
How to downgrade a Linux kernel...
https://arcolinux.com/how-to-downgrade-a-linux-kernel/
Borking my 3 year arch linux USB was a blessing in disguise, made me look for a persistent USB alternative...
the one described above boots Acer Chromebook C720P well, it works great, with kernels 5.0.5 & 5.0.7 -
I tested it on the modded full ROM MrChromebox firmware, but believe it will work as well in Seabios legacy mode.
notes to myself
Linux pot-pourri commands from my notes, for reference
these are copy & paste commands which I need put into one place, here...
I will rearrange them later with context where to be used...
placeholder...
Chromebook: Updating xenial to bionic w/ crouton:
$ sudo enter-chroot -n xenial
(xenial)[email protected]:~$ sudo apt-get install update-manager-core python-apt
(xenial)[email protected]:~$ sudo do-release-upgrade
$ sudo sh ~/Downloads/crouton -n xenial -u
$ sudo edit-chroot xenial -m bionic
Creating a dev environment in all Chrome OS x86 or arm:
shell
sudo dev_install
Creating a Visual Studio environment in arm:
shell
sudo su -
. <( curl -s https://code.headmelted.com/installers/chromebook.sh … )
Creating a Ubuntu chroot & X-Windows environment:
sudo sh ~/Downloads/crouton -t xfce -r xenial
If using rEFInd as bootloader, a useful command to get entries at boot in the UEFI menu is:
$ sudo efibootmgr -c -g -d /dev/sda -p 1 -w -L "rEFInd" -l '\EFI\refind\refind_x64.efi'
replace /dev/sda by /dev/sdx x=b,c... in other cases.
To check install is correct, issue:
$ [ -d /sys/firmware/efi ] && echo "EFI boot on HDD" || echo "Legacy boot on HDD]
Sometimes needed
1.:
$ sudo apt-get install --reinstall efibootmgr
$ sudo grub-install /dev/sda
$ sudo apt-get install --reinstall grub-efi
$ sudo grub-install /boot/efi
$ sudo grub-install --target=i386-efi /dev/sda1 --efi-directory=/boot/efi/ --boot-directory=/boot
2.:
$ sudo grub-mkconfig -o /boot/grub/grub.cfg
then again:
$ sudo apt-get -y install --reinstall grub-efi-ia32 grub-efi-ia32-bin
@ubuntu 18.04.1 works with efi on @bbenTech Intel Compute Stick (ICS) cherrytrail clone & with mbr (seabios legacy) on @Acer Chromebook C720P.
Managed to get it to boot w/ efi 32bit bootlader - but I had to get into GUI 1st & bypass the initramfs emergency mode - what was needed was correct UUID of EFI partition in /etc/fstab - then boot through grub manually...
UUID=XXXX-XXXX /boot/efi vfat umask=0077 0 1
When in grub, issue
set root=(hd0,gpt2)
configfile (hd0,gpt1)/efi/ubuntu/grub.cfg
(grub.cfg must have the UUID of (hd0,gpt2) in my case of /dev/sdb2
use
sudo blkid /dev/sdX to find UUID's)
that boots into Ubuntu 18.04
open terminal...
When in the GUI
in terminal issue:
sudo apt-get update
sudo apt-get -y install --reinstall grub-efi-ia32 grub-efi-ia32-bin
reboot
Notes:
Arch Linux
$ sudo grub-install --target=i386-efi /dev/sda2 --efi-directory=/boot/efi/ --boot-directory=/boot
$ sudo efibootmgr -c -g -d /dev/sda -p 2 -w -L "Arch" -l '\EFI\EFI\arch\grubia32.efi'
then:
$ sudo grub-mkconfig -o /boot/EFI/EFI/arch/grub.cfg
$ sudo mkinitcpio -p linux
from http://www.rodsbooks.com/efi-bootloaders/installation.html#alternative-naming
Arch Linux mainline kernel
$ sudo mount -o remount,size=6G,noatime /tmp
$ yaourt linux-mainline
more crouton / crostini stuff
Latest crostini kernel is 4.19.16 -
for lolz I installed mplayer, mpv & gnome-mpv (all Linux video players)
they do load videos from crostini, but with no sound (this is using cyan & eve v73) -
of course video works great in crouton Linux distros... or in Android with VLC etc...
RFC - Any idea how to get sound working through crostini?
of course this is not needed as within Android or crouton with say Ubuntu bionic, sound is perfectly fine
just fooling around crostini
from - https://forum.xda-developers.com/showpost.php?p=79527257&postcount=215
crouton bionic sound issues -
add following to /etc/pulse/daemon.conf -
default-sample-rate = 48000
default-fragments = 5
default-fragment-size-msec = 2
Access audio hardware directly (ALSA, JACK)
add yourself to the hwaudio group.
sudo usermod -a -G hwaudio "$USER"
Log out and log back in.
Test:
$ groups
slee2 hwaudio video sudo plugdev audio input
Stop CRAS
Make sure you've stopped CRAS, or else it will hold on to your audio device. In either ChromeOS or your chroot, run
$ sudo initctl stop cras
You might also need this to control audio -
$ alsamixer -c 0
from - https://github.com/dnschneid/crouton/wiki/Access-audio-hardware-directly-(ALSA,-JACK)
& https://github.com/dnschneid/crouton/wiki/Audio
Reinstall GRUB to the EFI partition using chroot
Notes to self-
sudo mount /dev/sdXXX /mnt
sudo mount /dev/sdXX /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdX
update-grub
Note : sdX = disk | sdXX = efi partition | sdXXX = system partition
To identify the partitions use GParted, the tool is included in the installation medium.
After having run the commands GRUB will be installed in the separate EFI partition.
Deploying, bootloading OSes such as Ubuntu manually
I like to initially install an OS to a 16/32 GB USB 3.0 stick, then dd it to a bigger SSD of I am happy with it, follows some notes on how it is done...
In previous post, I described how to fix an efi booting, but there is a caveat, one needs to know where & how to modify settings of efi bootlader, & /etc/fstab that tells the OS where to find partitions to load itself (bootstrap)...
These are some successful partition settings I had to deal with -
1. efi/mbr mix
$ sudo fdisk -l
Disk /dev/sdb: 465.8 GiB, 500107861504 bytes, 976773167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: gpt
Disk identifier: ***
Device Start End Sectors Size Type
/dev/sdb1 2048 411647 409600 200M EFI System
/dev/sdb2 411648 210208767 209797120 100G Microsoft basic data
/dev/sdb3 210415616 337403903 126988288 60.6G Linux filesystem
/dev/sdb4 337403904 430872575 93468672 44.6G Linux filesystem
/dev/sdb5 430872576 435066879 4194304 2G Linux swap
/dev/sdb6 435066880 624490495 189423616 90.3G Microsoft basic data
/dev/sdb7 624490496 976766975 352276480 168G Microsoft basic data
/dev/sdb8 210208768 210415615 206848 101M BIOS boot
Partition table entries are not in disk order.
/dev/sdb8 is BIOS boot invoked by bios_grub flag in gparted manage flags partition editor
/dev/sdb1 is efi partition flagged as boot, esp & legacy_boot in gparted manage flags partition editor
$ sudo fdisk -l
Disk /dev/sdc: 931.5 GiB, 1000204885504 bytes, 1953525167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: xxx
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 204800 100M BIOS boot
/dev/sdc2 206848 135235583 135028736 64.4G Linux filesystem
/dev/sdc3 135235584 286480383 151244800 72.1G Linux filesystem
/dev/sdc4 286480384 599062527 312582144 149.1G Microsoft basic data
/dev/sdc5 599062528 599984127 921600 450M Windows recovery environment
/dev/sdc6 599984128 1007575039 407590912 194.4G Microsoft basic data
/dev/sdc7 1007575040 1949327359 941752320 449.1G Microsoft basic data
/dev/sdc8 1949329408 1953103871 3774464 1.8G Linux swap
/dev/sdc9 1953105920 1953519615 413696 202M EFI System
/dev/sdc1 is BIOS boot invoked by bios_grub flag in gparted manage flags partition editor
/dev/sdc9 is efi partition flagged as boot, esp & legacy_boot in gparted manage flags partition editor
2. pure mbr / no BIOS boot - using Windows boot loader & easyBCD 3.2 to load Linux/Ubuntu
$ sudo fdisk -l
Disk /dev/sdc: 931.5 GiB, 1000204885504 bytes, 1953525167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: dos
Disk identifier: 0x767e7d2d
Device Boot Start End Sectors Size Id Type
/dev/sdc1 * 2048 472768511 472766464 225.4G 7 HPFS/NTFS/exFAT
/dev/sdc2 472768512 1422079999 949311488 452.7G 7 HPFS/NTFS/exFAT
/dev/sdc3 1422080221 1479591932 57511712 27.4G 83 Linux
/dev/sdc4 1479591933 1953523711 473931779 226G f W95 Ext'd (LBA)
/dev/sdc5 1479591936 1949331455 469739520 224G 83 Linux
/dev/sdc6 1949333504 1953523711 4190208 2G 82 Linux swap / Solaris
3. pure mbr (just Ubuntu, nothing else)
$ sudo fdisk -l
Disk /dev/sdc: 14.6 GiB, 15693664256 bytes, 30651688 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 2BB06DCE-2D30-4778-94BD-2FD214CD3C3B
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 204800 100M BIOS boot
/dev/sdc2 206848 28555263 28348416 13.5G Linux filesystem
/dev/sdc3 28555264 30650367 2095104 1023M Linux swap
In 3. this is what to expect when you install Ubuntu to mbr, it will ask you to also create a BIOS boot partition of at least 1 MB - I chose here 100 MB to safeguard for future change, it's kind of a blob with core image for booting...
4. pure efi (just Ubuntu & EFI partition, nothing else)
$ sudo fdisk -l
Disk /dev/sdc: 29.3 GiB, 31406948352 bytes, 61341696 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0B9FB340-99D5-03A3-D0EC-E74275E6E800
Device Start End Sectors Size Type
/dev/sdc1 2048 411647 409600 200M EFI System
/dev/sdc2 411648 58195967 57784320 27.6G Linux filesystem
/dev/sdc3 58195968 61335551 3139584 1.5G Microsoft basic data
in 4. I prep a disk with the three partitions EFI, ROOT & SWAP Assign the flags for the EFI partition as as boot, esp & legacy_boot in gparted, then use an install dvd/usb disk to install by assigning the correct partitions...
3 & 4 I use to deploy, if it's just them, I just dd to a bigger disk,
if not, I use the ROOT to dd to a partition in a target partition in a bigger disk that is already populated with say Windows or OS X, or any other,
care has then to be taken not to disturb the initial order,
so ROOT for Ubuntu should be put at the end of the original installations, etc.
In the next post I will take an example & walk through it...
efi/mbr partitions in pictures
1. efi/mbr mix
https://forum.xda-developers.com/attachment.php?attachmentid=4779410&stc=1&d=1560960108
https://forum.xda-developers.com/attachment.php?attachmentid=4779411&stc=1&d=1560960108
2. pure mbr / no BIOS boot - using Windows boot loader & easyBCD 3.2 to load Linux/Ubuntu
https://forum.xda-developers.com/attachment.php?attachmentid=4779413&stc=1&d=1560960108
3. pure mbr (just Ubuntu, nothing else)
https://forum.xda-developers.com/attachment.php?attachmentid=4779412&stc=1&d=1560960108
4. pure efi (just Ubuntu & EFI partition, nothing else)
https://forum.xda-developers.com/attachment.php?attachmentid=4779414&stc=1&d=1560960108
pictures in @twitter feeds -
https://twitter.com/inabster/status/1141482400112926723
https://twitter.com/inabster/status/1141482980151615488
RFC - how do we get the pictures to appear in the posts?
Bootloading examples
Method in post #13 required to have both the efi & bios boot partitions present
https://forum.xda-developers.com/showpost.php?p=79742668&postcount=13
This is a set piece for
Device Start End Sectors Size Type
/dev/sdb1 2048 411647 409600 200M EFI System
/dev/sdb2 411648 210208767 209797120 100G Microsoft basic data
/dev/sdb3 210415616 337403903 126988288 60.6G Linux filesystem
/dev/sdb4 337403904 430872575 93468672 44.6G Linux filesystem
/dev/sdb5 430872576 435066879 4194304 2G Linux swap
/dev/sdb6 435066880 624490495 189423616 90.3G Microsoft basic data
/dev/sdb7 624490496 976766975 352276480 168G Microsoft basic data
/dev/sdb8 210208768 210415615 206848 101M BIOS boot
sudo mount /dev/sdb3 /mnt
sudo mount /dev/sdb1 /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdb
update-grub
2nd example -
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 204800 100M BIOS boot
/dev/sdc2 206848 135235583 135028736 64.4G Linux filesystem
/dev/sdc3 135235584 286480383 151244800 72.1G Linux filesystem
/dev/sdc4 286480384 599062527 312582144 149.1G Microsoft basic data
/dev/sdc5 599062528 599984127 921600 450M Windows recovery environment
/dev/sdc6 599984128 1007575039 407590912 194.4G Microsoft basic data
/dev/sdc7 1007575040 1949327359 941752320 449.1G Microsoft basic data
/dev/sdc8 1949329408 1953103871 3774464 1.8G Linux swap
/dev/sdc9 1953105920 1953519615 413696 202M EFI System
sudo mount /dev/sdc3 /mnt
sudo mount /dev/sdc9 /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdc
update-grub
out of chroot, these commands are also useful:
sudo efibootmgr -c -g -d /dev/sdc -p 9 -w -L "ubuntu" -l '\EFI\refind\refind_x64.efi' #efi partition /dev/sdc9
sudo grub-install /boot/efi # this after having mounted in /etc/fstab /dev/sdc9 in /boot/efi
sudo efibootmgr -c -g -d /dev/sdb -p 1 -w -L "ubuntu" -l '\EFI\refind\refind_x64.efi' #efi partition /dev/sdb1
sudo grub-install --target=x86_64-efi /dev/sdb3 --efi-directory=/boot/efi/ --boot-directory=/boot
sudo grub-install --target=x86_64-efi /dev/sdc3 --efi-directory=/boot/efi/ --boot-directory=/boot
sudo grub-mkconfig -o /boot/grub/grub.cfg
sudo update-grub
To check install is correct, issue:
$ [ -d /sys/firmware/efi ] && echo "EFI boot on HDD" || echo "Legacy boot on HDD]
Two important config files to get a successful Arch Linux or Ubuntu boot are:
grub.cfg
fstab
fstab is in /etc/
/etc/fstab
grub.cfg can be found in /boot/grub & mounted efi partition /boot/efi in /boot/efi/EFI/ubuntu
grub.cfg can be used in a grub command line as follows:
set root=(hd0,gpt2)
configfile (hd0,gpt1)/efi/ubuntu/grub.cfg
(grub.cfg must have the UUID of (hd0,gpt2) in my case of /dev/sdb2
use
sudo blkid /dev/sdX to find UUID's)
or
configfile (hd0,gpt2)/boot/grub/grub.cfg
grub.cfg, fstab examples...
First
Disk /dev/sdb: 931.5 GiB, 1000204885504 bytes, 1953525167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 807AFD80-12D5-03A5-60BF-1E60B544E900
Device Start End Sectors Size Type
/dev/sdb1 2048 206847 204800 100M BIOS boot
/dev/sdb2 206848 135235583 135028736 64.4G Linux filesystem
/dev/sdb3 135235584 286480383 151244800 72.1G Linux filesystem
/dev/sdb4 286480384 599062527 312582144 149.1G Microsoft basic data
/dev/sdb5 599062528 599984127 921600 450M Windows recovery environment
/dev/sdb6 599984128 1007575039 407590912 194.4G Microsoft basic data
/dev/sdb7 1007575040 1949327359 941752320 449.1G Microsoft basic data
/dev/sdb8 1949329408 1953103871 3774464 1.8G Linux swap
/dev/sdb9 1953105920 1953519615 413696 202M EFI System
$ sudo blkid /dev/sdb9
/dev/sdb9: LABEL="UEFI" UUID="B07A-6430" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="f7ffc8f0-896a-01d2-78e0-eb63b544e900"
$ sudo blkid /dev/sdb3
/dev/sdb3: LABEL="UBUNTU16" UUID="8082d3f4-ec43-4310-af55-934b67078f05" TYPE="ext4" PARTLABEL="Basic data partition" PARTUUID="c0428fd0-896a-01d2-e843-2160b544e900"
$ sudo blkid /dev/sdb8
/dev/sdb8: TYPE="swap" PARTLABEL="Basic data partition" PARTUUID="0000e5a5-f7e0-c5fd-6ae9-f2754acb0100"
$ nano /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sdc3 during installation
UUID=6e69ee53-1a57-4cb5-b46f-f0f079fdf666 / ext4
# /boot/efi was on /dev/sda2 during installation
UUID=B07A-6430 /boot/efi vfat defaults 0 1
# swap was on /dev/sdc1 during installation
UUID=0000e5a5-f7e0-c5fd-6ae9-f2754acb0100 none swap sw $
$ nano /boot/efi/EFI/ubuntu/grub.cfg
search.fs_uuid 3fcb8592-bcc3-cf01-3048-8592bcc3cf01 root hd1,gpt3
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
Second
Disk /dev/sda: 465.8 GiB, 500107861504 bytes, 976773167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: gpt
Disk identifier: 4CACF8A0-B3A8-039F-283E-2B13EAECE700
Device Start End Sectors Size Type
/dev/sda1 2048 411647 409600 200M EFI System
/dev/sda2 411648 210208767 209797120 100G Microsoft basic data
/dev/sda3 210415616 337403903 126988288 60.6G Linux filesystem
/dev/sda4 337403904 430872575 93468672 44.6G Linux filesystem
/dev/sda5 430872576 435066879 4194304 2G Linux swap
/dev/sda6 435066880 624490495 189423616 90.3G Microsoft basic data
/dev/sda7 624490496 976766975 352276480 168G Microsoft basic data
/dev/sda8 210208768 210415615 206848 101M BIOS boot
Partition table entries are not in disk order.
$ sudo blkid /dev/sda1
/dev/sda1: LABEL="EFI" UUID="4579-67B0" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="42f7ecf0-d3b5-01d0-78f6-7ba1da69e800"
$ sudo blkid /dev/sda3
/dev/sda3: LABEL="UBUNTU18" UUID="6e69ee53-1a57-4cb5-b46f-f0f079fdf666" TYPE="ext4" PARTUUID="99b3c3d8-2c44-488b-a130-fefb68abbe5d"
$ sudo blkid /dev/sda5
/dev/sda5: UUID="93471658-7099-45fc-ac61-75e09b4bf08f" TYPE="swap" PARTUUID="fdb07319-debf-4394-9e71-27b3bca2a9ac"
$ nano /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sdc3 during installation
UUID=6e69ee53-1a57-4cb5-b46f-f0f079fdf666 / ext4
# /boot/efi was on /dev/sda2 during installation
UUID=4579-67B0 /boot/efi vfat defaults 0 1
# swap was on /dev/sdc1 during installation
UUID=93471658-7099-45fc-ac61-75e09b4bf08f none swap sw
$ nano /boot/efi/EFI/ubuntu/grub.cfg
search.fs_uuid 6e69ee53-1a57-4cb5-b46f-f0f079fdf666 root hd1,gpt3
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
Looking at the above examples, you can tease out where identifiers need be, usually the commands listed on previous posts would look after that, but sometimes they do not, so you need to amend / correct grub.cfg & fstab manually...
I hope this helps
Fixing Windows 10 EFI boot
In multi boot situations installing Ubuntu, one sometimes loses UEFI settings booting Windows 10 - here are some ways to repair / recover...
Resource needed - relevant boot install usb/dvd for Windows 10.
Use diskpart to repair uefi from troubleshooting repair command prompt.

How To Guide Flash GSI with Odin Only (no fastboot(D) or TWRP needed): [Kernelsu] LeOS-T (May) A13 QPR2 & Mod

1.Unlocked BootLoader.
2.-T22X with Stock ROM pre-installed. Or Any GSI.
3.Odin
4.Linux Sub-system wins10,11
5.https://github.com/ChromiumOS-Guy/SuperPatcherGSI :Autmated Script to Patch a Super.img with a GSI in python 3. "SuperPatcherGSI-x64.AppImage"
Releases · ChromiumOS-Guy/SuperPatcherGSI
Autmated Script to Patch a Super.img with a GSI in python 3 - ChromiumOS-Guy/SuperPatcherGSI
github.com
6.Download GSIs (extract *.img file)
7.Extract "super.img.lz4' from AP.tar.md5 (Your Firmware) with zip util.
How2
-Install Ubuntu-18.04 Linux sub-system on Wins10,11
-Create shotcut to Desktop
Open RUN box and type: \\wsl$
install python3
-Launch Ubuntu sub system.
Code:
sudo apt update && upgrade
sudo apt install python3 python3-pip ipython3
***Test Python
Create test.py file with this code. Or download from Attachment.
Code:
def printList(lst):
for item in lst:
print(item)
lst=[1,2,3,4,5]
printList(lst)
Execute with this command:
Code:
python3 test.py
If you saw this output then it works.
1
2
3
4
5
-exit and restart (sub-system)
-ReLaunch Ubuntu sub system.
-put "super.img.lz4" "SuperPatcherGSI-x64.AppImage"
"Any_GSI.img" Into "home/<linux_user_name/"
-install "lz4 package" and extract "super.img" from LZ4 format.
Code:
sudo apt install liblz4-tool
lz4 -d super.img.lz4 super.img
-Execute SuperPatcherGSI script
Command flag: [ interactive mode]
./SuperPatcherGSI-x64.AppImage -i super.img (input) -o super.new.img (output) -s 2 (device slots)
Code:
./SuperPatcherGSI-x64.AppImage -i super.img -o super.new.img -s 1
*Note: T22X has 1 slot.
EXAMPLE FROM LOG:
# insert GSI into Super partition
(base) [email protected]:~$ ./SuperPatcherGSI-x64.AppImage -i super.img -o test.img -s 1
flags successfully verified and appear to be correct, error code (OK)
============================
unpacking...
============================
Sparse image detected.
Process conversion to non sparse image ....[ok]
Extracting partition [system] .... [ok]
Extracting partition [odm] .... [ok]
Extracting partition [product] .... [ok]
Extracting partition [vendor] .... [ok]
============================
choose img to replace
============================
option number 0 system.img size of (3825119232) bytes
option number 1 product.img size of (1238544384) bytes
option number 2 vendor.img size of (652824576) bytes
option number 3 odm.img size of (4349952) bytes
Please Choose: yaap.img
Please Put a Number In!
Please Choose: 0 《-----------Your choice
Please Input Path To Replacment Partition:
yaap
Please Input a Valid Path to a IMG File!
Please Input Path To Replacment Partition:
yaap.img 《-------------Your choice
Are you sure this is the path to file (Y/n): y
Img replaced!
replace another (Y/n): n 《---------------Your choice
============================
device size (super.img size) in bytes must be evenly divisible by 512, default (5319659520) bytes:
metadata size in bytes must be evenly divisible by 512 default=~0.5KiB:
make sparse (flashable with fastboot) ? (Y/n): y 《-------------Your choice
============================
using these flags:
============================
--device-size=5319659520 --metadata-slots=2 --output test.img --metadata-size 512000 --sparse --partition=system:none:2911940608 --image=system=/home/tom/tmp/system.img --partition=product:none:1238544384 --image=product=/home/tom/tmp/product.img --partition=vendor:none:652824576 --image=vendor=/home/tom/tmp/vendor.img --partition=odm:none:4349952 --image=odm=/home/tom/tmp/odm.img
============================
lpmake I 06-25 12:20:44 530 530 builder.cpp:1093] [liblp] Partition system will resize from 0 bytes to 2911940608 bytes
lpmake I 06-25 12:20:44 530 530 builder.cpp:1093] [liblp] Partition product will resize from 0 bytes to 1238544384 bytes
lpmake I 06-25 12:20:44 530 530 builder.cpp:1093] [liblp] Partition vendor will resize from 0 bytes to 652824576 bytes
lpmake I 06-25 12:20:44 530 530 builder.cpp:1093] [liblp] Partition odm will resize from 0 bytes to 4349952 bytes
Invalid sparse file format at header magic
Invalid sparse file format at header magic
Invalid sparse file format at header magic
Invalid sparse file format at header magic
============================
cleaning...
============================
OK
(base) [email protected]:~$
============================
-Final: you will get " super.new.img" ( rename it to " super.img" before -》
Create "tar file of super.img" with zip utility.
-OPEN "ODIN" AND CONNECTED WITH "Download Mode of your SM-T22X
Flash "super.tar" at AP Slot.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
(No need to wipe or factory reset)
ErrorsMeaning/FixNot enough space on device for partition (PARTITION NAME HERE) with size (PARTITION SIZE HERE)this means that the --device-size flag for lpmake was set with a maximum size which is smaller than all the partitions (unpacked img files + GSI) combined.Invalid sparse file format at header magic / Invalid sparse file format at headerthis is actually a warning and can be ignored its actually a good sign if you get this warning
Reserve:
RW Dynamic partition with Linux sub-system .& How2 install LeOS-T (the final latest variant).
1.modify bootanimation .by delete /product/media/bootanimation.zip and flash livebootmagisk with kernelsu manager.
GitHub - symbuzzer/livebootmagisk: A Magisk and KernelSU module that enables unix-style (verbose) boot animation for Android devices
A Magisk and KernelSU module that enables unix-style (verbose) boot animation for Android devices - GitHub - symbuzzer/livebootmagisk: A Magisk and KernelSU module that enables unix-style (verbose)...
github.com
2.Make RW Super partition plus Add free spaces 700 MB.
3.Mod Home Launcher.

Categories

Resources