HOW-TO: Install Debian using debootstrap.
Using a live cd or existing Linux install to install Debian GNU/Linux using debootstrap.
Updated: 2015-01-11 debootstrap is used to create a Debian base system from scratch, without requiring the availability of dpkg or apt. It does this by downloading .deb files from a mirror site, and carefully unpacking them into a directory which can eventually be chrooted into. This guide is intended to be a basic installation for those who wish to run Debian's unstable branch, or run a minimal system. It does not cover partitioning schemes, file system details, or proprietary drivers. For this guide, we will assume the following: Branch: unstable (codename 'Sid') Architecture: amd64 Boot Style: BIOS / MBR Target partition: /dev/sda1 Filesystem: ext4 Network Interface: eth0 Debian Mirror: http://ftp.us.debian.org/debian - (Mirror List: http://www.debian.org/mirror/list) debootstrap version: 1.0.66 Dependencies: binutils, perl, tar, wget (if not using a Debian based distro) Installing debootstrap from a Debian based distribution For Debian based distributions, this will be as simple as: Code:
root@host# apt-get update Installing debootstrap from a non-Debian based distribution If you are installing from a non-Debian based distribution, you distribution may or may not have debootstrap available. To get debootstrap, you can download it directly from a Debian mirror. To view the packages available, use a web browser, or use this command: Code:
root@host# wget --no-remove-listing -O /tmp/deboot.html -q http://ftp.us.debian.org/debian/pool/main/d/debootstrap && grep 'all.deb' /tmp/deboot.html | awk -F 'href' '{print $2}' | cut -d '"' -f2 Look for the latest version listed, and download: Code:
root@host# wget -P /tmp/debootstrap http://ftp.us.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.66_all.deb Code:
root@host# cd /tmp/debootstrap Code:
root@host# ln -s /tmp/debootstrap/usr/sbin/debootstrap /usr/sbin/debootstrap Setup the target partition for install Create your filesystem, your mount point, and mount your partition: Code:
root@host# mkfs.ext4 -L Debian /dev/sda1 Installing the base system with network access Here, debootstrap will download, extract and install the base system packages to our target partition. debootstrap only fetches the base system without a kernel or bootloader, so we'll use the --include option to fetch those too. If you need packages not found in the main repository, you can include packages from contrib and non-free with this option --components main,contrib,non-free Usage: debootstrap --include <additional_packages,comma-separated> --arch <architecture> <release> <target> <mirror> Code:
root@host# debootstrap --include linux-image-amd64,grub-pc,locales --arch amd64 unstable /mnt/deboot http://ftp.us.debian.org/debian Code:
root@host# debootstrap --arch amd64 raring /mnt/deboot http://archive.ubuntu.com/ubuntu Installing the base system without network access, or to a different architecture If you do not have network or Internet access, you can use the --foreign option to start installation on a machine with network access, and finish on the machine that does not. This is also useful if your target machine is a different architecture than your host machine. Since your target won't have network access, make sure to use the --include option to have debootstrap fetch your kernel, bootloader, and any other packages you will want installed. Create a temporary directory, and use debootstrap to fetch the packages for the first stage of the install. Code:
root@host# mkdir /home/<user-name>/deboot Code:
root@host# debootstrap --foreign --include linux-image-powerpc,yaboot,locales --arch powerpc unstable /home/<user-name>/deboot http://ftp.us.debian.org/debian Code:
root@host# cd /home/<user-name>/deboot Code:
root@host# cd /mnt/deboot Code:
root@host# chroot /mnt/deboot /bin/bash Preparing the chroot environment Copy the mounted file systems table. It keeps the df command happy. (Will be overwritten upon boot.) Code:
root@host# cp /etc/mtab /mnt/deboot/etc/mtab Code:
root@host# mount -o bind /dev /mnt/deboot/dev Continuing the installation within chroot Entering the chroot environment: Code:
root@host# chroot /mnt/deboot /bin/bash Code:
root@chroot# grub-install /dev/sda Code:
root@chroot# blkid /dev/sda1 Code:
UUID=79168060-9d9c-4cf6-8ee9-bb846aee589b / ext4 defaults,errors=remount-ro 0 1 Code:
root@chroot# echo "<name-your-host>" > /etc/hostname Code:
root@chroot# dpkg-reconfigure locales Code:
root@chroot# passwd Code:
root@chroot# adduser <your-user-name> Setting up the network (eth0): Some basic tools are already included to manage your network, but nothing is configured for you yet. If you plan on installing a desktop environment, that may bring in tools such as network-manager or wicd to automatically configure your network. You can bring up your network manually each boot with the tools dhclient or ifconfig. For a dynamic IP (DHCP): Code:
root@host# dhclient -v eth0 Code:
root@host# ifconfig -v eth0 192.0.2.7 netmask 255.255.255.0 up For DHCP, the /etc/network/interfaces file should look like this: Code:
# This file describes the network interfaces available on your system Code:
# This file describes the network interfaces available on your system Install a display manager and a window manager Unless you're using this for a headless server, might be nice to have some sort of desktop to play with. Don't forget to update the package manager if you wish to install new packages: Code:
root@chroot# apt-get update Code:
root@chroot# apt-get install xserver-xorg wdm fluxbox xterm Code:
root@chroot# tasksel --new-install Finishing the install Clean the package cache: Code:
root@chroot# apt-get clean Code:
root@chroot# update-initramfs -u -k all Code:
root@chroot# exit -- Enjoy your fresh install of Debian! -- Additional Info Approx space used after base install: 491 MiB Approx bandwidth used: 94 MiB Approx space used after Fluxbox / wdm install: 714 MiB Approx bandwidth used including base: 152 MiB Approx space used after XFCE4 / lightdm install: 1077 MiB Approx bandwidth used including base: 266 MiB Approx space used after KDE 4 Standard install: 2036 MiB Approx bandwidth used including base: 597 MiB Approx space used after Gnome3 full install: 3329 MiB Approx bandwidth used including base: 994 MiB Troubleshooting Code:
W: Failure trying to run: chroot /mnt/deboot dpkg --force-depends --install /var/cache/apt/archives..... Code:
root@host# export PATH=$PATH:/sbin Code:
E: No pkgdetails available; either install perl, or pkgdetails.c from the base-installer source package ---------------------------------------------------------------------------------------- Debian doesn't boot! Code:
fsck exited with status code 0 Code:
root@chroot# update-initramfs -u -k all |
Now we have it here at LQ.
Cool! Not too many people use debootstrap but I've tried it & works great. The last time I did it I had to use 2 different tutorials because some of the commands didn't work. I'll try yours later. |
Let me know how it works for you. I've tested using Aptosid, Fedora, Arch and Slax.
|
I will, but I'm sure that it works I have to bookmark it so I don't have to search for it later.
|
A couple of comments. Firstly, debootstrap won't work from a cdrom/DVDrom; if you've got one and no internet connection, you can do something like
Code:
# mount /dev/sr0 /cdrom Code:
# debootstrap --unpack-tarball=/home/Wocky/linux.tgz wheezy /mnt/deboot |
Quote:
For example, I am running debian on live USB. It is /dev/sdg and it's partititon is /dev/sdg1. Will I be able to make my target partition /dev/sda1 which is a seperate hdd which has no OS or anything? |
No need for you to deboostrap the live-cd has an installer, but you need to have unallocated space to install to unless you're using the whole hdd.
|
Quote:
|
Thank you for your reply replica9000!
I have just a few more questions: Quote:
I have a 160gb hdd and I was looking to install a distro to a 40gb partition. Quote:
I imagine I have to substitute 'arch' for something else. I have an amd64 processor. Incidentally, would I be OK to simply install 'Sid' anyway, even if it is the unstable version? Quote:
Code:
root@chroot# passwd mypassword Quote:
|
Quote:
Quote:
Quote:
Quote:
Code:
passwd root |
Quote:
Quote:
Code:
debootstrap --include=linux-image-amd64,grub-pc --arch amd64 unstable /mnt/deboot http://ftp.us.debian.org/debian Quote:
Quote:
|
Quote:
However, since the example target partition is 'sda1' then I can simply create a partition of my choice on a hdd and use that as the example partition. Thank you very much!! The debootstrap program is the way to go! |
Quote:
|
Quote:
Quote:
|
That sounds good but I believe that it's a little advanced for a newbie.
|
All times are GMT -5. The time now is 05:24 AM. |