You are not logged in.
Hi
Lets think i have this:
arch-chroot /mnt /myScript.sh
I had send myScript.sh to that path in /mnt . How can I send a varaible to my new chroot environment ? my arch-chroot command is part of a script and have the variable $myDisk . myScript.sh must have the variable $myDisk with the content available in the new chroot. Can I do that ?
Last edited by Succulent of your garden (2025-02-12 21:39:57)
Offline
How can I send a varaible to my new chroot environment ?
# myDisk=value arch-chroot /mnt/ /myScript.sh
?
Offline
If it doesn't work , a few other possibilties are :
putting the envvar in a file that is included in the chroot mount and sourcing that file in the script
SO thread with several (untested by me) options .
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
I forget to comment that the the content of the variable $myDisk is given by the user by using read command. So I can hardcode it. It must be something like
arch-chroot /mnt /myscript.sh $myDisk
but that obviously does not works.
Offline
Seems like arch-chroot itself is a bash script as per https://wiki.archlinux.org/title/Chroot … rch-chroot
You can always make a copy and modify it to accept whatever arguments.
Last edited by ReDress (2025-02-12 15:27:53)
Offline
Seems like arch-chroot itself is a bash script as per https://wiki.archlinux.org/title/Chroot … rch-chroot
You can always make a copy and modify it to accept whatever arguments.
but that would work if I need launch the arch-chroot from a script ? I can paste the arch-chroot script directly but that would made my script a lot harder to mantain. I split the main scripts in two, its for my custom arch installation. The first part is before the chroot, and I really want to be able to just pass the variable from the first part to the second, so I can automate my custom installation without asking more than the necessary inputs by user. My $myDisk is the path of the drive which arch is being installed (for example /dev/sda), I need that variable to automate the grub installation for bios systems without the need to ask the user again.
Last edited by Succulent of your garden (2025-02-12 16:05:06)
Offline
I forget to comment that the the content of the variable $myDisk is given by the user by using read command.
read -p "Enter disk name: " myDisk
export myDisk
arch-chroot /mnt /myscript.sh
or
read -p "Enter disk name: "
myDisk="$REPLY" arch-chroot /mnt /myscript.sh
Offline
But I would do
read -p "Enter disk name: " myDisk
arch-chroot /mnt /myscript.sh "$myDisk"
and in myscript.sh:
myDisk="$1" # Or whatever parameter index it is
Offline
Thanks dimich you made my day undestranding that the chroot variables can be get using the $1 and so on. My script now works
Offline