Maia McCormick

Programmer, writer, nerd

USB Disk via Terminal

Achievement unlocked: accessing a USB disk via terminal!

Accessing a flash drive from terminal seems like it ought to be simple, but it’s varying degrees of a pain on different OS’s. It also seems like something I should have learned ages ago–especially considering that when I first started terminal-ing, Allison Kaptur’s advice to me was to quit Finder cold-turkey until I could do everything I wanted to do via terminal. Anyway, for anyone who’s a little confused by this, it’s actually pretty easy.

Mac

Look for your disk in /Volumes/[diskname]. A bit obscure, but actually super simple!

Linux

More of a pain. You have to create a directory in which to ‘mount’ the drive. Then you can work with the content of your drive through that directory, and when you’re done, just unmount. This set of instructions was found on Ask Ubuntu.

  1. Find what the disk is called using sudo fdisk -l. (Probably something like /dev/sdb1.)
  2. Create director in /media: sudo mkdir /media/usb
  3. Mount it: sudo mount /dev/sdb1 /media/usb. Your drive now lives in /media/usb, congratulations!
  4. When you’re done, unmount: sudo umount /media/usb (Note that the command is umount, NOT unmount. This one had me scratching my head for way longer than it should have.)

Comments