Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFE] make vtoyboot also allow read-write of ventoy partition, that is heed VTOY_LINUX_REMOUNT #43

Closed
hgkamath opened this issue Mar 19, 2022 · 19 comments

Comments

@hgkamath
Copy link

hgkamath commented Mar 19, 2022

First, thanking you for such a awesome utility.

This is a follow-up to ventoy/Ventoy#1326 ([Feature Request]: On being able to mount the ventoy partition read-write from within booted OS)

Feature request: Make it possible for a ventoy-native-boot of fixed-raw-image to mount containing ventoy-partition as read-write. This will make custom-install raw-image to be feature-par with liveiso-image. This will also make ventoy-native-booting an image work just like chainloading a linux-partition.
Present status: As of today, ventoy-native-boot of fixed-raw-image will not allow remounting of the containing ventoy-partition as read-write. The mount command inside the booted-OS will complain that the partition is busy/dirty.

As described in comment- this feature is far more useful to a native-boot of custom-install image than a liveiso image.

  • "A custom install rewritable-image, which preserves state (installed software, configuration, data), is more useful than a read-only livecd that loses all written data in the overlay tmpfs on reboot.
    Microsoft fixed size VHDX-native-boot allows the native-booted Win-OS to be able to edit files in the containing filesystem. So Ventoy/Linux should also aspire to do the same."
@ventoy
Copy link
Owner

ventoy commented Mar 19, 2022

Try this vtoyboot in the attachment
vtoyboot-1.0.20.tar.gz

set VTOY_LINUX_REMOUNT=1 in Ventoy before boot the image or add VTOY_LINUX_REMOUNT=1 as a linux kernel boot parameter in grub.cfg.

@hgkamath
Copy link
Author

hgkamath commented Mar 19, 2022

It works !! that's awesome !!

  • I used qemu to boot, download tar.gz, run vtoyboot.sh
  • I have the { "VTOY_LINUX_REMOUNT": "1" } set in the global /ventoy/ventoy.json
  • There are two grubs. ventoy-grub and the grub on the boot partition /dev/mapper/ventoy1 inside of the image. I was surprised that the inside grub did not need it to be set, which perhaps means external-ventoy-grub is config-loading the grub-configs on the inside,
  • I was able to mount /dev/sdc1 , write text to a file, unmount-remount, confirm test-text data persists, then reboot to my usual linux and see the test-text from there as well.

Shall both issues can be closed now ?

The fix came so soon. The mind is flooded with potentials of this feature. many many thanks.

@ventoy
Copy link
Owner

ventoy commented Mar 20, 2022

There are two methods to tell vtoyboot to enable this feature.
{ "VTOY_LINUX_REMOUNT": "1" } in /ventoy/ventoy.json is a global option. This will affect all the ISO/VTOY/ files when boot from Ventoy.

If you only want the vtoy image to enable this feature. Then you can add VTOY_LINUX_REMOUNT=1 to the kernel command line inside the image file (grub.cfg).

@candrapersada
Copy link

candrapersada commented Mar 26, 2022

If you only want the vtoy image to enable this feature. Then you can add VTOY_LINUX_REMOUNT=1 to the kernel command line inside the image file (grub.cfg).

how to do it in grub.cfg please explain in detail
and will VTOY_LINUX_REMOUNT=1 disappear when updating linux kernel+grub?

@hgkamath
Copy link
Author

hgkamath commented Mar 26, 2022

@candrapersada , Check with forums particular to the Linux distribution you use, in case there are differences. Below is for Fedora. I haven't tested this myself, as I have set Ventoy global json setting, so let know if I missed something.

