New steps in my adventure toward switching to GNU/Linux

Today, Garuda updated the kernel to the new version 6.10, that was recently released. So far, it seems to work flawlessly. My initial impression is that it’s significantly better than the 6.9.10 release, which messed with my Nvidia video driver, making video graphics jerky/fluttery.

This week, I installed MEGAsync (again), to see if some issues I encountered earlier have been fixed. It seems to be all good now. I configured the desktop client to sync my Documents and Pictures directories to directories of the same names on my MEGA.io storage space. I did this on both my desktop and primary laptop PCs, so when anything changes in these directories on either device, it’s reflected on the other. Next, I copied the contents of my OneDrive directory to my MEGA directory, so all those files are stored on MEGA.io too. I have a script I wrote to sync any changes on the OneDrive directory to the MEGA directory, using rsync. I’ve added it to my sync alias in (dot)bashrc, so when I manually sync OneDrive (using that alias), any changes will be reflected to the MEGA directory, and therefore, to MEGA.io.

Today, I installed Balena Etcher, so I can easily install ISO image files on USB sticks in GNU/Linux. Then I downloaded Rescuezilla (a GUI front end for Clonezilla, as a live ISO image file), and used Etcher to put it on a 16GB USB3 stick, then used that stick to image my primary laptop’s SSD drive, storing it on the device’s 2TB external drive. Unless things change significantly, I should have enough space on that drive to keep several images, so if something bad happens (like me doing something stupid during an ‘experiment’), I’ll at least be able to recover rather easily.

All in all, I’m feeling more and more ready to drop Windows, if Microsoft does all I suspect they will with the next major Windows upgrade. On the other hand, if they don’t do all the bad stuff I’m expecting, and I decide to keep them around for a bit longer, I’ll still have a great way to image all my computers (for free), and I’ll be able to end my Macrium Reflect subscription, saving some money in the bargain to boot. The best part of all this is that I got the MEGAsync desktop app, the onedrive client, and Balena Etcher from Garuda’s chaoticAUR repository, so any updates will come from Garuda, as part of my normal system maintenance routines.

This has been a good week for me,

Ernie

4 Likes

@ernie
Do you really want to know how linux works and how it is built? Then try
building “linuxfromscratch”, and you will find out, just how much distro installs
have became automated.

3 Likes

Why choose that verson of linux ?
Is it mainly to be used for gaming ?

At this point, all I want to be able to do is make GNU/Linux do whatever strikes my fancy at any given moment. Back in my MS-DOS days, I studied Assembly language, so I could learn to make (dot)com executables to add new functionality to DOS, or make it do things differently. The biggest lesson I learned during that time was a fundamental understanding of how an x86 PC works at the hardware level. I had a book about Assembly language, another book about the MS-DOS APIs and BIOS functions I could use to get things done, and an 8088-based PC with MS-DOS 3.1, and the debug debugger (what I used to translate my code into executable (dot)com files). For me, the best thing about GNU/Linux is that I can build bash scripts to make it do things for me. At some point, I may decide to give Linux from Scratch a go, just to see if I can do it, but not just yet. :slight_smile:

Ernie

2 Likes

Try Gentoo first. It will teach you some of the things needed for LFS

Use that if you want, but dd is the basic tool for copying anything to anywhere.
You do need to be careful with dd, it is capable of overwriting things if you make a mistake.

2 Likes

@nevj and @all:

That reminds me of a distrowatch article I just stumbled across a few days ago.

It´s about how to use dd in a safer way:

The author created a wrapper around dd by writing a shell script called safe-dd. The script looks like this:

#!/bin/bash

# This script invokes the dd command to copy a file. It first checks to make sure
# the target file (of) is not mounted.
# Warning, this may not work with device names containing a space.

