How to Safely Eject a USB Drive in Linux

When using a USB drive on a Linux system, it’s important to properly unmount and remove the drive to prevent data loss or corruption. Simply unplugging the drive without properly unmounting it can lead to issues.

In this guide, we’ll learn the simple steps and important safety tips for safely ejecting USB drives using the Linux command line.

Identify the USB Drive in Linux

First, you need to identify the device name of your USB drive by running the following lsblk command, which will list all block devices connected to your system.

lsblk
Check the USB Drive in Linux
Check the USB Drive in Linux

The above command displays all the storage devices connected to your system. Look for your USB drive in the list, which is usually labeled as /dev/sdX, where 'X' represents a letter (e.g., /dev/sdb, /dev/sdc, etc.).

In this example, the USB drive is identified as `/dev/sdc`. Make a note of this label; we’ll need it for the next step.

Unmount the USB Drive in Linux

Next, you need to unmount the USB drive by running the following umount command, specifying the mount point of the USB drive.

sudo umount /dev/sdc
lsblk
Umount USB Drive in Linux
Umount USB Drive in Linux

Safely Remove the USB Drive in Linux

After unmounting the drive, you can safely remove it from your system by running the following eject command.

sudo eject /dev/sdc

This will power down the USB drive and allow you to safely remove it.

Another way to safely remove a USB drive is to use the `udisksctl` command, which is part of the `udisks` package, that provides a command-line interface for interacting with storage devices.

sudo udisksctl unmount -b /dev/sdc

Then, power off the drive:

sudo udisksctl power-off -b /dev/sdc

After running these commands, you can safely remove the USB drive.

Conclusion

Safely removing a USB drive in Linux is an important step to prevent data loss or corruption. By following the steps outlined above, you can properly unmount and remove your USB drive using the Linux command line.

Remember, it’s always better to take the extra time to safely remove a drive than to risk losing your data.

Two small things before you go

If something didn’t work on your setup, leave a comment and tell me which distro and version you’re on. I read every one, and most of these articles got better because a reader pointed out what was missing.

And if it did work, share it. TecMint has stayed free for 14 years because people pass these articles around, and that traffic is what pays for writing the next one.

Leave a comment
Get two free Linux courses

Learn the Linux basics with two free courses and join 34,000+ readers getting practical TecMint tutorials and selected Pro TecMint articles every week.

Pro TecMint
Get lifetime access for $99

If you want to go beyond the free tutorials, Pro gives you 18 courses, 5 ebooks, and every future course I add. One payment, lifetime access, no renewals.

Ravi Saive
Ravi Saive
Administrator
About the author

I'm Ravi Saive, an award-winning entrepreneur and founder of several successful 5-figure online businesses, including TecMint.com, GeeksMint.com, UbuntuMint.com, and the premium learning hub Pro.Tecmint.com.

1 Comment

Leave a Reply
  1. Hello Ravi,

    Thanks a lot for the CLI commands. Since I use a DE (desktop environment), I usually use the ‘Disks‘ application to power off the USB drives.

    It does all that automatically… (I’m lazy ;) )

    Bye.

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.