Shell script not acessing external drive after upgrade to 16.04 LTS

Asked by George Hunter

I recently upgraded from Ubuntu 12.04 LTS to 16.04 LTS, and the shell script that I have used for 2 years to do weekly backups is not working on the new system.
Essentially the script makes a zip copy of /home and writes it to an external hard drive mounted (automatically on startup) at /media/TBAK. It fails with the error message
 zip warning: new zip file left as: /home/george/Backups/ziAWxxP8
 zip I/O error: Not a directory
 zip error: Could not create output file (was replacing the original zip file)
I have changed (recursively) the ownership of TBAK from root to me with no observable effect.
I can use the Nautilus file manager to read & write from TBAK, and to inspect & change permissions when allowed. It shows the permissions on the target directory (/media/TBAK/Backups) as drwxrwxr-x. If however I use ls -l from a terminal window, it shows -rwxr-xr-x. So the terminal window does not think that /Backups is a directory, which is presumably why the zip command fails.
There are several other directories on TBAK, which ls does not see at all, even as files. I used to be able to use the script to back up to a USB, but that isn't working either, and I presume for the same reason.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
George Hunter
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

What file system are you using on the USB storage?

Revision history for this message
George Hunter (c-admin-g) said :
#2

The external hard drive is Ext4; the USB is FAT

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3

If you run:

sudo mount -o rw,remount /media/TBAK

Does it remount OK? Does the backup work after that?

Revision history for this message
George Hunter (c-admin-g) said :
#4

Thanks for that suggestion.
I am just about to go on holiday, so trying this out (it's a desk top system) will have to wait till I get back.

Revision history for this message
George Hunter (c-admin-g) said :
#5

I tried that, it didn't work. Output was -

/media/TBAK >sudo mount -o rw,remount /media/TBAK
mount: /media/TBAK not mounted or bad option

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
/media/TBAK >dmesg | tail
[113428.385820] sd 4:0:0:0: [sdb] tag#0 Add. Sense: No additional sense information
[113428.385824] sd 4:0:0:0: [sdb] tag#0 CDB: ATA command pass through(12)/Blank a1 06 20 da 00 00 4f c2 00 b0 00 00
[114028.040349] sd 4:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_SENSE
[114028.040353] sd 4:0:0:0: [sdb] tag#0 Sense Key : Hardware Error [current] [descriptor]
[114028.040355] sd 4:0:0:0: [sdb] tag#0 Add. Sense: No additional sense information
[114028.040359] sd 4:0:0:0: [sdb] tag#0 CDB: ATA command pass through(16) 85 06 20 00 00 00 00 00 00 00 00 00 00 00 e5 00
[114028.393878] sd 4:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_SENSE
[114028.393883] sd 4:0:0:0: [sdb] tag#0 Sense Key : Hardware Error [current] [descriptor]
[114028.393885] sd 4:0:0:0: [sdb] tag#0 Add. Sense: No additional sense information
[114028.393888] sd 4:0:0:0: [sdb] tag#0 CDB: ATA command pass through(12)/Blank a1 06 20 da 00 00 4f c2 00 b0 00 00
/media/TBAK >

Revision history for this message
Manfred Hampl (m-hampl) said :
#6

For diagnostic purposes please provide the output of the following commands:

uname -a
lsb_release -crid
cat /etc/fstab
mount

Revision history for this message
George Hunter (c-admin-g) said :
#7

Sorry for the delay in replying. The results are

~ >uname -a
Linux george-CM6330 4.10.0-35-generic #39~16.04.1-Ubuntu SMP Wed Sep 13 09:02:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
~ >lsb_release -crid
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
~ >cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda6 during installation
UUID=8520e78a-1bf6-402d-8e84-8fd01b98ffb3 / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=a10d7f7a-d648-4d01-bfd5-5efdd29a57ea /boot ext4 defaults 0 2
# /home was on /dev/sda7 during installation
UUID=c62dce7a-9674-49c7-b0fb-ff6a84b59bac /home ext4 defaults 0 2
# swap was on /dev/sda5 during installation
UUID=8d492ebc-2b4a-47e8-abf6-13aa728c2bab none swap sw 0 0

~ >mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=1844144k,nr_inodes=461036,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=373284k,mode=755)
/dev/sda6 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
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/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=12684)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/sda1 on /boot type ext4 (rw,relatime,data=ordered)
/dev/sda7 on /home type ext4 (rw,relatime,data=ordered)
tmpfs on /run/user/7 type tmpfs (rw,nosuid,nodev,relatime,size=373284k,mode=700,uid=7,gid=7)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=373284k,mode=700,uid=1000,gid=1002)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1002)
/dev/sdb5 on /media/george/TBAK type ext4 (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)
/dev/sdb4 on /media/george/TFAT type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1002,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

Looks like TBAK is not mounted, so why can I acess it normally via the GUI?

Revision history for this message
Manfred Hampl (m-hampl) said :
#8

There is an automount feature that mounts extra partitions when you try accessing them in the file explorer GUI.
Have you noticed the different directories /media/TBAK and /media/george/TBAK ?

Is there any logic to mount the partition inside your backup script?

Revision history for this message
George Hunter (c-admin-g) said :
#9

Thank you for that, I think you have solved the problem, but I am not quite sure why.

/media/TBAK and /media/george/TBAK are indeed different; the latter agrees with the Nautilus listing, and if I use it it the backup script instead of /media/TBAK, the backup script works as expected.

No, the backup script does not attempt to mount the partition; it assumes it is already mounted. With the above modification it seems that assumption is correct.