0

My laptop for some reason will not power an external 2.5" HDD, so I am using a Raspberry PI to connect to the drive.

The problem is, I am struggling to perform tasks such as formatting disks and backing-up/restoring partitions. For example:

$ sshfs zaz@192.168.1.93:/dev/ /media/pi-dev
# ntfsclone -r -O /media/pi-dev/sda1 backup.iso
[sudo] password for zaz:         
ntfsclone v2016.2.22AR.2 (libntfs-3g)
ERROR(13): Couldn't access 'dev/sda1': Permission denied

How can I use sshfs to mount device files so that I can work with partitions?

1

SSHFS cannot do this. It cannot access block devices. (Source.)

You have four options:

  • SSH into the Pi, and mount the drive. Eg:

    root@pi# mount /dev/sda1 /mnt/disk
    

    Then use SSHFS to mount it on your laptop. Eg:

    user@laptop$ sshfs zaz@192.168.1.93:/mnt/disk/ /media/pi-disk
    

    Now you can modify files on the hard drive. However, I think this doesn't solve your problem - it sounds like you're trying to reformat or recover a failing disk.

  • SSH into the Pi, and run your disk recovery commands there. If you don't have enough space on the Pi to do a disk clone, consider trying something like:

    ntfsclone --save-image --output - /dev/hda1 | \
       gzip -c | ssh host 'cat > backup.img.gz'
    

    (Source: ntfsclone(8) manual.)

    This command clones a local partition, and saves it to a remote system.

  • Buy a powered USB hub. (The kind with a wall-wart.) They're pretty cheap, and you could connect your hard drive to your laptop without any power issues.

  • Use Network Block Device (NBD) to share the block device over the network. Example. I have never tried this, so you're on your own. ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.