Welcome! Log In Create A New Profile


Made a Debootstrap-script for Wheezy rootfs-generation.

Posted by JohnW 
Made a Debootstrap-script for Wheezy rootfs-generation.
February 09, 2015 08:21AM

I made a script that creates a complete "minbase" Wheezy-rootfs with the necessary modifications.
It even installs the kernel for you. Yes i'm not the first one here that has done it.


It's based Klaus M's "build_rpi_sd_card.sh"-script (http://blog.kmp.or.at/2012/05/build-your-own-raspberry-pi-image/) with information from Vlad's Debootstrap tutorial (http://forum.doozan.com/read.php?2,5986,page=1).

For more info check the links above.
To create the installation on a sd-card e.g. just run "./build_rootfs_kirkwood.sh /dev/mmcblk0".
If you've got a harddrive, be aware that it will wipe the entire partition table - so all partitions will get deleted (including any secondary data-ones).
If you run the script without any parameters it creates a img-file that the installation is put on. Handy for later use.

Inspect the script and tell me what you think.
Packages that's needed on the host to run it is "binfmt-support qemu-user-static debootstrap kpartx lvm2".

Place the kernel-package (linux-3.18.5-kirkwood-tld-1-bodhi.tar.bz2 i.e.) in the buildenv-folder (default /root/kirkwood/).

Password for root is "debian", eth0 is set to use DHCP.

When done, to mount the img-file run:
kpartx -va basic_wheezy_20150209.img
mount /dev/mapper/loop0p1 /mnt/

And unmount:
cd /root/kirkwood/
/umount /mnt
kpartx -d basic_wheezy_20150209.img

A few lines of code is added to /etc/rc.local and /etc/init.d/halt to controll the leds on startup/shutudown.
These are for the PogoPlug Mobile/V4, so you might need to adjust it if you're running anything else.
Just check these files in Bodhis rootfs that you've might already be running.

Re: Made a Debootstrap-script for Wheezy rootfs-generation.
February 21, 2015 04:11PM
Thanks for sharing John, that's a useful script, well done :D It's good to see people creating new stuff out of what's already been put out there ...

I wouldn't consider myself an expert, more a persistent amateur, so do take my comments with a pinch of salt !

Presumably, the purpose of the script is to create a almost bare minimum bootable rootfs, on the machine one wishes to use the rootfs on ? Ie it's not to be run on a Debian or Ubuntu x86 machine to create a bootable rootfs for an arm device ?

If so then a prerequisite is a bootable arm device with connected internet connection ? Also the script might need customising for the particular device - for instance GoFlexNet almost certainly has different LEDs

I'm asking the questions in order to find the utility of the script. For me personally I'm happy to trust bodhi to make a working rootfs if I need a "new" bare system, BUT this would give me another route for building a new rootfs.

JOINING UP some dots - a recent newbie on the forum trying to hack his pogoplug came into the same issues most of us had trying to do it, that is that Jeff's script is broken. So I'm wondering if your script could be modified to include the other things necessary to hack a pogoplug or GoFlex, ie upgrading uboot, setting arc_number etc ? I ask because it's on bodhi's list, but I imagine bodhi's list is quite long - http://forum.doozan.com/read.php?2,19821,19837#msg-19837

So, it's a possible avenue for further development, I'm sure bodhi would probably appreciate the help and help you test. Or maybe that's a new/separate script.

Also wondering if I could use it to build a Jessie rootfs. Personally I've been using Jessie over wheezy for some time now, from what I understand it's probably close to becoming the stable Debian quite soon anyway, and Jessie I haven't had any issues with on GoFlexNet. Presumably that'd just be a matter of changing the "deb_release" variable in the script ?

And presumably the script would only wipe the hard drive if that is the device specified as command line argument $1 ?


Don Charisma ... because anything is possible with Charisma

My blog - http://DonCharisma.org
Our commercial site - http://DonCharisma.com
Re: Made a Debootstrap-script for Wheezy rootfs-generation.
February 22, 2015 09:11PM
Download the script here from now: [CLICK HERE]

Hi Don, thank you for asking the questions - always nice! :)

You should be able to run this script on a ordinary PC with Debian or Ubuntu, the output will be the exact same!
I myself ran it on my PogoPlug V4 (running Bodhis rootfs!), just that it took a bit longer on it (about 30-40 minutes?).
Debootstrap is the component that does the magic and downloads and preps the whole rootfs.

Yes regarding the leds, you will most likely need to get the correct names and paths for them on your GoFlex.

These lines are added for the Pogoplug V4/Mobile to "/etc/rc.local" (startup).
#Turn on LED
if [ -d /sys/class/leds/status:green:health ]; then
echo default-on > /sys/class/leds/status:green:health/trigger

if [ -d /sys/class/leds/status:red:fault ]; then
echo none > /sys/class/leds/status:red:fault/trigger

And "/etc/init.d/halt" (shutdown)...
#Turn off LED
if [ -d /sys/class/leds/status:green:health ]; then
echo none > /sys/class/leds/status:green:health/trigger

if [ -d /sys/class/leds/status:red:fault ]; then
echo none > /sys/class/leds/status:red:fault/trigger

You could always adjust the paths afterwards, when you know what you got in "/sys/class/leds/".
Or take a look runnings Bodhis rootfs...

I supose you could use this to make a complete "uboot + rootfs"-script. Or maybe it's easier to just update Jeffs...
However the purpose was mainly just to have something that could generate a fresh rootfs using Debians repository if needed. Updating uboot is usually something you just do once.

Yes theres absolutely nothing wrong with Bodhis rootfs, which is almost identical to the output of this script.

Regarding Jessie, i'm sure you're able to generate a Jessie rootfs by changing "deb_release=wheezy" to "deb_release=jessie". I will try it someday.

And then you'll need to remove replace wheezy with jessie in this part also:
cat <<END > $rootfs/etc/apt/sources.list
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main
deb http://ftp.debian.org/debian/ wheezy main
deb-src http://ftp.debian.org/debian/ wheezy main

Yes, you will have "dd if=/dev/zero of=$device bs=512 count=1" running on the physical device that you specify before it runs fdisk and that stuff...
If you don't specify anything it will create a img-file that it will run everyhing on instead. Perfect if you just want to test the script etc.

If you have an on USB-drive laying around why not try installing Jessie on it? You could could always restore everything by plugging your old USB-drive back in. No harm done.

Btw, i'm a total newbie too - belive it or not. ;-)

Re: Made a Debootstrap-script for Wheezy rootfs-generation.
February 24, 2015 03:10AM
Hey John, thanks for answering all my questions ... and excellent job considering your newbie'ness ... one thing I really like about this forum is that there are new people coming in and learning how to Debian'ise (or break) stuff :D

The question about running on for instance an amd64 machine was more related to cross-compiling (cross architecture), which as far as I can see you're not doing in the script. What I mean is to get an ARM image on an amd64 laptop for instance. AND yes I take the point that one could generate an amd64 image on an amd64 machine.

I mentioned Jeff's broken script, because it would be very nice for newbies coming to be able to run it and for it not to break - so could be a worthwhile direction for you ... my first experience here was Jeff's script breaking !


Don Charisma ... because anything is possible with Charisma

My blog - http://DonCharisma.org
Our commercial site - http://DonCharisma.com

Your Email:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.