Installing images with DD, no need for emmc adapter, run on USB3 or M2 per default

Update2:

Update1:

I uploaded RADXA’s unedited images/sources as XZ, now it spares you all steps for cretion of SD, simply flash your SD with offline image and on first boot you can flash any internal device with dd from the guide in first post of this thread.

Since few weeks I am owner of quite many rock pi’s, first I got for myself 5 A devices (great buy), I liked is so much that I ordered another 5 B devices to test wlan and bluetooth (not so good buy).

First that I did is I read what are the requirements, I ordered only emmc cards. When everything arrived, I had to find out that radxa:

  1. uses a tool for imaging which is not available for rock architecture. Is the reason that you use it instead of posting simple guide how to do it with DD, is that to curbe on sales on emmc adapters which are anyway cheap. I wouldnt have other explanation, however, those adapters are actually obsolete if you have rockpi board.

  2. LXDE debian desktop is broken, after upgrade normal user has a broken system a no guides on radxa how to deal with it. So, I took minimal available image, ubuntu bionic which is also arm64.

  3. I installed bionic to find out it is broken, snap does not work, kernel was to old. After days, I checked once again why latest kernel is not installed to find out that radxa homepage has a typo, please correct it from ‘lastest’ to ‘latest’.

  4. Finally, I got mate, lxde, openbox as well as other desktops. So far, 4A devices have 0 issues where B devices have issues with wireless and bluetooth. I am not using wireless anyway, just wanted to test and prepare working image, but no, wireless has some issues, like that it is not working until the network is restarted, a workaround for me is currently to restart network on user login, it works. For bluetooth, well, it does not work properly, not sure for now if it is config or package/driver based, will post more when I got time for it.

Install to eMMC without adapter

Info: I would also preffer if you use xz format, instead gzip. Why I preffer XZ over GZ: because image file is much, much smaller, your Image recompressed into XZ is only 414,5 MB which is smaller than gzip radxa offers. So, my guide uses XZ commands, below I will show you how you can easily recompress with highest compression ratio.

Update1: _if you download repacked images from github, you can skip first three steps, they are only required for orginal image not recompressed image.

  1. Download official image and extract it
  2. cd into folder where your image is extracted
  3. compress it to xz with: xz -9ve --threads=8 rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img (it will delete .img file if succefully finished)
  4. Install image to your SD card, in my example I will use device: /dev/sdc
    xzcat rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img.xz | dd of=/dev/sdc bs=128M
    Info: you can use other bs values too, I did with 128M and it works
  5. Copy rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img.xz to your SD card, you dont need to resize SD card, there is enough place to copy xz compressed image to the root of your SD card (or any other location)
  6. Insert your SD card into your device with already installed emmc card
  7. on first login, simply run this command if you copied to root of your SD card (it is fifth partition)
    xzcat /rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img.xz | dd of=/dev/mmcblk1 bs=128M
  8. Shutdown your rockpi, take SD card out, switch it on and you are :slight_smile: using your emmc card => without any requirement for adapter.

I guess, adapter is required only for people who want to preflash new cards for sale, as if you have built your rock device with m2 adapter, then you have to take it all out before you can take the card out. At the same time, RADXA, not providing commands but a application which does not run on rock is bad, as in such cases you would kinda enforce your customers to take their devices completly out just to take the emmc out of the slot to flash it on other pc. I would always use method I described above. At the same time, it is very hard for me to believe that you do not know how to flash devices with DD, I think you posted guides with application because you though that everybody else familiar with linux will know it anyway which is not a case, you have normal users dependant on gui’s in linux too and they dont know how to flash with dd as well as it could be dangerous, with dd, you couold overwrite by mistake wrong disk.

How to install to M2

Here are 3 scenarios which I will describe:

I. Use M2/USB and eMMC together
II. Use M2/USB without onboard eMMC
III. Use M2/USB with eMMC and SD card

Use M2 and eMMC together

Above I described how you can flash on first boot to the emmc, you do the same here too

  1. write image to eMMC first
    xzcat /rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img.xz | dd of=/dev/mmcblk1 bs=128M
  2. write image to M2 disk
    xzcat /rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img.xz | dd of=/dev/nvme0n1 bs=128M
  3. delete with fdisk 5th partition on your eMMC card (this is root partition, I will later describe why we delete it here)
  4. Take your SD card out and reboot, thats it, your root will be now :slight_smile: m2 disk

