So, this should apparently be really simple, but had trouble finding any good answers online.
I have a mounted external usb hard drive.
I would like to unmount it, using bash. (Essentially I'm just looking for the equivalent bash command for right clicking on my external hard drive in nautilus and selecting 'unmount')
How can I achieve this?
Searching for "Unmount Hard Drive Terminal" yields http://ubuntuforums.org/showthread.php?t=842698.
russlar provides a solution:
open terminal, and run df -h. this will tell you all the hard drives mounted. then, run sudo umount /dev/<something>, where <something> is the name of the hard drive that you want to unmount.
Related
Is there a command for the apple terminal to brute force a wipe of everything including all partitions, master boot records, and data on a usb flash drive?
Just a little information about the situation:
I just got a stick from a friend which seems to be damaged but it isnt a physical defect. I guess he just removed the stick while formatting or so.
I already tried to repartition, reformat and erase the stick with the Mac Disc Utility and I tried to format it on windows. Nothing of it worked, so I decided to use terminal for it (im just getting used to terminal/bash, so im a complete newbie at this) and tried the commands (all with sudo and diskutil in front of them ofc) repairDisk, reformat, partitionDisk, eraseDisk or zeroDisk, but nothing worked. Im getting this error message now: Error: -69759: Securely erasing data to prevent recovery failed
Underlying error: 5: POSIX reports: Input/output error
So my final thought is now that I have to clean everything from this drive as it seems there is something broken on a very low level and i would assume that completely wiping it will result in my diskutil to install a complete new partition scheme and everything on the drive so it will eventually start working again..
Thank you all in advance!
Screenshots:
Try this in Terminal if you are CERTAIN it is disk3:
sudo dd if=/dev/zero of=/dev/rdisk3 bs=65536 count=1000
If it says the disk is busy, make it un-busy!
sudo diskutil unmountDisk /dev/disk3
First, check what disk# your usb is (to be certain) in a terminal:
sudo diskUtil list
then
sudo dd if=/dev/urandom of=/dev/<your_usb_disk_here> bs=1m
If you get busy error and/or if the usb is in use elsewhere, stop what you are doing there and unmount it first as Mark Setchell said
sudo diskutil unmountDisk /dev/<your_usb_disk_here>
If you get a funky name from using bootcamp assistant or something, and you cannot get dd or even Disk Utility to wipe it for some reason, like "permission" problem, use:
diskutil eraseVolume HFS+ NAME <your_usb_disk_here>
Note that the last arg is not e.g. /dev/disk2 , but just the last part, disk2
I have a need to duplicate about 10 USB thumb drives a day from a Dropbox folder that changes slightly each day (about 10GB of data). I considered the $300 "Aleratec 1:10 USB 3.0 Copy Cruiser" but upon study, realized it's no more than a USB 3.0 hub and some basic copying software. I can do this with my own USB 3.0 hub and Terminal in OS X! (Windows 10 is also available if there's an easier way.)
Question: Since the bus is faster than my drives, is there a way I can execute this command to write to all the drives simultaneously? Or any other creative suggestions appreciated. Thanks.
You can format them in parallel quite easily, if you make a little script. Say your drives have the word USB in their names, you could write something like this:
#!/bin/bash
# Don't barf if no drives mounted, or if USB is lowercase
shopt -s nullglob
shopt -s nocaseglob
# Iterate through all mounted USB drives
for drive in /Volumes/*USB* ; do
# rsync source to USB drive in background
echo rsync <options> <YOURSOURCE> "$drive" &
done
# wait for all parallel rsyncs to finish
wait
You would save that on your Desktop, as DuplicateUSB and then you make it executable like this in Terminal:
chmod +x "$HOME/Desktop/DuplicateUSB"
Then you can run it by double-clicking it, or going in Terminal and typing:
$HOME/Desktop/DuplicateUSB
At the moment, it only echoes what it would do, but doesn't actually do anything. When it looks to be correct, and you are happy with what it is doing, you can remove the word echo from the line with rsync in it so it actually does the rsync.
broken mount point, as it seens in mc
I'm trying to mount my work servers to local folder.
"sudo sshfs webuser#rgslb.com:/var/www/webuser/data/www /Volumes/rgslb.com"
It asks me password and silently proceed. But as result I have broken file, in mc it looks like ?rgslb.com, but "ls -l" says that there no this file in /Volumes. And when I unmounted it this mount point directory disappear.
Have any one has same situation? Thank you.
I got simple solution, do sshfs... without sudo, to ~/rgslb.com. And it works.
I have a huge batch of flash drives that I need to move files onto. I'd also love to rename the drives (they're all called NO NAME by default). I'd love to plug two drives in, run a terminal script on the computer to accomplish all of that (most importantly the file moving). Then remove the drives, put the next two in, run it again, etc. until I'm done. All of the drives are identically named.
Is batch executing like this possible, and does anyone know how to go about doing it?
I figured it out. Put each one in and run this command to rename the drive and then move the files into it:
diskutil rename /Volumes/OLDNAME "NEWNAME" && cp -r ~/Desktop/sourceFolder/. /Volumes/NEWNAME
In my day-to-day work (I'm using MS Windows), I keep my git bash (actually using console2 for this) open for the whole day. It is also very frequent that I mount new drives that I would like to work with git.
However I noticed that I need to exit the bash and open it again in order to make it recognize new drive letter.
Is there any command that 'registers' already mounted drive in git bash ?
thanks
edit2:
I do not have any option to left a comment under my own question (weird ..?), so I post it here:
$ mount -a
sh.exe": mount: command not found
Couple of things, had some difficulty finding sources so feel free to take it with a grain of salt.
Msysgit simply doesn't include a version of mount. It is my understanding that cygwin does, however. There is no simple way to either view all attached drives or mount a new drive in msys, and thus Git Bash.
To answer your question, you don't: Git Bash does not dynamically assign drives, so if you mount new drives, you need to close all instances and restart Git Bash (source). The source referenced there is cached here. Sorry there's not a nicer solution.
I commonly mount a drive to the file system and then have to run a script that alters some files on the from within a Git Bash session in Console 2.
If you mount something to a given drive letter, say F: on the Windows file system, and then start the Git Bash session it will have it mapped. I can mount/unmount the F: drive and the session can still access /f/ without any issues. So, mount all the drives you will typically need to hit and then start the session and hopefully you don't need to restart your Git Bash too often.
I find that if I exit all currently running git bash sessions and then launch a new one, then I can access the new drive, e.g. X:, in the new bash session under /x/.
Even launching a new git bash session is not enough if there was already one running; I must exit the previous git bash sessions and then launch one for it to make the new drive letters available.
I found that if I set
MSYS_WATCH_FSTAB=YesPlease
in my User Environment variables. Then everything worked.