Now that we’ve played with rootfs in chroot a bit, let’s see if we can actually boot something. When I install Alpine 3.16, I see three partitions; A boot partition /dev/sda1
, a swap partition /dev/sda2
, and the rootfs /dev/sda3
. When we start Alpine, the boot partition is mounted on /boot
. Here we find a couple of files, including vmlinuz-lts
. This file is our Linux kernel. Yup, if you never knew where that things was to be found, there it is! This can be a file or it can be a symbolic link to the actual kernel. On my Kubuntu for example, the kernel is called /boot/vmlinuz-5.15.0-52-generic
, but linked to from /boot/vmlinuz
. Note that on Kubuntu the file is vmlinuz
while on Alpine it’s vmlinuz-lts
. It seems the ‘vmlinuz’ name grew historically. Originally, Unix kernels were typically called ‘unix’, later it was possible to add an option called ‘Virtual Memory’ and the name of kernels compiled with that option were prefixed with ‘vm’. Later it got possible to compress the kernel file to save storage and the ‘x’ was changed to ‘z’ to show it’s a compressed kernel. Linux distributions just took over the same conventions. Anyhow, what we want to do now, is play with the rootfs and boot something up!
For the following we need an extra partition. You can use an extra drive, or add an extra partition with filesystem on the current drive. I don’t want to go into much detail on how you can do this stuff, you should find info online if needed. If you want to add a new formatted partition to the current drive, it’s probably easiest to do it from a live distro with a graphical DE (e.g. Trisquel) and do it with a graphical tool like gparted. In my case I have /dev/sda3
which holds my Alpine installation and /dev/sda4
which is the new partition.
When the kernel boots, it does some things and eventually starts /sbin/init
. This is very similar to what we did with chroot. The big difference is that there we said what to start, here Linux decides to start /sbin/init
. I’m unsure if this is hard coded or can be changed with config files somewhere, but from what I see online, it at least seems to be the norm to start this.
What we’ll try, is to use Alpine’s boot partition and boot something simple that we create on our own rootfs.
Just to see things working, I first booted into a live iso and copied all files from sda3 to sda4.
mkdir /mnt/sda1 /mnt/sda3 /mnt/sda4
mount /dev/sda1 /mnt/sda1
mount /dev/sda3 /mnt/sda3
mount /dev/sda4 /mnt/sda4
cp -r /mnt/sda3 /mnt/sda4
In the boot folder (/mnt/sda1) I notice a file extlinux.conf. This is from the part of our boot system where I don’t want to delve too much in yet, but one important line is APPEND root=UUID=91c0e3ea-fca1-4c7c-96ed-ebc551066204 modules=sd-mod,usb-storage,ext4 quiet rootfstype=ext4
. This tells us what partition should be considered as the one with the rootfs. I take the guess that this will probably also work with the name instead of UUID, so I changed this to APPEND root=/dev/sda4 modules=sd-mod,usb-storage,ext4 quiet rootfstype=ext4
. Just to be sure you can add a file or something to sda3 and sda4 just so you can be sure which of the two is used as rootfs, and then reboot the machine (without the live iso). The result was that we are now booted from /dev/sda4. That’s pretty sweet! Not only did we boot from another partition, the partition was filled up by simply copying files over. That implies to me that we don’t need certain bits to be set at a certain place on the drive or anything. Linux understands what’s on this drive and can execute things.
Let’s see if we can boot something up ourselves. First I change extlinux.conf back so it boots from /dev/sda3. First we make sure we can access the filesystem on our partitions, then we remove everything from sda3 and create the folders Linux needs. If something goes wrong, we can always boot again from a live iso, mount the drives where we think something went wrong, and fix things.
mkdir /mnt/sda3 /mnt/sda4
mount /dev/sda3 /mnt/sda3
mount /dev/sda4 /mnt/sda4
cd /mnt/sda3
rm -r ./
mkdir sys dev proc
If we reboot the machine now, we’ll get a kernel panic. Hooray! That means the kernel is booting, it just can’t continue which is normal since the partition it tries to boot from is empty, and therefor there’s no /sbin/init
to start. Let’s try to start a simple shell on boot. This is very similar to how we set things up with chroot. To set things up, we’ll boot from a live iso again.
Alpine uses something called Busybox. This is a single binary that contains a whole set of tools. For example, if you have Busybox installed, instead of doing ls
, you can also do busybox ls
. So what we’ll do is, we’ll copy busybox and the needed libraries to the rootfs we’re creating and then call it from an init script.
mkdir /mnt/sda3 /mnt/sda4
mount /dev/sda3 /mnt/sda3
mount /dev/sda4 /mnt/sda4
# We copy the binaries and libraries just like we had to do when playing with chroot
mkdir /mnt/sda3/bin
cp /mnt/sda4/bin/busybox /mnt/sda3/bin/busybox
mkdir /mnt/sda3/lib
cp /mnt/sda4/lib/ld-musl-x86_64.so.1 /mnt/sda3/lib/ld-musl-x86_64.so.1
Then we’ll create our init script and make it executable
cd /mnt/sda3
mkdir sbin
touch sbin/init
chmod +x sbin/init
echo '#!/bin/busybox sh' >> sbin/init
echo "echo 'Welcome to your very own Linux Distro!'" >> sbin/init
echo '/bin/busybox sh' >> sbin/init
If you made sure we’re using /dev/sda3 as root partition again on boot, you can now reboot and should see something like
Welcome to your very own Linux Distro!
sh: can't access tty: job control turned off
/ #
Awesome! Since busybox has a whole bunch of tools, we can already use these. If ls
doesn’t work, try busybox ls
. You can also try to add some folders or files (e.g. busybox touch catgirl_titties
), but you’ll quickly notice the filesystem is read-only. We can fix that with busybox mount -o remount,rw /
. There’s also the error “sh: can’t access tty: job control turned off”, but I conveniently decided to consider this one out of scope for this article 😏
When we want to exit our shell, we can do exit
, which will now give us a kernel panic. If you don’t want a kernel panic, you can call busybox poweroff -f
, which will immediately poweroff the machine.
When you call a program, you can give it a bunch of parameters. In the case of busybox ls
, we provide “ls” as a parameter. But one parameter that’s always provided is how the command was called. If we call busybox
, then busybox will know that this is how it was called. If we link a file called “ls” to busybox and then call that “ls” file, busybox will know that it was called with the command “ls”. Busybox is programmed in such a way that it will use this information to conclude what command you wanted to run and then run that. If you want a list of the commands busybox has, you can run busybox --list
. To see what location busybox expect these tools to be placed, you can do busybox --list-full
.
Knowing these things, there’s some optimalisations we can add.
First we’ll make it easier to call the commands by making system links to busybox in the correct locations.
busybox mount -o remount,rw /
# Maybe there's a built in way to do this, idk, this works :)
for link in $(busybox --list-full)
do
folder=$(busybox echo "$link" | busybox sed -E 's@(.*/)[^/]*$@\1@')
busybox mkdir -p "$folder"
busybox ln -s /bin/busybox "$link"
done
Another thing we can do, is change the init file to have the following content. That way the file system will be mounted as read-write, and when we do exit
, the machine will power off instead of throwing a kernel panic.
#!/bin/busybox sh
/bin/busybox mount -o remount,rw /
echo 'Welcome to your very own Linux Distro!'
/bin/busybox sh
/bin/busybox poweroff -f
Now we can reboot and we have our own very very minimal distro :D
Distro’s typically do more than just start a shell. They also have an init system to start up several services for example. Afaict busybox can do all that, but it requires more looking into. I’m not gonna do that now. For now we already have a neat thing to brag to our friends about, so let’s enjoy that first ;)
Comments
August 17, 2025 10:55
This is very educational content and written well for a change. It’s nice to see that some people still understand how to write a quality post.! situs 5ktoto This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article. Link slot Positive site, where did u come up with the information on this posting? I’m pleased I discovered it though, ill be checking back soon to find out what additional posts you include. msg 777 Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can’t wait to read lots of your posts. tulang4d
June 17, 2025 06:33
Very efficiently written information. It will be beneficial to anybody who utilizes it, including me. Keep up the good work. For sure i will check out more posts. This site seems to get a good amount of visitors. 해외선물 임대
June 17, 2025 14:18
Fantastic Put up, I’m sure a giant believer through post feed-back concerning webpages towards allow the blog page consultants recognise that they’ve further a specific thing positive towards the web! g string thongs women
August 19, 2025 10:44
Superior Place, My organization is a great believer during ad opinions regarding online websites that will let the webpage novelists recognize that they’ve put in an item worthwhile that will the online market place! data macau
August 19, 2025 12:51
Superior post, keep up with this exceptional work. It’s nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again! olxtoto login A great content material as well as great layout. Your website deserves all of the positive feedback it’s been getting. I will be back soon for further quality contents. Wedding photography Edmonton Excellent website! I adore how it is easy on my eyes it is. I am questioning how I might be notified whenever a new post has been made. Looking for more new updates. Have a great day! akun togel Excellent post. I was always checking this blog, and I’m impressed! Extremely useful info specially the last part, I care for such information a lot. I was exploring this particular info for a long time. Thanks to this blog my exploration has ended. bandar toto macau
July 2, 2025 11:38
erjiikk90xcvg,o
If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. 유흥알바 Thank you for such a well written article. It’s full of insightful information and entertaining descriptions. Your point of view is the best among many. 메랜대리 If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. 청주출장마사지 Hello There. I found your blog using msn. This is an extremely well written article. I will be sure to bookmark it and return to read more of your useful information. Thanks for the post. I’ll certainly comeback. pol88 login If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. Take Profit Trader payout rules macau jitu
July 2, 2025 11:55
erjiikk90xcvg,o
If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. 룸알바 Hey There. I found your blog using msn. This is a very well written article. I’ll be sure to bookmark it and come back to read more of your useful info. Thanks for the post. I’ll definitely return. 메랜대리 If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. 청주출장마사지 Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information specially the last part I care for such info a lot. I was seeking this particular information for a very long time. Thank you and good luck. pol88 alternatif If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. Take Profit Trader payout prediksi macau
August 25, 2025 12:57
What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. bandar Togel Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you. bandar togel online It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks. bandar slot online Great article Lot’s of information to Read…Great Man Keep Posting and update to People..Thanks Daftar Totoxl
August 25, 2025 12:57
What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. bandar Togel Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you. bandar togel online It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks. bandar slot online Great article Lot’s of information to Read…Great Man Keep Posting and update to People..Thanks Daftar Totoxl
July 7, 2025 11:55
Great post. The particular submit has an effect on plenty of important difficulties individuals community. We all can’t be uninvolved to be able to these kinds of difficulties. This kind of submit offers guidelines and also principles. Extremely useful and also sensible. IPTV UK
July 8, 2025 11:29
When i stunned while using the research people meant to makes unique post awesome. Superb pastime! halloween bachelorette underwear for women
July 17, 2025 07:36
A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. 美國寄香港
July 17, 2025 12:40
erjiikk90xcvg,o
If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. situs toto 4D If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. mawartoto If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. mawartoto If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. mawartoto If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. mawartoto mawartoto
July 17, 2025 12:41
erjiikk90xcvg,o
If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. situs toto If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. mawartoto togel If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. mawartoto togel If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. mawartoto togel If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. mawartoto togel mawartoto togel
July 21, 2025 10:25
I exactly got what you mean, thanks for posting. And, I am too much happy to find this website on the world of Google. situs toto togel 4D Wow, this is fascinating reading. I am glad I found this and got to read it. Great job on this content. I liked it a lot. Thanks for the great and unique info. mawartoto I am jovial you take pride in what you write. It makes you stand way out from many other writers that can not push high-quality content like you. mawartoto Today, I was just browsing along and came upon your blog. Just wanted to say good blog and this article helped me a lot, due to which I have found exactly I was looking. mawartoto You have performed a great job on this article. It’s very precise and highly qualitative. You have even managed to make it readable and easy to read. You have some real writing talent. Thank you so much. mawartoto mawartoto
July 21, 2025 10:27
I visit your blog regularly and recommend it to all of those who wanted to enhance their knowledge with ease. The style of writing is excellent and also the content is top-notch. Thanks for that shrewdness you provide the readers! 4D I am incapable of reading articles online very often, but I’m happy I did today. It is very well written, and your points are well-expressed. I request you warmly, please, don’t ever stop writing. mawartoto login Your blog is too much amazing. I have found with ease what I was looking. Moreover, the content quality is awesome. Thanks for the nudge! mawartoto login I know this is one of the most meaningful information for me. And I’m animated reading your article. But should remark on some general things, the website style is perfect; the articles are great. Thanks for the ton of tangible and attainable help. mawartoto login Superior post, keep up with this exceptional work. It’s nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again! mawartoto login mawartoto login
July 21, 2025 10:27
I visit your blog regularly and recommend it to all of those who wanted to enhance their knowledge with ease. The style of writing is excellent and also the content is top-notch. Thanks for that shrewdness you provide the readers! 4D I am incapable of reading articles online very often, but I’m happy I did today. It is very well written, and your points are well-expressed. I request you warmly, please, don’t ever stop writing. mawartoto login Your blog is too much amazing. I have found with ease what I was looking. Moreover, the content quality is awesome. Thanks for the nudge! mawartoto login I know this is one of the most meaningful information for me. And I’m animated reading your article. But should remark on some general things, the website style is perfect; the articles are great. Thanks for the ton of tangible and attainable help. mawartoto login Superior post, keep up with this exceptional work. It’s nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again! mawartoto login mawartoto login
July 22, 2025 10:05
erjiikk90xcvg,o
Very useful info. Hope to see more posts soon!. olxtoto slot Thank you for very usefull information.. olxtoto togel This is a brilliant blog! I’m very happy with the comments!.. koi toto I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading. situs togel 4d Awesome article! I want people to know just how good this information is in your article. It’s interesting, compelling content. Your views are much like my own concerning this subject. lawn sprinkler repair service koi toto
July 24, 2025 13:21
erjiikk90xcvg,o
If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. togel online If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. situs togel If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. olxtoto login If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. toto slot gacor If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. American Roof Repair & Replacement hptoto slot
July 24, 2025 13:22
erjiikk90xcvg,o
If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. situs toto If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. togel online If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. olxtoto link If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. toto slot 777 If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. American Roof Repair hptoto gacor
July 29, 2025 08:11
I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favorites blog site list and will be checking back soon. Please check out my site as well and let me know what you think. sekabet giriş
May 24, 2025 14:49
Brilliant text. A posting is affecting loads of imperative complications one’s world. Most people can’t be uninvolved so that you can all these complications. The following posting supplies plans plus basics. Pretty enlightening plus simple. cbg thc gummies
June 11, 2025 12:41
Outstanding submit, travelled in advance and also book marked your internet site. My partner and i can’t hold out to learn a lot more coming from an individual. weed carts cake
June 12, 2025 12:10
the actually great website. the realy informative plus a this kind of excellent career. i enjoy this kind of. boo baskets bachelorette
June 12, 2025 12:21
Love to read it,Waiting For More new Update and I Already Read your Recent Post its Great Thanks. Door handles
June 13, 2025 21:05
That is the amazing piece of writing, Thanks a lot for the purpose of rendering everybody this. Have post. hunting apparel for women
June 14, 2025 13:00
the actually great website. the realy informative plus a this kind of excellent career. i enjoy this kind of. loft conversions london