Linux Format

PC to Pi transfers

Swapping data between a Raspberry Pi and your PC can be tricky. Christian Cawley shows you all the useful options.

-

Swapping data between a Raspberry Pi and your PC can be tricky. Christian Cawley shows you the options.

One of the key aspects of using a Raspberry Pi involves copying data to it. This could be anything, depending on your use; perhaps you have a Bluetooth audio streamer project on the go, or a digital picture frame. You may need to send over a directory of MP3 files to play, or PNG images to view.

Dumping the files to a USB stick on your PC then dragging them from the flash storage on your Pi is one option. It’s straightfo­rward, but lacks finesse, and adds too much physical interactio­n. Instead, it’s smarter to use a network option, taking advantage of the local network to beam the data wirelessly or over Ethernet from your PC to your Pi. You might even set up a network share and make your Pi available to move data to and from, using any device on your network. These methods should work with all Raspberry Pi models, although some will be more suited to the later devices.

You can stick it!

Before we look at the high-tech alternativ­es, however, it’s worth going through the basics. Say you have a bunch of files you need to copy from a PC to your Raspberry Pi. All you should need to do is insert the USB drive in to your PC, wait for it to mount, then drag the files to it.

Safely eject the USB stick once the data has been copied, then insert it into your Raspberry Pi. At this point, it should be automatica­lly mounted in the Raspbian operating system – the results may vary with other Oses, though. If the USB stick doesn’t automatica­lly mount, open the terminal and find the UUID (Universal Unique Identifier ) of the device:

ls -l /dev/disk/by-uuid

The USB device will probably be labelled sda1; keep a note of the name regardless. Next, create a mount point like this:

sudo mkdir /media/usb

Next, set the Pi user as the folder owner.

sudo chown -R pi:pi /media/usb

Finally, mount the drive with:

sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi

All you need to do now is open the file manager, find the device in the left pane, and click to browse. You can then drag the files from the USB flash device to the intended directory on your Raspberry Pi. When you’re done, use the eject button in the file manager to remove the USB stick. If you manually mounted, enter:

sudo umount /media/usb

With microsd cards, things are a little different. Sure, you can use the /boot directory to copy data from your PC without disrupting the main file system, then drag it into place when the Pi is running. But if you want to use SD storage with a USB adaptor, you’ll need to install software that lets Raspbian access drives in the EXFAT format. SD storage is almost always formatted in this way as the file table has been optimised for SD cards. The tools you need are exfat-fuse and exfat-utils. These work together to mount EXFAT drives as well as format in EXFAT format.

As ever, start with an update and upgrade:

sudo apt update sudo apt upgrade

Once complete, install exfat-fuse and exfat-utils.

sudo apt install exfat-fuse sudo apt install exfat-utils

This is particular­ly useful if you’re planning to set up a Samba server or any other project that requires removable flash media.

Browsing by

Another straightfo­rward option for copying files from a desktop computer to your Pi is to use the browser. Two

 ??  ?? Email attachment limits will prevent you from sharing too much data from your PC to your Raspberry Pi, so keep an eye on file sizes.
Email attachment limits will prevent you from sharing too much data from your PC to your Raspberry Pi, so keep an eye on file sizes.

Newspapers in English

Newspapers from Australia