Pages

November 1, 2013

USB Thumb Drives: Mounting, Unmounting and Re-mounting

One of my hobbies is Linux distribution hopping. If you don't know what that means, it's that I regularly browse DistroWatch for news about new Linux releases. If something catches my interest, then I download the ISO, try out its live session in VirtualBox, and then finally, if impressed, install it to one of the partitions in my PC. And if it's that good, then I use it as my main OS.

The medium I use most when creating the installation media is a USB thumb drive. It's usually a no-brainer; just plug-in the thumb drive and the OS does its thing and auto-mounts it. The next part involves unmounting the thumb drive so that I can use the dd command to write the ISO to the thumb drive. I don't use the right-click » "Unmount" via the File manager because I just like typing in the command line

    $ sudo umount /dev/sdb1

and unmounted goes my thumb drive. Now I can proceed with

    $ sudo dd if=/path/to/file.iso of=/dev/sdb bs=4M; sync

and after some time, it finishes and I know that the distributions installation media is freshly baked. But sometimes I want to check the contents of the USB thumb drive, so I usually pull-out the drive, put it back in again and let the OS auto-mount it. So I thought to myself, "Isn't there a way to mount the USB thumb drive via the command line after dd command finishes without me pulling out and plugging back in the drive?" Apparently there is. And the command, in Ubuntu, is udisks. And using it is easy, it's just

    $ udisks --mount /dev/sdb1

and the USB thumb drive is remounted. Apparently, this same command can also be used to unmount the USB thumb drive

    $ udisks --unmount /dev/sdb1

Note that there is no need for the sudo superpowers to use the command.

That's it! Hopefully this will be useful for somebody out there

No comments:

Post a Comment