Steps to set the in-image boot-loader's kernel-argument

  1. First, you should be have made a vtoy-image in a VM, applied vtoyboot and already be able to successfully native-boot into it. It should be writable, but the ventoy-partition would be non-re-mountable.
  2. In order to make changes in the vtoy-image, you should have root privilege inside the booted image.
    You need to do one of, whatever you find convenient :-
    (a) via a VM, VM-boot directly into the vtoy-image
    (b) via a VM, VM-boot a different image having attached the vtoy-image as an additional drive
    (c) via ventoy native-boot, boot directly into the vtoy-image .
  3. Fedora images, by default, use grub bootloader. If booted directly (a,c), ensure boot partition is mounted at /boot and efi partition (if present) at /boot/efi . the grub.cfg in /boot/efi/Fedora/ should load-config the grub.cfg in /boot/grub2/ . If booted via another VM (b), find the boot, efi and main partitions (say /dev/vdb3, /dev/vdb1, /dev/vdb4) , create mount points ( /mnt/sys1_boot, /mnt/sys1_boot_efi , /mnt/sys1_main) and mount them to it. Trace through the Linux distribution-image's boot sequence to find 'the final grub' that loads the kernel. Usually it is (/boot)/grub2/grub.cfg
  4. To find the file/place where to add kernel cmdline arg:
    • These days, Linux distributions and various bootloaders like grub2 follow and support a convention called the "bootloader spec" (bls), where kernel specific parameters are stored in their own separate files, which any bootloader (like grub) knows how to read. Determine the partition 'the final grub' considers to be the grubrootfs (boot partition), In the boot-partition, locate the bls-directory (/boot)/loader/entries/ , find the file-entry for the kernel, edit the entry-file, append the aforementioned Ventoy kernel-argument to line leading with the word options . The kernel options in the bls 'entry-file' for a newly being installed kernel are cloned from the entry-file of a pre-existing 'default kernel'. So when configured correctly, they persist through kernel+grub updates. Read the 'bootloader spec' ,man grubbyand Fedora magazine article Setting kernel cmd line arguments with Fedora 30
    • In the old days, boot menu was generated and populated in the (/boot)/grub2/grub.cfg file itself, which one may modify directly. For each boot option there will be a kernel and initrd specified. The initrd line is to have the kernel arguments. To make the changes persist during kernel+grub updates, there is a way to save them in variables in a config file /etc/default/grub , in the main partition, which the grub2-mkconfig generation scripts use. Read the linux-distribution (Fedora) manual for the specific release-version for persisting grub configuration. As ventoy is a very recently created tool, distributions that claim to support ventoy, use recent grub2 versions and very likely already conform to the 'bootloader spec'. So this case might not arise.
    • For arbitrary live-image with different bootloader, not grub, but syslinux or something else, the method to pass kernel argument would all be different, but I am unsure if other bootloaders are ventoy bootable.
    • Every distribution will have a way to persist the grub per-kernel cmdline arguments through kernel+grub updates. You need to read the distributions manual, As they use the same tools/scripts, the steps will be very likely similar to Fedora.
  5. Reboot as ventoy nativeboot and check that /proc/cmdline has the kernel argument and that the ventoy-partition is indeed mountable as read-write.

The two ways of setting the option discussed above are:

  1. global-ventoy-option by either manually editing the global-plugin-control json or using the plugson tool
  2. as in-image boot-loader's kernel-argument

My curiosity questions are, (Q1) How does the Ventoy json global option work? How does that parameter percolate into the image and be assigned in the initramfs dm script that does the ventoy-pivot-remount? One answer would be, that the outer ventoy-grub is config-loading the inner image grubs. Another answer would be, it is setting a firmware environment variable that is later probed by script. But, if any of these is the case, then there should also be a 3rd way, albeit non-persistent, to provide the setting, apart from the two ways discussed already, (Q2) that is, Can the option be set manually when booted into in the ventoy-grub, and then select the vtoy-vdisk. That is, in general, can Ventoy-options be set to value imperatively in the vetoy-grub prompt itself, on a need basis, i.e. toggled if boolean?

@candrapersada
Copy link

candrapersada commented Mar 27, 2022

changes persist during kernel+grub updates for Manjaro and Linux Mint?

