The instructions provided by @leroydouglas does exactly as you want.
You need to be very careful using the Terminal command line blindly since a simple typographical error could end with catastrophic results including data loss. The command line has absolutely no safety nets, so be extremely careful with it.
You should make sure to have good backups to that computer and that external drive before doing anything else.
You really should get some basic understanding of the command line before you start blindly entering commands. In fact, any command you want to use, you should understand what it will do including the options associated with that command.
Here is a link to an introduction to the command line which can get you started with the basics (while this tutorial uses the Bash shell, most of the instructions will also apply to the more recent Zsh as well):
https://scriptingosx.com/2017/07/first-steps-in-terminal/