NeuroAgent

Connecting External Drives in Midnight Commander

Complete guide to connecting and using external drives in Midnight Commander. Learn how to mount USB drives and work with files.

Question

How to connect and use an external drive in Midnight Commander (mc)?

NeuroAgent

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

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:

bash
groups $USER

If you don’t see the required groups, add the user:

bash
sudo usermod -a -G plugdev $USER

Device identification

Connect the USB drive and identify its name using the command:

bash
lsblk

or

bash
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

  1. Launch Midnight Commander by typing mc in the terminal
  2. Connect the USB drive to the computer
  3. In the left or right panel of the file manager, press F5 to refresh the list
  4. 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:

  1. In Midnight Commander, navigate to the /mnt or /media directory
  2. Create a mount point if it doesn’t exist:
    F7 (Create directory)
    /mnt/usb
    
  3. Press Ctrl+U to mount the device
  4. 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

bash
sudo file -s /dev/sdb1

Mounting different filesystems

For FAT32/NTFS:

bash
sudo mount -t vfat -o iocharset=utf-8 /dev/sdb1 /mnt/usb

For NTFS:

bash
sudo mount -t ntfs-3g /dev/sdb1 /mnt/usb

For ext2/ext3/ext4:

bash
sudo mount /dev/sdb1 /mnt/usb

For automatic type detection:

bash
sudo mount -a /dev/sdb1

Checking successful mounting

bash
mount | grep /dev/sdb1

or

bash
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

  1. In Midnight Commander, navigate to the /mnt/usb or /media/usb directory
  2. Use the function keys:
    • F5 - Copy files
    • F6 - Move files
    • F7 - Create directory
    • F8 - Delete files

Copying files between drive and system

  1. Open the source directory on one panel
  2. Navigate to the target directory on the other panel
  3. Select files to copy
  4. Press F5 and confirm the operation

Viewing file contents

Midnight Commander allows viewing text files without exiting the program:

  1. Select a file
  2. Press F3 (View)
  3. 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:

bash
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)

  1. Find the device UUID:
bash
sudo blkid /dev/sdb1
  1. 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:

bash
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:

bash
sudo chown -R $USER:$USER /mnt/usb

Device not detected

Check if the device is detected at all:

bash
dmesg | tail

Filesystem not supported

Install the necessary packages:

bash
sudo apt install ntfs-3g exfat-utils

Drive mounts only as root

Add the user to the storage group:

bash
sudo usermod -a -G storage $USER

Clearing device cache

Sometimes restarting udev helps:

bash
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.