Version 1 vs 2
Version 1 vs 2
Content Changes
Content Changes
I often want to mount a system in a chroot; I often forget all the specifics, and just end up Googling them to try and make sure I don't forget anything.
```
lang=bash
# First, mount the system as, say
sudo mount /dev/sda4 /mnt
# Then these are the bits from your running Linux system you need to mount into the chroot
mount -t proc proc /mnt/proc/
mount -t sysfs sys /mnt/sys/
mount -o bind /tmp /mnt/tmp/
mount -o bind /dev /mnt/dev/
```
Or a more elegant and complete approach:
```
lang=bash
sudo mount /dev/sda1 /mnt
for name in proc sys dev; do sudo mount --bind /$name /mnt/$name; done
sudo mount --bind /etc/resolv.conf /mnt/etc/resolv.conf
sudo chroot /mnt/ /bin/bash
```
External documentation:
* https://wiki.debian.org/RescueLive
I often want to mount a system in a chroot; I often forget all the specifics, and just end up Googling them to try and make sure I don't forget anything.
```
lang=bash
# First, mount the system as, say
sudo mount /dev/sda4 /mnt
# Then these are the bits from your running Linux system you need to mount into the chroot
mount -t proc proc /mnt/proc/
mount -t sysfs sys /mnt/sys/
mount -o bind /tmp /mnt/tmp/
mount -o bind /dev /mnt/dev/
```
Or a more complete approach:
```
lang=bash
# Mount the partition in question
sudo mount /dev/sda1 /mnt
# Mount the main shared system stuff
for name in proc sys dev; do sudo mount --bind /$name /mnt/$name; done
# Mount the resolv config for network resolution
sudo mount --bind /etc/resolv.conf /mnt/etc/resolv.conf
# Mount /dev/pts since it often complains if not
sudo mount --bind /dev/pts /mnt/dev/pts
# Explicitly chroot to a /bin/bash shell, because surely bash is there!
sudo chroot /mnt/ /bin/bash
```
External documentation:
* https://wiki.debian.org/RescueLive
I often want to mount a system in a chroot; I often forget all the specifics, and just end up Googling them to try and make sure I don't forget anything.
```
lang=bash
# First, mount the system as, say
sudo mount /dev/sda4 /mnt
# Then these are the bits from your running Linux system you need to mount into the chroot
mount -t proc proc /mnt/proc/
mount -t sysfs sys /mnt/sys/
mount -o bind /tmp /mnt/tmp/
mount -o bind /dev /mnt/dev/
```
Or a more elegant and complete approach:
```
lang=bash
# Mount the partition in question
sudo mount /dev/sda1 /mnt
# Mount the main shared system stuff
for name in proc sys dev; do sudo mount --bind /$name /mnt/$name; done
# Mount the resolv config for network resolution
sudo mount --bind /etc/resolv.conf /mnt/etc/resolv.conf
# Mount /dev/pts since it often complains if not
sudo mount --bind /dev/pts /mnt/dev/pts
# Explicitly chroot to a /bin/bash shell, because surely bash is there!
sudo chroot /mnt/ /bin/bash
```
External documentation:
* https://wiki.debian.org/RescueLive