One flash drive for Emergency repair + Timeshift backup

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
Post Reply
pbear
Level 15
Level 15
Posts: 5662
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

One flash drive for Emergency repair + Timeshift backup

Post by pbear »

Recently, I had a Reese's moment.* As a matter of routine, I have two flash drives in a drawer next to my computer. One is a smallish drive (4 GB) with the live ISO for my current main system plus persistence (casper-rw file). Can be small because all I want persistence for is settings, the internet connection, disable screen blanking, etc. The other drive is larger, originally 32 GB now 64 GB, where I save manual Timeshift snapshots. In a sense, it's not a backup, as I don't dupe it off the internal snapshots. Rather, it's a second set of snapshots, in case the regular snapshots (on the internal drive) get corrupted. By the way, there are no data files in either set of snapshots; those are backed up separately.

* For non-Americans, Reese's is a candy bar with peanut butter and chocolate. For many years, its signature slogan was "Two great tastes that taste great together!"

The Reese's moment came when I was taking inventory of my flash drives, figuring out which were obsolete and available for reuse, when it occurred to me there's no reason for the emergency repair drive and Timeshift backup to be separate. Indeed, there's an obvious advantage to having them together, as one of the main reasons I have an emergency repair drive is for restoring Timeshift snapshots! Moreover, this answers a perennial complaint on the Forum. When told it's important to keep the live ISO as a repair tool, the user (usually a newbie) will object it's intolerably wasteful, a 2 GB ISO squatting on a 64 GB (or whatever) flash drive. Here you go, something useful to do with that space, solving two problems at once. Of course, the second partition doesn't have to be used for Timeshift. Can be regular storage, data file backups, etc. Timeshift just happens to be what appeals to me.

As for how, that's a little tricky, as most ISO-to-USB burning tools overwrite the whole device, using the ISO 9660 file system which can't be shrunk to make room for another partition. That's why folks who try end up complaining about waste. There may be other ways to do this, but I only know of one for Windows and another for Linux, so those are what I'm going to describe below.* Before starting, you need to decide two things. First, how much persistence do you want? If just for settings, 500 MB will be plenty. If you want to install some apps, you might want 4 GB (which is the limit at present for the Windows method). With the Linux method (can be done on a Windows machine, by using a live session), can be more than 4 GB, but don't go crazy. The more persistence you have, the less space you'll have for storage. It's a repair drive, not a surrogate operating system.

* Anticipating the question, yes, Rufus recently added a persistence function which uses a casper-rw partition. Only works with Ubuntu 19.10 and later, so not Mint 19.x which is based on Ubuntu 18.04. Presumably it will work with LM20. That only solves the persistence problem, though. So far, experimenting with Ubuntu 20.04, I can find no way to coax Rufus into leaving a data partition alone. That's the real point of this exercise. Persistence is a bonus. I've figured out a workaround to add a data partition after Rufus has done it's thing, but that's twice as complicated as the UUI method, so I'm not going into it here.

As for how to use, I don't leave the Timeshift drive plugged in, because I have a laptop. If it were a desktop or tower, I probably would. Typically, I do a manual snapshot when the kernel gets updated, maybe skipping an update if there was one recently. Remember, these are the backup snapshots. Regular snapshots are scheduled, running daily and weekly, with a one month look-back. Backup snapshots go back several months, mainly cuz I have plenty of room on the drive, so might as well. You're free to set up your own schedule, obviously, just mentioning what I do for illustration. If you use the flash drive in lieu of saving snapshots on the internal drive, I'd recommend taking them more often, say once per week. A nice thing about manual snapshots is that Timeshift tells you on the same screen where you create them how much space remains at target.

If you neede to restore a snapshot, you might want to look at a demo I wrote describing that. I did the Timeshift restore from a live session, just as you would be with this tool. The specific context was using Timeshift to transfer a system, but the same steps apply to a regular restore.
pbear
Level 15
Level 15
Posts: 5662
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: One flash drive for Emergency repair + Timeshift backup

Post by pbear »

Windows Method:

The simple way to set up the drive is Pendrive Linux's Universal USB Installer, which works only in Windows. Download and move to a convenient location in your file system. It's a portable, so you're gonna run it by double-clicking, rather than installing. I tested this tutorial with version 1.9.9.0.

Then you need an ISO. Not going to describe that here. See the official download page. . In theory you could have UUI download the ISO for you, but that would skip the verification steps, which is not a good plan.

Next up is formatting the flash drive. You have to do this in Linux, as Windows' Disk Management tool doesn't support the particular combination of partitions needed to make this work, in particular, a removable drive with multiple partitions, one of them fat32. Open GParted; attach target flash drive; File > Refresh Devices. Create new partition table; msdos (MBR) is fine. Create two partitions, one formatted fat32 and the other ext4. If using the data partition to share with Windows, format it ntfs instead; this format cannot be used for Timeshift, though. Size of the fat32 partition should be equal to the size of the ISO plus however much persistence you want, total size 3 to 6 GB. You specify size in MiB, so 3072 to 6144 MiB (GiB x 1024). Allocate remaining space to the ext4/ntfs partition; be sure to assign a label, e.g., Timeshift or Backups. Should look something like this:

Image

