How To Copy Files From Mac To USB Hard Drive

How To Copy Files From macOS To USB External Hard Drive In Command-Line.

How To Copy Files From Mac To USB Hard Drive

 

  • Method 1: How To Copy Files From macOS To USB External Hard Drive In Command-Line.

  • Method 2: How to copy files to flash drive using mac terminal

  • Method 3: Mac File Transfer via Single User Mode / Command Line

  • Master the macOS command line: How to navigate files and folders in Terminal

 

 

Method 1

  1. Open a terminal and run the command cp -R Documents /usb.
  2. The -R parameter will copy all the subdirectories under the Documents directory to the USB external hard drive.
  3. But above command may raise an error message such as usb/Pics: No such file or directory.
  4. This is because the USB external hard drive is mounted under /Volumes folder, so you should add the /Volumes directory before USB disk name when you run the cp command.
    cp -R Documents /Volumes/usb-name

 

Method 2

How to copy files to flash drive using mac terminal

Question:

Hi, so I’ve been having trouble copying files to a external drive and someone suggested that I try using the terminal to see does that work. For example, if i have a folder on the desktop name “old iTunes” and I want to copy it to a flash drive call “sony samsung” would the command be cp ~/Desktop/old iTunes ~/Volume/sony samsung

thanks

Answer:

The UNIX (command-line) cp(1) command neither protects extended attributes, or copies recursively, by default. If that “old iTunes” is a folder, then the following will copy the folder and its cotents to ~/Volume/”sony samsung.”

cp -pr ~/Desktop/”old iTunes” /Volume/”sony samsung/old iTunes”

Otherwise you will get an error message that “old iTunes” is a directory (not copied). If you do not specify “old iTunes” as the target directory, all of the files in the source “old iTunes” will be splattered all over the “sony samsung” destination.

A command that will preserve extended attributes and do the same thing as above is the ditto(1) command:

ditto ~/Desktop/”old iTunes” /Volume/”sony samsung/old iTunes”

 

Method 3

Mac File Transfer via Single User Mode / Command Line

 

  • Start in Single User Mode by holding down Command-S when starting the Mac.
  • Commands can also be typed via Terminal app when OS X is running.

See also: https://support.apple.com/en-us/HT201573
More tips: http://www.tekrevue.com/tip/mac-startup-options/

 

Terminal Command Workflow

 

  1. Type diskutil list to view available drives
  2. Type diskutil mount /dev/disk1s2 (Disk 1, Partition Scheme 2 – may be different on your Mac) to gain read/write access on that disk.
  3. Type cd /Volumes to switch current folder to Volumes where Mac OS lists all mounted drives.
  4. Type ls to list contents of Volumes folder.
  5. Type mkdir to create a new folder (on the USB drive)
  6. The cp -a command copies files/folders from one path to another.

 

Walkthrough

Start in Single-User Mode by holding Command-S as mentioned above You type -> diskutil list

/dev/disk0 (Physical Disk #1: Macintosh HD)

TYPE  NAME  SIZE  IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 120.5 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3

/dev/disk1 (Physical Disk #2: PIZZA_PIZZA_256GB)

#: TYPE  NAME  SIZE  IDENTIFIER
0: GUID_partition_scheme *256.0 GB disk1
1: EFI 209.7 MB disk1s1
2: Apple_HFS PIZZA_PIZZA_256GB 255.7 GB disk1s

You type -> diskutil mount /dev/disk1s2

Volume PIZZA_PIZZA_256GB on disk1 mounted

You type -> cd /Volumes

/Volumes 13:05:47

You type -> ls

Macintosh HD            PIZZA_PIZZA_256GB                 Recovery Disk Assistant

You type -> cd /Volumes/PIZZA_PIZZA_256GB
You type -> mkdir RecoveredFiles
You type -> cd RecoveredFiles
You type -> cp -a ~/Photos Photos

/Volumes/PIZZA_PIZZA_256GB/RecoveredFiles 13:07:20

Which should copy the entire Mac Photos folder to /Volumes/PIZZA_PIZZA_256GB/RecoveredFiles/Photos

  1. An empty line after running the cp command indicates success
  2. Copy folder and contained files together using cp -a /Source/FolderName /Destination/FolderName
  3. Copy single files without the -a using cp /Source/file.jpg /Destination/file.jpg
  4. ~/Photos is the same as /Users/alex/Photos

More copying examples

You type -> cp ~/Photos/myphoto.jpg Photos/myphoto.jpg
You type -> cp -a ~/Documents /Volumes/PIZZA_PIZZA_256GB/RecoveredFiles/Documents
You type -> cp -a ~/Desktop /Volumes/PIZZA_PIZZA_256GB/RecoveredFiles/Desktop

Exit Single User Mode

You type -> reboot

Mac will reboot normally

 

 

Master the macOS command line: How to navigate files and folders in Terminal

Learn how to perform functions using your Mac’s Terminal commands.

  • Delete file: rm -Rf /Volumes/Machintosh HD – Data/Users/…YOURID…/Desktop/filename.pdf
  • Delete folder: rm -Rf /Volumes/Machintosh HD – Data/Users/…YOURID…/Desktop/TESTFOLDERFORDELETE
  • Look sizes: df – H
  • Look inside to folder: ls /Volumes/Machintosh HD – Data/Users/…YOURID…/Desktop/

terminal-macos-big-sur-1-2-8733766

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Top