Avatar of the person chatting

I'm using Linux 4.17.10-pmagic. Want to view the contents of a hard drive I have connected via a USB adapter. How can I see what's on that drive?

You can use the command lsblk to view a list of all the block devices currently connected to your system, including the USB hard drive. Once you have identified the device name (e.g. /dev/sda1), you can use the command mount to mount the device and make its contents accessible. Then you can use the command ls to view the contents of the mounted device, or you can use the command cd to navigate into the device and explore its contents.

Also you can use the command fdisk -l to see the partitions of the hard drive and then use the mount command to mount the partition you want.

For example, if the device name is /dev/sda1:

sudo mount /dev/sda1 /mnt ls /mnt

This will mount the drive to /mnt directory and list the contents of the drive.

Avatar of the person chatting

I only have devices named /dev/loop252 and /dev/ram0 etc.

The devices you mentioned, such as /dev/loop252 and /dev/ram0, are not block devices and cannot be used to access a USB hard drive.

The /dev/loop* devices are loop devices and /dev/ram* are RAM disk devices.

You should check if the hard drive is properly connected to the computer and powered on. Also, you should check that the USB adapter is working correctly. Also, check if you have the necessary permissions to access the drive. If the drive is properly connected and powered on, you should see it listed when you run the command lsblk with root privilege.

Try running sudo lsblk command, it will show you all the block devices connected to your system. If the drive is still not showing up, try to connect it to a different USB port or to a different computer to see if the issue is with the drive or the USB adapter.

Avatar of the person chatting

only devices shown with 'sudo lsblk' are loop253, sr0, loop254 and loop252

It seems that the USB hard drive is not being recognized by the system.

Here are a few things you can try:

  • Make sure that the hard drive is properly connected to the computer and powered on.
  • Try connecting the hard drive to a different USB port or to a different computer to see if the issue is with the drive or the USB adapter.
  • Check if you have the necessary permissions to access the drive.
  • Try to check if the hard drive is detected by the system using dmesg command after connecting it. It will show you any messages related to the drive.
  • If the hard drive is still not showing up, it may be a hardware issue with the drive or the USB adapter. In that case, you may need to replace the drive or the adapter.

Please let me know if there's anything else I can help you with.

Avatar of the person chatting

how can I see what usb devices the system sees

You can use the command lsusb to see a list of all USB devices currently connected to your system. This command will show you the vendor and product ID of each connected device, as well as its device class, subclass, and protocol.

Alternatively, you can also use the command dmesg | grep -i usb to see a list of all USB-related messages that have been recorded in the kernel log. This can be useful to see if the system has detected a new USB device and if there are any errors related to it.

Another option is to check the /sys/class/usb_device/ directory, it contains a subdirectory for each USB device that is currently connected to the system.

You can also use ls /sys/class/usb_device/ to see the USB devices connected to the system, and then use cat /sys/class/usb_device/<device>/product to see the details of the device.

You can also use tools like 'lsusb' and 'usb-devices' which will give you more detailed information about the connected USB devices.

Avatar of the person chatting

I can see the USB drive adapter with that command. I unplugged the USB drive adapter and ran the command again and it's not shown. I plugged it back in but it's listed again. Is there a way to have Linux try to mount the drive now that I've unplugged and plugged back in?

When you unplug and replug a USB drive, Linux will detect the change and may automatically mount the drive for you. However, this behavior can vary depending on your system's configuration and the type of file system the drive is using.

You can try the following command to check if the drive is now mounted:

mount | grep /dev/sd*

It will show you all the partitions that are currently mounted.

You can also use the lsblk command to check if the hard drive is now recognized by the system, and if so, its device name. Once you have the device name, you can use the mount command to mount the device manually.

Alternatively, you can use the 'udisksctl' command to mount the drive.

udisksctl mount -b /dev/sdx

Where x is the partition of the hard drive you want to mount.

You can also use 'udisksctl monitor' command to see the changes of the connected storage devices.

If the drive is still not showing up, it may be a hardware issue with the drive or the USB adapter. In that case, you may need to replace the drive or the adapter.

