Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emmc #44

Open
mariusares opened this issue Jul 1, 2020 · 84 comments
Open

Emmc #44

mariusares opened this issue Jul 1, 2020 · 84 comments

Comments

@mariusares
Copy link

Hi
First of all thank you for your great work.
It's like a nice surprise ...

I have installed the bare ubuntu with kernel 14.7 from :
https://mega.nz/#!obIAVQiA!G0CCABkLunCcG8hEqMf7NfjTBK1jgMytt2f0VdtOl08
I can't see the emmc on fdisk ...
Do you recommend a different kernel version?
Is any chance to have a bare debian 10 os with a stable kernel too? I mean on debian/Raspbian you have 2 kernels. Version 3 what runs ok and smoothie but is no AP network mode compatible and Version 4,4 where load average is pretty high (over 1 on idle)
For those who use i2c, gpio, spi, serial and wifi ap mode, a bare system is great.
Thank you for your time

@avafinger
Copy link
Owner

I can't see the emmc on fdisk ...
A: BananaPi M2Z does not have eMMC!

Do you recommend a different kernel version?
A: Scroll down the github page and you see the kernel history and new kernel versions, personally i like the kernel 5.3 and 5.7.
Kernel 5.3 has great CPU Temp management and performance, Kernel 5.7 has a lot of bug fixes and it is maintained by the Linux community.

Is any chance to have a bare debian 10
A: Sorry, i am an Ubuntu user but would like to move to Debian, it can happen soon or take years.
The idea behind this Image is to have a CLI (Command Line Interface and minimal) with few installed packages, M2Z has 512 MB of DRAM, users will not be pleased to run a Full Desktop, yet it is possible. You can install LXDE or try Armbian.

Start with this IMG and upgrade the kernel to 5.7:
https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal/releases/tag/v2.4

Upgrade Kernel:
https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal/releases/tag/v3.7

Kernel and some IMG releases:
https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal/releases

@mariusares
Copy link
Author

I understand, i chose banana pi over raspberry pi because rpi won't implement eMmc on their boards anytime soon, but it's so poor on software support.
Thanks to people like you who color a bit that side of the room :)
I'll try to get your kernel sources to compile them in a debian system ... When I'll get some time to be honest ...

@avafinger
Copy link
Owner

This board has eMMC but the layout is a bit different:
http://www.banana-pi.org/m2pz.html

@mariusares
Copy link
Author

This is the board i have right now
Si basically you are suggesting to upgrade the os image from Ubuntu 16.4 to ubuntu 19.* and kernel 5.7
I understand that Ubuntu 16.4 it's LTS correct?
Can I use the kernel 5.7 and configuration on Ubuntu 16.4?
I probably look stupid but i cant find the download links :)
Thank you

@mariusares
Copy link
Author

I got the links
Sorry I'm on mobile so ...

@avafinger
Copy link
Owner

Ubuntu 19.10

@avafinger
Copy link
Owner

Ubuntu 19.10 - Eoan Ermine with Kernel 5.3.5

@avafinger
Copy link
Owner

Can I use the kernel 5.7 and configuration on Ubuntu 16.4?
yes, i think it is possible, but the deb package will install the modules in /usr/lib/modules and i think Ubuntu 16.04 LTS has it in /lib/modules

If after you boot and you don't see the modules with lsmod you will have to move /usr/lib/modules/KERNEL_VERSION to /lib/modules/

If this happens you won't be able to ssh to the board and will need to use HDM or the serial debug

@mariusares
Copy link
Author

I'll give it a try.
What I need is Gpio, uart, i2c , spi , eth, wlan+ap mode and stability ...
Let me install it and I'll get back to you
Thank you

@mariusares
Copy link
Author

mariusares commented Jul 2, 2020

ok so kernel 5.3 and 5.7 only detects /dev/mmcblk0 ...
there is no way to detect eMMC for some reason
any clue please?
U-Boot SPL 2017.09-h2 (Jul 06 2018 - 10:16:12)
DRAM: 512 MiB
Trying to boot from MMC2
MMC Device 1 not found
spl: could not find mmc device. error: -19
SPL: failed to boot from all boot devices

ERROR ### Please RESET the board

This is with the image flashed on eMMC ...
works on sd card but not on eMMC ...

@avafinger
Copy link
Owner

Try this:

1 - Update u-boot (only the bootloader) from this tag:
https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal/releases/tag/v1.7