@hgkamath
Copy link
Author

Manjaro is arch based, Mint is ubuntu/debian based. It is very likely the recent versions of both the said-distros use the same tools and boot up sequence, and to some extent the same partition and file layout as Fedora. So the same steps should work for them. You need to read up their documentation or ask on their respective forums.

@ventoy
Copy link
Owner

ventoy commented Mar 27, 2022

how to do it in grub.cfg please explain in detail

Edit /etc/default/grub file, append VTOY_LINUX_REMOUNT=1 to the end of GRUB_CMDLINE_LINUX_DEFAULT option.
For example, GRUB_CMDLINE_LINUX_DEFAULT="quiet splash VTOY_LINUX_REMOUNT=1"
After that, run sudo update-grub

and will VTOY_LINUX_REMOUNT=1 disappear when updating linux kernel+grub?

NO.

@candrapersada
Copy link

candrapersada commented Mar 27, 2022

will the information be added to the Ventoy Document?
And how to fix insmod error could not insert module /tmp/dm_patch.ko invalid paramenters for Manjaro
IMG20220327143216

@ventoy
Copy link
Owner

ventoy commented Mar 27, 2022

Which manjaro iso file did you use to install the vtoy file?

@candrapersada
Copy link

candrapersada commented Mar 27, 2022

@candrapersada
Copy link

what is the cause of VTOY_LINUX_REMOUNT not working properly for Manjaro and other Archlinux based?

@ventoy
Copy link
Owner

ventoy commented Apr 2, 2022

@candrapersada
Try this release for manjaro.

vtoyboot-1.0.20.tar.gz

@candrapersada
Copy link

Try this release for manjaro.

vtoyboot-1.0.20.tar.gz

yes but not working for VTOY_LINUX_REMOUNT

@ventoy
Copy link
Owner

ventoy commented Apr 5, 2022

@candrapersada
Try this release for manjaro
vtoyboot-1.0.20.tar.gz

@candrapersada
Copy link

yes works well thank you

@JoergVogt
Copy link

how to do it in grub.cfg please explain in detail

Edit /etc/default/grub file, append VTOY_LINUX_REMOUNT=1 to the end of GRUB_CMDLINE_LINUX_DEFAULT option. For example, GRUB_CMDLINE_LINUX_DEFAULT="quiet splash VTOY_LINUX_REMOUNT=1" After that, run sudo update-grub

and will VTOY_LINUX_REMOUNT=1 disappear when updating linux kernel+grub?

NO.

@JoergVogt
Copy link

Hi,

I am currently trying out the following:

menuentry "Try or Install Ubuntu" {
set gfxpayload=keep
linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed noprompt quiet splash VTOY_LINUX_REMOUNT=1 ---
initrd /casper/initrd
}

Unfortunately it does not work.

Do you have any ideas?

@nikescar
Copy link

nikescar commented Sep 26, 2024

menuentry "Try or Install Ubuntu" { set gfxpayload=keep linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed noprompt quiet splash VTOY_LINUX_REMOUNT=1 --- initrd /casper/initrd }
Do you have any ideas?

you have to change vmlinuz also. below works for fedora live iso file.

# replace default boot options in grub2
sudo sed -i 's/rd.live.image quiet rhgb/rd.live.image VTOY_LINUX_REMOUNT=1/g' /EFI/BOOT/grub.cfg # VTOY_LINUX_REMOUNT=1
sudo sed -i 's/rd.live.image quiet rhgb/rd.live.image VTOY_LINUX_REMOUNT=1/g' /boot/grub2/grub.cfg # VTOY_LINUX_REMOUNT=1
# modify boot option in kernel
sudo grubby --update-kernel /images/pxeboot/vmlinuz --remove-args="rhgb quiet" --args="VTOY_LINUX_REMOUNT=1" # /images/pxeboot/vmlinuz

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

No branches or pull requests

5 participants