Subject: Re: Bug#836211: dpkg: Cannot upgrade some packages on overlayfs: Invalid cross-device link

From: Guillem Jover <[email-masked]>
Date: Sat, 17 Sep 2016 17:36:09 +0200

Control: reassign -1 linux
Control: affects -1 dpkg

Hi!

[ Reassigning to linux, where this can be fixed. Upstream has provided
  a preliminary patch to this bug report, which might need testing and
  perhaps some polishing? Trimmed irrelevant information. ]

On Wed, 2016-08-31 at 12:16:10 -0300, Felipe Sateler wrote:
> Package: dpkg
> Version: 1.18.10
> Severity: normal

> overlayfs does not support renaming directories when the directories
> live in the lower filesystem:
> 
>  * Directory renames only allowed on "pure upper" (already created on
>  * upper filesystem, never copied up).  Directories which are on lower or
>  * are merged may not be renamed.  For these -EXDEV is returned and
>  * userspace has to deal with it.  This means, when copying up a
>  * directory we can rely on it and ancestors being stable.
> 
> https://github.com/torvalds/linux/blob/v4.8-rc2/fs/overlayfs/copy_up.c#L318-L322
> 
> Unfortunately this means that dpkg fails at least in the case where a
> directory is converted into a file: apt 1.3~rc2 moves
> /usr/share/bug/apt/script to /usr/share/bug/apt . This causes dpkg to
> fail when running in an overlayfs with the following error:
> 
> # dpkg -i /var/cache/apt/archives/apt_1.3~rc3_amd64.deb 
> (Reading database ... 11401 files and directories currently installed.)
> Preparing to unpack .../archives/apt_1.3~rc3_amd64.deb ...
> Unpacking apt (1.3~rc3) over (1.3~rc2) ...
> dpkg: error processing archive
> /var/cache/apt/archives/apt_1.3~rc3_amd64.deb (--install):
>  unable to move aside './usr/share/bug/apt' to install new version: Invalid cross-device link
> dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
> Processing triggers for libc-bin (2.23-5) ...
> Errors were encountered while processing:
>  /var/cache/apt/archives/apt_1.3~rc3_amd64.deb
> 
> I don't know what the correct workaround should be.
> 
> This can break pre-build upgrades in sbuild when the schroot is of
> overlayfs type.

> -- System Information:
> Debian Release: stretch/sid
>   APT prefers unstable-debug
>   APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental-debug'), (1, 'experimental')
> Architecture: amd64 (x86_64)
> Foreign Architectures: i386
> 
> Kernel: Linux 4.6.0-1-amd64 (SMP w/4 CPU cores)

Thanks,
Guillem