• Linux
  • September 2023
    M T W T F S S
     123
    45678910
    11121314151617
    18192021222324
    252627282930  
  • Meta

My Scripts for ISOs

I’ve never really been into distro-hopping, but I do occasionally put different distros in VMs or actual hardware. I currently run Debian, Linux Mint, Linux Mint Debian Edition, MX Linux, and BunsenLabs on different machines. I keep current ISO files for these distributions as well as a few others that look interest me.

I haven’t always checked the ISO files I download against the checksum files. It seemed like a hassle to do it, but I always confirm that the files I download are genuine.

When I need to install a distro on a laptop or desktop, I generally need write the ISO to a USB stick. Some distros, like Mint, have a utility for that, but I’ve found that it’s not always reliable. I’ve copied ISO files to a USB drive with Ventoy installed, but my experience with Ventoy has been rather disappointing. Sometimes it works, and sometimes it doesn’t.

The most consistent method I’ve found, particularly for Debian and Debian-based distributions, has been using dd to write the ISO to a USB drive. As everyone knows, dd is potentially dangerous.

To deal with these problems, I’ve written a couple of scripts to verify and reduce the risks. They aren’t fullproof, but they’ve worked well for me.

My check-iso script displays the ISO and checksum files in a directory and prompts me to enter the appropriate files. I can either type them in, but I usually highlight the file with my mouse and use the center-click to copy it to the prompt. I don’t know if that works in all terminals, but it works in Kitty and Terminator. The script then compares the two checksums and tells me whether they match.

When I download an ISO file from a distro’s website, I get the checksum and put it in a file whose name identifies the distro and the type of checksum, for example, distro-iso.sha256. If the site’s checksum file contains checksums for multiple versions, I’ll break that file down into individual files for each because my script reads the first field on the first line.

The write-iso script lists the available ISO files and a prompt. Then it checks to see if a USB drive is attached and mounted, and lists the available removal media with its capacity. The user enters the appropriate device at the prompt and is prompted to confirm the choice which must be explicity answered with yes or no.

When it comes to scripts, like a poem, they’re never finished. Most of the time, they’re abandoned when they’ve outlived their usefulness or I find something else that does the job better.

3 Responses

  1. Lately, I’ve been tweaking my scripts for checking and writing ISO files to a USB drive. I renamed the check-iso script to verify-iso so it more clearly descirbed the script’s functon. The most recent change to the scripts was to incorporate fzf (fuzzy-finder) to select the ISO files, checksum files, and the target USB drive. I’m quite happy with the results.

    Recently, I finally resolved my issues with my GitHub account and have updated my repositories there. The srcipts are available in my bashscripts repository on GitHub. Feel free to download or clone the repository. If you’re just downloading these particular scripts, be sure to download functionlib as well and put in your ~/bin directory. This is a library of frequently used functions that I source in most of my scripts.

  2. I tweaked the write-iso script a little further. My systems with desktop environments will usually detect when a USB drive is inserted, then mount it and open up a file manager. My i3 systems don’t do that, although if I open Thunar, it will see the drive, and when I click on it, it will mount the drive and show its contents. Once the drive is mounted, I can work with it normally.

    The script already shows me the available USB drives and once I’ve selected one, I need to mount it if it’s not already mounted. Knowing the base device name, such as sdc, I have the script append a 1 to it, and check to see if it’s mounted. If not, I create a mount point in the /media/$USER directory and mount the drive to that location. If the drive is already mounted, I extract the name of the mount point to be used to unmount the drive and remove the mount point after the dd operation has completed.

    The functions I created for mounting and unmounting at USB drive will undoubtedly be useful in a script for working with USB drives on systems that don’t automatically mount them. Now that I’m inspired, I’ll probably write that one in the next few days.

  3. I’m still making improvements to the verify-iso and write-iso scripts. Lately, I’ve refined how I enter the filenames and the USB drives by implementing two different methods that don’t require the read command or typing in the information. One method uses fzf (Fuzzy Finder) if it’s installed and the other creates a numbered menu that uses the select command. It creates an array from the output of either find or lsblk and I select the files or the drive from the menu.

    Thanks to Kris Occhipinti, his videos on using Fuzzy Finder and creating file selection menus, inspired me to incorporate these ideas into my scripts.

Comments are closed.