Compare commits

..

No commits in common. "fd82804710f7bbe88e83fb7dcb5a22cb21a1c365" and "75891d0d4efe1593d095157b2edbf961e0e94664" have entirely different histories.

3 changed files with 8 additions and 36 deletions

View file

@ -1,38 +1,10 @@
# Alpine Chroot # Alpine Chroot
### Installation
To create a base alpine chroot on any alpine system, run: To create a base alpine chroot on any alpine system, run:
```sh ```sh
chmod +x *.sh chmod +x *.sh
./alpine_init.sh ./alpine_init.sh
``` ```
But this is assuming your current working directory is the directory of the
cloned repository.
When it is your first time in the chroot, run: Assuming your current working directory is the directory of the cloned repository.
```sh
./chroot_init.sh
```
### Usage
Most people will go "into" the chroot via:
```sh
chroot /mnt/chroot sh
```
But you must remember that you can just as well run any program in the chroot
as:
```sh
chroot /mnt/chroot <program>
```
Because **chroots are not jails, containers, or sandboxes**. They simply change
what the system sees as the "root" point of the file system.

View file

@ -7,8 +7,7 @@ mv repositories /etc/apk/repositories
# setting the mirror # setting the mirror
apk add curl apk add curl
curl -LO http://nl.alpinelinux.org/alpine/MIRRORS.txt curl -LO http://nl.alpinelinux.org/alpine/MIRRORS.txt
repo_domain=`head -n 1 /etc/apk/repositories | sed -e "s/.*\/\///" | sed -e "s/\//\ /" | awk '{print $1}'` mirror=`grep $(head -n 1 /etc/apk/repositories) | sed -e "s/.*\/\///" | sed -e "s/\//\ /" | awk '{print $1}') MIRRORS.txt`
mirror=`grep $repo_domain MIRRORS.txt`
rm MIRRORS.txt rm MIRRORS.txt
# setting the chroot dir # setting the chroot dir
@ -20,10 +19,9 @@ arch=$(uname -m)
# set up apk # set up apk
version="2.12.7-r0" version="edge"
curl -LO ${mirror}/latest-stable/main/${arch}/apk-tools-static-${version}.apk curl -LO ${mirror}/latest-stable/main/${arch}/apk-tools-static-${version}.apk
tar -xzf apk-tools-static-*.apk tar -xzf apk-tools-static-*.apk
rm apk-tools-static-*.apk
# install the alpine base installation onto the chroot # install the alpine base installation onto the chroot
./sbin/apk.static -X ${mirror}/latest-stable/main -U --allow-untrusted -p ${chroot_dir} --initdb add alpine-base ./sbin/apk.static -X ${mirror}/latest-stable/main -U --allow-untrusted -p ${chroot_dir} --initdb add alpine-base
@ -37,9 +35,8 @@ mount -o bind /sys ${chroot_dir}/sys
cp -L /etc/resolv.conf ${chroot_dir}/etc/ cp -L /etc/resolv.conf ${chroot_dir}/etc/
# prepare the APK repositories # prepare the APK repositories
branch="edge" # change if you want a specific version branch=$version # change if you want a specific version
mkdir -p ${chroot_dir}/etc/apk mkdir -p ${chroot_dir}/etc/apk
echo "${mirror}/${branch}/main" > ${chroot_dir}/etc/apk/repositories echo "${mirror}/${branch}/main" > ${chroot_dir}/etc/apk/repositories
cp chroot_init.sh ${chroot_dir}/chroot_init.sh chroot ${chroot_dir} chroot_init.sh
chroot ${chroot_dir} sh

View file

@ -13,3 +13,6 @@ rc-update add syslog boot
rc-update add mount-ro shutdown rc-update add mount-ro shutdown
rc-update add killprocs shutdown rc-update add killprocs shutdown
rc-update add savecache shutdown rc-update add savecache shutdown
# login shell
sh -l