1

Why does a copy operation to a directory that serves as a mountpoint not copy the data to the mounted drive?

I bought a 2 terabyte drive and mounted it in a subdirectory within my home directory.

Where /dev/sdb is my 500GB system drive and /dev/sda is my 2TB data drive:

Partition        Mountpoint
/dev/sdb1   ->   /
/dev/sdb3   ->   /home
/dev/sdb2   ->   swap
/dev/sda1   ->   /home/data

This all seems to work, and even shows up in df -h properly (i.e., /dev/sda1 is mounted on /home/data [to regenerate the fstab I booted into my arch disk live environment and mounted the partitions to the folders in /mnt that I wanted to partition, running genfstab -U /mnt > /mnt/etc/fstab; it worked])

Last night I set my box to running a 650GB copy operation to /home/data. Imagine my surprise when tons of copy operations failed due to being out of diskspace.

df -h shows that /dev/sdb3 is full but /dev/sda1 is nearly empty (77MB). The mount point is functioning properly, so far as I can tell, but the copy operation put all the data in /dev/sdb3! Presumably, if I unmount the drive, the music will still be in /home/data.

Clearly there is something about mounting and fstab that I am not fully understanding.

The particular entry in fstab reads:

# /dev/sdb1
UUID=<UUID>    /            ext4     rw,relatime 01

# /dev/sdb3
UUID=<UUID>    /home        ext4     rw,relatime 02

# /dev/sda1
UUID=<UUID>    /home/data   ext4     rw,relatime 02

Before regenerating the fstab, I had a swap entry in fstab. I'm not sure why it didn't regenerate.

Update: I managed to get the output of mount:

proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sys on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
dev on /dev type devtmpfs (rw,nosuid,relatime,size=4051032k,nr_inodes=1012758,mode=755)
run on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
/dev/sdb1 on / type ext4 (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
bpf on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=44,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13569)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)
configfs on /sys/kernel/config type configfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
/dev/sdb3 on /home type ext4 (rw,relatime)
/dev/sda1 on /home/data type ext4 (rw,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=811560k,mode=700,uid=1000,gid=1000)
| improve this question | | | | |
  • 1
    Are you sure the quoted fstab is correct? It also mounts sdb3 under /home/data although that is your /home partition. – Stefan Hamcke Dec 31 '18 at 12:45
  • Whoops. I copied it from the screen rather than from the computer. – malan Dec 31 '18 at 13:06
  • Unfortunately, I'm at work now, so if this is something that requires a lot more information and isn't simply a known quirk, I'm going to have to wait to post more data. – malan Dec 31 '18 at 13:12
  • 1
    Please verify your mounts by adding the output of mount to your question. – Hermann Dec 31 '18 at 13:22
  • @Hermann I managed to get it. – malan Dec 31 '18 at 14:18
2

You mention that your copy command is cp -r /mnt/music data/ when you're in ~.

This means that you're copying your data into /home/<username>/data, since ~ would expand to /home/username.

However, your external drive is mounted as /home/data, according to the mount output you supplied. To finish your goal, you need to do two things:

  • copy all the data from /home/<username/data to the /home/data directory.
    • rsync -avHP /home/<username>/data/* /home/data/ (or some variation)
    • this moves all the data out of your home partition and into the external drive.
  • fix up how you want to access the drive
    • leave it mounted as /home/data, and just access it that way
    • one option would be to create a symlink in ~ to access it: ln -s /home/data ~/data
    • another option would be to edit your fstab to set the mountpoint for the external drive to /home/<username>/data
| improve this answer | | | | |
  • 1
    Holy cow Tim. Thank you so much. PEBCAK. I knew there was something horrifically stupid I was overlooking. – malan Dec 31 '18 at 17:44
  • We've all been there, @malan. That's why makes this site (and the other StackExchange sites) so valuable. – Tim Kennedy Dec 31 '18 at 19:12

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.