2 - make sure eMMC is active
#18

3 - Make sure the root device is correct for eMMC, change it in /boot/boot.cmd

@mariusares
Copy link
Author

there is no /dev/sd* ...
dd if=./bootloader_2z_v3.bin conv=notrunc bs=1k seek=8 of=/dev/mmcblk0p1
so /dev/mmcblk0p1 is the /boot sd card partition ...
is that OK?

@avafinger
Copy link
Owner

/dev/sd* is for USB SDHC reader/writer (if you connect to a PC box running Linux)
/dev/mmcblk0p1 that is OK if you do from M2Z

@mariusares
Copy link
Author

i did this :
#11 (comment)
basically i can see the eMMC now but i cant boot from eMMC ... do you have the kernel+kernel config able to boot from eMMC or we have to do that manually? im on Ubuntu 19.10 now with kernel 5.3 ...
root@bpi-m2z:# uname -a
Linux bpi-m2z 5.3.5 #1 SMP Mon Oct 7 21:22:23 -03 2019 armv7l armv7l armv7l GNU/Linux
root@bpi-m2z:
# fdisk -l
Disk /dev/mmcblk0: 29.29 GiB, 31439454208 bytes, 61405184 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: dos
Disk identifier: 0x2474af91

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 49152 253951 204800 100M 83 Linux
/dev/mmcblk0p2 253952 15777791 15523840 7.4G 83 Linux

Disk /dev/mmcblk2: 7.29 GiB, 7818182656 bytes, 15269888 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: dos
Disk identifier: 0x2474af91

Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 49152 253951 204800 100M 83 Linux
/dev/mmcblk2p2 253952 15777791 15523840 7.4G 83 Linux
root@bpi-m2z:~#

@mariusares
Copy link
Author

i`m trying to change some settings here

setup boot_device

fdt set mmc${boot_mmc} boot_device <2>

and i get the same result on boot
U-Boot SPL 2017.09-h2 (Jul 06 2018 - 10:16:12)
DRAM: 512 MiB
Trying to boot from MMC2
MMC Device 1 not found
spl: could not find mmc device. error: -19
SPL: failed to boot from all boot devices

ERROR ### Please RESET the board

@mariusares
Copy link
Author

There is no boot.cmd ... I'll try to decompile boot.scr and edit it in order to take action ...
Let's see the result ...

@avafinger
Copy link
Owner

boot.cmd.tar.gz

to be able to boot from eMMC you have to format it and copy the bootloader, boot, and rootfs.
There is a script that does that, search the releases and find the latest and instead of passing /dev/sdX you will pass /dev/mmcblkY

@mariusares
Copy link
Author

well is not working for me unfortunately ...

@avafinger
Copy link
Owner

Boot from SD card and see what you get with this command:

ls /dev/mmcblk*

@mariusares
Copy link
Author

root@bpi-m2z:# ls /dev/mmc*
/dev/mmcblk0 /dev/mmcblk0p2 /dev/mmcblk2boot0 /dev/mmcblk2p1
/dev/mmcblk0p1 /dev/mmcblk2 /dev/mmcblk2boot1 /dev/mmcblk2p2
root@bpi-m2z:
#
its strange ...
the bootloader should read the sd card and emmc as well ...

@avafinger
Copy link
Owner

1 - when booting from SD CARD:
/dev/mmcblk0 is your SD CARD
/dev/mmcblk2 is your eMMC

2 - when booting without SD CARD

/dev/mmcblk? - It changes device number, you should figure out what number will be, possible 1.

3 - Update u-boot with: https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal/releases/tag/v3.4

4 - Use this scripts to format and install kernel and rootfs and update bootloader with the new version:
https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal/releases/tag/v15

              sudo ./format_sd_mainline.sh  /dev/mmcblk2
              sudo ./flash_sdcard_mz2_v2.sh  /dev/mmcblk2

reboot without SD CARD, i think a debug ttl uart is indispensable

@avafinger
Copy link
Owner

try:
fdt set mmc${boot_mmc} boot_device <boot_mmc>

@mariusares
Copy link
Author

i`m controlling the board via uart ttl
the image does not see emmc without modification
the bootloader does not boot from emmc

https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal/releases/tag/v3.4

fdisk -l:
root@bpi-m2z:~# fdisk -l
Disk /dev/mmcblk0: 29.29 GiB, 31439454208 bytes, 61405184 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: dos
Disk identifier: 0x2474af91

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 49152 253951 204800 100M 83 Linux
/dev/mmcblk0p2 253952 15777791 15523840 7.4G 83 Linux
root@bpi-m2z:~#

still can`t see the emmc ...
so i have to use

#11 (comment)
bpi-m2-zero-v4.dtb_eMMC.zip

with this dtb the emmc is /dev/mmcblk2 and i dont think that would be changed after that ... so ... i dont know what would be the resolution ...

@avafinger
Copy link
Owner

This DTB has eMMC enabled, try with this dtb.
bpi-m2-zero-v4.dtb_emmc.tar.gz

  • unzip it into /boot
  • sudo ln -sf bpi-m2-zero-v4.dtb_emmc bpi-m2-zero-v4.dtb
  • sync && sudo reboot

This for kernel 5.7.x-server

@mariusares
Copy link
Author

you mean this one?
https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal/releases/tag/v3.7

i can only see that 5.7 kernel but no "server" tag on it

@avafinger
Copy link
Owner

yes!

@mariusares
Copy link
Author

this is output from sd-card boot
root@bpi-m2z:~# fdisk -l && uname -a && ls -la /boot && cat /etc/issue*
Disk /dev/mmcblk0: 29.3 GiB, 31439454208 bytes, 61405184 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: dos
Disk identifier: 0x58b49123

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 49152 253951 204800 100M 83 Linux
/dev/mmcblk0p2 253952 15532031 15278080 7.3G 83 Linux

Disk /dev/mmcblk2: 7.3 GiB, 7818182656 bytes, 15269888 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: dos
Disk identifier: 0x58b49123

Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 49152 253951 204800 100M 83 Linux
/dev/mmcblk2p2 253952 15532031 15278080 7.3G 83 Linux
Linux bpi-m2z 5.7.6 #1 SMP Sun Jun 28 00:11:55 -03 2020 armv7l armv7l armv7l GNU/Linux
total 12220
drwxrwxr-x 3 ubuntu ubuntu 4096 Jul 3 17:39 .
drwxr-xr-x 21 root root 4096 Jan 15 2018 ..
lrwxrwxrwx 1 root root 20 Jan 15 2018 boot.scr -> bpi-m2-zero_boot.scr
-rw-r--r-- 1 root root 26886 Jul 6 2018 bpi-m2-zero-v1.dtb_4.17.4-m2z
-rw-r--r-- 1 root root 27076 Jul 6 2018 bpi-m2-zero-v2.dtb_4.17.4-m2z
-rw-r--r-- 1 root root 28817 Jun 28 04:30 bpi-m2-zero-v4.dtb_5.7.6
-rw-rw-r-- 1 ubuntu ubuntu 28813 Jul 3 16:15 bpi-m2-zero-v4.dtb_emmc
lrwxrwxrwx 1 root root 23 Jul 3 17:39 bpi-m2-zero.dtb -> bpi-m2-zero-v4.dtb_emmc
-rw-r--r-- 1 root root 924 Jul 6 2018 bpi-m2-zero_boot.cmd
-rw-r--r-- 1 root root 996 Jul 6 2018 bpi-m2-zero_boot.scr
-rw-rw-r-- 1 ubuntu ubuntu 978454 Jul 6 2018 initrd.img
drwx------ 2 root root 16384 Nov 5 2017 lost+found
lrwxrwxrwx 1 root root 12 Jul 3 17:34 zImage -> zImage_5.7.6
-rwxr-xr-x 1 root root 5376808 Jul 6 2018 zImage_4.17.4-m2z
-rwxr-xr-x 1 root root 6000368 Jun 28 03:48 zImage_5.7.6
Ubuntu 16.04.4 LTS \n \l

Ubuntu 16.04.4 LTS
root@bpi-m2z:~#

dd if=/dev/mmcblk0 of=/dev/mmcblk2 bs=10M status=progress
then i removed the sd-card and boot from eMMC ...
output:

U-Boot SPL 2020.04 (Apr 21 2020 - 14:52:45 +0000)
DRAM: 512 MiB
Trying to boot from MMC2
MMC Device 1 not found
spl: could not find mmc device 1. error: -19
SPL: failed to boot from all boot devices

ERROR ### Please RESET the board

on Ubuntu 19.10 the same ... so that dtb has a problem by booting from emmc ...

@avafinger
Copy link
Owner

Who told you this instructions would work?

dd if=/dev/mmcblk0 of=/dev/mmcblk2 bs=10M status=progress
then i removed the sd-card and boot from eMMC ...

@mariusares
Copy link
Author

well how can i boot from eMMC ?

@avafinger
Copy link
Owner

avafinger commented Jul 3, 2020

Trying to boot from MMC2
MMC Device 1 not found

boot.cmd must tell the boot loader what device number eMMC is.
If you boot with SD CARD, eMMC has ID number X, if you boot WITHOUT SDCARD eMMC has ID number Y.

I will release a new Kernel and will prepare the script for writing to eMMC and try to guess which ID number we can try.
This takes some time, i am at work now.

Meanwhile, you can edit the boot.cmd (mount it booting with SD CARD) and recompile it to .scr, unmount it, and reboot.
Try Device number 2

@avafinger
Copy link
Owner

root=/dev/mmcblk0p2 => adjust to root=/dev/mmcblk1p2
and fstab

@mariusares
Copy link
Author

[ 2.532005] Run /init as init process
Kernel params: console=ttyS0,115200 earlyprintk rootfstype=ext4 root=/dev/mmcblk1p2 rw rootwait fsck.repair=yes panic=10 no_console_suspend consoleblank=0 drm_leak_fbdev_smem=1
Waiting for root system /dev/mmcblk1p2, countdown : 5
Waiting for root system /dev/mmcblk1p2, countdown : 4
Waiting for root system /dev/mmcblk1p2, countdown : 3
Waiting for root system /dev/mmcblk1p2, countdown : 2
Waiting for root system /dev/mmcblk1p2, countdown : 1
Rootfs: /dev/mmcblk0p2
[ 28.215766] /dev/mmcblk0p2: Can't open blockdev
[ 28.223334] /dev/mmcblk0p2: Can't open blockdev
mount: mounting /dev/mmcblk0p2 on /mnt/root failed: No such file or directory
umount: can't unmount /mnt/root: Invalid argument
Dropping to a shell.

/ # [ 32.481996] vcc3v0: disabling
[ 32.485067] vcc5v0: disabling
[ 32.488083] cam-avdd: disabling
[ 32.491268] cam-dvdd: disabling

/ #

@avafinger
Copy link
Owner

So must be: Waiting for root system /dev/mmcblk2p2

Try to check in the shell.

ls /dev/mmcbl*

@mariusares
Copy link
Author

mariusares commented Jul 6, 2020

/ # ls /dev/mmc*
/dev/mmcblk2 /dev/mmcblk2boot1 /dev/mmcblk2p2
/dev/mmcblk2boot0 /dev/mmcblk2p1
/ # [ 64.482738] cfg80211: failed to load regulatory.db

i`ll fix it now in few minutes
and the /etc/fstab as well

