Chroot to porteus
-
- Contributor
- Posts: 678
- Joined: 26 Jun 2013, 14:03
- Distribution: x64 Openbox
- Location: Russia is causing the immense damage to humanity
- Contact:
Chroot to porteus
Has anyone ready script to mount porteus base modules and changes directory at /mnt/chroot-porteus and chroot to it? Does anyone use something like this?
You have mind and feelings. Be wise and clever.
Chroot to porteus
Hi
first you would use the xzm2dir command to unpack your module then consider this link
[SOLVED] chroot on v 3.5 A=/usr/local/sbin/newroot
ie starting from cd
first you would use the xzm2dir command to unpack your module then consider this link
[SOLVED] chroot on v 3.5 A=/usr/local/sbin/newroot
ie starting from cd
Code: Select all
cd <result of xzm2dir>
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/
mount -t devpts pts dev/pts/
chroot . /bin/bash
- brokenman
- Site Admin
- Posts: 6105
- Joined: 27 Dec 2010, 03:50
- Distribution: Porteus v4 all desktops
- Location: Brazil
Re: Chroot to porteus
I do this regulary.
Call the script as: script /path/to/001-core.xzm
EDIT:
To unmount
umount -l /mnt/chroot/sys
Code: Select all
mkdir /mnt/chroot
xzm2dir $1 /mnt/chroot
mount -t proc proc /mnt/chroot/proc
mount --rbind /dev /mnt/chroot/dev
mount --rbind /sys /mnt/chroot/sys
chroot /mnt/chroot /bin/bash
EDIT:
To unmount
Code: Select all
exit
umount /mnt/chroot/dev/pts
umount /mnt/chroot/dev
umount /mnt/chroot/proc
How do i become super user?
Wear your underpants on the outside and put on a cape.
Wear your underpants on the outside and put on a cape.
-
- Contributor
- Posts: 678
- Joined: 26 Jun 2013, 14:03
- Distribution: x64 Openbox
- Location: Russia is causing the immense damage to humanity
- Contact:
Re: Chroot to porteus
I want replace "xzm2dir" with "mount -t aufs".
You have mind and feelings. Be wise and clever.
- brokenman
- Site Admin
- Posts: 6105
- Joined: 27 Dec 2010, 03:50
- Distribution: Porteus v4 all desktops
- Location: Brazil
Re: Chroot to porteus
You can do that, but remember your mountpoint will be read only.
How do i become super user?
Wear your underpants on the outside and put on a cape.
Wear your underpants on the outside and put on a cape.
- francois
- Contributor
- Posts: 6445
- Joined: 28 Dec 2010, 14:25
- Distribution: xfce plank porteus nemesis
- Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.
Re: Chroot to porteus
Good to read that. I thought porteus was unchrootable from another installation.
Prendre son temps, profiter de celui qui passe.
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: Chroot to porteus
Digression slightly off topic
Followed all the links, brings back memories. With last gasp of hdd on old m/c, managed to dd installed kanotix system to usb stick. Bios could not boot from usb. Grub no good here, finally found kexec-loader, which booted off floppy and then be used to boot usb. Next complication was Kanotix initrd lacked usb kernel modules. Added plop rescue system to usb, booted plop then an exec chroot to Kanotix partition (in this instance pivot_root did not work), which got the entire system back, running off usb, but with plop kernel.
Finally with fully functioning system, could have sorted out the kernel modules. However there was no point anymore as the plop kernel was one of the latest, and had all necessary kernel modules. No immediate urgency to get new m/c. Could bide my time, and it was many moons later before the right opportunity showed up, 14 months to be precise.
Brand new computer without o/s offered at knock-down price. Presumably thinking was to draw people in with the price, and then when they found they could do nothing with the bare machine, they would then be sitting ducks for high pressure sale of win$oze etc. But with Linux it was a different story.
Followed all the links, brings back memories. With last gasp of hdd on old m/c, managed to dd installed kanotix system to usb stick. Bios could not boot from usb. Grub no good here, finally found kexec-loader, which booted off floppy and then be used to boot usb. Next complication was Kanotix initrd lacked usb kernel modules. Added plop rescue system to usb, booted plop then an exec chroot to Kanotix partition (in this instance pivot_root did not work), which got the entire system back, running off usb, but with plop kernel.
Finally with fully functioning system, could have sorted out the kernel modules. However there was no point anymore as the plop kernel was one of the latest, and had all necessary kernel modules. No immediate urgency to get new m/c. Could bide my time, and it was many moons later before the right opportunity showed up, 14 months to be precise.
Brand new computer without o/s offered at knock-down price. Presumably thinking was to draw people in with the price, and then when they found they could do nothing with the bare machine, they would then be sitting ducks for high pressure sale of win$oze etc. But with Linux it was a different story.
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
-
- Contributor
- Posts: 110
- Joined: 03 Feb 2020, 18:51
- Distribution: Porteus XFCE v5.0rc2 x86_64
- Location: Poland
Chroot to porteus
It's time to dig up this topic.
Some time ago I wrote script that chroots to Porteus, the same as currently running one or different; it's possible to activate and deactivate modules, and even chroot to PorteuX on Porteus. Only base modules are being activated by this script. Use at your own risk.
Some time ago I wrote script that chroots to Porteus, the same as currently running one or different; it's possible to activate and deactivate modules, and even chroot to PorteuX on Porteus. Only base modules are being activated by this script. Use at your own risk.
Code: Select all
#!/bin/bash
# porteus-chroot is a script that creates chroot environment of Porteus.
# This script requires AUFS support on running system.
# Use this script on your own risk.
# created by i3slkiller <https://gitlab.com/i3slkiller/porteus-chroot>
set -e
VERSION=1
unset CHROOTDIR
showHelp() {
echo "Usage: $0 [parameters] [porteus dir*]"
echo ""
echo "Arguments:"
echo " -h, --help show help"
echo " -c, --chroot path set chroot path (default: /tmp/chroot-RANDOM)"
echo " -s, --shared path share host directory with chroot (can be used multiple times)"
echo " -w, --sharedrw path share writable host directory with chroot (can be used multiple times)"
echo " -v, --version show script version"
echo ""
echo "* - porteus dir is optional on Porteus and derivatives, and required on other distros"
}
showVersion() {
echo "porteus-chroot version $VERSION <https://gitlab.com/i3slkiller/porteus-chroot>"
}
OPTS=hvc:s:w:
LONGOPTS=help,version,chroot:,shared:,sharedrw:
ARGS=$(getopt --options=$OPTS --longoptions=$LONGOPTS --name $0 -- $@)
[ $? != 0 ] && echo "Command arguments parsing error" && exit 126
eval set -- $ARGS
SHAREDDIRS=()
SHAREDDIRSRW=()
while true; do
case $1 in
-h|--help) showHelp; exit;;
-v|--version) showVersion; exit;;
-c|--chroot) CHROOTDIR="$2"; shift 2;;
-s|--shared) SHAREDDIRS+=("$2"); SHAREDDIRSRW+=(0); shift 2;;
-w|--sharedrw) SHAREDDIRS+=("$2"); SHAREDDIRSRW+=(1); shift 2;;
--) shift; break;;
*) echo "Unknown error"; exit 127;;
esac
done
[ $UID != 0 ] && echo "This script need to be executed as root" && exit 1
! grep -q aufs /proc/filesystems && echo "No AUFS support detected on this system" && exit 2
if [ -n "$1" ]; then
PORTXZMS="$1"
else
if [ -n "$PORTDIR" ]; then
PORTXZMS="$PORTDIR"
else
echo "Porteus dir must be set"
showHelp
exit 16
fi
fi
showVersion
if [ -z "$CHROOTDIR" ]; then
while true; do
CHROOTDIR="/tmp/chroot-$RANDOM"
[ ! -e "$CHROOTDIR" ] && break
done
fi
mkdir -p "$CHROOTDIR"
CHROOTDIRFS=$(find "$CHROOTDIR" -mindepth 0 -maxdepth 0 -type d -printf '%F')
[ $CHROOTDIRFS == aufs ] && mount -t tmpfs -o mode=0755 porteus-chroot "$CHROOTDIR"
pushd "$CHROOTDIR"
mkdir -p live/memory/{changes,images,xino}
mkdir -p live/porteus
mkdir -p live/tmp
mkdir -p host/porteus/{base,modules,optional}
mkdir -p union
mount -t aufs -o nowarn_perm,xino=live/memory/xino/.aufs.xino,br:live/memory/changes=rw aufs union
mkdir -p union/mnt/live union/mnt/host
mount -o bind live union/mnt/live
mount -o bind host union/mnt/host
echo "Loading Porteus from \"$PORTXZMS\""
mount -o ro,bind "$PORTXZMS/base" union/mnt/host/porteus/base
[ -d "$PORTXZMS/modules" ] && mount -o ro,bind "$PORTXZMS/modules" union/mnt/host/porteus/modules && ln -sf /mnt/host/porteus/modules union/mnt/live/porteus/modules
[ -d "$PORTXZMS/optional" ] && mount -o ro,bind "$PORTXZMS/optional" union/mnt/host/porteus/optional && ln -sf /mnt/host/porteus/optional union/mnt/live/porteus/optional
find union/mnt/host/porteus/base -type f -name "*.xzm" -printf "%f\n" | sort | xargs -i bash -c '
mkdir -p "union/mnt/live/memory/images/{}"
mount -o ro "union/mnt/host/porteus/base/{}" "union/mnt/live/memory/images/{}"
mount -o remount,add=1:union/mnt/live/memory/images/{}=rr union
echo "/mnt/host/porteus/base/{}" >> union/mnt/live/tmp/modules
'
mount -t proc proc union/proc
mount -t sysfs -o ro sysfs union/sys
cp /etc/resolv.conf union/etc/
for i in etc/profile root/.bashrc home/guest/.bashrc; do
! grep -q "PS1='(chroot)" union/$i && sed -i "s/PS1='/PS1='(chroot) /g" union/$i
done
CHROOTDISTRO=$(find union/etc/porteu? -mindepth 0 -maxdepth 0 -type d -printf '%f')
[ $CHROOTDISTRO == porteux ] && CHROOTDISTRONAME=PorteuX || CHROOTDISTRONAME=Porteus
echo "export DISTRO=$CHROOTDISTRO
export BOOTDEV=chroot
export BASEDIR=/mnt/host
export PORTDIR=/mnt/host/porteus
export MODDIR=/mnt/host/porteus/modules
export PORTCFG=/dev/null" > union/etc/profile.d/$CHROOTDISTRO.sh
chmod 755 union/etc/profile.d/$CHROOTDISTRO.sh
echo -e "nomagic\nbase_only\nnorootcopy" > union/etc/bootcmd.cfg
echo "# Booting device:
chroot
# $CHROOTDISTRONAME data found in:
/mnt/host/porteus
# Changes are stored in:
memory
# Non standard /rootcopy dir:
none
# Modules activated during boot time:
$(cat union/mnt/live/tmp/modules)
# Base module versions:
$(cat union/etc/$CHROOTDISTRO/*)" > union/var/log/$CHROOTDISTRO-livedbg
for (( i=0; i<${#SHAREDDIRS[*]}; i++ )); do
mkdir -p union/mnt/shared$i
if [ ${SHAREDDIRSRW[i]} == 1 ]; then
echo "Mounting \"${SHAREDDIRS[i]}\" to \"/mnt/shared$i\" as writable"
mount -o bind "${SHAREDDIRS[i]}" union/mnt/shared$i
else
echo "Mounting \"${SHAREDDIRS[i]}\" to \"/mnt/shared$i\" as read-only"
mount -o ro,bind "${SHAREDDIRS[i]}" union/mnt/shared$i
fi
done
chroot union /bin/bash
popd
umount -Rl "$CHROOTDIR/union"
[ $CHROOTDIRFS == aufs ] && umount "$CHROOTDIR" && rmdir "$CHROOTDIR"
- francois
- Contributor
- Posts: 6445
- Joined: 28 Dec 2010, 14:25
- Distribution: xfce plank porteus nemesis
- Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.
Chroot to porteus
Very interesting and useful.
Thanks.
Thanks.
Prendre son temps, profiter de celui qui passe.
Chroot to porteus
i3slkiller's script looks really useful for chrooting into Porteus. Thanks for sharing!