

This gives the device name (yours will be different, of course), mount point, file-system type, options, and two numeric fields: the first of these should be zero (it relates to the unused dump backup program), while the second is the order of check and repair at boot: 1 for the root file system, 2 for other permanently mounted disks for data, and 0 (no check) for all others. Find them with sudo blkid , which also helpfully tells you the label, if any, that often contains the make and model of external drives, or look in /dev/disk/by-uuid .įor an NTFS-formatted drive, we called sudo nano /etc/fstab and added the following to the end of the file: /dev/disk/by-uuid/E4EE32B4EE327EBC /media/usb1t ntfs defaults 0 0 Fortunately, disks (or rather, disk partitions) have unique labels known as UUIDs randomly allocated when the partition is created. Raspbian knows which disks to mount at boot time by reading the file-system table ( /etc/fstab ), and we could put our /dev/sda1 in there, but if we start up with two drives plugged in, the wrong one may be selected. You can then mount the disk with sudo mount -t vfat /dev/sda1 /media/usb , where vfat (or ntfs or ext2) is the file-system type. Lastly, you need a mount point (somewhere to place the device on the file-system hierarchy) with appropriate permissions.

It also gives file-system information, which you need in order to mount the disk. Called with the list option sudo fdisk -l , it performs no partitioning, but simply lists partitions on those disks connected to your Pi. Another way of seeing connected devices that aren’t necessarily mounted is with fdisk, a low-level tool used to divide disks up into partitions, before creating file systems on those disks (see the “Format” boxout). On other Linux systems, if /var/log/messages draws a blank, try /var/log/syslog . You can see what’s being assigned by running tail -f /var/log/messages , then plugging in the USB device. The next device plugged in will be /dev/sdb1 . The /dev/sda1 refers to the first (or only) partition on /dev/sda . Now we can mount it just the way we want. An error will result if the device is in use, so change directory and/or close apps using files from the device. mount will show an entry beginning something like “ /dev/sda1 on /media/FLASH DRIVE… ” and you can unmount with sudo umount /dev/sda1 (yes, that is umount without an “n”). If you haven’t yet typed startx , then the disk will not get automatically mounted if you have, then you need to unmount it. Plug in a USB drive (remember that the Pi is not happy to power drives itself: either use a powered drive, or plug a USB flash drive into a powered USB hub). You’ll see a lot of device “none” for various bits of the virtual system that you don’t need to worry about the devices that concern us start with /dev/ and have names like /dev/mmcblk0p1 for partitions of the Pi’s SD card, and /dev/sda1 for plugged-in USB drives. The information displayed is of the form device on mount point, file-system type, options. It’s a bit like seeing a book on your shelf, but not being allowed to open or read it.ĭisks and disk-like devices are mounted by Raspbian on a virtual file system, and you’ll rarely need to worry about what goes on beneath that layer of abstraction, but to see some of it, type mount. It’s an odd concept to accept: the computer knows there’s a disk plugged in, but its contents remain invisible until the Pi is told to mount it. Plugging a drive or flash memory device into your Pi (connecting it to your computer) is not the same as making it available for the Pi to interact with (mounting it) so that Raspbian knows what’s on it and can read, write, and alter files there. It's available on all the usual digital services so you could own it instantly. Or, as is more often the case, you may want to mount a disk when the Raspberry Pi is running a project that doesn’t involve anyone getting as far as typing startx at the command line, as such graphical fripperies aren’t necessary for most connected devices.įor more command line tips and projects such as this, you should check out our brand new Ebook, Conquer the Command Line. Although Raspbian will, when booted as far as the GUI, automatically mount any disk-type device (USB flash key, camera, etc.) plugged into the USB port and offer to open it for you, you may wish to get more direct control of the process.
