LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 06-09-2013, 12:35 AM   #1
replica9000
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Debian, FreeBSD, Android
Posts: 1,051
Blog Entries: 2

Rep: Reputation: 224Reputation: 224Reputation: 224
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
root@host# apt-get install debootstrap




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
Unpacking the .deb file:
Code:
root@host# cd /tmp/debootstrap
root@host# ar vx debootstrap_1.0.66_all.deb
root@host# tar -xf data.tar.gz
Temporary setup:
Code:
root@host# ln -s /tmp/debootstrap/usr/sbin/debootstrap /usr/sbin/debootstrap
root@host# ln -s /tmp/debootstrap/usr/share/debootstrap /usr/share/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
root@host# mkdir /mnt/deboot
root@host# mount -t ext4 /dev/sda1 /mnt/deboot




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
debootstrap can also be used to install Ubuntu (ex. Raring Ringtail):
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
root@host# debootstrap --foreign --include linux-image-amd64,grub-pc,locales --arch amd64 unstable /home/<user-name>/deboot http://ftp.us.debian.org/debian
If we were installing to a PowerPC...
Code:
root@host# debootstrap --foreign --include linux-image-powerpc,yaboot,locales --arch powerpc unstable /home/<user-name>/deboot http://ftp.us.debian.org/debian
Next we'll change to our temporary directory and create a tarball for use on the target machine.
Code:
root@host# cd /home/<user-name>/deboot
root@host# tar czf ../debian-stage2.tgz .
Copy the debian-stage2.tgz file to the target machine. Assuming your target partition is ready, change to the target directory and extract the tarball.
Code:
root@host# cd /mnt/deboot
root@host# tar xzf /path/to/debian-stage2.tgz
Next we'll enter the chroot environment for a moment to complete the second stage of the install.
Code:
root@host# chroot /mnt/deboot /bin/bash
root@chroot# /debootstrap/debootstrap --second-stage
root@chroot# exit




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
Binding the virtual filesystems. Until your new install is booting on it's own, we'll borrow these from the host.
Code:
root@host# mount -o bind /dev /mnt/deboot/dev
root@host# mount -o bind /proc /mnt/deboot/proc
root@host# mount -o bind /sys /mnt/deboot/sys




Continuing the installation within chroot
Entering the chroot environment:
Code:
root@host# chroot /mnt/deboot /bin/bash
Since we used the --include option to get grub, it was installed, but not configured.
Code:
root@chroot# grub-install /dev/sda
root@chroot# update-grub
Setting up /etc/fstab for the root filesystem. Use the blkid command to get the UUID of /dev/sda1.
Code:
root@chroot# blkid /dev/sda1
Then add this entry to /etc/fstab using the UUID output from the command above:
Code:
UUID=79168060-9d9c-4cf6-8ee9-bb846aee589b / ext4 defaults,errors=remount-ro 0 1
Give your new install a name. If not, your new install won't have a name, or inherit the name of the host you are installing from.
Code:
root@chroot# echo "<name-your-host>" > /etc/hostname
Configure your locale:
Code:
root@chroot# dpkg-reconfigure locales
Create a password for root:
Code:
root@chroot# passwd
Create a normal user:
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
For a static IP:
Code:
root@host# ifconfig -v eth0 192.0.2.7 netmask 255.255.255.0 up
You can have this automatically done for you when the system boots by editing the file below.

For DHCP, the /etc/network/interfaces file should look like this:
Code:
# 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
For a static IP, the /etc/network/interfaces file should look like this:
Code:
# 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
   address 192.0.2.7
   netmask 255.255.255.0
   gateway 192.0.2.254




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
Here are some examples of installing a desktop:
Code:
root@chroot# apt-get install xserver-xorg wdm fluxbox xterm
- or -
root@chroot# apt-get install xserver-xorg lightdm xfce4
- or -
root@chroot# apt-get install gdm3 gnome
- or -
root@chroot# apt-get install kdm kde-standard
You can use also use tasksel to install a desktop for you. To see the available options:
Code:
root@chroot# tasksel --new-install




Finishing the install
Clean the package cache:
Code:
root@chroot# apt-get clean
Update the ramdisk:
Code:
root@chroot# update-initramfs -u -k all
Exit the chroot environment:
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.....
W: See /mnt/deboot/debootstrap/debootstrap.log
Check that :/sbin is in your PATH, if not:

