[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

Next revision
Previous revision
Next revisionBoth sides next revision
howtos:slackware_admin:how_to_chroot_from_media [2012/09/25 01:31 (UTC)] – moved from the howto namspace mfillpothowtos:slackware_admin:how_to_chroot_from_media [2015/06/25 13:10 (UTC)] – [Volume Preparation] Removed a useless dot after </code> didierspaier
Line 1: Line 1:
 <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). --> <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). -->
 ====== Chroot From Installation Media ====== ====== Chroot From Installation Media ======
-Slackware is full of tools that can help when the system becomes unstable and cannot boot. One exampleis upgrading the kernel image and forgetting to run lilo afterwards.+Slackware is full of tools that can help when the system becomes unstable and cannot boot. One example is upgrading the kernel image and forgetting to run lilo afterwards.
  
-In order to gain access to your system without booting directly to it, it is possible to use an installation media such as CD1 or the DVD. Once the installation media loads and starts, you can change the media's root directory into a mounted hard-disk partition and use it as the root directory, thus running commands directly from it and affecting it.+In order to gain access to your system without booting directly to it, it is possible to use an installation media such as Slackware CD1 or the DVD. Once the installation media loads and starts, you can change the media's root directory into a mounted hard-disk partition and use it as the root directory, thus running commands directly from it and affecting it.
  
-==== Volume preperation ==== +===== Volume Preparation ===== 
-<note important>The examples here are vary basic and expect that the entire system is located in a single partition. If you have a different partition table, please make sure that you mount all the needed partitions with care.</note>+<note important>The examples here are very basic and expect that the entire system is located in a single partition. If you have a different partition table, please make sure that you mount all the needed partitions with care.</note>
  
 In the simplest of examples, a single hard disk was partitioned locally, normally and it is not encrypted in any way. In this case, all you need to do is to make sure what is the partition's 'name' is and continue to the mounting section. In the simplest of examples, a single hard disk was partitioned locally, normally and it is not encrypted in any way. In this case, all you need to do is to make sure what is the partition's 'name' is and continue to the mounting section.
Line 12: Line 12:
 If this is not the case, and you are using LVM/EVMS or an encrypted volume you will need to prepare the volumes before you can mount and chroot into them: If this is not the case, and you are using LVM/EVMS or an encrypted volume you will need to prepare the volumes before you can mount and chroot into them:
  
-To unlock your LUKS partition, you will need to 'open' it and give it a name with this command (sdxn as example): ''cryptsetup luksOpen /dev/sdxn crypted'' (any name will do)At this point you will be prompted to insert the pass-phrase to unlock the volume. This partition will be mapped to '/dev/mapper/crypted'.+To unlock your LUKS partition, you will need to 'open' it and give it a name with this command (sdxn as example):  
 + 
 +<code>cryptsetup luksOpen /dev/sdxn crypted (any name will do)</code>  
 + 
 +At this point you will be prompted to insert the pass-phrase to unlock the volume. This partition will be mapped to '/dev/mapper/crypted'.
  
 For LVM volumes you need to make sure that the system can recognize and activate the volume. This is done by running the commands: For LVM volumes you need to make sure that the system can recognize and activate the volume. This is done by running the commands:
-  * ''vgscan --mknodes''    // : searches for logical volumes, this might take a while//+  * ''vgscan %%--%%mknodes''    // : searches for logical volumes, this might take a while//
   * ''vgchange -ay''    // : activates the found volumes//\\   * ''vgchange -ay''    // : activates the found volumes//\\
   * If more than one group was found, you can select which one to activate with ''vgchange -ay groupName''   * If more than one group was found, you can select which one to activate with ''vgchange -ay groupName''
  
-==== Volume mounting ====+===== Volume Mounting =====
 After the preparation stage we can continue to mount the volume(s). You can use ''/mnt'' as it is only needed if you are planning to run the setup program. After the preparation stage we can continue to mount the volume(s). You can use ''/mnt'' as it is only needed if you are planning to run the setup program.
      
 After we make sure which partitions are needed, we need to mount them:   After we make sure which partitions are needed, we need to mount them:  
