billw2 / rpi-clone

A shell script to clone a booted disk.
BSD 3-Clause "New" or "Revised" License
2.51k stars 333 forks source link

Don't work on osmc #70

Open fmarzocca opened 5 years ago

fmarzocca commented 5 years ago

I am trying to use the script with osmc (www.osmc.tv) but I get this error: Error: Could not stat device /dev/systemd

Any tip?

arigit commented 5 years ago

Same issue here. Did you ever find a solution? I also have two OSMC installs, one with rpi-clone working and the other without. However, both are at the same version (july 2019) , the only difference is that one is a fresh install vs. the other one is an old install that has been upgraded over time. The difference must be some package missing in the fresh install that rpi clone depends on and is not documented (my guess)

arigit commented 5 years ago

I found the issue.

In the OSMC fresh install, rpi-clone fails to determine the source disk, which rpi-clone tries to guess by finding which device hosts the /boot directory, by using findmnt.

This is strange thing: in the fresh install,

mount |grep boot
systemd-1 on /boot type autofs (rw,relatime,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
/dev/mmcblk0p1 on /boot type vfat (rw,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)

There is the strange first line showing "systemd-1". This is also reflected by the command that rpi-clone uses:

/home/osmc/rpi-clone# findmnt /boot -o source -n
systemd-1
/dev/mmcblk0p1

So the quick hack to solve this is: look for the following line:

src_boot_dev=`findmnt /boot -o source -n`

and replace it with

src_boot_dev=`findmnt /boot -o source -n | grep -v -e "systemd"`

After this rpi-clone worked perfectly in my system

fmarzocca commented 5 years ago

Great! Thank you very much!!

arigit commented 5 years ago

@fmarzocca Hi, can you reopen this issue? we need a developer to take a look, I found a quick workaround but this, however this change did not get merged into rpi-clone script yet and there may be much better solutions than mine to the problem.

Bottom line this Issue should stay open until the problem is solved in the rpi-clone source code here.

fmarzocca commented 5 years ago

Yes, you are right!

billw2 commented 5 years ago

src_boot_dev=findmnt /boot -o source -n | grep -v -e "systemd"

That excludes the systemd, but I'm not confident about why that line is there or if somewhere else or down the road there might be something else extra besides systemd. I think matching /dev/ would be more general.

So will this work as well on osmc?

src_boot_dev=findmnt /boot -o source -n | grep "/dev/"

arigit commented 5 years ago

@billw2 Yes - this works, and it's a better approach. That way you are guaranteed to catch always the physical device which is the one you need for rpi-clone

Just for context, I've been doing a little research on the systemd mount on /boot, it's brought up by a systemd service called 'automount' that OSMC appears to have tweaked for their own specific reasons. In most other distros, the automount of /boot is done only if there was no line in fstab covering it, and in that case it is a temporary mount that is only kept during boot, and then gets unmounted. OSMC seems to behave a little different than other distros on this.

billw2 commented 5 years ago

On Mon, 26 Aug 2019 10:28:23 -0700 Ari notifications@github.com wrote:

@billw2 Yes - this works, and it's a better approach. That way you are guaranteed to catch always the physical device which is the one you need for rpi-clone

Thanks for the feedback. I've pushed the change to filter findmnt results for /dev/

fmarzocca commented 5 years ago

src_boot_dev=findmnt /boot -o source -n | grep "/dev/"

I confirm this is working on my osmc too...