[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
Last revisionBoth sides next revision
howtos:general_admin:setting_up_a_slackware_chroot [2015/10/29 06:44 (UTC)] – Added fstab section. duganhowtos:general_admin:setting_up_a_slackware_chroot [2020/11/16 12:52 (UTC)] – fixup formatting and contents aaditya
Line 1: Line 1:
-==== Setting up a Slackware chroot ====+===== Setting up a Slackware chroot =====
  
 There are multiple reasons why you might want to set up a Slackware chroot: There are multiple reasons why you might want to set up a Slackware chroot:
Line 8: Line 8:
 For this guide, we'll create a chroot at **/chroot_folder** from **slackware-14.1-install-dvd.iso**. For this guide, we'll create a chroot at **/chroot_folder** from **slackware-14.1-install-dvd.iso**.
  
-=== Obtaining a Slackware installation of your desired architecture ===+==== Obtaining a Slackware installation of your desired architecture ====
  
 Start with a Slackware installation DVD. Download it from from http://www.slackware.com/getslack/ via torrent. Start with a Slackware installation DVD. Download it from from http://www.slackware.com/getslack/ via torrent.
  
-=== Installing the packages ===+==== Installing the packages ====
  
-== Automatically ==+=== Automatically ===
  
-You can create your chroot and install Slackware into it using the following elegant script: [[http://dawoodfall.net/files/scripts/bash/mkchroot]]+You can create your chroot and install Slackware into it using the following elegant script: [[http://tty1.uk/scripts/slackware/mkchroot]]
  
-== Manually ==+=== Manually ===
  
 First, create a folder which will contain the chroot: First, create a folder which will contain the chroot:
Line 43: Line 43:
 </code> </code>
  
-=== Mounting the Chroot ===+=== Setting up required files ===
  
-To have the chroot mounted permanently, add the following to your fstab:+== 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> <file>
-/dev             chroot_folder/dev             none bind,auto +/dev             chroot_folder/dev             none bind,auto 0 0 
-/proc            chroot_folder/proc            none bind,auto +/proc            chroot_folder/proc            none bind,auto 0 0 
-/sys             chroot_folder/sys             none bind,auto +/sys             chroot_folder/sys             none bind,auto 0 0 
-/etc/resolv.conf chroot_folder/etc/resolv.conf none bind,auto+/etc/resolv.conf chroot_folder/etc/resolv.conf none bind,auto 0 0
 </file> </file>
  
-If you don't want to reboot at this point, then you can mount the chroot manually:+And reboot. Then run the following command to mount the chroot folder:
  
 <code bash> <code bash>
Line 60: Line 76:
 </code> </code>
  
-Also, refer to: ([[howtos:slackware_admin:how_to_chroot_from_media#volume_mounting]]).+=== Manual mount ===
  
-=== Chrooting into the Chroot ===+Refer to: ([[howtos:slackware_admin:how_to_chroot_from_media#volume_mounting]]).
  
-Now that the chroot is set up, you can chroot into it:+=== Entering the Chroot === 
 + 
 +Now that the chroot is set up, one can chroot into it:
  
 <code bash>chroot /chroot_folder /bin/bash</code> <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 ===
Line 76: Line 100:
 When you're done, exited the chroot by pressing //Ctrl+d//. When you're done, exited the chroot by pressing //Ctrl+d//.
  
-=== One Use: Building 32-bit Packages ===+==== Usecase: Building 32-bit Packages ====
  
-== Mounting partitions ==+=== Mounting partitions ===
  
 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: 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:
Line 92: Line 116:
 ARCH=i686 ./my_package.SlackBuild</code> ARCH=i686 ./my_package.SlackBuild</code>
  
-=== Links ===+=== An alternative way to build other ARCH packages ===
  
-http://www.linuxquestions.org/questions/slackware-installation-40/install-slackware-to-a-folder-using-chroot-825598/#post4093831+Instead of using `ARCH=i686' before running a slackbuild, we 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'.
  
-== Notes ==+**SYNOPSIS** 
 +<code> 
 +  setarch arch [options] [program [argument...]] 
 +</code>
  
-Wrote small script to automate these steps.+When we run `linux32' it starts new shell, so we can also use it to chroot:
  
-https://raw.githubusercontent.com/aadityabagga/scripts/master/chroot.sh+<code> 
 +  chroot /path/to/chroot linux32 /bin/zsh 
 +</code> 
 + 
 +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: 
 + 
 +<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 112: 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 ()