(This is part of a larger series on finding your footing on Arch Linux.)
Goal: Read from and write to external USB drives, including those with the NTFS file system.
- Wiki: USB storage devices
- Wiki: NTFS-3G
Requirements (depending on the file systems you want to interact with):
These packages allow read/write interaction with the file systems commonly used on USB media.
Well there’s a decent amount going on here. You should roughly grok what a block device is, and what partitions are. You should know what a file system is. You have to mount the USB drive’s filesystem to your computer, so the USB drive’s files are accessible on your system.
For future reference, run
lsblkand remember the output without a USDB connected
Physically connect USB drive to computer via a USB port
lsblkand identify the drive’s block device and data partition:
It takes a little experience to interpret the output. The USB drive’s block device might be
sdb. Identify the data partition based on the known disk size—the data partition should take up the majority of the full disk size.
- Create a mount directory inside
/mntto hold the drive’s files. You can name it whatever you want; perhaps use the manufacturer of the drive:
sudo mkdir /mnt/seagate
You only need to do this step once.
- Mount the drive’s data partition to the mount directory
sudo mount /dev/sdb2 /mount/seagate
lsblkto check that the USB drive is mounted to the just-created mount directory.
Interact with the files on the USB drive from the
/mnt/seagatedirectory, reading and writing as needed. You’ll need root privileges to write.
- To eject the drive
umount /mnt/seagate # by specifying mount point (preferred) umount /dev/sdb2 # by specifying device # Power off echo 1 > /sys/block/DISK_NAME/device/delete
man umount, specifying the mount directory is preferred, in case the physical device is mounted to multiple directories.
For the power off line see https://unix.stackexchange.com/a/43450 and ArchWiki: USB storage/Device not shutting down after unmounting all partitions
This package allows you to disconnect power from an e.g. USB drive, which makes for safer ejecting.
Mount drive with
- Eject with
udisksctl unmount -b /dev/sdb2
-bflag specifies that
/dev/sdb2refers to a block device. Note that a device partition, e.g.
sdb2, is used. Only the device itself, e.g.
sdb, is used below with
- Power off with
udisksctl power-off -b /dev/sdb
Again, note that
udisksctl unmountuses the device’s data partition (e.g.
udisksctl power-offuses the device itself (e.g.
mount command should detect the USB drive’s file system and use the appropriate library if needed.
See e.g. https://wiki.archlinux.org/title/NTFS-3G: the
mount command should know to use the
ntfs file system after an installation of