LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   HOW-TO: Install Debian using debootstrap. (https://www.linuxquestions.org/questions/debian-26/how-to-install-debian-using-debootstrap-4175465295/)

replica9000 01-10-2015 11:13 AM

Quote:

Originally Posted by Higgsboson (Post 5298598)
3. Install base system, kernel and bootloader. I'll be using a UK mirror site. Unfortunately, I have a Radeon 4200 sound card - so I'll need 'contrib' and 'non-free' versions of debian.
Code:

root@host# debootstrap --include=linux-image-amd64,grub-pc --arch amd64 stable main contrib nonfree  /mnt/deboot http://ftp.uk.debian.org/debian

To add contrib and non-free, your command should look like this:
Code:

root@host# debootstrap --include=linux-image-amd64,grub-pc --components=main,contrib,non-free --arch amd64 stable /mnt/deboot http://ftp.uk.debian.org/debian


Quote:

Originally Posted by Higgsboson (Post 5298598)
6. Copy correct file onto install for network access. I needed to do this after the install but I'm not sure when to put in the command:
Code:

cp /etc/resolv.conf /mnt/etc/resolv.conf

I'll be updating this soon. I'll probably leave an example of /etc/network/interfaces since copying it from the host may not work in a lot of cases. Using that file should work, but there could be other options of achieving the same result. For instance, you're installing stable, which is still using Sys-V init. Unstable should be installing systemd init by default. The host I used for the test the other day was using upstart init. Each might have it's own method of configuring network interfaces.



Quote:

Originally Posted by Higgsboson (Post 5298598)
9. 'Install a display manager and a window manager':
Code:

root@chroot# apt-get install xserver-xorg wdm fluxbox xterm
- or -
root@chroot# apt-get install xserver-xorg lightdm xfce4

It would be good here to know commands for different GUIs.

Can anyone please say if the above is ok for a new install?

When I update it, I could add a couple more examples of installing desktop managers. Since you're interested in Gnome, this should get you a basic Gnome desktop. Also, this will install network-manager, which should configure your network for you.
Code:

apt-get install gdm3 gnome-shell gnome-terminal

Higgsboson 01-10-2015 11:48 AM

Quote:

Originally Posted by replica9000 (Post 5298691)
I'll be updating this soon. I'll probably leave an example of /etc/network/interfaces since copying it from the host may not work in a lot of cases. Using that file should work, but there could be other options of achieving the same result. For instance, you're installing stable, which is still using Sys-V init. Unstable should be installing systemd init by default. The host I used for the test the other day was using upstart init. Each might have it's own method of configuring network interfaces.

Wow, thanks for looking throught it, dude!

To make my target partition (sda2) bootable for GRUB, I've used Gparted and flagged it as a 'boot' partition.

EDDY1 01-10-2015 02:02 PM

Quote:

To make my target partition (sda2) bootable for GRUB, I've used Gparted and flagged it as a 'boot' partition.
It doesn't matter about boot flag if you just do "grub-install /dev/sda" it will install grub to the / partition but also make entry to MBR to point to your grub.
Depending on your system you may want to create a swap partition.

Higgsboson 01-10-2015 03:36 PM

Quote:

Originally Posted by EDDY1 (Post 5298760)
It doesn't matter about boot flag if you just do "grub-install /dev/sda" it will install grub to the / partition but also make entry to MBR to point to your grub.
Depending on your system you may want to create a swap partition.

Thanks dude. That's good to know. I read somewhere that it's easier just to have GRUB on each linux OS.

Swap files and swap partitions are certainly a good idea. I'm gonna have to find out a bit more and decide where to put them.

EDDY1 01-10-2015 03:43 PM

It's easier to have only 1 grub & let it control everything.
Once you have grub installed any other OS can be added to debian's grub by running "update-grub"

colorpurple21859 01-10-2015 06:40 PM

For a complete desktop run one of the following depending on the preferred desktop:
tasksel --new-install install kde-desktop
tasksel --new-install install xfce-desktop
taslsel --new-install install gnome-desktop
tasksel --new-install install lxde-desktop
The network setup will take care of it's self when installing a full desktop.

colorpurple21859 01-10-2015 10:44 PM

I've been playing around with it some. Firmware has to be install if needed and the tasksel command for a full install with the best results is something similar to this after doing apt-get update:
Code:

tasksel --new-install install standard laptop gnome-desktop

replica9000 01-10-2015 11:16 PM

Quote:

Originally Posted by colorpurple21859 (Post 5298946)
I've been playing around with it some. Firmware has to be install if needed and the tasksel command for a full install with the best results is something similar to this after doing apt-get update:
Code:

tasksel --new-install install standard laptop gnome-desktop

Thanks for the info. I'll probably add it when I update the OP.

Higgsboson 01-11-2015 10:37 AM

I have completed the install to my sda2 partition using debootstrap.
The install was successful and a debian OS is running- but there is a problem.

Originally, the GRUB boot menu would offer options to boot debian from sda1 and Windows from a seperate hdd in sdb1.
But now that I've installed a new debian distro in sda2 - I get a new GRUB menu which only offers the option to boot from sda2.
The options for sda1 and sdb1 have disappeared.

I tried update-grub and the output is:
Code:

update-grub
Generating grub.cfg ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-3.2.0-4-amd64
Found initrd image: /boot/initrd.img-3.2.0-4-amd64
done

But the GRUB boot menu is unchanged and only sda2 can be accessed.

I used a live USB and removed the boot flag on sda2.
I then added a boot flag to sda1.
However, this has had no effect.

Does anyone know why GRUB isn't seeing the 2 distros on sda and the Windows on sdb?

replica9000 01-11-2015 10:49 AM

You could try installing os-prober. It's supposed to detect other OSes so Grub can add them to it's menu.

Higgsboson 01-11-2015 11:31 AM

Quote:

Originally Posted by replica9000 (Post 5299170)
You could try installing os-prober. It's supposed to detect other OSes so Grub can add them to it's menu.

Yes, the GRUB tutorial refers to using os-prober too. But it also says 'refer to the grub.cfg file, os-prober section'. But it isn't clear where that is. http://dedoimedo.com/computers/grub-...mozTocId835620

The GRUB tutorial is a little bit complicated. It also seems to be saying if you install a new distro, then the previous GRUB bootloader gets overwritten. But then starts talking about the difference between GRUB legacy and GRUB2.

This looks like a GRUB issue, so I'm going to start a new thread about the bootloader.

EDDY1 01-11-2015 01:58 PM

You do need os-prober I just tried to update-grub on my other system which had no os-prober which got no results. After installing it, it saw the other systems.

Higgsboson 01-11-2015 02:12 PM

Quote:

Originally Posted by EDDY1 (Post 5299261)
You do need os-prober I just tried to update-grub on my other system which had no os-prober which got no results. After installing it, it saw the other systems.

Yes, I tried installing os-prober and I got an error message:

Code:

apt-get install os-prober
Reading package lists... Done
Building dependency tree     
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 fglrx-driver : Depends: libfglrx (= 1:12-6+point-3) but it is not going to be installed
                Recommends: fglrx-modules-dkms (= 1:12-6+point-3) but it is not going to be installed or
                            fglrx-kernel-12-6+point
                Recommends: libgl1-fglrx-glx-i386 but it is not installable
                Recommends: fglrx-glx-ia32 but it is not going to be installed
 libgl1-fglrx-glx : Depends: libfglrx (= 1:12-6+point-3) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

So now I've had to start a new thread about sorting out my non-free sound card issue.
I resolved it on my first install. But with this second install I'm getting slightly different error messages.

EDDY1 01-11-2015 04:01 PM

Post your /etc/apt/sources.list

Higgsboson 01-13-2015 02:52 PM

Quote:

Originally Posted by EDDY1 (Post 5299261)
You do need os-prober I just tried to update-grub on my other system which had no os-prober which got no results. After installing it, it saw the other systems.

Now that I've sorted out the install of a broken package, I've been able install os-prober and it resolved the problem.

I read a tutorial on GRUB but it didn't mention that after a new install, GRUB can't probe for existing installs.
So it seems os-prober is essential for creating multi-boot systems with GRUB.

Did you use debootstrap to create your new install?

patrick295767 06-05-2016 09:31 AM

You may check my thread you have a cool method to install debian using debootstrap :

http://www.linuxquestions.org/questi...ks-4175581486/

stevenatadv 02-13-2017 10:09 PM

it works
 
But you also needs config swap partition.

Xeratul 09-02-2022 04:32 AM

One command only is needed:

Code:


  apt-get update ; apt-get install -y -f debootstrap ;  debootstrap  --no-check-gpg    --include=debootstrap,wpasupplicant  ascii  .  http://pkgmaster.devuan.org/merged  ; mkdir usr/src


Quote:

Originally Posted by replica9000 (Post 4968093)
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


gatopeich 12-21-2023 07:54 AM

Debootstraping Mint to USB disk in 2023
 
Kudos for this guide which is simple but hard to find online.

Many many thanks.

I am using it to install Mint on a USB drive, from a Mint Vanessa system.

This is now easier than it was but it still not widely known so here is my recipe:

On host system:
Code:

$ sudo apt update
$ sudo apt install debootstrap

# Format fresh ext4 filesystem on sdc2, and fat32 on sdc1
$ mkdir NewMint && sudo mount /dev/sdc2 NewMint
$ debootstrap jammy NewMint
... takes about 5 minutes to run

$ sudo cp /etc/mtab NewMint/etc/mtab  # Not sure if this was required!
$ sudo cp /etc/apt/sources.list.d/official-package-repositories.list NewMint/etc/apt/sources.list.d/

$ sudo mount --rbind /dev NewMint/dev
$ sudo mount --rbind /proc NewMint/proc
$ sudo mount --rbind /sys NewMint/sys

# Mount Fat32 partition /dev/sdc1 for EFI boot:
$ sudo mkdir -p NewMint/boot/efi
$ sudo mount --rbind /dev/sdc1 NewMint/boot/efi

$ sudo chroot NewMint bash

We are inside target system now, run the following:
Code:

root@target# apt update && apt install tasksel grub2
...
root@target# apt install grub2
...
root@target# grub-install /dev/sdc  # The USB drive device
Installing for i386-pc platform.
...
root@target# tasksel --new-install
Software selection
------------------

At the moment, only the core of the system is installed. To tune the system to your needs, you can choose to
install one or more of the following predefined collections of software.

  1. Debian desktop environment  4. ... GNOME Flashback  7. ... MATE  10. web server
  2. ... GNOME                  5. ... KDE Plasma      8. ... LXDE  11. SSH server
  3. ... Xfce                    6. ... Cinnamon        9. ... LXQt  12. standard system utilities

(I choose 3 here, it takes a while to install it but less than downloading the 3GB ISO!)

# Make it bootable:
root@target# grub-install /dev/sdc
...
root@target# update-grub
...
done

Outside again, unmount everything before extracting the drive:
[CODE]
$ sudo umount USB-Mint/boot/efi
$ sudo umount USB-Mint/dev
$ sudo umount USB-Mint/proc
$ sudo umount USB-Mint/sys
$ sudo umount USB-Mint
[CODE]

Now try to boot that from USB!


All times are GMT -5. The time now is 04:51 AM.