This is my very first public rust
project for fun purposes.
Obviously this was written in Rust - a systems programming language
by a noob rustacean with a few hours of experience with rust 😝
My code may seem funny in some parts since I've just tried to apply what I've learnt so far apart from the better ways of doing such tasks
So, kindly ignore as long I'm a noob LoL
- First of all you need rust. Follow the link below and you will know what to do.
It'll also autoinstall rustc and cargo for you.
- Once you have rust and everything it brings, we add a new target. Run the following command:
rustup target add x86_64-unknown-linux-musl
Or if you wan to make for 32bit arch then the target should be
i686-unknown-linux-musl
.
- After you have the build targets installed simply run the following command:
RUSTFLAGS='-C link-arg=-s' cargo build --release --target x86_64-unknown-linux-musl # For 64bit
# or
RUSTFLAGS='-C link-arg=-s' cargo build --release --target i686-unknown-linux-musl # For 32bit
Then you should find the output as
target/x86_64-unknown-linux-musl/release/rusty-magisk
(64bit)
- Copy your
ramdisk.img
and therusty-magisk
binary in an ext4 partition directory and run the following commands:
su
mkdir ramdisk && ( cd ramdisk && zcat ../ramdisk.img | cpio -iud && mv init init.real )
rsync rusty-magisk ramdisk/init && chmod 777 ramdisk/init && ( cd ramdisk && find . | cpio -o -H newc | gzip > ../ramdisk.img )
Tl;dr: In short, you need to rename
init
executable toinit.real
and putrusty-magisk
asinit
inside yourramdisk.img
.
-
If your system image is
system.sfs
then you need to extract it, an quick way to do that is:7z x system.sfs && rm system.sfs
-
Once you have
system.img
you need to mount it:mkdir mdir && sudo mount -o loop system.img mdir
-
Now rename
init
toinit.real
by running the following command:sudo mv mdir/init mdir/init.real
-
Lastly put
rusty-magisk
binary asinit
executable at/
of system.img:sudo rsync rusty-magisk mdir/init && chmod 777 mdir/init
I'm assuming that you have
rusty-magisk
binary at the same dir as your android-x86 OS files.Quick-tip: You can also get pre-built
rusty-magisk
binaries at https://github.com/AXIM0S/rusty-magisk/releases : Rusty-Magisk can be easily installed from GearLock.