Code:
root@host# export PATH=$PATH:/sbin
root@host# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
----------------------------------------------------------------------------------------

Code:
E: No pkgdetails available; either install perl, or pkgdetails.c from the base-installer source package
Perl probably isn't installed. Please install Perl.

----------------------------------------------------------------------------------------

Debian doesn't boot!

Code:
fsck exited with status code 0
sulogin: cannot open password database!
Segmentation fault
Chances are, your root filesystem isn't configured properly in /etc/fstab. Fix the root entry, then run:
Code:
root@chroot# update-initramfs -u -k all

Last edited by unSpawn; 01-24-2015 at 09:02 AM. Reason: //Updated by replica9000, fixed typo
 
Old 06-09-2013, 12:41 PM   #2
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
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.
 
Old 06-09-2013, 12:44 PM   #3
replica9000
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Debian, FreeBSD, Android
Posts: 1,051
Blog Entries: 2

Original Poster
Rep: Reputation: 224Reputation: 224Reputation: 224
Let me know how it works for you. I've tested using Aptosid, Fedora, Arch and Slax.
 
Old 06-09-2013, 12:48 PM   #4
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
I will, but I'm sure that it works I have to bookmark it so I don't have to search for it later.
 
Old 08-05-2013, 03:52 AM   #5
Wocky
Member
 
Registered: Oct 2004
Location: Australia
Posts: 37

Rep: Reputation: 2
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
# tar czf /home/Wocky/linux.tgz /cdrom/pool
Then use (for example)
Code:
# debootstrap --unpack-tarball=/home/Wocky/linux.tgz wheezy /mnt/deboot
Secondly, if you're running on a 64-bit machine, having /lib in your LD_LIBRARY_PATH environment variable can cause problems (because multiarch support also uses /lib64). Before you do any of the above, check that LD_LIBRARY_PATH doesn't contain /lib.

Last edited by Wocky; 08-05-2013 at 06:42 AM.
 
Old 01-01-2015, 12:46 AM   #6
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Rep: Reputation: 49
Quote:
Originally Posted by replica9000 View Post

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
root@host# mkdir /mnt/deboot
root@host# mount -t ext4 /dev/sda1 /mnt/deboot
Can the target partition be on a seperate empty hard disk?

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?
 
Old 01-01-2015, 02:36 AM   #7
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
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.
 
Old 01-01-2015, 09:28 AM   #8
replica9000
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Debian, FreeBSD, Android
Posts: 1,051
Blog Entries: 2

Original Poster
Rep: Reputation: 224Reputation: 224Reputation: 224
Quote:
Originally Posted by Higgsboson View Post
Can the target partition be on a seperate empty hard disk?

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?
Yes. You can use any empty partition for your target.
 
Old 01-02-2015, 03:07 AM   #9
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Rep: Reputation: 49
Thank you for your reply replica9000!

I have just a few more questions:

Quote:
Originally Posted by replica9000 View Post
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
root@host# mkdir /mnt/deboot
root@host# mount -t ext4 /dev/sda1 /mnt/deboot
I can't see a command for the sizing of the partition. How does that work?
I have a 160gb hdd and I was looking to install a distro to a 40gb partition.

Quote:
Installing the base system:
----------------------------------------------------------------------------------------
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.
Usage: debootstrap --include=<addtional_packages,comma-separated> --arch <architecture> <release> <target> <mirror>
[code]
root@host# debootstrap --include=linux-image-amd64,grub-pc --arch amd64 unstable /mnt/deboot http://ftp.us.debian.org/debian
What would be the command if I want to install the stable debian 7.7?
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:
Create a password for root:
Code:
root@chroot# passwd
So is the command to create a password like this:

Code:
root@chroot# passwd mypassword
Is this correct?

Quote:
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.

Code:
root@chroot# apt-get install xserver-xorg wdm fluxbox xterm
- or -
root@chroot# apt-get install xserver-xorg lightdm xfce4
What is the command for using the gnome shell, please?
 
Old 01-02-2015, 07:32 AM   #10
colorpurple21859
Senior Member
 
