forked from pythops/jetson-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-rootfs.sh
executable file
·57 lines (45 loc) · 1.36 KB
/
create-rootfs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/bash
#
# Author: Badr BADRI © pythops
#
set -e
ARCH=arm64
RELEASE=focal
# Check if the user is not root
if [ "x$(whoami)" != "xroot" ]; then
printf "\e[31mThis script requires root privilege\e[0m\n"
exit 1
fi
# Check for env variables
if [ ! $JETSON_ROOTFS_DIR ]; then
printf "\e[31mYou need to set the env variable \$JETSON_ROOTFS_DIR\e[0m\n"
exit 1
fi
# Install prerequisites packages
printf "\e[32mInstall the dependencies... "
apt-get update > /dev/null
apt-get install --no-install-recommends -y qemu-user-static debootstrap binfmt-support coreutils parted wget gdisk e2fsprogs libxml2-utils > /dev/null
printf "[OK]\n"
# Create rootfs directory
printf "Create rootfs directory... "
mkdir -p $JETSON_ROOTFS_DIR
printf "[OK]\n"
# Run debootstrap first stage
printf "Run debootstrap first stage... "
debootstrap \
--arch=$ARCH \
--foreign \
--variant=minbase \
--include=python3,python3-apt \
$RELEASE \
$JETSON_ROOTFS_DIR > /dev/null
printf "[OK]\n"
cat <<EOF > $JETSON_ROOTFS_DIR/etc/resolv.conf
nameserver 1.1.1.1
EOF
cp /usr/bin/qemu-aarch64-static $JETSON_ROOTFS_DIR/usr/bin
# Run debootstrap second stage
printf "Run debootstrap second stage... "
chroot $JETSON_ROOTFS_DIR /bin/bash -c "/debootstrap/debootstrap --second-stage" > /dev/null
printf "[OK]\n"
printf "The rootfs has been created successfully.\n"