[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howtos:general_admin:setting_up_a_slackware_chroot [2015/03/23 05:10 (UTC)] – /* update and add notes */ aadityahowtos:general_admin:setting_up_a_slackware_chroot [2020/11/16 12:54 (UTC)] (current) – [See also] fix formatting aaditya
Line 1: Line 1:
-**Goal:** I wanted to setup a Slackware chroot in order to build 32 bit packages on my 64 bit system.+===== Setting up a Slackware chroot =====
  
-== Obtaining a Slackware installation of your desired architecture ==+There are multiple reasons why you might want to set up a Slackware chroot: 
 +  * building 32-bit packages on a 64-bit multilib system 
 +  * building -stable packages on a -current system 
 +  * building (and testing) packages for SBo on a clean system
  
-For a 32 bit chroot I downloaded installation disks 1 and 2 from http://www.slackware.com/getslack/ via torrent.+For this guide, we'll create a chroot at **/chroot_folder** from **slackware-14.1-install-dvd.iso**.
  
-== Installing the packages ==+==== Obtaining a Slackware installation of your desired architecture ====
  
-Create folder which will contain the chroot.+Start with Slackware installation DVD. Download it from from http://www.slackware.com/getslack/ via torrent.
  
-Mount the installation ISO(s). After they have been mounted the packages in them (found under the //slackware// folder) can be installed to the chroot folder with:+==== Installing the packages ====
  
-''installpkg --root /<chroot-target> a/*.t?z ap/*.t?z l/*.t?z n/*.t?z''+=== Automatically ===
  
-''installpkg --root /<chroot-target> d/*.t?z k/*.t?z t/*.t?z tcl/*.t?z''+You can create your chroot and install Slackware into it using the following elegant script: [[http://tty1.uk/scripts/slackware/mkchroot]]
  
-(additional sets can be installed in a similar way)+=== Manually ===
  
-== Chroot ==+First, create a folder which will contain the chroot:
  
-After the chroot folder has been populated with packages we can proceed to chroot into it ([[howtos:slackware_admin:how_to_chroot_from_media#volume_mounting]]).+<code bash>mkdir /chroot_folder</code> 
 + 
 +Mount the installation ISO: 
 + 
 +<code bash> 
 +mount -o loop slackware-14.1-install-dvd.iso /mnt/cdrom 
 +cd /mnt/cdrom 
 +</code> 
 + 
 +After the ISO has been mounted, the packages (found under the //slackware// or //slackware64// folder) can be installed to the chroot folder with: 
 + 
 +<code bash> 
 +installpkg --root /chroot-folder */*.t?z 
 +</code> 
 + 
 +Then unmount the ISO: 
 + 
 +<code bash> 
 +umount /mnt/cdrom 
 +</code> 
 + 
 +=== Setting up required files === 
 + 
 +== fstab == 
 + 
 +The following minimal snippet can be used for ///chroot_folder/etc/fstab// 
 + 
 +<file> 
 +# <file system> <mount point>   <type>  <options>       <dump>  <pass> 
 +tmpfs           /dev/shm        tmpfs    defaults        0      0 
 +devpts          /dev/pts        devpts   noexec,nosuid,gid=tty,mode=0620  0      0 
 +sysfs           /sys            sysfs    defaults        0      0 
 +proc            /proc           proc     defaults        0      0 
 +</file> 
 + 
 +==== Entering the Chroot ==== 
 + 
 +=== Automatic mount === 
 + 
 +To have the chroot mounted permanently, add the following to your __host system's__ ///etc/fstab//: 
 + 
 +<file> 
 +/dev             chroot_folder/dev             none bind,auto 0 0 
 +/proc            chroot_folder/proc            none bind,auto 0 0 
 +/sys             chroot_folder/sys             none bind,auto 0 0 
 +/etc/resolv.conf chroot_folder/etc/resolv.conf none bind,auto 0 0 
 +</file> 
 + 
 +And reboot. Then run the following command to mount the chroot folder: 
 + 
 +<code bash> 
 +mount /chroot_folder 
 +</code> 
 + 
 +=== Manual mount === 
 + 
 +Refer to: ([[howtos:slackware_admin:how_to_chroot_from_media#volume_mounting]]). 
 + 
 +=== Entering the Chroot === 
 + 
 +Now that the chroot is set up, one can chroot into it: 
 + 
 +<code bash>chroot /chroot_folder /bin/bash</code> 
 + 
 +**Note** 
 + 
 +Wrote a small script to automate the chroot steps. 
 + 
 +https://raw.githubusercontent.com/aadityabagga/scripts/master/chroot.sh
  
 === Updating packages === === Updating packages ===
  
-After that I setup slackpkg and updated the packages ([[slackware:beginners_guide#configure_a_package_manager]]).+After that, you can run slackpkg and update the packages([[slackware:beginners_guide#configure_a_package_manager]]). 
 + 
 +=== Exiting === 
 + 
 +When you're done, exited the chroot by pressing //Ctrl+d//
 + 
 +==== Usecase: Building 32-bit Packages ====
  
 === Mounting partitions === === Mounting partitions ===
  
-I needed to mount the partition which contained the SlackBuilds for which I wanted to make a package, I used the command:+I use a chroot to build 32-bit packages on a 64-bit system. I needed to mount the partition which contained the SlackBuilds for which I wanted to make a package, As my Slackware host mount point is (in this example) at /slackware_host_mount_point, I used the command:
  
-''mount -B /<slackware-host-mount-point> /<chroot-mount-point>''+<code bash>mount -B /slackware_host_mount_point /chroot_folder 
 +</code>
  
 (http://www.thegeekstuff.com/2013/01/mount-umount-examples/) (http://www.thegeekstuff.com/2013/01/mount-umount-examples/)
Line 35: Line 113:
 Then I built the package by executing the Slackbuild as follows: Then I built the package by executing the Slackbuild as follows:
  
-''ARCH=i686 ./<my-package>.SlackBuild''+<code bash> 
 +ARCH=i686 ./my_package.SlackBuild</code>
  
-=== Exit and unmounting ===+=== An alternative way to build other ARCH packages ===
  
-Finally I exited the chroot by pressing //Ctrl+d//, and unmounted the mount points I had mounted earlier.+Instead of using `ARCH=i686' before running a slackbuildwe can use a program 
 +called `setarch', which, among other things, can set the ARCH and the kernel 
 +version in the shell.  It has some handy symlinks, such as linux32 or i586, 
 +which saves some typing.  The `linux32' command will set the reported kernel'
 +ARCH as `i686'.
  
-== Links ==+**SYNOPSIS** 
 +<code> 
 +  setarch arch [options] [program [argument...]] 
 +</code>
  
-http://www.linuxquestions.org/questions/slackware-installation-40/install-slackware-to-a-folder-using-chroot-825598-print/+When we run `linux32' it starts new shell, so we can also use it to chroot:
  
-== Notes ==+<code> 
 +  chroot /path/to/chroot linux32 /bin/zsh 
 +</code>
  
-Wrote a small script to automate these steps.+or it could be run after chrooting into our new root.  Settings will revert to 
 +normal when we exit the new shell One useful option is to change the kernel'
 +reported version:
  
-https://raw.githubusercontent.com/aadityabagga/scripts/master/chroot.sh+<code> 
 +  chroot /path/to/chroot linux32 --uname-2.6 /bin/zsh 
 +</code> 
 + 
 +That `--uname-2.6' isn't a typo, there has to be a dash between the flag and 
 +the version.  The setarch(8) man page shows all the options. 
 + 
 +-- 
 +Dave 
 + 
 +====== See also ====== 
 + 
 +  * https://wiki.archlinux.org/index.php/Chroot 
 +  * http://www.linuxquestions.org/questions/slackware-installation-40/install-slackware-to-a-folder-using-chroot-825598/#post4093831
  
 ====== Sources ====== ====== Sources ======
Line 55: Line 158:
 <!-- * Original source: [[http://some.website.org/some/page.html]] --> <!-- * Original source: [[http://some.website.org/some/page.html]] -->
 <!-- Authors are allowed to give credit to themselves! --> <!-- Authors are allowed to give credit to themselves! -->
-<!-- * Originally written by [[wiki:user:xxx User X]] -->+* Originally written by [[wiki:user:aaditya Aaditya]]
 <!-- * Contributions by [[wiki:user:yyy | User Y]] --> <!-- * Contributions by [[wiki:user:yyy | User Y]] -->
  
Line 61: Line 164:
 <!-- You must remove the tag-word "template" below before saving your new page --> <!-- You must remove the tag-word "template" below before saving your new page -->
 {{tag>howtos}} {{tag>howtos}}
 +
 howtos:general_admin:setting_up_a_slackware_chroot ()