Setting up a new computer
I love getting a new computer. I don't copy over all my files from my old computer anymore. Instead, I like to use it as a chance for a fresh start.
I have a vision, but so far it's been only a dream. My vision is that I could get access to any new computer, and within a few minutes be totally up and running with my full developer work environment, all my photos and videos, my documents, and everything else I have and need. The reality is nothing like this, of course. But I'm getting closer to it. Here's how I did it with my new laptop this past month.
Software
The first thing I need to do is set up my operating system (arch btw) and download all the software I need and use on a regular basis.
For me, this includes installing i3, fish, VS Code, git, rsync, rclone, mariadb, node, keepassxc, aws-cli, terminator, chromium, libreoffice, spotify, syncthing, workrave, and a few other things.
I could probably automate this and install everything that I had on my old computer, but I actually love the process of starting from scratch here and only installing the software I actually need and use. Arch Linux starts with a very minimalist environment, so I know that there's really nothing on this computer that I haven't explicitly installed.
Starting from scratch also gives a chance to try out some new internal services. For example, I'm now trying out using iwctl to manage my wifi connections instead of wpa_supplicant.
SSH keys
Once I have my software installed, the only thing I have to copy over from my old computer on a usb stick are my SSH keys, ie. the contents of ~/.ssh/
.
These keys give me access to everything else. Once I have these keys, I'm already starting to feel at home.
Git
The SSH keys give me access to servers.
On one of these server lives my private Git repositories.
I like to keep all these git clones in a /code
directory on my computer.
I clone all my active projects via ssh:
sudo mkdir /code
sudo chown jesse:jesse /code
cd /code
git clone ssh://[email protected]/~/git/codingwithjesse
git clone ssh://[email protected]/~/git/joyofsvelte
git clone ssh://[email protected]/~/git/dotfiles
# etc..
dotfiles
One of the Git repos I cloned is a private dotfiles
repository that has all the configuration I care about.
I make sure to push changes to this repo from my old computer one last time before cloning here.
I use symlinks in my home directory so that the files live in the repo.
I have an install.sh
in my dotfiles
repo that sets it all up:
#!/bin/bash
BACKUP=backup-`date +%s`
mkdir "$BACKUP"
mv ~/.bashrc "$BACKUP"
mv ~/.bash_prompt "$BACKUP"
mv ~/.bash_profile "$BACKUP"
mv ~/.aws "$BACKUP"
mv ~/.gitconfig "$BACKUP"
mv ~/.config/i3 "$BACKUP"
mv ~/.config/i3status "$BACKUP"
mv ~/.config/fish "$BACKUP"
mv ~/.config/rclone "$BACKUP"
mv ~/.local/share/fish/fish_history "$BACKUP"
DIR=`pwd`
ln -s $DIR/.bashrc ~/.bashrc
ln -s $DIR/.bash_profile ~/.bash_profile
ln -s $DIR/.bash_prompt ~/.bash_prompt
ln -s $DIR/.aws ~/.aws
ln -s $DIR/.gitconfig ~/.gitconfig
ln -s $DIR/.config/i3 ~/.config/i3
ln -s $DIR/.config/i3status ~/.config/i3status
ln -s $DIR/.config/fish ~/.config/fish
ln -s $DIR/.config/rclone ~/.config/rclone
ln -s $DIR/.local/share/fish/fish_history ~/.local/share/fish/fish_history
Of course, the set of dotfiles you care about will probably be different.
rsync
I also keep a backup of all my important documents (taxes, contracts, PDFs and spreadsheets) and my passwords (keepass database) on my server. I use rsync to backup these files, and I also use it to restore my backups:
rsync -avz [email protected]:~/docs ~/docs
rsync -avz [email protected]:~/passwords ~/passwords
Perhaps I could keep these in Git repos as well, for simplicity. It might be nice to have versioning on my tax documents and contracts, even though they don't change much.
rclone
For larger files, like photos and videos, I use rclone to manage an encrypted backup in object storage. I really enjoy using rclone. I love how it provides a really easy user command-line user interface, abstracting away a wide variety of cloud storage systems. I've switched between these services based on price a few times, and it was really easy to do.
rclone also has a useful ability to mount a backup to a directory.
For the first time on this new computer, I have this set up in /mnt/media
, with directories like /mnt/media/photos
and /mnt/media/videos
so I can easily browse and view all my content without copying anything to my computer.
I have this set up as a user-based systemd
service.
It's user-based so that it has access to my credentials in ~/.config/rclone
.
I created a file in ~/.config/systemd/user/rclone.service
:
[Unit]
Description=rclone
AssertPathIsDirectory=/mnt
# Make sure we have network enabled
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/rclone mount --allow-other --vfs-cache-mode full media: /mnt/media
# Perform lazy unmount
ExecStop=/usr/bin/fusermount -zu /mnt/media
# Restart the service whenever rclone exists with non-zero exit code
Restart=on-failure
RestartSec=15
[Install]
# Autostart after reboot
WantedBy=default.target
I enabled and started it with systemctl
:
systemctl --user daemon-reload
systemctl --user enable rclone
systemctl --user start rclone
This was my first time creating a systemd
service manually, and the first time I added a user-based service, and I found it really cool.
I would like to learn more about systemd
.
It seems like a really simple and powerful system, so I can see why so many people have strong feelings about it.
Home! Sweet home!
From here I'm all set-up and ready to go. I immediately feel at home, and quickly forget that this isn't the same computer I've always used.
All my code lives in Git repos that I push to a remote server. All my important configuration files live in a Git repo. All my important documents and passwords get backed up to a remote server. All my photos and videos live in a remote bucket storage. As long as I have access to my SSH keys, I'll be able to get up and running from scratch on a new computer within a few hours.
There's really nothing that lives only on this computer, and that makes me feel great.