only boot partition is on eMMC, rest of the space can be used as you wish, emmc cards are to expensive compared to m2, I got them all up to 128gb, but to be honest, I preffer to use available space on eMMC as extended boot folder so that I can boot other images, but some of you might want to format it as swap, however, I would recommend you using swapfile on your M2 disk as it is much, much faster than your eMMC.

Use M2 without onboard eMMC

  1. Just follow steps from above to install image to M2 disk and switch off rock pi (dont reboot)
  2. Prepare SD card, insert it into your cardreader, mount 4th partition which is vfat, labeled boot.
  3. Edit file /booot/extlinux/extlinux.conf and change PARTUUID part to your m2 device on your rock, which is: root=/dev/nvme0n1, here one example:
    Change:
root=PARTUUID=b921b045-1d

to

root=/dev/nvme0n1
  1. Insert your SD card and start rockpi which should now run with root on M2 disk

All this would be much easier with 2 sdcards if you have, one for clean installation kinda live sd and another one as boot partition for m2/usb disks.

Use M2 with eMMC and SD card

It is the same as previous steps above where I find it more practical to use eMMC for booting, some might want to use SD card because they want to create lvm with several disk, including onboard eMMC, for that only possibility to boot would be from SD card.

  1. Boot into your system with SD card
  2. create LVM/RAID
  3. Install XZ image to that LVM/RAID
  4. Edit extlinux.conf on your SD card to use new LVM/RAID device as root partition.

Please note that LVM/RAID requires mdadm to be installed: apt-get install mdadm

You can do the same with LVM and RAID if you boot from eMMC instead of SD card and keep SD slot free.

finished.

I wrote this to get responses if anybody requires it. If yes, I will push it to my repo on github as well as can upload original images recompressed to xz, ubuntu bionic mate desktop, ubuntu bionic lxde desktop, ubuntu bionic openbox destkop. I can publish my scripts creating those images, as I found it easier to edit original image instead of precompiling own images, however, some packages for ubuntu might need to be recompiled as well, if I publish images, I will create a repo on launchpad, including flashing scripts etc…

I included in my desktops VSCode, keepass2 with plugins and all rockchip packages, so RADXA does not update/offer proper images, I might upload it all.

PS: sorry for typos, I am just to lazy to reread this for mistakes

1 Like

One thing I might have forgotten, snap does not work on clean install, you need to update kernel to get snap working which sucks on debian linaro provided by RADXA as it is broken, thats why I started clean bionic one, so far I am using 5 devices since over 30 days which run on 100cpu, full RAM, big bandwith a lot writes to the disk. I experienced not a single crash since I installed my os’s.

For snap installations and to get ubuntu software center to work, install snapd and then install snapcraft from snap, not from apt, using: sudo snap install snapcraft --classic will install it and all snap applications (old/new) will work.

Additional EDIT:
I see that I posted --threads=8 for xz compression. If your cpu has 4 cores or less, use --threads=2 to speed up compression, if you have only 1 cpu, dont use --threads at all

EDIT3: I guess this can be changed:
grafik

it is not important at all that boot partition is elsewhere, in fact, I would anyway keep my bootloader on emmc or sd, probably emmc as I would like to keep sd free for ability to boot recovery. Looking through your scripts, how to build etc… is quite time intensive where well established solutions are well known. If I have old disks which I want to use, here rock fits perfectly too, getting usb3 hub which provides also enough power for disks/devices connected, but here I could use LVM/RAID. Is it marked as not possible because the bootloader is not on M2 or because nobody did it until now? Because reading through the forum I clearly see that some people have it also installed to m2 disks.

Once again, wireless and bluetoth are still more experimental than stable, where the price difference from A to B is around the same as if I buy external wifi and bluetooth which work stable, but I am positive all issues will be resolved.

Keeping my wishes short, keep your wiki centralized, maybe it would be better to use wiki on github which is directly connected to everything and so can be updated in more efficient manner, for both, users and customers. At the end, you can display your github page also as html in similar/same way your current wiki is.

I wish I have find your post 2 days ago as I literally spent sleepless 2 days trying to use a 16G sd card to install the image on a 64GB emmc without the emmc adapter and then expanding the file-system to use the full space. Your method worked like a charm with no headache.

Thank you so much for having a full guide. I really appreciate this.

Great that it helped you ;), I was forced to find it out as I got emmc card without adapter.

I will publish today/tommorow my scripts, to install it on SD card, you will have to to run only ./create_cevap_sd.sh, example to prepare SD Card which will have MATE desktop as default, and you can create file on SD card: FLASHDEFAULTM2 (for M2) or FLASHDEFAULT (for flashing internal eMMC) or FLASHDEFAULTUSB (for flashing USB on /dev/sda, meaning, dont connect additional USB disks during installation). Thats it, then you insert SD card, it flashes and shutds down, takes really like 50 seconds or less. You see that it finished after it shuts down. Then you just take SD card out and thats it, you can also keep SD card inside and your SD card will be booted if it is inserted, including that it will preinstall choosen desktop.

Available for now are MATE, MATE_NORECOMMENDS, LXDE, LXDE_NORECOMMENDS, OPENBOX (in openbox no settings are set, thats for those who want to build their desktops by themself), I use lightdm for scripts as I think that most would use lightdm, however, I find lxdm maybe better for rock4.

Example command: sudo ./usr/bin/create_cevap_sd.sh "sdc" "/home/dev/go/github.com/cevap/rockpi4-bionic-lxde/images/rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt-cevap.img.xz" "n" "y" "MATE"

first n stand for: ZeroFormat before applying image (y- yes, n- no)
y after it means: Copy xz image to SD (y - yes, n - no)

This is great, but this will need a Linux machine handy with SD card reader. I took a slightly different approach since I am using windows.

Thanks again for your effort.

you are welcome :wink:

not really, as from Windows you will download image.xz which includes image in itself, for windows users, just flash your SD with my image and thats it, you can use of course Etcher or whatever soft radxa recommends

EDIT: Of course I could provide some installer, like NSIS or MSI which will install batch scripts and you even get them in your startmenu, I guess its not worth the effort, as I will anyway provide release Image.xz which includes everything, will add suffix: offline to them. But if RADXA team thinks installer for flashing with batch scripts could be done, that is no problem, as you can do all of that with windows batch or power shell. However, I would dislike to work with Windolls systems, I hate to boot windols as it is operating system which works 3-4% for you and 96-97% for microsoft, putting :slight_smile: yourself back in priority

I actually do not want to install any desktop. I am using this for homeasisstant purely.

that is why I said and configured it the way that it installs automaticly, per default, I do not place for minimal image /etc/MATE or /ect/LXDE, which would trigger desktop installation. What I do include is OpenSSH server which is required to connect to the server per ssh, assumed it was in image by RADXA but it wasnt. RADXA uses also vim where most users probably are more familiar with nano. Those are minimal packages which I will include, for myself I include in minimal also mc (midnight commander) as it is quite handy if you need file browser in terminal.

If you want to install mate, you will either create /etc/MATE or you will download mate image instead of minimal, however, my scripts are not prepared image, my scripts work with official RADXA images letting you adapt whatever you need or not, because there is never configuration that fits everybody

Got you. great work and appreciated.

1 Like

I uploaded RADXA’s unedited images/sources as XZ, now it spares you all steps for cretion of SD, simply flash your SD with offline image and on first boot you can flash any internal device with dd from the guide in first post of this thread.

EDIT: @RADXA, I still hope you will provide additionaly XZ packed images. Normal image is ~25% smaller in size than published gzip, where where offline XZ which includes in itself full image is only around 35% bigger compared to gzip

format Size in MB
gzip 518
xz 395
xz-offline 770

EDIT2: Offline image fits to old standard, it fits on a CD :), those were the times…

EDIT3: Github servers are quite slow, would be good if RADXA provides XZ officially instead of 3rd party compiling images for users.

Repo updated, I did not test now all images with all scripts, I assume they work (lightdm needs some fixes), so, with that, I use for now LDXM for my scripts instead of lightdm, but lightdm works too, however, I uninstall lightdm during the initial desktop installation.

Here is how to flash and autoflash your internal devices:

Replace /dev/sdx with a device which you want to flash, !!make sure you flash correct device otherwise you may overwrite some other disk!!!. To see which device your SD card is run `fdisk -l’ or start disk utility like gnome-disks or gparted

git clone https://github.com/cevap/rockpi4-bionic
cd rockpi4-bionic/images
sudo make-all.sh # you can make only image that you wish, just edit make-all.sh to your needs if you need to
cd ..
# if you want mate, change lxde to mate, no_recommends is a version which does not install all unrequired applications
# if you need full desktop with office tools etc, use lxde/mate, if you do not want desktop at all, use minimal
IMGXZFILE="/home/dev/go/github.com/cevap/rockpi4-bionic/images/rockpi4b-ubuntu-bionic-lxde_norecommends-20190104_2101-gpt-cevap.img.xz"
# available options for device: emmc, m2, usb, sd
# available options for copy image into image: copy, y, n
# You can recompress any image into xz and flash it, current script uses origianl RADXA ubuntu bionic release
sudo ./usr/bin/create_cevap_sd.sh "sdX" "copy" "emmc" "${IMGXZFILE}"
  1. thats it. Insert now your SD into your rock device
  2. wait until rock shuts down, plug the power out of your rock
  3. take out your SD card and power on your rock, wait 5-6 reboots until everything is installed and enjoy your OS installed to emmc/m2. You can install to USB too, but it would require some rebuilding which I did not implement for now.

Those scripts work with official RADXA releases and if you do not have image at all, running make-all.sh will download origianl image and repack it to xz without any user interaction.

EDIT: tested lxde_norecommends, everything works on boot, only bluetooth is an issue

about bluetooth:
I can add according part to login scripts in LXDM/LightDm which make bluetooth available and working on first boot, however, the patch keeps running in the background which causes the cpu to go above 20% for nothing and it has to be killed manually (or with some delayed script). Now this is nasty and I actually did not want to include all the scripts on login phase as I do assume that RADXA will fix bluetooth package and that would produce then additoinal effort and maybe broken systems on devices which used the fix.

If I plug cheapest usb bluetooth devices it works properly, for those who require stable bluetooth should either wait until bluetooth package is fixed or buy simply new bluetooth device, for me it is a waste of time to create scripts for a workaround which obviously will be cleared soon.

EDIT2: just as note, if you install any of desktop packages, some extras like wireshark, keepass, inkscape and gimp are installed (some other packages too), just unmark/delete/edit packages you need or do not need:

EDIT3: to run synaptic, there is a workaround required, synaptic-pkexec does not work on LXDM.

Additional features

  1. Edit and customize easily
    You need some customized setup? Or you dislike some packages preinstalled? You can change it all easily by editing scripts to your needs and git fits perfect for that too.

  2. Easy flashing of internal/external devices
    If you flashed your SD with my script, you have all scripts and settings which enables you very fast flashing. Just copy any of created rockpi4b-ubuntu-bionic-*.img.xz onto the root of your SD card and create a file on SD card: FLASHDEFAULT (for emmc) or FLASHDEFAULTM2 which triggers flashing. Default filenames are
    a). FLASHDEFAULT (if you want to flash internal eMMC)
    b). FLASHDEFAULTM2 (if you want to flash M2 disk connected via RADXA m2 extender board)
    c). FLASHDEFAULTUSB (if you want to flash USB disk,) (not booting currently with orig RADXA image)
    d). FLASHDEFAULTLVM (if you want to install root to LVM disk) (not booting currently with orig RADXA image)
    e). FLASHDEFAULTRAID0 (if you want to install on RAID0 with 2 USB disks) (not booting currently with orig RADXA image)

  3. Fast reflash
    All files are available under /etc/ folder with a prefix _. They are all editable and you do not need root rights to rename them. Normally if you flashed your SD with cevap scripts then you already do have image on its root and simply renaming as example mv /pathToYourSdRoot/etc/_FLASHDEFAULTM2 /pathToYourSdRoot/etc/FLASHDEFAULTM2 would be enough to trigger flashing of your M2 disk even if you already have flashed emmc (by flashing M2 disk with default flashing will erase your eMMC). If you do not want to erase eMMC disk but still flash M2, then use non default script by simply using FLASHnVME0 instead of FLASHDEFAULTM2

  4. Provides LXDE and MATE (openbox, and some other incoming…) as well as LXDE_NORECOMMENDS and MATE_NORECOMMENDS which are without additional software packages like libreoffice and other which come with default desktop installations

  5. Simple run of first boot and all installations
    Create/Rename any of first boot scripts _FIRST_BOOT, _SECOND_BOOT, _THIRD_BOOT, _FOURTH_BOOT, _FIFTH_BOOT. If you want it to run fully automatic all of the stages, create /etc/FIRST_BOOT. If you trigger any later BOOT script, it will run then all up to last FIFTH

  6. Simple installation of desktops (for now only LDXE and Mate with LXDM (default) or LightDM)
    If you have installed minimal cevap version and want to trigger all scripts for desktop installation, create file /etc/LXDE (for full LXDE with LXDM), /etc/MATE (for full Mate with LXDM) or /etc/LXDE_NORECOMMENDS for LXDE without additonal sofware (installed with --no-install-recommends), same goes for /etc/MATE_NORECOMMENDS

As the screen is black during installation and boot ups, if you need to check how far it is (especially if installing full desktops, it takes some time) then connect to your rock over ssh and run this command to check dpkg status (installation of packages):
cat < /var/log/dpkg.log