Debian – Is it possible to run debootstrap within a fakeroot environment

debiandebootstrapfakeroot

I have a script that prepares an installation image by running debootstrap, does some modifications on the files and then copies the files to a disk image backed up by a file.

This works under root, but I wanted to be able to run the script without root privileges, as it really shouldn't need any privileged resources. I thought that I'd just run the whole script using fakeroot, but debootstrap fails with

W: Failure trying to run: chroot /tmp/tmp..... mount -t proc proc /proc

Is there a way around that?

Best Answer

In general, yes, it is possible to run debootstrap as a non-root user by way of fakeroot, but there are more details to it than that.

The immediate problem you seem to be having is trying to use chroot as a non-root user; you need to use fakechroot instead, in addition to fakeroot. For example:

fakechroot fakeroot debootstrap sid /tmp/sid

Later problems you may run in to include creating loopback mounts or creating disk image partition tables as a non-root user.

Instead of working through all these details one by one, you may find it easier to use a debootstrap variant like polystrap, which also handles cross-compilation (eg, generate an armhf image from x86-64) if you end up wanting that some day.

Related Question