7

I recently purchased an external USB hard drive and wanted to use it as a portable boot drive. I installed Linux Mint 18.1 on it and got everything working.

Then I started to think about using that drive to install Linux on other machines. I assumed that whatever a live boot USB does should be possible from a full-blown Linux installation. I looked around and the only option I found was from Ubuntu: Installation/From Linux. Their solution is to create a partition, fill it with the ISO contents and then boot from that to launch the installer. I did follow those instructions and got it working as expected, however, I still feel there must be a way to install Linux from Linux without booting into an ISO.

I just found a related question: Installing without booting. There is an answer there that suggests there is some sequence of operations that could be run to install Linux on another partition, but I would need more detail than provided there. Is that process documented somewhere?

Honestly, I would be more comfortable if I could just run the installers that are included in the live boot images of each distro. Or some kind of semi-authoritative script that would do the same thing. Is there a package in the repos that would provide such a thing (eg. a Linux Mint installer package that could be installed using apt-get or yum)?

2
  • 1
    I have no experience with that but I believe it this be referred to as a bootstrap install.
    – phk
    Commented Apr 25, 2017 at 17:37
  • @phk Thank you. That is a good keyword to know. After seeing your comment, I remembered a part of the Ubuntu guide that I had ignored since the first method worked for me. It was about using the debootstrap utility to install. That looks to be the solution, will update after I try it. Commented Apr 25, 2017 at 17:48

2 Answers 2

8

There is an example to install debian from a Linux-mint live USB (or any debian based distro). If you have a debian based distribution already installed on your hdd , you can install other debian based distro using chroot and debootstrap from the existing OS.

Boot from the live USB .Use gparted to create your root , swap ,/home... partitions.

If you prefer the command line ( fdisk , parted ..) , there is how to activate the swap partition :

mkswap /dev/sdaY
sync
swapon /dev/sdaY

Let's say you need to install debian bullseye .

Install the debootstrap package :

sudo apt-get install debootstrap

Create the /mnt/stable then mount your root partition (sdaX)

sudo mkdir /mnt/stable
sudo  mount /dev/sdaX /mnt/stable

Install the base system:

sudo debootstrap --arch amd64 bullseye /mnt/stable http://ftp.fr.debian.org/debian
sudo mount -t proc none /mnt/stable/proc
sudo mount -o bind /dev /mnt/stable/dev
sudo chroot /mnt/stable /bin/bash

Set up your root password:

passwd

Add a new user:

adduser your-username

Set up the hostname :

echo your_hostname > /etc/hostname

Configure the /etc/fstab:

add the following lines:

/dev/sdaX        /             ext4    defaults                 0    1
/dev/sdaY         none          swap    sw                      0    0
proc             /proc         proc    defaults                 0    0

use the debian documentation to edit your /etc/apt/sources.list.

Configure locale :

apt install locales
dpkg-reconfigure locales

Configure you keyboard:

apt install console-data
dpkg-reconfigure console-data

Install the kernel:

apt-cache search linux-image

Then:

apt install linux-image-5.10.0-2-amd64

Configure the network:

editor /etc/network/interfaces

and past the following:

auto lo
iface lo inet loopback

allow-hotplug eth0 # replace eth0 with your interface
iface eth0 inet dhcp

allow-hotplug wlan0 # replace wlan0 with your interface
iface wlan0 inet dhcp

To manage the wifi network, install the following packages:

apt install iproute2 network-manager iw

Install grub :

apt install grub2
grub-install /dev/sda
update-grub

You can install a desktop environment through the command tasksel :

apt install aptitude tasksel

Run the following command and install your favourite GUI:

tasksel

Finally, exit the chroot and reboot your system

Documentation: D.3. Installing Debian GNU/Linux from a Unix/Linux System

Debian wiki:

3
  • 1
    This is a great answer. Thank you. I would just like to point out that this does not need to be done from a Live USB. This could be done from any Debian based Linux that is already running which is what I was looking for. (That may be what the parenthetical in your first sentence was getting at, I wasn't sure) Commented Apr 25, 2017 at 20:19
  • One thing I had to add to this: the old machine I was using to prep was BIOS, but the new machine I was prepping for was UEFI, so I had to use refind-install --usedefault /dev/sda2 to get a bootloader installed. Commented Jun 24, 2019 at 8:03
  • I can't believe that debootstrap doesn't do all that for you. Chances that I remember all this stuff next time are zero.
    – jsaddwater
    Commented Jan 22, 2020 at 21:38
0

USB-creator does this for USB sticks. I imagine it should be able to handle any removable media.

https://community.linuxmint.com/software/view/usb-creator-gtk

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .