billw2 / rpi-clone

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

Original SD card gets mounted #83

Open NickD9 opened 4 years ago

NickD9 commented 4 years ago

I removed my original SD card, inserted a new one flashed with Raspbian Lite and then rebuilt the system.... all good so far. It's been running for a few months so thought it was time to clone it, and wanted to use rpi-clone to clone it back to the original card I removed. I put the original in a USB card reader, inserted it into the Pi, and it mounted the EXT4 partition as "/", and totally refused to unmount it. "/" was already occupied by the resident SD card, I had TWO root partitions, and nothing would resolve the issue until I rebooted and reformatted the original card using a Windows PC before reinserting into the Pi. All went fine after that, rpi-clone did its thing and I've got my cloned card.

Any ideas why the original got mounted, and will it happen again if pop the clone back in for an incremental update?

billw2 commented 4 years ago

On Wed, 23 Oct 2019 13:57:26 -0700 NickD9 notifications@github.com wrote:

I removed my original SD card, inserted a new one flashed with Raspbian Lite and then rebuilt the system.... all good so far. It's been running for a few months so thought it was time to clone it, and wanted to use rpi-clone to clone it back to the original card I removed. I put the original in a USB card reader, inserted it into the Pi, and it mounted the EXT4 partition as "/", and totally refused to unmount it. "/" was already occupied by the resident SD card, I had TWO root partitions, and nothing would resolve the issue until I rebooted and reformatted the original card using a Windows PC before reinserting into the Pi. All went fine after that, rpi-clone did its thing and I've got my cloned card.

Any ideas why the original got mounted, and will it happen again if pop the clone back in for an incremental update?

I think this could happen if both your original and new SD cards had the same disk id (the PARTUUID) and they would for sure if both were imaged from the same .img file. Then because the PARTUUID is referenced in fstab or maybe because auto mounting is enabled, the system automatically mounted the SD card in the card reader on top of root.

rpi-clone does a PARTUUID check of the card reader disk and the booted disk. If the numbers are the same, rpi-clone changes the destination PARTUUID so you should not have that problem again when you do the next incremental clone.

Bill

NickD9 commented 4 years ago

Ah yes, they were both from the same image I’d previously taken, so you’re absolutely right. Would the OS mounting it be seen as a feature or an OS bug:-) Many thanks for your help, rpi-clone is a work of genius and much appreciated. Any chance of it creating img files in the near future ;-) Regards, Nick

Sent from my iPhone

On 24 Oct 2019, at 00:49, billw2 notifications@github.com wrote:

On Wed, 23 Oct 2019 13:57:26 -0700 NickD9 notifications@github.com wrote:

I removed my original SD card, inserted a new one flashed with Raspbian Lite and then rebuilt the system.... all good so far. It's been running for a few months so thought it was time to clone it, and wanted to use rpi-clone to clone it back to the original card I removed. I put the original in a USB card reader, inserted it into the Pi, and it mounted the EXT4 partition as "/", and totally refused to unmount it. "/" was already occupied by the resident SD card, I had TWO root partitions, and nothing would resolve the issue until I rebooted and reformatted the original card using a Windows PC before reinserting into the Pi. All went fine after that, rpi-clone did its thing and I've got my cloned card.

Any ideas why the original got mounted, and will it happen again if pop the clone back in for an incremental update?

I think this could happen if both your original and new SD cards had the same disk id (the PARTUUID) and they would for sure if both were imaged from the same .img file. Then because the PARTUUID is referenced in fstab or maybe because auto mounting is enabled, the system automatically mounted the SD card in the card reader on top of root.

rpi-clone does a PARTUUID check of the card reader disk and the booted disk. If the numbers are the same, rpi-clone changes the destination PARTUUID so you should not have that problem again when you do the next incremental clone.

Bill

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

billw2 commented 4 years ago

I think allowing this kind of mounting is for a feature having to with union or overlay files systems in Linux. But I don't know much about them.

Others have asked about backups to a .img file and I have thought I would see if it's something I could add. It's just that I need to find the time to look into it.

On Wed, 23 Oct 2019 20:53:35 -0700 NickD9 notifications@github.com wrote:

Ah yes, they were both from the same image I’d previously taken, so you’re absolutely right. Would the OS mounting it be seen as a feature or an OS bug:-) Many thanks for your help, rpi-clone is a work of genius and much appreciated. Any chance of it creating img files in the near future ;-) Regards, Nick

Sent from my iPhone

On 24 Oct 2019, at 00:49, billw2 notifications@github.com wrote:

On Wed, 23 Oct 2019 13:57:26 -0700 NickD9 notifications@github.com wrote:

I removed my original SD card, inserted a new one flashed with Raspbian Lite and then rebuilt the system.... all good so far. It's been running for a few months so thought it was time to clone it, and wanted to use rpi-clone to clone it back to the original card I removed. I put the original in a USB card reader, inserted it into the Pi, and it mounted the EXT4 partition as "/", and totally refused to unmount it. "/" was already occupied by the resident SD card, I had TWO root partitions, and nothing would resolve the issue until I rebooted and reformatted the original card using a Windows PC before reinserting into the Pi. All went fine after that, rpi-clone did its thing and I've got my cloned card.

Any ideas why the original got mounted, and will it happen again if pop the clone back in for an incremental update?

I think this could happen if both your original and new SD cards had the same disk id (the PARTUUID) and they would for sure if both were imaged from the same .img file. Then because the PARTUUID is referenced in fstab or maybe because auto mounting is enabled, the system automatically mounted the SD card in the card reader on top of root.

rpi-clone does a PARTUUID check of the card reader disk and the booted disk. If the numbers are the same, rpi-clone changes the destination PARTUUID so you should not have that problem again when you do the next incremental clone.

Bill

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/billw2/rpi-clone/issues/83#issuecomment-545731731