Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Use partuuid in installed_os.json #497

Merged
merged 1 commit into from
Oct 1, 2018
Merged

Conversation

procount
Copy link
Contributor

@procount procount commented May 7, 2018

When installing an OS to a USB storage device, the partitions used for the OS are referenced assuming the device remains consistent as /dev/sdaX. I had one user who booted PINN with 2 USB sticks - one with the OS installations on it (sda), and the other used as the destination (sdb). Naturally the partition was stored as /dev/sdb6 in installed_os.json, but on later boots, the device was referenced as /dev/sda so the OS could not be found.

I think that OSes installed to an external USB should be referenced by partuuid in os_config.json and installed_os.json, just like is done in cmdline.txt and /etc/fstab.

Do you think the attached Pull Request will solve this issue? Are there any problems with it?

@procount
Copy link
Contributor Author

procount commented May 8, 2018

In order for the 1st commit to compile, I also had to move 4 uuid related functions from multiimagewritethread.cpp to util.cpp.

@@ -530,7 +530,13 @@ bool MultiImageWriteThread::processImage(OsInfo *image)
QVariantList vpartitions;
foreach (PartitionInfo *p, *partitions)
{
vpartitions.append(p->partitionDevice());
QString part = p->partitionDevice();
if (part.left(13) != "/dev/mmcblk0p")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, what happens if you remove this special-casing for /dev/mmcblk0 and instead always use the partuuid?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to have some Linux distributions that came with an initramfs that did not support partuuid parameters (e.g. OSMC).
Not sure if that's still the case in recent versions though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@procount I wonder if it'd be worth adding an extra param to the os.json / os_list.json files stipulating whether they support partuuid parameters, and then only using this partuuid code if they do?

Copy link
Contributor Author

@procount procount May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we piggy-back the supports_usb_root or support_usb_boot parameters for that? I think they serve a similar purpose...?

Copy link
Contributor Author

@procount procount May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, if an OS doesn't support partuuid, then it can't be installed to USB. If so, then the additional code won't be necessary. I'm sure @XECDesign or @maxnet explained the use of supports_usb_root and supports_usb_boot somewhere but I can't find the reference.

@lurch
Copy link
Collaborator

lurch commented May 15, 2018

In order for the 1st commit to compile, I also had to...

Might be beneficial to swap the order of the commits?

@procount
Copy link
Contributor Author

If I were to rebase to reorder the commits (or even squash them), wouldn't it wreck all this conversation, comments, history etc when I push it up (probably with -f to force it?)

@lurch
Copy link
Collaborator

lurch commented May 15, 2018

Nope, I don't think so.

@procount
Copy link
Contributor Author

OK I'm willing to give it a go - Which do you prefer: swap or squash?

@procount procount force-pushed the partuuid branch 2 times, most recently from bf6f5e8 to 08fa9ff Compare May 15, 2018 14:43
@procount
Copy link
Contributor Author

I swapped first, then squashed, and both worked, so I guess the git warnings about rebasing and force pushing only apply to the public repository that others have used and not to pull requests.

@lurch
Copy link
Collaborator

lurch commented May 15, 2018

Yeah, IIRC the git warnings are about mucking up the history if somebody else has already cloned the branch you're rebasing - but since you're rebasing a private branch in order to create a PR, it's very unlikely that somebody else has cloned your procount:partuuid branch 🙂

@procount
Copy link
Contributor Author

Updated with bugfix to use Hexadecimal partition numbers from PARTUUIDs

@XECDesign
Copy link
Contributor

@maxnet, does this look okay to you?

@maxnet
Copy link
Collaborator

maxnet commented Aug 20, 2018

Looks ok, although I haven't tried it.

@XECDesign
Copy link
Contributor

Thanks for taking a look. I'll test it out before it goes in a release.


int partitionNr;
QRegExp parttype("^PARTUUID");
if (parttype.indexIn(partition) == -1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably use http://doc.qt.io/archives/qt-4.8/qstring.html#startsWith here instead?

@procount
Copy link
Contributor Author

@XECDesign - I finally got around to testing this with boot on sd card and root on USB stick.
It correctly used PARTUUIDS for the USB partitions and interpreted the HEX partition numbers correctly.
(Of course, it helps if you build and test from the correct GIT branch!)

@XECDesign XECDesign merged commit 5241b1d into raspberrypi:master Oct 1, 2018
@XECDesign
Copy link
Contributor

Many thanks

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

Successfully merging this pull request may close these issues.

4 participants