@avafinger
Copy link
Owner

we now know ..
root= /dev/mmcblk2p2
fstab must reflect the same.

for the record:
which boot.scr is the correct one?

@mariusares
Copy link
Author

[ 2.481578] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[ 2.491546] platform regulatory.0: Falling back to sysfs fallback for: regulatory.db
[ 2.492587] No soundcards found.
[ 2.505182] Freeing unused kernel memory: 1024K
[ 2.572998] Run /init as init process
Kernel params: console=ttyS0,115200 earlyprintk rootfstype=ext4 root=/dev/mmcblk2p2 rw rootwait fsck.repair=yes panic=10 no_console_suspend consoleblank=0 drm_leak_fbdev_smem=1
Waiting for root system /dev/mmcblk2p2, countdown : 5
Rootfs: /dev/mmcblk2p2
[ 2.735318] EXT4-fs (mmcblk2p2): bad geometry: block count 1909760 exceeds size of device (1876992 blocks)
mount: mounting /dev/mmcblk2p2 on /mnt/root failed: Invalid argument
umount: can't unmount /mnt/root: Invalid argument
Waiting for root system /dev/mmcblk2p2, countdown : 4
Rootfs: /dev/mmcblk2p2
[ 7.891324] EXT4-fs (mmcblk2p2): bad geometry: block count 1909760 exceeds size of device (1876992 blocks)
mount: mounting /dev/mmcblk2p2 on /mnt/root failed: Invalid argument
umount: can't unmount /mnt/root: Invalid argument
Waiting for root system /dev/mmcblk2p2, countdown : 3
Rootfs: /dev/mmcblk2p2
[ 13.028491] EXT4-fs (mmcblk2p2): bad geometry: block count 1909760 exceeds size of device (1876992 blocks)
mount: mounting /dev/mmcblk2p2 on /mnt/root failed: Invalid argument
umount: can't unmount /mnt/root: Invalid argument

