Heroic IT measures on an HP Pavilion x360 Convertible.

Note: The purpose of this post is mostly to document how to reconfigure laptops like my mom's to boot from a flash drive. The actual imaging process is only parenthetically laid out. If you're in a position where this is something you find yourself doing chances are you're already a competant sysadmin and know how to use dd anyway. However, I can't just leave it unfinished.

Due to how many things are now inextricably tied to one's computers these days, from banking to paying bills, it seemed a good idea to back up my mom's laptop while I was in town last year. Reason being, if the drive failed or if the laptop was otherwise unusable, I wouldn't be able to take care of any of her finance-related stuff. Also, I didn't relish the thought of carrying her laptop back west with me (I had to do that anyway, but that's beside the point) and wanted to have the option of virtualizing it on Windbringer. Plus, I'd also have the capability of doing a forensic data analysis if I needed to.

The first thing I did was get my hands on suitable storage media. I wound up ordering a 4 terabyte WD My Passport (affiliate link) and a protective case (affiliate link) to store it in for long periods. Said case isn't too expensive, has a little mesh pouch inside for storing a USB cable and one or two flash drives, and fits the drive perfectly. It works nicely enough as a combo that I use the same thing now at home to make on-site backups of Windbringer, but that's neither here nor there.*

The second thing to do was figure out how to boot my mom's laptop, an HP Pavilion x360 Convertible off of a flash drive so that I could rip a disk image (a block-for-block copy of the hard drive written into a single file) onto the external storage described above. The tools in question were already at hand, a flash drive with the Arch Linux installation image written to it and the dd utility that's a part of every Linux distro. However, it wasn't obvious how to use the latter to use the former. I messed around for half an hour or so trying the usual tricks to get into the system configuration and enable "boot from USB" support. So, once I figured it out I wrote it down, so I could write it down here.

The x360 Convertible has to be powered off. Hold down the ESC key as you power it up. When you see "ESC...Pause Startup" tap the ESC key again. When the menu appears, hit the F10 key to jump into the BIOS Setup panel. Now, to be able to boot from USB you need to turn off Secure Boot (because there's a much better than zero chance that a random Linux live image off the Net is going to be able to boot any other way). To do this, cursor over to System Configuration, then down to Boot Options. Hit the enter key to open the Boot Options menu. Make sure that "USB Boot" is enabled; if it's not hit the F5 key to toggle it to Enabled. Then cursor down to Secure Boot, and hit the F5 key to set it to Disabled. Hit F10 to save the new settings and exit. The laptop will reboot.

Now, here's the weird thing: To confirm the deactivation of Secure Boot, you will be shown a random four digit code and you will be asked to type it back in. I guess this is to give you a chance to ask yourself "Do I really want to do this?" In this case, yes, you do. Type the four digits back in (they won't be displayed) and hit enter. The laptop will reboot itself again. You'll probably want to hold down the power button after it does so that the laptop completely powers itself off. Plug your bootable flash drive into one of the USB ports.

When the laptop reboots, hold down the ESC key like you did before and tap it when the "ESC...Pause Startup" line appears. In the Startup Menu that appears, hit F9 to pick a different boot device. Cursor to "USB Hard Drive (UEFI)", which should be your flash drive. Hit the enter key. At the UEFI screen pick your Linux distro; for me the text was "Arch Linux archiso x86_64 UEFI CD". Hit the enter key and follow the on-screen directions to live boot your Linux distro.

The actual get-stuff-done bit can be done from any Linux live distro. This is how it looked for me, adapt as necessary for Ubuntu or whatever.

Now to figure out which drive is the one you want to copy. ls -alF /dev/sd? will show you what drives are there but not what they are. fdisk -l /dev/sda should show you the laptop's internal hard drive. On my mom's laptop it had five partitions, the first an EFI System, one named "Microsoft reserved," two named "Microsoft basic data," and one named "Windows recovery environment". That's the one you want. When I plugged in the external drive it was recognized as /dev/sdc. I repartitioned, encrypted, and formatted the external drive per the usual process. Once the external drive was unlocked and mounted to /mnt I started the imaging process:

root@archiso ~ # dd if=/dev/sda of=/mnt/moms_laptop-20201015.img bs=4M status=progress

Unfortunately, this takes a while. I just left the laptop on the dining room table, plugged in, and checked back on it periodically. About 24 hours later it was done, and I shut everything down normally with shutdown -h now.

That's pretty much it. If you want to make an offsite backup of the disk image, now's the time to do it. Just make sure you allot enough time for the backup to finish.

*Why do I occasionally say stuff like "I use the same thing now at home?" It's because I'm talking about something that worked so well that I started doing it every day for my stuff. I'm trying to express how much I like and (relatively) trust it. Consider it a professional opinion.