Skip to content

Instantly share code, notes, and snippets.

@fqborges
Created May 20, 2025 18:33
Show Gist options
  • Select an option

  • Save fqborges/3e01b9d8ba58e083e4b33b418851319b to your computer and use it in GitHub Desktop.

Select an option

Save fqborges/3e01b9d8ba58e083e4b33b418851319b to your computer and use it in GitHub Desktop.
Install Debian from hdd partition

Install Debian from hdd partition

You can install debian or try a debian live from your hdd, without needing a cd or usb stick.

Instructions here are based on a debian forum topic [1]. There are alternative solutions for text based installers that does not need to copy files from inside the iso file, and just downlad them from debian mirrors, for that see [2].

Recommended: create install/recovery partition

Use your partition editor of choice to:

  • free 4 GB at the end of your hdd (move and/or shrink partitions if necessary)
  • create a 4GB ext4 partition at the end of your hdd
  • mount it at /mnt/install-media

The path /mnt/install-media would be assumed though all this document.

OBS: if you have a separated home partition and are going to keep it untouched during installation, you theoretically can use a path there.

download your iso

Choose your iso image from debian download page at https://www.debian.org/distrib/. We will use the current latest live kde iso (at the time this document is being written) as an example.

cd /mnt/install-media
wget https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-12.9.0-amd64-kde.iso

copy boot files from iso

cd /mnt/install-media
sudo mkdir /mnt/iso
sudo mount -o loop debian-live-12.9.0-amd64-kde.iso /mnt/iso
sudo cp /mnt/iso/live/initrd.img /mnt/iso/live/vmlinuz .
sudo umount /mnt/iso
sudo rm -rf /mnt/iso

OBS: some isos have initrd-[version].img and vmlinuz-[version] files instead, or both.

Edit grub entry

You /etc/grub.d/40_custom should look like this:

❯ cat /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "debian-live.iso" {
  insmod ext2
  set root='(hd0,4)' 
  set iso="/debian-live-12.9.0-amd64-kde.iso"
  linux /vmlinuz findiso=$iso boot=live components quiet splash
  initrd /initrd.img
}

Make sure you have the following correct:

  • set root='(hd0,X)': where X is your partition number starting on 1. For our default configuration, it is: 1=boot, 2=root, 3=home, 4=install/recovery
  • set iso="ISO": where X is path to downloaded iso
  • linux VMLINUZ ...: where VMLINUZ is path to vmlinuz file cp from iso
  • initrd INIT: where INIT is path to initrd.img file cp from iso

Apply grup changes

sudo update-grub

Reboot and boot from iso

sudo reboot

After rebooting, select grub menu entry: 'debian-live.iso'

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment