Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8806001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:00:31+00:00 2026-06-14T02:00:31+00:00

If your shell script helps you to safely remove your flash disk after finishing

  • 0

If your shell script helps you to safely remove your flash disk after finishing its job. The solution is expected to meet the following needs:

  1. Suppose the flash disk is mounted as /media/A together with many other flash disks, and the code can selectively just remove /media/A without interfering other disks. For example, I can pass /media/A as an argument.
  2. A light solution. Installing another package of size 100 MB to finish the task drives one crazy.
  3. I know some commands like hdparm except their documents are hard to read. If one can offer me a solution, I hope he/she can offer also the explanation of the parameters, etc.
  4. Best if the code can handle all kinds of flash disks (for example, my old one bought in 2003 with 32 MB) (and portable disks optionally).
  5. It should achieve the exact effect as right-clicking the disk → clicking "safely Remove Drive". The safety concern will prevail, otherwise one may just unplug the disk, which usually won’t hurt.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:00:32+00:00Added an answer on June 14, 2026 at 2:00 am

    You can do this using udisks. It is not installed by default, but it is easy enough to install (the package is like a megabyte in size once installed)…

    sudo apt-get install udisks
    

    Once installed, you can detach a USB drive with the following commands…

    sudo udisks --unmount /dev/sdb1
    sudo udisks --detach /dev/sdb
    

    The first line unmounts it. Just like any other partition you can still remount it at this point. The second line detaches it. After this it is powered down and you have to remove/reinsert it to remount.

    To clarify, sdb is the device and sdb1, sdb2, sdb3, etc. are partitions on the device. Also, you will need to unmount all mount points before you attempt to detach the device. Usually with a USB stick/drive there is only one but it is a warning you should know about none the less.

    Getting the device name from the mount point would require you pull it from mount or something.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks For your Valuable support, Now i m able to run shell script in
I am new to this shell-script programming so need your help to write a
Your job is to design a Project Plan class library which supports the tracking
i need some help with a shell script. I want to start a shell
I am writing some BASH shell script that will continuously check a file to
I want to write a shell script to help me start gdb and input
I have made a mistake with a shell script and I have backup files
I've been having some problems with a shell script that changes a configuration file
quick question, how do I write a shell script that prompts users to enter
I want to build a shell script to execute the following two commands, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.