Registered: Jan 2008
Location: florida panhandle
Distribution: slackware64-current, puppy, ubuntu
Posts: 2,046

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
What would be the command if I want to install the stable debian 7.7?
You can run tasksel. https://wiki.debian.org/tasksel https://wiki.debian.org/DebianDesktop/Tasks

Quote:
I imagine I have to substitute 'arch' for something else. I have an amd64 processor
If I remember correctly it is based on the arch of the system you running debootstrap from.

Quote:
Incidentally, would I be OK to simply install 'Sid' anyway, even if it is the unstable version?
Yes, just beware, you may get breakage from time to time that you will have to fix, but usually doesn't happen very often.

Quote:
So is the command to create a password like this:
Code:
passwd root

Last edited by colorpurple21859; 01-02-2015 at 07:35 AM.
 
Old 01-02-2015, 11:23 AM   #11
replica9000
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Debian, FreeBSD, Android
Posts: 1,051
Blog Entries: 2

Original Poster
Rep: Reputation: 224Reputation: 224Reputation: 224
Quote:
Originally Posted by Higgsboson View Post
Thank you for your reply replica9000!

I have just a few more questions:


I can't see a command for the sizing of the partition. How does that work?
I have a 160gb hdd and I was looking to install a distro to a 40gb partition.
I didn't cover partitioning in this how-to. Maybe next time I update it.



Quote:
Originally Posted by Higgsboson View Post
What would be the command if I want to install the stable debian 7.7?
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?
In this line change unstable to stable:
Code:
debootstrap --include=linux-image-amd64,grub-pc --arch amd64 unstable /mnt/deboot http://ftp.us.debian.org/debian


Quote:
Originally Posted by Higgsboson View Post
So is the command to create a password like this:

Code:
root@chroot# passwd mypassword
Is this correct?
Yes. simply entering passwd will prompt to change to root password. Entering passwd <someone's username> will prompt to change the password for that user.



Quote:
Originally Posted by Higgsboson View Post
What is the command for using the gnome shell, please?
should be apt-get install gnome-shell
 
Old 01-02-2015, 12:13 PM   #12
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Rep: Reputation: 49
Quote:
Originally Posted by replica9000 View Post
I didn't cover partitioning in this how-to. Maybe next time I update it.
In fairness, the beginning of your how-to has already mentioned it will not cover partitions.
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!
 
Old 01-02-2015, 07:54 PM   #13
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Quote:
Thank you very much!! The debootstrap program is the way to go!
It's actually the way to go when you can't boot to any media cd/dvd/usb other than that you're better off using the installer from the cd/dvd/usb.
 
Old 01-02-2015, 10:58 PM   #14
replica9000
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Debian, FreeBSD, Android
Posts: 1,051
Blog Entries: 2

Original Poster
Rep: Reputation: 224Reputation: 224Reputation: 224
Quote:
Originally Posted by Higgsboson View Post
In fairness, the beginning of your how-to has already mentioned it will not cover partitions.
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!
Glad I could be some help. Partitioning can get tricky depending on if one was using msdos or gpt with bios or uefi setups.

Quote:
Originally Posted by EDDY1 View Post
It's actually the way to go when you can't boot to any media cd/dvd/usb other than that you're better off using the installer from the cd/dvd/usb.
I suppose this method is good for users who wish to use unstable, or have special setups. I used to use the net-install CDs, but those aren't released for unstable. So after install, I had to update/upgrade the whole system again anyways.
 
Old 01-03-2015, 03:08 AM   #15
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
That sounds good but I believe that it's a little advanced for a newbie.
 
  


Reply

Tags
chroot, debian, debootstrap, ubuntu


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
chroot debian 32 bits on amd64 debootstrap error. mariogarcia Debian 2 02-23-2011 02:20 AM
Debian PPC Install errors (debootstrap, error 1) kdepa Debian 3 03-29-2007 06:27 AM
LXer: Installing Debian GNU/Linux using debootstrap LXer Syndicated Linux News 0 08-21-2006 10:21 AM
Debian install error /usr/lib/debootstrap/pkgdetails GT_Onizuka Debian 0 11-01-2005 01:11 AM
There have a error with debootstrap install debian cbz789 Debian 2 04-22-2005 06:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 02:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration