 Okay, this video is part of a series. We're going over just the basics of working with Android images. It's boot loader. It's boot images and recovery images. Last time we looked at taking, they twerped the team team win recovery project and extracting that image, that recovery image and making some modifications. Right now my phone is at the boot loader screen that has been unlocked which we went over in the first tutorial. Sure, check out the annotation on the screen or the link in the description for the full playlist. And the way I got to the boot loader was running this command sudo adb reboot boot loader. And as I mentioned in previous tutorials, tools that we're going to be using is the fast boot adb and boot a boot IMG which if you're on a Debian based system you can whoops run this command otherwise check whatever package manager and your repositories for those programs. And let's go ahead and boot into a recovery image. So I'll just, I'll boot into, if you watched the previous video, the custom recovery I made with the Punisher theme. It's just the same twerp recovery but with a different theme and I changed some of the wording on the screen. So we're going to say sudo fast boot Punisher whatever image you're booting. This is not making any modifications on the phone. This is just loading the image to RAM and booting it. And once it's loaded up I can then run sudo adb shell and that brings me to the shell on the phone. In the recovery by default you have a root shell. So I'm root on this phone right now in the recovery. Now on the screen right now on the phone there's buttons for doing backups and recoveries and other modifications to the phone. I do recommend using that to make a backup but you can also manually backup partitions. But first let's look at all the partitions. If we do mount you can see there's a bunch of stuff already mounted. You can see by default the recovery mounted some partitions which you can modify that. It should all be in this file if we list out our files here. You can see there's knit rc and we're not going to get into that too much on this. If I go into it with a text editor you can see that there's going to be, it's creating some directories and it's going to mount some directories. So this is where you can modify what partitions get mounted and where. Let's go ahead and just exit out of that. We're not going to get into that in this tutorial but I just wanted to show you that. But how do you know what partitions are what? Well there's a few different ways of doing that. If we cd into device now if you're used to Linux systems you can usually hit list in here and there's usually going to be a sd something or an hd something. You won't see that on an Android device. What we wanted to go into is block device. So we're in a folder called dev for devices forward slash block. If we list out here you can see a bunch of block devices and really there's two that we're worried about these MMC BLK. So the MMC block devices you got block device one and block device zero. Block device zero should be your internal hard drive on your phone and the block one device should would be an sd card if you have one in the phone which I do. And of course just like looking at sda one sda two this is the first device we have p1 which partition my sd card only has one partition and that's sd card one as far as Android is concerned sd card zero on this device is my internal memory which is also block device one and you can see there are a lot of partitions like 30 some partition skipping a few numbers so 20 to 30 partitions here. How do you know which device is which? Well there's two ways of doing this. We can run the parted command which is my preferred way of doing this is just how I do it. We can do parted and the name of the block device so MMC BLK zero because I want my internal and I'll hit enter. So now we're running the parted command on that device and if we type in print it will print all the partitions and their labels. So as we can see user data is here your system which is your main operating system which you can modify but you want to be careful doing and we'll talk about that in future tutorials. We have a recovery and a boot you also notice that you have a boot backup and you have a lot of partitions on here and some of them are basic formats EXT-4 or EXT-2. Ones that are not such as our recovery is going to be packaged like the image that we had before that that we extracted they had a kernel in it and an operating system initial RAM disk and a boot config file so you have a boot and recovery both about the same size in this case tells you where it starts and how big it is so you got start and then size of that partition so on the actual hard drive it's starting at the hundred and seventh megabyte and it's going to the hundred and seventeenth megabyte and it's about 10 megabytes in size. Recovery is the default recovery because we haven't flash anything over if you flashed a custom recovery that's where it will be let's go ahead and pull our boot image so I'm going to type in exit or quit let's try quit there we go quit to get out of that to allow to clear the screen now if you use the screen of your phone while in recovery mode you could have backed up you would have backed up the recovery and probably the boot image as well but you can manually do that if you're familiar with Linux you can use the DD command which is pretty much on every Linux system even routers and phones like this so again let's check out mount and we can see the SD card one is mounted that's going to be my SD card I'm going to CD to that so change directory to that you can list out you can see I have a few things listed out here and I've actually already done this but I'll quickly do it's not very big I'll run the DD command so DD and then IF for input file and I'm gonna say well I need to remember what number the partition was and I forgot so I'll say parted device block M our block device zero and I'll say print again and you can see right here I want to grab the boot which is partition 31 31 okay so again we'll type in quit clear the screen and I'll say DD in file equals device block device oh you can't autocomplete on this so let's go ahead and make sure we type everything right I'm gonna say list device block device M zero P what did I say I said it was scrolling up here 31 31 remember that you gotta remember that number 31 so now I can I don't need to even run that command but I'll clear that out now I'll say DD in file IF equals and we'll say that device and I'll say out file equals and I'll say I was called boot dot IMG just make sure you're not overwriting a file that already exists that you've already backed up I'll hit enter didn't take very long it's only 10 megabytes there's no output if you're copying a bigger like your system it might take a little while and it's not gonna give you any progress bar just let it go okay so I've pulled that partition put it into an image on my SD card let me exit out so now I'm back at the prompt for my computer here as you can see I have the images I've created what I'm gonna do is I'm gonna do pseudo ADB pull and from SD card one my boot oops boot dot IMG okay and if I list this out you can see that I have pulled the boot IMG file and if I list it out you can see how big it is and it should be about 10 megabytes which it is and if I run file on the name it tells me that it is the Android boot IMG as a kernel RAM disk very very similar to our recovery image but this is our boot image this is the partition that every time we start our phone is the image that runs it puts the initial RAM disk and kernel into RAM and then it mounts the other system directory system partitions and runs off that so we can make modifications to that flash it back to the phone or we can make modifications to that and boot it like a live CD as we did with the recovery without actually making changes to the partition on the phone okay so let me go ahead and real quick here I can remove the boot folder that we created in a previous tutorial and just like the previous tutorial what I can do here is I can let's remake the boot folder I just want to clear it out I'll move into it and again we'll use the a boot IMG program to extract the boot IMG and you can see they created three files and we're going to want to extract the init RD IMG so we will say G unzip dash C the file oh you know before that let's make a directory to extract all this to otherwise it extracted here and things will get messy we'll extract we'll make a directory called RAM disk and move into that directory and then we will use gun zip dash C the init RAM disk image we'll pipe that into CPIO dash I and as you can see we've extracted you can see that the actual boot partition has a lot more startup files and has all these different files that start up things by the zygote is the actual Android interface radios touch screen USB drivers that's all that sort of stuff and you create your own custom image and add it in here which we're going to do in a future trial probably the next tutorial I think I have a plan for an it RC is basically where all the other stuff loads if we were to move into that you can see it imports other boot scripts and I do want to point out that these are not shell scripts even though some of the commands look the same but you can call shell scripts from here and there are a list of commands that you can do like making directory mounts and changing the owner writing to stuff writing the files writing strings to files and we will get into that a little bit more again in a future tutorial don't want to go over too much in one video exit out of that so we've extracted it we could make changes modify it and then boot it again I don't want to get too much into that in this story because we're going to start doing a lot of stuff with this image but now you have the actual original boot image the boot partition from your phone back this up back up all the partitions whether using the recovery image on the phone you know the twerp or if you DD each one I actually did both to have double backups in case I screw anything up as long as I don't screw up the the bootloader portion of it I always go to the bootloader and flash or boot whatever images I have backed up so once you have everything backed up you should be good to go very hard to mess things up that you can't recover from again besides the actual bootloader on the phone you screw that up good luck with that so yeah we're going to modify this image to make changes to how the phone boots and I've done this in the past with previous versions of Android and it's very easy to change permissions on your shell to give you root access on newer versions of Android they have disabled it so that you can't use what's called set UID on files so before you used to be able to take your shell your sh file from your phone from the system partition make a copy of that and then change its permission to say anytime this program is run by any user run as root obviously that's a bad idea that's how Android devices used to be new range devices do not let that happen you can change it and it will just run as whatever user runs it as which is your regular shell user we need to figure out a way to root the device that allows you will have root and also I think is a bit more secure because before if you did that if you created that SU file a lot of phones have that if you got malicious piece of software on your phone it could check for that SU file and run it what I want to do is I want to create something that I can like a root what's what I'm looking for a root program root service that I can turn on and off and have that be password protected and maybe even a password and key protected so I can have two steps and I can turn it on and I'm also the way I have my phone set up is I don't have root installed to the phone although I could do that what I do do is I do do is I can boot a boot image anytime I want then I can go type in username password maybe set a key get my root shell which is a little bit different than then just SU and at any point if I reboot my phone it disables it again and to get that root access again I'll need to boot from my computer again and I that's just a little steps of security although you can set it up so that you flash the image and it boots with the root access every time still being password protected so a lot of things to think there I think that this is a more complex way of doing it but a better way of doing it definitely good thing that Android has disabled that set UID on those files that obviously was a security issue but yeah we are a new way of doing things and so I showed you today just how to look at what partitions are on your Android device and how to pull them off using DD and how to extract it which I went over a previous tutorial I also went over in the previous tutorial how to recompact that which we'll be doing more of once we look at how we modify stuff so that's it for the story if you're enjoying these they're a little more advanced I hope you're enjoying them be sure to check out my website filmsbychrist.com that's Chris the K there should be a link in the description be sure to like share and subscribe and as always I hope that you have a great day I hope again I hope you're enjoying this tutorials another little more advanced but there's not too many tutorials out there on this sort of stuff it took me a lot digging around and poking around for days just messing with my system to figure all this out so I'm hoping this helps you learn and you don't have to do as much poking around as I did have a great day okay this is an introduction to filmsbychrist.com I'm Chris that's Chris the K that's me right there my daughter ember and my wife Jennifer we pretty much live in the swamps of Florida I'm a firefighter by day as well as by night we work long hours but that's not why you're here you're here about the videos I put up on YouTube these videos are mainly about computers and programming which means most my videos look something like this and if that's what you're interested in great if not that's alright I do videos on other topics too such as video editing special effects photo editing 3d design and music creation if you are one of my viewers and you enjoy my videos my patreon page is a place we can go to help support my videos so I asked that you take the time to go to my patreon page and look at different levels of rewards you can receive for different levels of backing there should be a link in the description of this video if you were watching it on YouTube otherwise you can visit patreon.com forward slash metal x 1000 and I thank you for your time and your support have a great day