1

Files saved on an external hard drive disappear when that drive is mounted to another computer.

I have two Intel NUCs running Ubuntu 20.04 LTS server in separate physical locations, each with a 2TB hard drive. I have a 524GB directory that I want to move from NUC1 to NUC2, so rather than rsync it across the Internet, I thought I would try copying it from NUC1 onto an external 4TB hard drive, then moving the external hard drive (formatted ExFAT with GUID partition scheme) to NUC2 and copying it onto NUC2.

To begin I plugin the external 4TB Seagate USB drive into NUC1 and list block devices:

$ lsblk -e7
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  1.8T  0 disk
├─sda1   8:1    0  512M  0 part /boot/efi
└─sda2   8:2    0  1.8T  0 part /
sdb      8:16   0  3.7T  0 disk
├─sdb1   8:17   0  200M  0 part
└─sdb2   8:18   0  3.7T  0 part

So I want to manually mount sdb2 (the 4TB external drive), which I am going to mount on /mnt (a carry-over of my habit of reserving /media on my Desktop Ubuntu instances to mount volumes using Nautilus software). First I make a directory to which I am going to mount the drive:

$ sudo mkdir -p /mnt/4TB 

Then I mount the drive:

$ sudo mount /dev/sdb2 /mnt/4TB
FUSE exfat 1.3.0 

Then I make a directory files/ on the mounted drive into which I copy the 524GB of files using rsync, confirmed by sync:

$ sudo mkdir -p /mnt/4TB/files
$ sudo rsync -av /home/foo/files/ /mnt/4TB/files/
$ sync

The uid and gid for my user foo is 1000. The copy takes many hours. I verify the files are there:

$ sudo df -H
Filesystem      Size  Used Avail Use% Mounted on
udev            4.1G     0  4.1G   0% /dev
/dev/sda2       2.0T  1.7T  228G  88% /
/dev/sdb2       4.1T  524G  3.6T  13% /mnt/4TB
(ignoring all the tmpfs and loop lines)

I unmount the external drive:

sudo umount /dev/sdb2 

I unplug the external USB drive from NUC1, drive for 5 hours and reverse/repeat the process after plugging the external drive into NUC2:

$ lsblk -e7
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  1.8T  0 disk
├─sda1   8:1    0  512M  0 part /boot/efi
└─sda2   8:2    0  1.8T  0 part /
sdb      8:16   0  3.7T  0 disk
├─sdb1   8:17   0  200M  0 part
└─sdb2   8:18   0  3.7T  0 part

$ sudo mkdir -p /mnt/4TB

$ sudo mount /dev/sdb2 /mnt/4TB
FUSE exfat 1.3.0

The files/ directory on the external drive is there:

$ cd /mnt/4TB/
$ ls -l
total 256
drwxrwxrwx 1 root root 262144 Nov 12 04:43 files

... but there is nothing in it:

$ sudo df -H
Filesystem      Size  Used Avail Use% Mounted on
udev            8.3G     0  8.3G   0% /dev
/dev/sda2       2.0T  7.7G  1.9T   1% /
/dev/sdb2       4.1T  103M  4.1T   1% /mnt/4TB

and when I try to copy the non-existent files from the external drive onto NUC2, of course nothing happens:

$ sudo rsync -av /mnt/4TB/files/ /home/foo/files/
sending incremental file list 
./

sent 41 bytes  received 19 bytes  120.00 bytes/sec
total size is 0  speedup is 0.00

The uid and gid for my user foo on NUC2 is 1002.

What is going on? Where are the files? What am I not understanding?

1 Answer 1

0

I don't know why your files have disappeared, but I can tell you how to more reliably ensure they do not disappear in the future. You write that you formatted your external 4TB Seagate USB drive as ExFAT with GUID partition scheme. ExFAT (Extensible File Allocation Table) is a proprietary file system introduced by Microsoft. I have always found ExFAT volumes to be problematic on Ubuntu. To use your ExFAT external drive on Ubuntu you need to install supporting packages:

sudo apt update
sudo apt install exfat-fuse exfat-utils

Alternatively I would advise that you just use the ext4 journaling file system (or fourth extended filesystem) native to Linux as the default file system for many distributions including Debian and Ubuntu. Then you will be getting the full benefit of everything open-source and native to Ubuntu.

Here's what I suggest:

  1. Format your sdb 4TB external drive with ext4 (ref https://help.ubuntu.com/community/InstallingANewHardDrive):
$ sudo mkfs -t ext4 /dev/sdb
  1. Mount your formatted sdb drive as before on NUC1:
$ sudo mkdir -p /mnt/4TB/ (as required)
$ sudo mount /dev/sdb /mnt/4TB
  1. Create your files/ directory on the mounted drive as before into which you can copy your 524GB of files using rsync, confirmed by sync - note the changes I'm suggesting to rsync:
$ sudo mkdir -p /mnt/4TB/files
$ sudo rsync -avhW --no-compress --progress /home/foo/files/ /mnt/4TB/files/
$ sync
  1. Unmount your hard drive, physically remove it and drive it to your other location:
sudo umount /dev/sdb
  1. Mount the drive on your NUC2 and copy the files to its internal drive using rsync (don't forget to unmount the external drive if you don't want it on there after you are done):
$ sudo mkdir -p /mnt/4TB/ (as required)
$ sudo mount /dev/sdb /mnt/4TB
$ sudo mkdir -p /home/foo/files/ (as required)
$ sudo rsync -avhW --no-compress --progress /mnt/4TB/files/ /home/foo/files/
$ sync

Let me know if this works for you.

1
  • Great. I should clarify that drives formatted with the ext4 journaling file system will not be portable to macOS and Windows - fat32 and ExFAT are for portability. Nov 16, 2020 at 14:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .