Command Line Wonders: Lessons from Extending Linux Partitions and Data Restoration
When it comes to system optimization, data restoration, or partition modifications, your most versatile tool is often the command line. In this article, I’ll recount some valuable lessons I learned while managing Linux partitions and backing up data on a Zorin OS Pro 16.2 system.
The Background: Set Up and Problem Identification
For context, my system setup consisted of separate root (/) and home (/home) directories, each on individual partitions. Over time, my home partition began to dwindle in space, despite the root partition still having ample room. Thus, a plan emerged: shrink the root partition and extend the home partition.
Before making any changes, I wisely backed up my home partition using Deja dup, storing the backup on an old external hard drive. I did this while still operating on my Zorin OS before switching to a Live USB session for the upcoming operations. From the very beginning, I was using ChatGPT, asking initial questions about the safety and procedures of shrinking and extending partitions.
Shrinking the root partition using the Disks tool was successful, although GParted was less cooperative. However, when it came time to extend the home partition, a problem arose. Due to the nature of the ext4 file system, the files within the partition were located at its beginning, not fragmented across it. In essence, the GParted or Disks tool would have to shift these files towards the start of the partition – a task that caused my system to restart unexpectedly when 60% was complete.
The Trials: Unsuccessful Attempts at Resolution
During my attempts to resolve the issue, my system started failing disk checks on the modified partition. In a state of panic, I reformatted the partition and tried to restore my home partition using my earlier backup. Yet, the restoration process was tediously slow, and with no visible logs in the UI to indicate what was going wrong, it felt like a shot in the dark.
Hoping to find clues, I decided to check the monitor app. The app revealed CPU and RAM usage but didn’t provide any clear insights into the underlying problem. The CPU usage was hovering around 8%, which seemed normal. However, hovering over the duplicity process revealed the running command, which would later prove to be a crucial piece of the puzzle.
Several more attempts were made to restore the partition using Backups. I even moved the backup files to an internal NTFS partition to eliminate possible USB disconnection issues. Yet, even after leaving the restoration to run overnight, I woke up to find my laptop had shut down completely.
The Breakthrough: Command Line to the Rescue
Throughout the process, I have been using ChatGPT for advice. It helped me uncover the duplicity command parameters and the inner workings of the backup. I learned about the archive directory, which held a list of all the backed-up files and their metadata.
Initially, I tried running duplicity from within the Live USB session, restoring enough directories to allow login. However, this led to permission issues and a seemingly endless login loop.
ChatGPT suggested creating a new user using Ctrl+Alt+F3 at the login screen. I followed this advice but found that the login issues persisted. It was clear that the problems lay with the home partition itself.
So, I decided to run duplicity directly from within the login shell instead of the Live USB. The advantages of the command line became abundantly clear. The terminal provided a real-time update of the files being copied – feedback that was sorely missing from the UI. The restoration process was also noticeably quicker.
Although I encountered some permission issues when reassigning the restored partition to my Zorin user, I overcame those hurdles. Ultimately, I was successful in restoring my home partition.
The Lessons Learned: The Power of the Command Line
The experience provided two key takeaways. Firstly, the value of a comprehensive backup cannot be overstated. Secondly, the power and versatility of the command line are unmatched. While UIs can offer a more user-friendly experience, they lack the ability to provide feedback when something goes wrong. In contrast, the command line almost always provides hints that help you navigate the issue. From now on, I’ll be leaning heavily on the command line and advise you to do the same. It may not always be the most straightforward route, but it’s often the most informative one.