If by some mad chance you already have a Timeshift flash drive and want to add a partition for live-ISO-plus-persistence, you can do that. In GParted, right-click the partition and select Move/Resize. Tab twice; enter size for new partition, then Shift-Tab to update size of Timeshift partition; click checkmark to Apply; will take a while to run. When finished, create the ISO partition using the space just cleared, formatting it fat32, of course. Notice the new partition is sdb2 (or similar), where it would be sdb1 if starting with a fresh flash drive. Doesn't matter. The live ISO partition doesn't need to be first.

Burn the ISO. Fire up UUI. Select Linux Mint from the list of OS types. Browse to ISO file (Step 2), and double-click. Select target; choose by drive designation (whatever gets assigned when you attach the drive). Be sure to select the correct partition, as burning the ISO will overwrite everything at target. Select persistence and move slider to select how much; might as well take the maximum available, as the excess space in the fat32 partition can't be used for anything else. Click install. Takes a while, as the persistence file has to be generated by writing zeros equal to the size of the file.

Boot USB drive to test. Set up internet connection; copy an app shortcut to Desktop (any app will do, I usually do the calculator); open Terminal and run timedatectl set-local-rtc 1 (this keeps the live session from screwing up your Windows clock). Reboot to confirm persistence is working, i.e., internet connection is set automatically and app shortcut is still on Desktop. Boot Windows; probably your clock is off; open Control Panel. Go to Date & Time > Internet Time (tab) > Change settings > Update now. If you ran timedatectl as suggested, should only have to do this once.

Set up Timeshift. Insert flash drive to USB slot. Fire up Timeshift. Go to Settings > Location. Select the flash drive partition. If not certain which that is, open Disks (on Menu), find the partition there, and note it's location (something like /dev/sdb2). FYI, although you identify the storage location by device ID, Timeshift in fact saves the location by UUID, so it doesn't matter whether the partition is assigned a different slot next time (e.g., because there's already another flash drive inserted).

If convenient, go ahead and take a snapshot. Label it when done (double-click Comment field). Restore internal drive as snapshot location. Eject the flash drive (unless leaving attached more-or-less permanently).
pbear
Level 15
Level 15
Posts: 5662
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: One flash drive for Emergency repair + Timeshift backup

Post by pbear »

Linux Method:

The only Linux app I know that works for this is mkUSB, developed by sudodus (Nio Sudden Wiklund), senior guru at Ubuntu forums.
Currently on version 12 (dus). Install from his PPA:

Code: Select all

apt add-repository ppa:mkusb/ppa
apt update
apt install mkusb usb-pack-efi
Note: sudo not needed, but will be prompted for password. I install mkUSB as a matter of course on my main system. As mentioned in the Introduction, also can be installed to a live session, so this method can be used on a Windows machine (albeit using Linux commands, not Windows commands).

Then you need an ISO. Not going to describe how to do that here. See the official download page.

To start mkUSB, select from Menu > System Tools (or type mkusb in Terminal), then select option “d” (for 12). Enter sudo password. Acknowledge overwrite warning. Select install, then ‘Persistent live’. Navigate to select ISO; select target drive from list; “Use defaults” for drive settings. Select % of remaining space for persistence. For reference, 5% of the free space on a 64 GB flash drive will be just under 3 GB of persistence. Do the math to figure out the right % for your situation. Read warnings. Double check installation target. Hit “Go!” Confirm proceed even though not installing Ubuntu.

By default, mkUSB formats the data partition ntfs. If using for storage and sharing with a Windows machine, that's fine. For Timeshift, has to be reformatted to ext4 (generally want to do that anyway, if using the flash drive exclusively for Linux). Reformat with GParted. Notice the data partition is last on the drive but called sdb1 (assuming the drive is sdb), not sdb5 as you might expect (at least, I did). Indeed, it's a goofy partition table, five partitions, only two of which have user data. By the way, if you want to edit the boot menu, manually mount usbboot (the third partition) and edit grub.cfg. Know also, mkUSB has a built-in boot-to-RAM option, dual BIOS and UEFI compatibility, and even works with secure boot.

Image

From here on is mostly the same as the Windows method.

Boot USB drive to test. Set up internet connection; copy an app shortcut to Desktop (any app will do, I usually do the calculator). Reboot to confirm persistence is working, i.e., internet connection is set automatically and app shortcut is still on Desktop.

If doing this on a Windows machine, or will be booting the flash drive on a Windows machine, run timedatectl set-local-rtc 1 so the live session will use the internal system clock. And, if doing this on a Windows machine, on first Windows boot your clock probably will be off. Open Control Panel; go to Date & Time > Internet Time (tab) > Change settings > Update now. Should only have to do that once.

Set up Timeshift. Insert flash drive to USB slot. Fire up Timeshift. Go to Settings > Location. Select the flash drive partition. If not certain which that is, open Disks (on Menu), find the partition there, and note it's location (something like /dev/sdb2). FYI, although you identify the storage location by device name, Timeshift in fact saves the location by UUID, so it doesn't matter whether the partition is assigned a different slot next time (e.g., because there's already another flash drive inserted).

If convenient, go ahead and take a snapshot. Label it when done (double-click Comment field). Restore internal drive as snapshot location. Eject the flash drive (unless leaving attached more-or-less permanently).
Post Reply

Return to “Tutorials”