linux · power

linux: creating a debian ppc64le img using deboostrap

debootstrap is a tool which can install a Debian base system into a sub-directory of another, already installed system. It doesn’t require an installation CD, just access to a Debian repository.

In this tutorial, we are going to use a Debian 8 (Jessie) ppc64le as a host for our sysroot build environment. You can get a free POWER virtual machine at MiniCloud to reproduce the steps described here 🙂

step #1: create a disk image

dd if=/dev/zero of=debian-ppc64le.img seek=10240M bs=1 count=0


  • /dev/zero is a special file in Unix-like operating systems that provides as many null characters (ASCII NUL, 0x00) as are read from it.
  • seek = n, skip n blocks (using the specified output block size) from the beginning of the output file before copying.
  • bs = BYTES, read and write up to BYTES bytes at a time.
  • count = N, copy only N input blocks.

step #2: create a new file system

/sbin/mke2fs -t ext4 -i 1024 -b 1024 -m 5 -F -v ./debian-ppc64le.img


  • mke2fs: create an ext2/ext3/ext4 filesystem.
  • -t: specify the filesystem type (i.e., ext2, ext3, ext4, etc.) that is to be created.
  • -i: specify the bytes/inode ratio. mke2fs creates an inode for every bytes-per-inode bytes of space on the disk. The larger the bytes-per-inode ratio, the fewer inodes will be created.
  • -b: specify the size of blocks in bytes. Valid block-size values are 1024, 2048 and 4096 bytes per block.
  • -m: specify the percentage of the filesystem blocks reserved for the super-user.
  • -F: force mke2fs to create a filesystem.
  • -v: verbose execution.

step #3: create a temporary mount point

mkdir ./tmp

step #4: mount the .img

sudo mount -o loop ./debian-ppc64le.img ./tmp/


  • mount: all files accessible in a Unix system are arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command serves to attach the filesystem found on some device to the big file tree.
  • -o: allow specifying a comma separated string of options.
  • loop: loop device is a pseudo device (a file) that acts as a block-based device.

step #5: deboostrap a new Debian

sudo apt-get install debootstrap
sudo debootstrap jessie ./tmp/

step #6: chroot into your new image

A chroot is a way of isolating applications from the rest of your computer, by putting them in a jail. It is basically a special directory on your computer which prevents applications, if run from inside that directory, from accessing files outside the directory. In many ways, a chroot is like installing another operating system inside your existing operating system.

sudo chroot ./tmp

step #7: customize your image

Once you chrooted your image you can install or modify anything you desire. For example, execute update and upgrade:

apt-get update
apt-get upgrade

Configure the network:

static IP:

vi /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp


vi /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static

If you intend to boot this system, you probably want a Linux kernel and a boot loader.

apt-cache search linux-image

Install the kernel package using its package name:

apt-get install linux-image-*

To make your system bootable, set up your boot loader to load the installed kernel with your new root partition:

apt-get install grub2
grub-install /dev/sda2

You have now a basic system configured. If you would like to make the system a bit more mature:

tasksel install standard

step #8: umount

umount ./tmp

step #9: compress your new image

bzip2 -9 -z -f -v ./debian-ppc64le.img


  • bzip2 a block-sorting file compressor which compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding.
  • -9 (or –best) set the block size to 900 k when compressing.
  • -z forces compression, regardless of the invocation name.
  • -f force overwrite of output files. Normally, bzip2 will not overwrite existing output files. Also forces bzip2 to break hard links to files, which it otherwise wouldn’t do.
  • -v show the compression ratio for each file processed.

And that’s  all. You now have a brand new Debian Jessie ppc64le image to used wherever you want.

Some good references:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s