You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rascul cb1e1841b4
remove unnecessary semicolon
1 year ago
src remove unnecessary semicolon 1 year ago
.editorconfig editorconfig 5 years ago
.gitignore gitignore 5 years ago add contributing 5 years ago
COPYING mit license 5 years ago
Cargo.lock cargo 5 years ago
Cargo.toml cargo 5 years ago linux only 5 years ago skel directory support added with --skel option 5 years ago rustfmt shell script 4 years ago
rustfmt.toml rustfmt 5 years ago

build a minimal chroot/container/vm filesystem by taking a list of files and putting them and their necessary libs into a target rootfs directory

this is linux only


rascul@coyote:~/mkroot$ cargo run -- -h
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/mkroot -h`
mkroot 0.1.0
rascul <>

    mkroot [FLAGS] [OPTIONS] <DIR> <FILES>...

    -h, --help       Prints help information
    -V, --version    Prints version information
    -v, --verbose    Verbose

        --ldd <LDD>                Path to LDD [default: /usr/bin/ldd]
        --osname <OSNAME>          OS name (for /etc/os-release) [default: mkroot]
        --osversion <OSVERSION>    OS version (for /etc/os-release) [default: 1.0]

    <DIR>         Directory for root filesystem
    <FILES>...    Files to parse

rascul@coyote:~/mkroot$ cargo run -- -v rootfs /bin/bash /usr/bin/tree
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/mkroot -v rootfs /bin/bash /usr/bin/tree`
Building root fs for ["/bin/bash", "/usr/bin/tree"] in rootfs
Checking /bin/bash
Adding /lib64/
Adding /lib64/
Adding /lib64/
Adding /lib64/
Adding /lib64/
Checking /usr/bin/tree
Adding /lib64/
Adding /lib64/
Creating directory rootfs
Creating directory rootfs/bin
Creating directory rootfs/dev
Creating directory rootfs/etc
Creating directory rootfs/home
Creating directory rootfs/lib
Creating directory rootfs/lib64
Creating directory rootfs/proc
Creating directory rootfs/root
Creating directory rootfs/run
Creating directory rootfs/sbin
Creating directory rootfs/sys
Creating directory rootfs/tmp
Creating directory rootfs/usr
Creating directory rootfs/var
Creating directory rootfs/usr/bin
Copying /bin/bash to rootfs/bin/bash
Copying /usr/bin/tree to rootfs/bin/tree
Copying /lib64/ to rootfs/lib64/
Copying /lib64/ to rootfs/lib64/
Copying /lib64/ to rootfs/lib64/
Copying /lib64/ to rootfs/lib64/
Copying /lib64/ to rootfs/lib64/
Setting linker rootfs/lib64/ to mode 0o755
Creating file etc/os-release

rascul@coyote:~/mkroot$ sudo chroot rootfs /bin/bash

bash-4.4# exit

rascul@coyote:~/mkroot$ wget -q -O rootfs/sbin/init

rascul@coyote:~/mkroot$ chmod 0755 rootfs/sbin/init

rascul@coyote:~/mkroot$ sudo systemd-nspawn -D rootfs/ /sbin/init /bin/bash
Spawning container rootfs on /home/rascul/mkroot/rootfs.
Press ^] three times within 1s to kill container.
Timezone America/Chicago does not exist in container, not updating container timezone.

bash-4.4# tree -x
|-- bin
|   |-- bash
|   `-- tree
|-- dev
|-- etc
|   |-- os-release
|   `-- resolv.conf
|-- home
|-- lib
|-- lib64
|   |--
|   |--
|   |--
|   |--
|   `--
|-- proc
|-- root
|-- run
|-- sbin
|   `-- init
|-- sys
|-- tmp
|-- usr
|   `-- bin
`-- var
    `-- log
        `-- journal

17 directories, 10 files

bash-4.4# exit
Container rootfs exited successfully.