linux-apfs-rw icon indicating copy to clipboard operation
linux-apfs-rw copied to clipboard

readwrite option not working

Open muammar opened this issue 4 years ago • 16 comments

Thanks for this effort you are making by enabling apfs on Linux. I used your other tool to format an external hard disk, and everything seems to work. When I mount the newly formatted partition with:

sudo mount -o readwrite /dev/sdc1 Backup 

And I try to create anything either with sudo or as a regular user; it does not let me do that.


mkdir: cannot create directory ‘hola’: Read-only file system

PS. This is on Debian Unstable.

muammar avatar Aug 20 '21 13:08 muammar

That's weird. Any output on dmesg?

eafer avatar Aug 20 '21 22:08 eafer

[   66.504090] ucsi_acpi USBC000:00: PPM init failed (-110)
[   86.067204]  sdb: sdb1
[  105.562233]  sdb: sdb1
[  327.690887] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)
[  423.904292]  sdb: sdb1
[  440.258117]  sdb: sdb1
[  530.870511] APFS (26g): experimental write support is enabled
[  535.085950] APFS (26g): large devices are not supported
[  535.085953] APFS (26g): aborting transaction

Large devices are not supported. That’s the problem. This is a 2TB hard drive.

muammar avatar Aug 21 '21 03:08 muammar

2TB is not that big, that message is intended for containers above 7 TB or so. Did you say that you used my mkfs? The problem is most likely over there, I'll take a look.

eafer avatar Aug 23 '21 19:08 eafer

I just pushed a patch to the mkfs, when you can let me know if it fixed your problem. One thing you should know: large containers above 1.4Tb or so may be usable with my module alone, but the official implementation of apfs will probably reject them. I'll fix this eventually, but I don't have the time now.

eafer avatar Aug 24 '21 05:08 eafer

@eafer sorry that I got back to you late. I tried again, but it still does not work.

[  149.340916] sd 10:0:0:0: [sdb] Spinning up disk...
[  150.362462] .....ready
[  154.458851] sd 10:0:0:0: [sdb] 3906963456 512-byte logical blocks: (2.00 TB/1.82 TiB)
[  154.459092] sd 10:0:0:0: [sdb] Write Protect is off
[  154.459097] sd 10:0:0:0: [sdb] Mode Sense: 47 00 10 08
[  154.459376] sd 10:0:0:0: [sdb] No Caching mode page found
[  154.459385] sd 10:0:0:0: [sdb] Assuming drive cache: write through
[  154.522900]  sdb: sdb1
[  154.524696] sd 10:0:0:0: [sdb] Attached SCSI disk
[  356.970552]  sdb: sdb1
[  515.548842] APFS (26g): experimental write support is enabled
[  518.284555] APFS (26g): unable to read container object map
[  518.284564] APFS (26g): aborting transaction
(base) 

What could be happening in this case? I tried mounting the hard disk formatted with macOS, and also with your tools, and in both cases, I am unable to write. I will just check the disk and try again.

muammar avatar Sep 18 '21 23:09 muammar

@muammar I'm trying to create a debian package, if someone wants to help? https://mentors.debian.net/package/linux-apfs-rw/

alexmyczko avatar Sep 28 '21 11:09 alexmyczko

@muammar I'm trying to create a debian package; if someone wants to help? https://mentors.debian.net/package/linux-apfs-rw/

I would be interested, and if it works, I can try to help you upload it to the Debian archives (I am a DD). I will install it on my Debian unstable and check if I get writing support.

muammar avatar Sep 28 '21 11:09 muammar

i guess it's far from ready, but after you install, i'm able to run dkms build linux-apfs-rw/0+git20210928 but somehow couldn't get a kernel module, to modprobe, any help is welcome.

alexmyczko avatar Sep 28 '21 11:09 alexmyczko

@muammar i think this one looks good already: https://mentors.debian.net/package/apfsprogs/ (except for the missing unicode license part, needs clarification with upstream)

alexmyczko avatar Sep 28 '21 14:09 alexmyczko

@alexmyczko Thanks for your effort, it would be nice to see this packaged for Debian. I don't have any experience with that, but let me know if I can help. You should start a separate issue though, since Muammar's problem is not yet fixed.

eafer avatar Oct 04 '21 21:10 eafer

Hello Do I need to use the apfsprogs tools as well to enable write support?

AdityaGarg8 avatar Oct 14 '22 15:10 AdityaGarg8

Do I need to use the apfsprogs tools as well to enable write support?

No, you need to use the readwrite mount option. The README explains it, but be careful, it's likely to cause some corruption.

eafer avatar Oct 14 '22 19:10 eafer

Well I tried with readwrite option on a 4GB APFS formatted USB drive, but was not successful.

BTW, I noticed there was a demand for a Debian package for the same. I am hosting this driver in my APT repo. It shall be updated regularly since I have also set a scheduled job to look for updates from this repo of yours and publish a newer version if available.

AdityaGarg8 avatar Oct 14 '22 20:10 AdityaGarg8

Are there any logs that I can share to fix my write issue?

AdityaGarg8 avatar Oct 14 '22 20:10 AdityaGarg8

@eafer

This is what I get on mounting as readwrite

aditya@MacBook:~$ sudo mount -o readwrite /dev/sda2 /mnt
[sudo] password for aditya: 
mount: /mnt: WARNING: source write-protected, mounted read-only.