-   
-  mount /dev/<location> /mnt 
  
-Next, we need to prepare three virtual directories to be used by the environment. Those are ''/dev'' a directory with virtual files that represent hardware devices, ''/proc'' a directory with virtual files that represent processes and ''/sys'' which contains the kernel and other system files: +<code>mount /dev/<location> /mnt</code> 
-   +Here are 3 common examples.  
-  mount -o bind /dev /mnt/dev + 
-  mount -o bind /proc /mnt/proc +1. The first is just a simple installation with everything installed under / mounted under /dev/sda1. No LVM or additional drives. 
-  mount -o bind /sys /mnt/sys+ 
 +<code>mount /dev/sda1 /mnt</code> 
 + 
 +2. In the next example we have two drives. The user has set up his or her Slackware system to use /dev/sdb1 for /home and /dev/sda1 for everything else. 
 + 
 +<code>mkdir /mnt/home # We need a directory to mount which needs to be under the directory we intend to chroot into. 
 +mount /dev/sda1 /mnt 
 +mount /dev/sdb1 /mnt/home</code> 
 + 
 +3. For the third example the user has used LVM and has already made their volume group known to the kernel. The user is using the logical volumes "root, usr, home, opt, var, srv" all under one volume group labeled "myvg". In addition, this user has used LUKS encryption and therefore has placed a small /boot under /dev/sda1. 
 + 
 +<code>mkdir /mnt/{boot,usr,home,opt,var,srv} # Create the necessary directories. 
 +mount /dev/sda1 /mnt/boot 
 +mount /dev/myvg/root /mnt 
 +mount /dev/myvg/usr /mnt/usr 
 +mount /dev/myvg/home /mnt/home 
 +mount /dev/myvg/opt /mnt/opt 
 +mount /dev/myvg/var /mnt/var 
 +mount /dev/myvg/srv /mnt/srv</code> 
 + 
 +We could have also used a for loop for everything except /boot (/dev/sda1) and / (/dev/myvg/root) in this example: 
 +<code>for dir in usr home opt var srv 
 +do 
 +  mount /dev/myvg/$dir /mnt/$dir 
 +done 
 +</code> 
 + 
 +Next, we need to prepare three virtual directories to be used by the environment. Those are ''/dev''a directory with virtual files that represent hardware devices, ''/proc''a directory with virtual files that represent processes and ''/sys'' which contains the kernel and other system files: 
 + 
 +<code>mount -o bind /dev /mnt/dev 
 +mount -o bind /proc /mnt/proc 
 +mount -o bind /sys /mnt/sys</code>
  
-==== Chrooting ===+===== Chrooting =====
 Once the partition is mounted, we can chroot to it: Once the partition is mounted, we can chroot to it:
      
-  chroot /mnt /bin/bash+<code>chroot /mnt /bin/bash</code>
      
-<note important>If LVM preperation was involved it might be necessary to re-run ''vgscan --mknodes'' and ''vgchange -ay'' as they were created inside the installation media'ramdisc and not in the mounted partition.</note>+<note important>If LVM preparation was involved it might be necessary to re-run ''vgscan %%--%%mknodes'' and ''vgchange -ay'' as they were created inside the installation media'ramdisk and not in the mounted partition.</note>
      
 The bash prompt that you see here is a bash prompt started on your system. You can now work on this environment naturally. For example editing ''/etc/lilo.conf'' and executing ''/sbin/lilo'' will happen on your system, not from the installation media. The bash prompt that you see here is a bash prompt started on your system. You can now work on this environment naturally. For example editing ''/etc/lilo.conf'' and executing ''/sbin/lilo'' will happen on your system, not from the installation media.
Line 50: Line 83:
 <!-- Please do not modify anything below, except adding new tags.--> <!-- Please do not modify anything below, except adding new tags.-->
 <!-- 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 slackware_administration chroot recovery author_cmyster}}
 howtos:slackware_admin:how_to_chroot_from_media ()