I'm trying to create an ext4 filesystem in a .img file so that I can transfer it to other machines. Unfortunately, when I unmount and re-mount it, it gets mounted as read-only. I can reproduce the issue on two separate PCs -- a laptop running Ubuntu 20.04 and a desktop running Ubuntu 23.04 -- using the following steps:
- In GNOME, run Disks, select "New disk image", create a 1GB .img file in your home directory, click "Attach new image", then "Format partition" and format it as ext4. This creates device
/dev/loop5
, contents mounted at /media/my-username/volume-label
.
- Open it in GNOME Files (nautilus). Copy some files into it.
- Unmount it using GNOME Files (nautilus).
- Mount it again by clicking on the .img file in GNOME Files.
- Try to copy some more files - you can't - it's read-only.
How can I mount it multiple times properly?
P.S. In case it's relevant, a puzzling thing is when I created the file system, a window opened very briefly asking for my password, but it closed before I had a chance to type anything, and then the new FS opened in Files seemingly without any issues.
Further info:
$ ls -l *.img;id
-rw-rw-r-- 1 k314159 k314159 1000000000 Aug 16 10:27 t.img
uid=1000(k314159) gid=1000(k314159) groups=1000(k314159),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),132(lxd),133(sambashare),136(docker)
$ grep loop5 /etc/mtab
/dev/loop5 /media/k314159/test ext4 rw,nosuid,nodev,relatime 0 0
# Then after using GNOME Files (nautilus) to dismount & remount:
$ grep loop5 /etc/mtab
/dev/loop5 /media/k314159/test ext4 ro,nosuid,nodev,relatime 0 0