How to connect and use an external drive in Midnight Commander (mc)?
Midnight Commander (mc) allows connecting and working with external storage devices through filesystem mounting. To use a USB drive, you first need to connect it to the system and mount the filesystem, then open Midnight Commander to work with files on that device.
Contents
- System preparation for working with external drives
- Connecting a drive through Midnight Commander
- Manual mounting via terminal
- Working with files on an external drive
- Automatic mounting on boot
- Troubleshooting common issues
System preparation for working with external drives
Before connecting an external drive, ensure your system is ready to work with USB devices. Most modern Linux distributions automatically detect and mount USB drives, but Midnight Commander may require additional configuration.
Checking access rights
The user must be a member of the plugdev or storage group to access external drives without root privileges. To check group membership, run:
groups $USER
If you don’t see the required groups, add the user:
sudo usermod -a -G plugdev $USER
Device identification
Connect the USB drive and identify its name using the command:
lsblk
or
fdisk -l
You’ll see something like /dev/sdb1 or /dev/sdc1 depending on the number of disks in the system.
Connecting a drive through Midnight Commander
Midnight Commander has built-in capabilities for mounting and working with external drives.
Automatic detection
- Launch Midnight Commander by typing
mcin the terminal - Connect the USB drive to the computer
- In the left or right panel of the file manager, press
F5to refresh the list - If the system automatically mounted the drive, it should appear in the device list
Manual mounting through Midnight Commander
If automatic mounting doesn’t work:
- In Midnight Commander, navigate to the
/mntor/mediadirectory - Create a mount point if it doesn’t exist:
F7 (Create directory) /mnt/usb - Press
Ctrl+Uto mount the device - In the window that appears, enter:
Device: /dev/sdb1 (or your device) Mount point: /mnt/usb Filesystem type: vfat (or auto)
Manual mounting via terminal
Sometimes you need to manually mount the drive via terminal before using it in Midnight Commander.
Identifying filesystem type
sudo file -s /dev/sdb1
Mounting different filesystems
For FAT32/NTFS:
sudo mount -t vfat -o iocharset=utf-8 /dev/sdb1 /mnt/usb
For NTFS:
sudo mount -t ntfs-3g /dev/sdb1 /mnt/usb
For ext2/ext3/ext4:
sudo mount /dev/sdb1 /mnt/usb
For automatic type detection:
sudo mount -a /dev/sdb1
Checking successful mounting
mount | grep /dev/sdb1
or
df -h
Working with files on an external drive
After successful mounting, you can fully work with files in Midnight Commander.
Navigation to mounted device
- In Midnight Commander, navigate to the
/mnt/usbor/media/usbdirectory - Use the function keys:
F5- Copy filesF6- Move filesF7- Create directoryF8- Delete files
Copying files between drive and system
- Open the source directory on one panel
- Navigate to the target directory on the other panel
- Select files to copy
- Press
F5and confirm the operation
Viewing file contents
Midnight Commander allows viewing text files without exiting the program:
- Select a file
- Press
F3(View) - For viewing in hexadecimal format, press
F4
Automatic mounting on boot
To gain permanent access to external drives, you can configure automatic mounting.
Through /etc/fstab
Open the fstab file for editing:
sudo nano /etc/fstab
Add a line for your device:
/dev/sdb1 /mnt/usb vfat defaults,users,rw,iocharset=utf-8 0 0
Through UUID (recommended method)
- Find the device UUID:
sudo blkid /dev/sdb1
- Add to fstab:
UUID=your-uuid /mnt/usb vfat defaults,users,rw,iocharset=utf-8 0 0
Through systemd (for modern distributions)
Create a unit file:
sudo nano /etc/systemd/system/usb-mount.service
Content:
[Unit]
Description=Mount USB Drive
After=network.target
[Service]
Type=oneshot
ExecStart=/bin/mount /dev/sdb1 /mnt/usb
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Troubleshooting common issues
“Permission denied” error
If you encounter a permission denied error when mounting:
sudo chown -R $USER:$USER /mnt/usb
Device not detected
Check if the device is detected at all:
dmesg | tail
Filesystem not supported
Install the necessary packages:
sudo apt install ntfs-3g exfat-utils
Drive mounts only as root
Add the user to the storage group:
sudo usermod -a -G storage $USER
Clearing device cache
Sometimes restarting udev helps:
sudo udevadm control --reload-rules
sudo udevadm trigger
Sources
Unfortunately, no current sources were found online for this query. The information is provided based on standard practices for working with Midnight Commander and Linux systems.
Conclusion
- Midnight Commander provides a convenient interface for working with external drives through its built-in mounting functions
- For successful operation, it’s necessary to correctly identify the device and filesystem type
- Automatic mounting via fstab or systemd ensures permanent access to USB drives
- When encountering permission access issues, check user group membership and mounting settings
- For working with various filesystems, additional packages may be required (ntfs-3g, exfat-utils)
For in-depth study of Midnight Commander, it’s recommended to use the built-in help (F1) and your Linux distribution’s official documentation.