/home on btrfs is gone?

I installed endeavouros about two days ago. I chose LUKS on top of btrfs on a brand new 1tb crucial nvme drive.

I was running some code in Pycharm and my home directory is just brand new? It happened while I was typing in Pycharm. All the files just disappeared. All my configs are gone, firefox configs, i3-wm configs, etc.

/var/cache, /var/log and / subvols look ok. Everything is still installed, logs are still there. I couldn’t find anything in the logs (journalctl -xe) but systemd logs always confused me. btrfs device stats /home shows no errors.

Any advice? Did I revert to a snapshot or something? I’m new to btrfs.

Maybe you accidentally unmounted the subvol holding your home directory?
What does sudo mount give you? Anything mounted to /home?
Or try sudo btrfs subvolume list / to see which subvolumes you got

What code were you running?

What specifically were you typing?

Can you share the output of findmnt --real

finmnt --real:

TARGET       SOURCE                                                         FSTYPE OPTIONS
/            /dev/mapper/luks-0323e6ae-e989-4cb8-ae03-bece70c40262[/@]      btrfs  rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=256,subvol=/@
├─/home      /dev/mapper/luks-0323e6ae-e989-4cb8-ae03-bece70c40262[/@home]  btrfs  rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=257,subvol=/@home
├─/var/cache /dev/mapper/luks-0323e6ae-e989-4cb8-ae03-bece70c40262[/@cache] btrfs  rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=258,subvol=/@cache
├─/var/log   /dev/mapper/luks-0323e6ae-e989-4cb8-ae03-bece70c40262[/@log]   btrfs  rw,noatime,compress=zstd:3,ssd,space_cache=v2,subvolid=259,subvol=/@log
└─/efi       /dev/nvme1n1p1                                                 vfat   rw,relatime,fmask=0137,dmask=0027,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remoun

Nothing crazy, paramiko, dspy, I made a few temp files with tempfile. I also have no clue what exactly I was typing. Is there any way that me typing in Pycharm (not running as root by the way) could have screwed one subvolume in my btrfs? I mentioned it to say it happened right in front of me, not after a suspend or hibernate or when I booted it was gone, etc.

Are there core commands like rm, dd or mv … in the source code?

How did you install Pycharm?

I’m making temp files and folders with tempfile, and removing them with Path().unlink() and rmtree. Unlink just calls os.unlink which won’t remove directories. mkdtemp makes directories in /tmp. Its possible rmtree ate /home, but I don’t see it in my code. (I push to a git repo on a server frequently.)

    def create_temp_file(self, mode='w'):
        temp_file = tempfile.NamedTemporaryFile(mode, delete=False).name
        self.temp_files.append(temp_file)
        return temp_file

    def create_temp_folder(self):
        temp_folder = tempfile.mkdtemp()
        self.temp_files.append(temp_folder)
        return temp_folder

    def __del__(self):
        if self.nginx:
            self.nginx.terminate()
            self.nginx.wait()
        for temp_file in self.temp_files.pop():
            if Path(temp_file).is_file():
                Path(temp_file).unlink()
            else:
                rmtree(temp_file)

I yay’d pycharm from extra/pycharm-community-edition.

Well expletive.

Just ran the bits of my code that create and then later remove tempfiles/directories. It ate my home again.

I’d like to apologize to btrfs for doubting you.

Thanks TomZ, BluishHumility, dalto, zesko for pointing be in the right direction.

If you don’t have a read-only home-snapshot in the same system, a rollback is impossible.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.