Avatar of the person chatting

hey, I now see sda when I ran lsblk again

Great, it looks like the hard drive is now recognized by the system.

You can use the mount command to mount the device manually. For example:

sudo mount /dev/sda1 /mnt

This will mount the first partition of the hard drive to the /mnt directory.

Alternatively, you can use the 'udisksctl' command to mount the drive:

udisksctl mount -b /dev/sda1

Once the drive is mounted, you should be able to navigate to the /mnt directory and access the contents of the hard drive.

cd /mnt ls

You can unmount the drive with the command:

udisksctl unmount -b /dev/sda1

Please let me know if there is anything else I can help you with.

Avatar of the person chatting

using the first command I get the message 'device /dev/sda1 does not exist'

I apologize, the error message you're seeing is because the device /dev/sda1 does not exist.

It could be that the hard drive is not partitioned or the partition table is not recognized by Linux. You can use the fdisk -l command to list all the partitions on the hard drive and check if the partition table is recognized by Linux.

If the drive is not partitioned, you can use the fdisk command to create partitions.

Alternatively, you can use other partitioning tools like 'gdisk' or 'parted' to create partitions and format the drive.

You can also try using the command ls /dev/sd* or ls /dev/nvme* to see the device name, sometimes it could be that the device name is different than expected.

Please let me know if there's anything else I can help you with.

Avatar of the person chatting

'ls /dev/sd*' shows me '/dev/sda'. I'm pretty sure the drive is using FAT16 or FAT32 if that matters

If the drive is using FAT16 or FAT32 file system, you should be able to mount it without any issues.

You can try mounting the drive with the following command:

sudo mount -t vfat /dev/sda /mnt

This command will mount the drive to the /mnt directory using the vfat file system.

You can also use 'ntfs-3g' package to mount ntfs partitions.

sudo apt-get install ntfs-3g sudo mount -t ntfs-3g /dev/sda /mnt

Once the drive is mounted, you should be able to navigate to the /mnt directory and access the contents of the hard drive.

cd /mnt ls

It could be that the drive is not partitioned and it's unformatted, in that case, you need to format the drive before you can use it. You can use 'mkfs' command to format the drive with the desired file system.

sudo mkfs -t vfat /dev/sda

Please let me know if there is anything else I can help you with.

Avatar of the person chatting

'can't read superblock'

The error message "can't read superblock" suggests that there may be an issue with the file system on the hard drive. This can happen when the file system is corrupted, or when the hard drive is not properly formatted.

You can try using the fsck command to check and repair the file system.

sudo fsck /dev/sda

You can also try the following command to mount the drive and repair it at the same time:

sudo mount -t vfat -o rw,noatime,sync /dev/sda /mnt

The -o option is used to specify mount options and the options used above are to mount the drive as read-write, noatime and sync.

If the file system is corrupted or unrepairable, you may need to reformat the drive, this will erase all the data on the drive.

It could also be the case that the drive is physically damaged, in that case, you may need to consider replacing the drive.

Please let me know if there's anything else I can help you with.

Avatar of the person chatting

so I tried some other drives, a drive with NTFS format showed up automatically I could browse it using the GUI no problem. Tried another drive that has some variation of the FAT file system and get the same superblock errors

It sounds like the issue might be specific to the FAT file system. It is possible that the FAT file system on that drive is corrupted and cannot be read by the system.

You can try using the fsck command to check and repair the file system. If the file system is corrupted or unrepairable, you may need to reformat the drive, this will erase all the data on the drive.

sudo fsck -t vfat /dev/sda

Another option is to try using a different tool to check the file system, like dosfsck

sudo dosfsck -a /dev/sda

This command will check and repair the file system.

You can also try using a specialized tool for FAT file system like testdisk, it can be used to recover data from damaged file system.

sudo apt-get install testdisk sudo testdisk /dev/sda

It could also be the case that the drive is physically damaged, in that case, you may need to consider replacing the drive.

Please let me know if there is anything else I can help you with.