How to install OS on SD card from Linux?

There is no app to flash OSMC into SD card on Linux, although there was in the past. AppImage would be perfect for that (distro agnostic).

I had to do it manually, so I found on some article to put it on SD card with dd:

sudo dd bs=4M if=/dev/zero of=/dev/mmcblk0 oflag=sync
sudo dd bs=4M if=OSMC_TGT_rbp2_20200607.img of=/dev/mmcblk0 status=
progress && sync

It worked fine, and the OS booted, installed itself, and it worked. When installing HGO EU (for HBO GO) add-on, it needed to install widewine component for DRM content, which was 1GB download. During that process, the system went blank. Literally, just black screen, no output or any reaction. Had to reboot the Raspberry Pi 3 B+ and then I got serious boot error about system file error (not able to read/write into secondary partition that system created) with suggestion to reinstall OS.

So I did repeat the first steps and… get the same error over and over. Tried other SD cards and… raspberry won’t even boot. So the issue is not with SD card but methodology, that weirdly worked fine for the first time.

So how do I install the system properly on SD card from Linux?

P.S. I registered to forum and… after creating account all I could do was to file a ticket. I had to reload forum on another tab to be logged in. Why so confusing?

Have you tried another SD card?

Your SD card may be failing.

Support tickets are usually for returns or sales queries. The community forum is the best place to get support for Raspberry Pi.

Yes, I tried at least 3 SD cards and they all are no recognized by rasberry and it doesn’t boot. All I did was to use the commands as shown above: zero disc and flash the image.

This can’t be coincidence. Maybe it also depends on what I used those SD cards for - it was used to install updates on GPS device (Garmin), so the update app was putting download files there and install it from there. Not sure what technology it was used, since it was all proprietary app. But I could use it many times for more updates, so the SD cards were working fine.

Nevertheless, zeroing SD card should erase everything and flash the image just fine.

I’m puzzled, why there are no direct instructions how to use dd on Linux, so there would be no problems. Terminal is distro agnostic, so this should be a simple and short guide. Without it, we must use some weird, obscure resources, not sure if the command variation we found won’t mess anything.

Your power supply may be insufficient and causing corruption on the SD card.
There are also OSMC optimised cards here that are designed for running OSMC / an OS.

If you’re using Linux – you usually know how to write an image to external media.

Don’t zero the card. It will cause unnecessary writes and reduce lifespan.

The tool you used is fine, but writing zeros to the SD card every time will trash the SD card.

There are plenty of imaging tools available.

We are working on resurrecting the OSMC installer for Linux, but it will take some time to modernise it. We found that it was used by less than in 1 in 100 downloaders, and presumably only then to use the preseeding tool.

Such as?

I tried imagewriter, but it only allows to write into USB. I would love to try some others, although I know they are just GUI shells for dd, but maybe they use some better optimized options then I did?

May be, but the power supply was in a bundle, dedicated to that unit, along with a classic cover. Just like the cover, power supply has a raspberry logo, so I assume this is the official stuff. Besides, I’m preparing SD cards on my laptop and then try to use them inside raspberry, and they all don’t work, so something must be off. Initially I thought that was the problem with the SD, but now I believe it may be a mixture of both. The first SD just failed, but the others must be prepared or flashed in some other way to make them work, since they weren’t empty and used by proprietary software. In theory, zeroing should clean them, but maybe the normal options are not enough. I don’t know enough dd to figure out what to set, so I could be sure it’s empty.

Also, when I do zeroing, I get some weird error about lack of space (which is not a typical error), but writing seems to be fine. And oh, another problem is that after zeroing, the SD card has only 3,8GB of space, and it should show 29,99GB or something like that, so zeroing is not working properly. Someone with intricate knowledge of how discs, sectors, tables and partitions work should step in.

Yes and no. There are plenty novice Linux users who don’t. Besides, dd tool has many options and because we know basic ones to write Linux image to USB, doesn’t mean we know how to set it to create an optimized image on SD card. Maybe there are some differences we should pay attention to? Or maybe not? I don’t know and nobody seems to know.

Besides, not all Linux users are technic or IT specialists. Many of us are just semi-technical power users, who don’t understand advanced, technical jargon, but are doing fine on most day-to-day basis. We need some help, tutorials to figure out stuff thou.

Just as the Windows users are very, very different, from power users, IT specialists to casual users who wouldn’t handle a simple issue with the system. In the same way, Linux users differ, but on average, we are more technical and know our way around the systems. However, assuming that we all posses the same kind of esoteric and advanced knowledge is just wrong.

If the downloader was in a deb format, this is indeed an obsolete format. AppImage would be the best one. It would work for everyone, just download and run. Nothing more is needed.
With time, there will be more Linux users who will choose the convenience and simplicity of that solution. It would also ensure, that the process of flashing SD is done by the book. Now, I don’t know what am I doing, because there may be many variations or a simple knowledge piece that can make the whole difference.

1 Like


1 Like

balenaEtcher or the official Raspberry Pi Disk imaging tool which supports OSMC.

We will re-design the tool in 2022, and hopefully reintroduce a stop gap before the new tool is introduced so we can support installation on Linux.

I’m also planning to allow OSMC to be reinstalled on Vero 4K / 4K+ devices without needing a USB or SD card by introducing a recovery mode that can download and install images over the network.

The Linux installer is a lower priority at this time and only @Tom_Doyle and I are working on bringing the current imaging utility back up.

It would be good to know which distribution you are using. We can at least verify what we have for that.

Power supplies can degrade.
But it is clear you have a hardware failure.

This is because you are writing zeros in 4MB block alignments and your SD card likely does not end on a 4MB boundary.