if [ $# -lt 2 ]
then
  echo "Please provide an input file and an output file."
  exit 1
fi

start=$(echo $@ | sed 's/of=/\^/')
end=$(echo $start | cut -f 2 -d '^')
target=$(echo $end | cut -f 1 -d ' ')

echo "Checking $target"
df | grep $target
if [ $? -eq 0 ]
then
  echo "Output file $target is mounted. Refusing to continue."
  exit 2
fi

echo "Executing nice dd $@ status=progress"
nice /usr/bin/dd $@ status=progress
sync
echo "Finished writing and sync."

Here´s the explanation to it:

The first few lines do a quick sanity check to make sure we have at least two parameters, presumably a file we want to use and a destination device where the file will be sent.

The echo, sed and cut commands which follow look for a parameter that specifies the destination location (also known as the output file, or of). When we find this parameter, it is saved in the variable $target.

The script then uses the df command to get a list of all mounted filesystems and uses grep to see if our destination matches any mounted locations. In other words, if we ask safe-dd to write to the location /dev/sda and /dev/sda1 is where our root filesystem is located, the line “df | grep $target” will spot the match and the script will not continue.

The last block of the script tells the user it is going to proceed and then launches the dd command, passing along the parameters we’ve specified. The script then forces a filesystem synchronization, meaning data intended to be written to a thumb drive should actually be written and not simply cached. The script then announces its work is finished.

and:

[It´ll] act as a friendly wrapper around the dd command and prevent data loss (such as overwriting a mounted drive) in most scenarios. This means I can run a command, such as the one below, and not worry about it causing damage:

sudo safe-dd if=Fedora-38-Workstation.iso of=/dev/sdc

I haven´t tried it myself so far but thought it might be worth mentioning it here. :wink:

Many greetings from Rosika :slightly_smiling_face:

3 Likes

Truth be told, I just wanted to get Rescuezilla installed on a USB drive, so I could use it to create backup images for my laptop and desktop computers, and Balena Etcher is the utility Rescuezilla directed me to use, so I installed it without thinking. I’ve used dd before, but I’m not familiar enough with it to be comfortable yet. I’ll give it a try for future live images, though, because I think it would be a good idea for me to become more familiar with it and other basic tools that come with GNU/Linux.

Clonezilla is another learning target for me. I use the CLI to sync OneDrive in GNU/Linux, and I use it to update my system too. Eventually, I want to get away from all these graphical utilities, and be able to work in the terminal emulator as easily as I do with the GUI equivalents.

Ernie

2 Likes

Thank you for that script, @Rosika! I’m going to copy and save it, so I can use it the next time I want to put an ISO image on a USB stick. :slight_smile:

Ernie

2 Likes

Hi Ernie, :wave:

you´re welcome.

Perhaps you might like to read through the complete distrowatch article (the link to which I provided in my previous post) before trying out the script.

It holds some more background information.

Cheers from Rosika :slightly_smiling_face:

1 Like

I’ll do that. :slight_smile:

UPDATE
I gave the safe-dd script a try, and I get an error “required file not found”

I use KDE’s Kate editor, and it provides shellcheck output and LSP diagnostics, but none of that has been helpful.

I’m not very good with sed or stuff like “s/of=/^/” yet, so for the time being, I think I’ll simply use dd with great care. I always make a habit of reading what I wrote at least twice before I commit to a change, or run a command line, especially in the terminal emulator, so if I’m careful, hopefully, that’ll be enough.

Ernie

3 Likes

@ernie :

Hi Ernie, :wave:

thanks for your feedback.

I´ve been discussing this script with ChatGPT and it thinks the world of it.
Basically this script should work as intended.

Some potential issues could be:

  • Incorrect Script Path:

    Make sure the script is being executed with the correct path.
    If the script is in the current directory, ensure it is executed with ./safe-dd and not just safe-dd.

  • File Permissions:

    Ensure the script has execute permissions. Run:

    chmod +x safe-dd

  • File Paths:

    Ensure the input file (if=...) and output file (of=...) paths are correct and accessible.
    Use absolute paths if necessary.

  • Example Command:

Ensure the command used to run the script is correct. Here’s an example:

./safe-dd if=/dev/sdb of=/path/to/usb_backup.img

or even:

./safe-dd if=/dev/sdb of=/path/to/usb_backup.img bs=4M

It should work. :wink:

Hope it helps.

Many greetings from Rosika :slightly_smiling_face:

2 Likes

That is a good goal to have Ernie.
CLI is better for system work, because you can script it (see the script command) and keep a record of what you have done. Then if you have to back track, you dont rely on memory.

2 Likes

@nevj and @ernie :

Yes, that´s great.

And may I add that setting fish as your default shell helps in making things much easier, especially when the need arises to access some “complicated” command (syntax-wise) which already resides in your history. :wink:
Just a fragment of its syntax is needed, then Arrow Up and you´ll find it in a jiffy.

That´s just one of its advantages.

See also:

Many greetings from Rosika :slightly_smiling_face:

1 Like

O.K., I did as you suggest, and set the file to be executable, listed the directory contents, then I attempted to run it. Here’s the output:

 ╭─ernie@Traveler3 in ~/Scripts took 3ms
[🔍] × chmod +x safe-dd

 ╭─ernie@Traveler3 in ~/Scripts as 🧙 took 42s
 ╰─λ ls
.rwxr-xr-x 700 ernie 27 Jul 06:30  safe-dd

 ╭─ernie@Traveler3 in ~/Scripts as 🧙 took 9ms
 ╰─λ ./safe-dd /home/ernie/Downloads/rescuezilla-2.4.2-64bit.jammy.iso /dev/sda1
bash: ./safe-dd: cannot execute: required file not found

Any ideas?

Ernie

1 Like

Hi Ernie, :wave:

could you provide the exact command?
How did you enter it in the terminal?

Cheers from Rosika :slightly_smiling_face:

P.S.:

./safe-dd /home/ernie/Downloads/rescuezilla-2.4.2-64bit.jammy.iso /dev/sda1

Is this the one?
Yes, it is. I noticed it too late. Sorry.

1 Like

@ernie :

Hi again,

  • Is dd installed on your system? Well, I guess it is. Just a thought.

  • Ensure the shebang line (#!/bin/bash) at the top of the safe-dd script is correct and that /bin/bash exists. Verify by running:
    ls -l /bin/bash

  • ensure that the script is in the directory from which you’re trying to run it

  • If you edited the script with an editor that might insert special characters or formatting, try opening the script in a basic text editor (like nano or vim) and ensure no unexpected characters are present.

  • Sometimes, the error might stem from syntax errors in the script or missing commands. Here’s a simplified version of the script to ensure there are no syntax errors:

#!/bin/bash

if [ $# -lt 2 ]; then
  echo "Please provide an input file and an output file."
  exit 1
fi

# Extract the target file path
target=$(echo "$@" | sed 's/.*of=\([^ ]*\).*/\1/')

# Check if the target is mounted
if df | grep -q "$target"; then
  echo "Output file $target is mounted. Refusing to continue."
  exit 2
fi

# Execute dd with progress status
echo "Executing nice dd $@ bs=4M status=progress"
nice /usr/bin/dd "$@" bs=4M status=progress

sync
echo "Finished writing and sync."

The last one was suggested by ChatGPT. :wink:

Hmm, perhaps someone else can be of better help.

Sorry Ernie.

Cheers from Rosika :slightly_smiling_face:

1 Like

Yup. The ISO file for rescuezilla’s in my Downloads directory, and the USB stick I’m attempting to write it to mounts at /dev/sda1.

Ernie

2 Likes

I know of 2 distros that have fish as the default shell

  • Artix
  • GhostBSD
2 Likes

@nevj :

Hi Neville, :wave:

thanks for the information. I never knew that.

In Lubuntu and in Linux Lite I had to install it and make it the default shell for myself.

Cheers from Rosika :slightly_smiling_face:

1 Like

Yes

I checked. It is. The output of ls -l /bin/bash is

 ╭─ernie@Traveler3 in ~ took 4ms
 ╰─λ ls -l /bin/bash
.rwxr-xr-x 1.1M root  3 Jul 16:22  /bin/bash

The file’s in my ~/Scripts directory, and cd’d to
~/Scripts
before I ran the command.

I didn’t. I used KDE’s Kate editor.

I copied/pasted this simplified version to a new file using nano, then ran my command again, with the same result.

Ernie

2 Likes