tune2fs doesn't set UUID on a loopback device after mount/unmount

Bug #1745186 reported by Slava Abramov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
e2fsprogs (Ubuntu)
New
Undecided
Unassigned

Bug Description

Below is the script we're running. tune2fs doesn't set UUID (can be checked with blkid) and exits abnormally (so that commands after tune2fs call are not getting executed).

If we move tune2fs call above the mount command, everything works fine. Also, it works fine everywhere else including Ubuntu 16.04.3.

#!/bin/bash
set -e
FOREMAN_SIZE=100
UUID="7b48ec41-a9fc-4937-b368-dfeae01c49f7"
MNT=$(mktemp -d -t mnt.XXXXXXXXXX)
trap "[[ -z "$MNT" ]] || rm -rf $MNT ||:" 0 1 2 3 15
if [[ -f foreman.tar.xz ]] && [[ ! -f foreman.img ]]; then
        echo "Creating \"foreman\" home image ..."
        qemu-img create -f raw -o size=${FOREMAN_SIZE}G foreman.img
        lo=$(sudo losetup --show -f foreman.img)
        echo -e "n\np\n\n\n\nw" | sudo fdisk $lo ||:
        sudo kpartx -asv $lo
        sudo mkfs.ext4 /dev/mapper/${lo##*/}p1
        sudo mount /dev/mapper/${lo##*/}p1 $MNT
        sudo tar -C $MNT -Jxvf foreman.tar.xz
        sudo umount $MNT
        sudo tune2fs /dev/mapper/${lo##*/}p1 -U $UUID
        sudo kpartx -d $lo
        sudo losetup -d $lo
fi

ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: e2fsprogs 1.43.5-1
ProcVersionSignature: Ubuntu 4.13.0-31.34-generic 4.13.13
Uname: Linux 4.13.0-31-generic x86_64
ApportVersion: 2.20.7-0ubuntu3.7
Architecture: amd64
CurrentDesktop: XFCE
Date: Wed Jan 24 12:02:26 2018
InstallationDate: Installed on 2018-01-10 (14 days ago)
InstallationMedia: Xubuntu 17.10 "Artful Aardvark" - Release amd64 (20171017.1)
SourcePackage: e2fsprogs
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Slava Abramov (contik32) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.