And my dmesg

aditya@MacBook:~$ sudo dmesg | grep apfs
[  101.590889] apfs: loading out-of-tree module taints kernel.
[  101.590937] apfs: module verification failed: signature and/or required key missing - tainting kerne

AdityaGarg8 avatar Oct 14 '22 20:10 AdityaGarg8

Also, the name of my APFS volume is not being displayed in Files app, and GNOME disks also marks my USB Drive as no mounted, in-spite of it actually being mount.

AdityaGarg8 avatar Oct 14 '22 20:10 AdityaGarg8

***@***.***:~$ sudo mount -o readwrite /dev/sda2 /mnt
[sudo] password for aditya: 
mount: /mnt: WARNING: source write-protected, mounted read-only.

This doesn't seem to be an apfs problem. Your device at /dev/sda2 appears to be on read-only mode for some reason. Maybe it has a physical switch for that?

Also, the name of my APFS volume is not being displayed in Files app

APFS containers don't have a label themselves. You do have a label for each volume, but a single partition can hold multiple volumes, so I don't think there is any sane way for linux file managers to report that. If they wanted they could report the gpt partition label when it's available, but that doesn't involve APFS.

GNOME disks also marks my USB Drive as no mounted, in-spite of it actually being mount.

I have no idea how file managers tell apart mounted and unmounted devices, but it probably doesn't involve the driver directly. Maybe they check /proc/mounts. I just checked on thunar and it seems to work, but not every single time. I'll try to look into it at some point, but maybe you'll get faster results if you just ask the nautilus devs.

eafer avatar Oct 17 '22 20:10 eafer

This doesn't seem to be an apfs problem. Your device at /dev/sda2 appears to be on read-only mode for some reason. Maybe it has a physical switch for that?

No it doesn't have a physical switch. I had formatted it using macOS 12 to APFS. Should I use apfsprogs?

AdityaGarg8 avatar Oct 18 '22 10:10 AdityaGarg8

No it doesn't have a physical switch

What do you get if you run blockdev --getro /dev/sda2? I think you'll get a 1, which means read-only. I don't know why, but maybe there's something on dmesg that explains it.

eafer avatar Oct 18 '22 18:10 eafer

What do you get if you run blockdev --getro /dev/sda2? I think you'll get a 1, which means read-only. I don't know why, but maybe there's something on dmesg that explains it.

aditya@MacBook:~$ sudo blockdev --getro /dev/sda2
[sudo] password for aditya: 
0

I am getting a 0.

AdityaGarg8 avatar Oct 18 '22 18:10 AdityaGarg8

And it still doesn't mount? Weird. What about after you try to mount with readwrite, do you still get a 0?

eafer avatar Oct 18 '22 18:10 eafer

Yeah, I am still getting a 0.

I just noticed that I am able to rename files after mounting as readwrite. But I am not able to copy new files or edit existing files.

AdityaGarg8 avatar Oct 18 '22 18:10 AdityaGarg8

aditya@MacBook:/mnt$ sudo cp /media/aditya/"TOSHIBA EXT1"/ubuntu/iso-firmware.deb ./
cp: cannot create regular file './iso-firmware.deb': Read-only file system

AdityaGarg8 avatar Oct 18 '22 18:10 AdityaGarg8

I did manage to write one file luckily, but now its refusing to even rename.

AdityaGarg8 avatar Oct 18 '22 18:10 AdityaGarg8

You can rename files on a read-only mount? What do you get for your apfs filesystem on /proc/mounts? If you can also send me all your dmesg since the first mount.

eafer avatar Oct 18 '22 18:10 eafer

I did manage to write one file luckily, but now its refusing to even rename.

But are you still getting mount: /mnt: WARNING: source write-protected, mounted read-only, or is that gone?

eafer avatar Oct 18 '22 18:10 eafer

But are you still getting mount: /mnt: WARNING: source write-protected, mounted read-only, or is that gone?

I am not getting this now.

AdityaGarg8 avatar Oct 18 '22 18:10 AdityaGarg8

I reformatted the USB to APFS again using macOS and added a text file there. Now, I was able to rename, and even edit the file. But, as I tried to copy a debian package to the USB, it suddenly became read-only again.

Just in case you wish to know, my USB drive is 4Gbs.

AdityaGarg8 avatar Oct 18 '22 18:10 AdityaGarg8

aditya@MacBook:~$ sudo dmesg | grep apfs
[  103.578879] apfs: loading out-of-tree module taints kernel.
[  103.578939] apfs: module verification failed: signature and/or required key missing - tainting kernel
aditya@MacBook:~$ sudo dmesg > apfs.log
aditya@MacBook:~$ sudo dmesg | grep APFS
[  186.334622] APFS (33g): experimental write support is enabled
[  203.507090] APFS: space manager is versioned
[  227.194568] APFS (33g): internal pool seems full
[  227.194572] APFS (33g): unable to read container object map
[  227.194574] APFS (33g): aborting transaction
[  227.194576] APFS (33g): failed to delete orphan inode 0x9e

AdityaGarg8 avatar Oct 18 '22 18:10 AdityaGarg8

Do you want the full dmesg?

AdityaGarg8 avatar Oct 18 '22 18:10 AdityaGarg8