@mariusares
Copy link
Author

i`ll try to copy it one more time ... so it is the bpi-m2-zero_boot_1.scr with root=/dev/mmcblk2p2 and /etc/fstab modified right now

@avafinger
Copy link
Owner

right, did you use the format_mainline.sh /dev/mmcblk2 to burn the eMMC? I think you used dd..

@mariusares
Copy link
Author

well i formated and after i used dd

@avafinger
Copy link
Owner

that's why you get: [ 7.891324] EXT4-fs (mmcblk2p2): bad geometry: block count 1909760 exceeds size of device (1876992 blocks)

@avafinger
Copy link
Owner

i will redo the scripts with your information and you burn the eMMC.
you can try to fix this using disk while boot from SD CARD.

@mariusares
Copy link
Author

so how can i copy from sd card afer format without using dd ?

@avafinger
Copy link
Owner

I would tar.gz the boot and the rootfs and untar in each partition (eMMC), is faster.

@mariusares
Copy link
Author

i resized the partition . working from emmc now ...

@mariusares
Copy link
Author

Would you like a working image?

@avafinger
Copy link
Owner

I don't have the board. Maybe you make a backup of eMMC and announce it on the forum. What is the Ubuntu version?

@mariusares
Copy link
Author

is the 16.04 LTE ... is your image actually
root@bpi-m2z:~# uname -a && cat /etc/issue && fdisk -l
Linux bpi-m2z 5.7.6 #1 SMP Sun Jun 28 00:11:55 -03 2020 armv7l armv7l armv7l GNU/Linux
Ubuntu 16.04.4 LTS \n \l

Disk /dev/mmcblk2: 7.3 GiB, 7818182656 bytes, 15269888 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: dos
Disk identifier: 0x58b49123

Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 49152 253951 204800 100M 83 Linux
/dev/mmcblk2p2 253952 15269886 15015935 7.2G 83 Linux
root@bpi-m2z:~#

@mariusares
Copy link
Author

it is strange ... i have resized the partition and i reboot it then worked
now i reboot the system again and i got the same error ...

Waiting for root system /dev/mmcblk2p2, countdown : 3
Rootfs: /dev/mmcblk2p2
[ 12.948746] EXT4-fs (mmcblk2p2): bad geometry: block count 1909760 exceeds size of device (1876991 blocks)
mount: mounting /dev/mmcblk2p2 on /mnt/root failed: Invalid argument
umount: can't unmount /mnt/root: Invalid argument

@avafinger
Copy link
Owner

I will prepare the scripts late tonight.

@mariusares
Copy link
Author

I'll try to setup the partitions manually ...

@avafinger
Copy link
Owner

Script to format and create partitions (/boot and /rootfs)

  • sudo ./format_sd_mainline.sh /dev/mmcblk2 (boot from SD CARD)
  • copy /boot from SD CARD to /boot in eMMC
  • copy /rootfs from SD CARD to /rootfs in eMMC
  • burn the u-boot (the new one)
  • copy the correct scr
  • change /etc/fstab in eMMC

Make sure the symlinks are corrects

format_sd_mainline.sh.tar.gz

@mariusares
Copy link
Author

mariusares commented Jul 7, 2020

ok so ... on your script, when you formated the partition you have the syntax
mkfs.ext4 -F -b 4096 -E stride=2,stripe-width=1024 -L boot ${out}1

should be p1 and p2 ...
mkfs.ext4 -F -b 4096 -E stride=2,stripe-width=1024 -L boot ${out}p1

now the partitions can be mounted

@mariusares
Copy link
Author

I have an working eMMC image
Unfortunately it is huge and is not easy to upload...
Any way you might think that we can have a smaller image and to expand the fs after installing? What do you think?

@avafinger
Copy link
Owner

Yes, there are ways to shrink the IMG. I will think one of them. What size did you get?

@mariusares
Copy link
Author

Around 7G unzipped ...
I'll zip it when I'll go home
If I'll shrink the partition to 2G let's say, the img would be around that size as well ...
Btw: what kernel version would you recommend ?
The latest 5.7.7 is ok? ... I'm looking for a stable version
Thank you

@avafinger
Copy link
Owner

avafinger commented Jul 7, 2020

  • Boot with eMMC and do a:

sudo apt-get clean

  • Boot from SD CARD and and mount eMMC (the rootfs in eMMC) and run:
cd /tmp
mkdir -p eMMC
sudo mount -t ext4 /dev/mmcblk2p2 ./eMMC

sudo rm -rf eMMC/home/ubuntu/.cache/*
sudo rm -rf eMMC/home/ubuntu/Downloads/*
sudo rm -rf eMMC/home/ubuntu/.kodi/*
sudo rm -rf eMMC/tmp/*
sudo rm -rf eMMC/tmp/.*
sudo rm -rf eMMC/var/tmp/*
sudo truncate --size 0 eMMC/var/log/wtmp
sudo truncate --size 0 eMMC/var/log/lastlog
sudo truncate --size 0 eMMC/var/log/dmesg 
sudo truncate --size 0 eMMC/var/log/Xorg.0.log.old
sudo truncate --size 0 eMMC/var/log/btmp 
sudo truncate --size 0 eMMC/home/ubuntu/.bash_history 
sudo truncate --size 0 eMMC/root/.bash_history
sudo truncate --size 0 eMMC/var/log/wtmp 
sudo truncate --size 0 eMMC/var/log/btmp 
sudo truncate --size 0 eMMC/var/log/lastlog
sudo truncate --size 0 eMMC/var/log/syslog
sudo truncate --size 0 eMMC/var/log/lightdm/*.log
sudo truncate --size 0 eMMC/var/log/tallylog
sudo truncate --size 0 eMMC/var/log/faillog
sudo truncate --size 0 eMMC/var/log/apt/term.log
sudo truncate --size 0 eMMC/var/log/apt/history.log
sudo rm -rf eMMC/var/backups/*.gz
sudo rm -rf eMMC/home/ubuntu/iperf
sudo rm -rf eMMC/tmp/*
sudo rm -rf eMMC/tmp/.*
sudo rm -rf eMMC/var/tmp/*
sudo rm -rf eMMC/home/adduser.sh
sudo rm -rf eMMC/etc/NetworkManager/system-connections/*
sudo rm -rf eMMC/var/lib/apt/lists/*
sudo rm -rf eMMC/var/cache/apt/archives/*
sudo rm -rf eMMC/var/log/*.1
sudo rm -rf eMMC/var/log/apt/*.log.xz
sudo find eMMC/var/log/journal -name "*.journal"| xargs sudo rm -rf
sudo find eMMC/var/log/journal -name "*.journal~"| xargs sudo rm -rf
sudo find eMMC/var/log/ -name "*.gz"| xargs sudo rm -rf
sudo find eMMC/var/backups/ -name "*.gz"| xargs sudo rm -rf
sudo find eMMC/var/log/ -name "*.log"| xargs sudo truncate --size 0
sudo find eMMC/var/backups/ -name "*.*"| xargs sudo truncate --size 0
sudo find eMMC/var/lib/dhcp/ -name "*.*"| xargs sudo truncate --size 0

Copy the rootfs and Compress it:

tar -cvpzf rootfs_16.04.tar.gz --directory=./eMMC .

unmount eMMC

sudo umount ./eMMC

Do the same for the /boot partition in eMMC

mkdir -p eMMC_boot
tar -cvpzf boot_16.04.tar.gz --directory=./eMMC_boot .
sudo umount ./eMMC_boot

@mariusares
Copy link
Author

mariusares commented Jul 7, 2020

Ok and you have two zip files ....
Now how many users know how to create the partitions, how to write the bootloader and how to install the files in emmc?
I have the emmc installed blank, this is why I'm trying to make a image
The system is insane fast ...
I'm expecting to be stable too.
You did a great job

@avafinger
Copy link
Owner

avafinger commented Jul 7, 2020

You can shrink rootfs partition to 2.2G (after the clean up described above) and 7zip the /dev/mmblck2 for the users, they just need to dd to /dev/mmcblk2 and resize!

@mariusares
Copy link
Author

ok, the large image when is zipped is less than 300MB and it is with full eMMC size and settings ..

@mariusares
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants