How to create a bootable Debian Linux on a USB flash drive

How do you install Debian Linux on your computer? This isn’t obvious. The old way is to download the Debian Linux and burn it to a DVD. How many computers still come with DVD drive? As the Internet becomes more prevalent, our reliance on a local copy of files becomes less and less.

The interesting thing about setting up a new operating system is that it assumes you have a computer running an existing operating system. If you want to change it, you need a current operating system that is up and running.

In this example, I will use a MacBook Pro. There are similar steps for other operating systems.

Downloading the Debian Linux to a USB flash drive is the preferred option these days. It is portable and allows you to re-use the USB flash drive for other uses in the future.

Download the ISO Image

The latest stable Debian Linux ISO image is available from the Debian site at cdimage.debian.org.

There are many installers available for the Debian Linux operating system. Specify the directory containing your CPU installed in your computer. If you’re running the amd64 architecture, go into the amd64 directory to get this specific ISO.

For example, this link will download the amd64 ISO CD image for a network install. This is 349MB which is a lot smaller than the DVD image which is 3.7GB.

I recommend you use this image since it will save you some time from downloading a large file which you will later have to copy over to your USB flash drive.

Once downloaded, convert the ISO image to an IMG image from the Terminal.

hdiutil convert debian-10.5.0-amd64-netinst.iso -format UDRW -o debian-10.5.0-amd64-netinst.img

The hdiutil command will attach .dmg to the filename. Filename should have .dmg suffix so rename it.

mv debian-10.5.0-amd64-netinst.img.dmg debian-10.5.0-amd64-netinst.img

Transfer the image file to your computer

There are various ways to get the image to your computer. You can use a CD, DVD or USB flash drive. I recommend using a USB flash drive since it is convenient, easy to carry, and relatively fast as compared to the other options.

Insert the USB flash drive into the USB port on your computer.

Check which mount point the USB flash drive it is using. It should be something like /dev/diskX where X is a number.

diskutil list

Commands below assume your mount point is at /dev/disk2.

Unmount the USB flash drive.

diskutil unmountDisk /dev/disk2

Remove all the data from your USB flash drive and format it as FAT32.

sudo diskutil eraseDisk FAT32 USB /dev/disk2

After the USB flash drive has been formatted, it will be mounted again. You will need to unmount it again.

diskutil unmountDisk /dev/disk2

Copy the image to the USB flash drive.

sudo dd if=debian-10.5.0-amd64-netinst.img of=/dev/disk2 bs=1m

If a popup appears stating

“Terminal.app” would like to access files on a removable volume.

Click OK.

It will take some time to copy the image to your USB flash drive. Depending on the speed of your USB drive, it may take about 15 minutes.

Install Debian Linux on your computer

Insert the USB flash drive on your computer.

When your computer boots up, you will get the “Debian GNU/Linux installer menu (BIOS mode)” with a few choices. Select the first one which is “Graphical install”.

Go through the options such as language, keyboard, and network.

Once the installation is completed, remove the USB flash drive from your computer. Otherwise, your computer will boot up from the USB flash drive again. Click Continue to reboot your computer.

Username is not in the sudoers file

Once you logged in to Debian Linux as the user you created during the installation, you will notice something interesting. You don’t have any sudo powers. This is very limiting since you can’t even do an update.

bob@paris:~$ sudo apt update
[sudo] password for bob:
bob is not in the sudoers file.  This incident will be reported.

The solution is to add this user bob to the sudo group. Use su to switch as the root user.

bob@paris:~$ su -
Password:
root@paris:~# usermod -aG sudo bob
root@paris:~# exit
logout

Logging out as user bob and logging back in doesn’t seem to work anymore. You need to restart your computer.

Disable Hibernation

By default, Debian Linux will hibernate your computer after 20 minutes. This means that your hard drive will power down and you will lose your Internet access.

From a power management and energy saving perspective, this is a good thing.

If you have large files that you download or have things you run in the background and you’re not actively using the computer, this is not a good thing. You don’t want your connection to suddenly drop.

What you can do is disable this feature. It is found by clicking on the power icon at the top right corner of your screen. When a window appears, click on the icon that looks like a wrench. Doing so will open up the Power UI.

Under the “Suspend & Power Button” section, click “On” in the “Automatic suspend” section. When the “Automatic Suspend” window appears, click the button that says “When idle”. This should disable the hibernation.

Leave a Comment