You should not zero the card as you will significantly reduce its lifespan. You would only do something like this if it was changing hands and you wanted to fully erase the data on the card for privacy purposes.

AppImage is designed to allow applications to run in a sandboxed environment. It will be a struggle to allow it to then have raw, block level access to USB peripherals, otherwise it would violate this principle. Therefore it is not suitable for disk imaging applications.

If you say your power supply is good, but you are using (what seems to be) old SD cards which fail after an hour, then this is a hardware problem. You may have exacerbated the decline of these cards by writing unnecessary data to them.


I managed to find a solution.

It looks like the zeoring was not fully done because the crash that caused system file error blocked the entire SD. I managed to unblock OS partition, but the remaining one was still blocked and thus not accessible for zeroing.

I fixed that by flashing entire Manajro iso (Linux distribution) which unlocked entire SD as it was on the beginning. Then I could properly clean it and then flash the OSMC, which creates OS partition and free space.

This free space was not available before, so raspberry wouldn’t boot. Now when it’s available, it booted and installed OS correctly.

To avoid install issues with huge widevine component (over 1GB size), I resized OS partition to 6GB.

Now all seems to be working, aside widevine, which is installed but no DRM content launches. The system is trying to load a video, the screen flickers and system stops loading, without any error notice. But that’s an entire different issue for another case.

To sum up, this wasn’t a SD card issue, but a result of a second partition lock (read only) that happened after the crash. This corrupted the whole process of zeroing or flashing OS. Once I was able to unlock the entire SD, all went back to normal and system reinstallation was a success.

Noted. However, I suspect that doing it just a few times shouldn’t impact the SD lifespan significantly, especially that this is not an everyday operation. Although, I could be mistaken.

This is just recently bought and this was a first day of usage. I doubt it degraded that fast ;), unless I got a broken unit.

I thought so too, but it turned out to be a software issue after all. Although, I’m not sure what caused the initial crash during widevine install. My money goes on lack of space on OS partition, that is tiny by default, but I could be wrong. It would still be nice if OSMC would expand OS partition during install to at least 2 GB if there is enough space available.

Ah, thank you for the info. I didn’t think about that. What about snap or flatpack? They also have sandbox but may have some ways out, since a variety of apps are working through those formats.

OSMC automatically uses all available space of the SD card. The installer formats the SD card on first boot and creates the secondary, ext4 partition.

Are you using official images from

Yeah, the problem was with the secondary ext4 partition (that wen’t on full lockdown and became invisible after zeroing) and yes, I used the official download from the link you provided.

Now I have a samba question, where are the samba shares located? On fat (OS) or ext4 partition?
I see Samba Shares nicely in my Linux computer, but I don’t know how much space I have to use there and if I have permissions to put and modify files inside.

The Samba share are from /home/osmc so fro the ext4 partition and also any automounted device (e.g. USB Stick) will be a samba share.

1 Like

Thanks. I will have a couple more questions, but I post it later in a topic like “Newbie questions about OSMC and Kodi”.

Then your SD card is definitely defective. Official images always resize the card to full capacity on the first boot.

No, you misunderstood me. OS did exactly that, it created ext4 partition to the full capacity of SD. The problem was, after the crash, this partition became read-only and was not possible to modify in any way. It also caused OS boot failure, because expected the partition to be accessible, since it wanted to mount home. Additionally, because of that, even dd wouldn’t access it when zeroing and showed “lack of space error”. Only bigger image than 3,8GB was able to override in its place and restore locked space.

In other words, the crash caused some serious file system error that confused dd, which was breaking zeroing when it came to that partition. When I zeroed SD, that partition became invisible. If I skipped zeroing and just wrote the system, it showed the same symptoms as before - normal partition and inaccessible partition. In the result there was not enough space in SD and boot was not possible.

Hi Michaldybczak,

As Sam advised above, I’ve been working on bringing back the the installer to linux:

I appreciate if you get a chance to test please.

The .deb release should work Debian 10/11 and derivatives (Ubuntu, mint, etc)
The .rpm - Should work on Redhat 7/8 and derivatives (Fedora, Centos, Rocky, etc). Should also support Opensuse Tumble & Leap.

Also please be advised the installer has re-enabled preseeding for networking on the vero4k/vero4k+, but there still work on going to restore this function on the devices themselves.
Scratch that I’ve been advised the preseeding restore has been merged and should be working.

Thanks Tom.

Edit: New release for Zero W 2

FWIW, if an SD card gets corrupted I reach for the SD Card Formatter from the SD Association. It’s possible it’s only for Windows, though.

Or h2testw but also only Windows

Probably there are some solutions on Linux, but I didn’t research it long enough. Anyway, the trick with flashing a much bigger image worked. It’s not ideal, but works and is simple.

At the moment OSMC is working fine, it didn’t crash during widevine install, so everything is OK.

Thanks guys!

Just a hint from my side: I had no problems in installation of osmc from a linux machine using dd (as described in the very first post) using a 32GB sdcard.

But if there is a crash of a running linux (like osmc) you might end up with a corrupt filesystem. In that situation you can run filecheck of the sdcard by plugging it into your linux machine. Beware NOT to mount the sdcard. From dmesg e. g. you’ll get the device name something like /dev/sdXX (typically one of the last messages after inserting your sdcard). As superuser run fsck to repair the potentially broken partition of your sdcard. Commands run as superuser are potentially dangerous and might harm your running system, thus only run them if you know what you are doing.

I, too had some crashes of osmc during some experiments. And afterwards the filesystems from osmc were not clean (that’s normal for any linux OS), but it was still fully functional.

I, too, believe that either your sdcard is broken or your powersupply is bad.

Regards, Michael

1 Like

We automatically perform a fsck (filesystem check) on boot from initramfs, but we are not overly aggressive with its implementation.