LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-01-2023, 05:31 AM   #1
dchmelik
Senior Member
 
Registered: Nov 2008
Location: USA
Distribution: Slackware, FreeBSD, Illumos, NetBSD, DragonflyBSD, Plan9, Inferno, OpenBSD, FreeDOS, HURD
Posts: 1,067

Rep: Reputation: 147Reputation: 147
Question virtualization/chroot of other OSs/GNU/Linuxes


Lately I setup several other GNU/Linux partitions and chroot into them from Slackware, just to know about those, as I administer some others for users (on other PCs) and in future might work as a computer programmer and/or system administrator and use some others. I also have NetBSD & FreeBSD & DragonFlyBSD UNIXes on partitions and setup reading (not writing, unstable) those (except doesn't work with DragonFlyBSD FFS/UFS) so I don't always have to reboot if I want to save files from one. If something goes wrong with Slackware and I can't fix it right away, sometimes I boot FreeBSD (same /home on ZFS). SlackBuilds.org (SBo) has a SlackBuild for debootstrap which people use to install Debian in a chroot. I used to use Debian in late 1990s and early '0s so would rather try Devuan... their installer didn't work for me, eventually always showing disorganized mess of lines on an AMD Radeon RX 6900 XT regardless of monitor (I think everything newer than FreeBSD has problems with the exception of OpenBSD).
        Ones I tried so far are KDE Neon GNU/Linux & GNU/Linux Mint (what a mess! I administer the former for users and used to administer the latter) and in the past some similar miscellaneous ones, and Gentoo GNU/Linux, all which chroot fine even to use network and update those OS... however after successfully installing Fedora and openSUSE (what a mess!) and running bash on them, then rebooting into Slackware (and similarly mounting /dev, /proc, /sys in a way which works for all others) the following happens.

Code:
root@cosmos:~# chroot /fedora
chroot: failed to run command ‘/bin/bash’: Permission denied
root@cosmos:~# chroot /suse
chroot: failed to run command ‘/bin/bash’: Permission denied
Perhaps the question is more suited to their forums, but what could be the cause of this? I wonder if it has to do with whether they use SELinux or this depends on 'running some service (systemd)', etc.
        If this works with debootstrap I'd just like to see it eventually work with all major GNU/Linux. Chroot is good for command-line stuff but can be hard to configure X to work right, for which people suggested using virtual machines (VMs) which I'd like to learn how to use these partitions for those in (A)QEMU. In the past I used Xen (it'd be nice to do similar with *BSD and be able to switch there from Slackware) but it was difficult to keep updated and I don't know you could run X sessions in that unless they were separate (unlike Qubes which uses Xen to run programs from each OS in one X session but is extremely security-focused (for activists, etc.) to a point it can be impractical for average people who don't need that to an extreme level, like doesn't let you use network in 'DOM0').

Last edited by dchmelik; 06-01-2023 at 06:21 AM.
 
Old 06-01-2023, 05:47 AM   #2
nobodino
Senior Member
 
Registered: Jul 2010
Location: Near Bordeaux in France
Distribution: slackware, slackware from scratch, LFS, slackware [arm], linux Mint...
Posts: 1,564

Rep: Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892
I can help you with I do with SFS:

Code:
# mkidir /mnt/sfs
# mount -t auto /dev/sda2 /mnt/sfs
# export SFS=/mnt/sfs
#  echo $SFS
# cd /mnt
copy the 2 following scripts under /mnt

Code:
#!/bin/bash
mount -v --bind /dev "$SFS"/dev
mount -vt devpts devpts "$SFS"/dev/pts -o gid=5,mode=620
mount -vt proc proc "$SFS"/proc
mount -vt sysfs sysfs "$SFS"/sys
mount -vt tmpfs tmpfs "$SFS"/run
if [ -h "$SFS"/dev/shm ]; then
  mkdir -pv "$SFS"/"$(readlink "$SFS"/dev/shm)"
fi
Code:
#!/bin/sh
chroot "$SFS" /usr/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login
then execute them:

Code:
# chmod +x *.sh
# ./mount-sfs
# ./chroot1
And here you are in the chrooted environnement.

I just tried it with linux-mint now.

Last edited by nobodino; 06-01-2023 at 05:48 AM.
 
Old 06-01-2023, 06:02 AM   #3
dchmelik
Senior Member
 
Registered: Nov 2008
Location: USA
Distribution: Slackware, FreeBSD, Illumos, NetBSD, DragonflyBSD, Plan9, Inferno, OpenBSD, FreeDOS, HURD
Posts: 1,067

Original Poster
Rep: Reputation: 147Reputation: 147
Thumbs up answered my own question

I prefer to mount as I've learned with Slackware, which is usually with '-o bind', not '-vt', which I don't recall what that does differently, but I read some OS need a 'remount' line as shown in what I use below... I'd just forgotten to try the remount line with openSUSE, Fedora but now did and they now chroot fine.

Code:
mount -o bind /dev /neon/dev                                                                                                                  
mount -o bind /proc /neon/proc                                                                                                                
mount -o bind /sys /neon/sys                                                                                                                  
mount -o remount,dev,exec /neon                                                                                                               
mount -o bind /dev /mint/dev                                                                                                                  
mount -o bind /proc /mint/proc                                                                                                                
mount -o bind /sys /mint/sys                                                                                                                  
mount -o remount,dev,exec /mint                                                                                                               
mount -o bind /dev /fedora/dev                                                                                                                
mount -o bind /proc /fedora/proc                                                                                                              
mount -o bind /sys /fedora/sys                                                                                                                
mount -o remount,dev,exec /fedora                                                                                                             
mount -o bind /dev /suse/dev                                                                                                                  
mount -o bind /proc /suse/proc                                                                                                                
mount -o bind /sys /suse/sys                                                                                                                  
mount -o remount,dev,exec /suse                                                                                                               
mount -o bind /dev /gentoo/dev                                                                                                                
mount -o bind /proc /gentoo/proc                                                                                                              
mount -o bind /sys /gentoo/sys                                                                                                                
mount -o remount,dev,exec /gentoo
I'm not marking this solved without some more discussion of how to run X (or Wayland) in some of these, preferably with chroot, optionally with Xen, and least preferably (but acceptable) with virtual machines (VM) using these installations on their partitions... I want it done one of these ways to make copying easier when I'm not using them. VM is least preferable because you have to press buttons to get the mouse back out.
 
Old 06-04-2023, 08:01 PM   #4
notzed
Member
 
Registered: Dec 2020
Location: South Australia
Distribution: slackware64-current
Posts: 95

Rep: Reputation: Disabled
This is the script I use for a chroot gentoo that I use to build the packages for a slower system. I only really run emerge from it though.

Code:
#!/bin/sh
mount /dev/nvme1n1p2 /mnt/gentoo
mount /dev/nvme1n1p1 /mnt/gentoo/boot

pushd /mnt/gentoo

mount --types proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --bind /run /mnt/gentoo/run

echo "Enter chroot environment"
unshare -u chroot /mnt/gentoo /bin/bash

echo "Back home"
popd
umount -l /mnt/gentoo/dev{/shm,/pts,}
umount -R /mnt/gentoo
 
1 members found this post helpful.
Old 06-12-2023, 08:10 PM   #5
dchmelik
Senior Member
 
Registered: Nov 2008
Location: USA
Distribution: Slackware, FreeBSD, Illumos, NetBSD, DragonflyBSD, Plan9, Inferno, OpenBSD, FreeDOS, HURD
Posts: 1,067

Original Poster
Rep: Reputation: 147Reputation: 147
Question

Quote:
Originally Posted by notzed View Post
This is the script I use for a chroot gentoo that I use to build the packages for a slower system. I only really run emerge from it though. [...]
That is interesting. What's the purpose of other mount arguments/flags/switches than ones given on docs.slackware.com; do they work better?
 
Old 06-13-2023, 12:05 AM   #6
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,461
Blog Entries: 7

Rep: Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561
Something else you might consider:

Code:
tail -n +6 /var/lib/pkgtools/packages/lxc* | head -n 11
There has been a ton of development in that space over the past 10-odd years.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Chrooting just a process in a C++ on Linux littleplane Programming 4 04-18-2012 11:21 AM
[SOLVED] Chrooting a Linux distro inside another bulls_i3 Linux - Virtualization and Cloud 3 10-28-2010 03:51 AM
LXer: Chrooting into a Linux environment LXer Syndicated Linux News 0 06-29-2008 09:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration