Do you mean the following ?
- list the partitions (same as now)
- let the user choose a partition (same as now)
- if the filesystem is btrfs,
- mount the top level subvolume on /target
- list the subvolumes
- if there are subvolumes (other than top level),
- let the user choose a subvolume (including top level and default)
- if the selected subvolume is not top level,
- unmount the top level subvolume
- mount the selected subvolume on /target
Close, except for the last 3 steps. What I suggested:
- Not changing the way partition selection happens
- Not changing the way /target is populated
When it comes to executing the shell I suggested:
- If more than 1 btrfs subvolume exists then enumerate all of the btrfs subvolumes for the user in a list
- Do not adjust any mounted volumes/subvolumes based on this selection
- Use the user selected or default subvolume as the directory to execute the chrooted shell in
The first issue can be solved by mounting the top level subvolume
instead of the default subvolume.
I suggest that mounting the top level subvolume in /target is the only reasonable option unless all subvolumes are enumerated and are offered as a choice to become what is mounted at /target. Perhaps then the way to approach this should be:
- If more than one subvolume exists in a btrfs partition enumerate all of the subvolumes and display them in a list to the user
- Use the selection of the user as the contents of /target, or if there is only one subvolume then mount it under /target without prompting, or if there are no subvolumes then make the contents of /target the top level subvolume.
- Offer the top level subvolume as a choice in the list of subvolumes if more than one subvolume is available
Do you mean if the filesystem has only the top level subvolume ? Or only
one subvolume such as @rootfs in the top level subvolume ?
Not knowing any better I'd suggest:
- If there is only a top level subvolume then do not prompt the user for a selection and mount it at /target
- If there is only a single subvolume in the top level subvolume then do not prompt the user for a selection
I suppose it may make sense in the case of a single subvolume inside the top level subvolume to offer a choice between the top level subvolume and the single subvolume under the top level one.