Skip to content

Instantly share code, notes, and snippets.

@M41KL-N41TT
Last active February 20, 2024 01:41
Show Gist options
  • Save M41KL-N41TT/c6b0fb1f5e155f7ef4c589e6eadd42fe to your computer and use it in GitHub Desktop.
Save M41KL-N41TT/c6b0fb1f5e155f7ef4c589e6eadd42fe to your computer and use it in GitHub Desktop.
Correct Permissions for New Partition (BTRFS) [Linux]

Correct Permissions for New Partition (BTRFS) [Linux]

Commands and Solutions:

1. Set File Owner and Group:

chown -R $USER:$GROUP /run/media/$(whoami)/docs

1.1. SUPER SAIYAN ONELINER: Print the Groups Current User is Added To

getent group|grep -w $(whoami) | grep -w -v $(id -g) | awk -F ':' '{print $1}'

2. Set File Mode Bits:

chmod -R 755 /run/media/$(whoami)/docs

2.1. Set Restricted Deletion Flag (Optional):

chattr +i /run/media/$(whoami)/docs

2.2. Set Sticky Bit (Optional):

chmod +t /run/media/$(whoami)/docs

2.3 Update /etc/fstab (Optional):

echo "/dev/btrfs-partition /run/media/$(whoami)/docs btrfs defaults,user_subvol_rm_allowed 0 0" >> /etc/fstab

Conclusion:

  • Set the file owner and group to the user who created the partition.
  • Set the file mode bits to 755.
  • Whether to set the restricted deletion flag and sticky bit is up to the individual user.

Notes:

  • Commands should be executed in a terminal window with appropriate permissions.
  • Replace /run/media/$(whoami)/docs with the actual mount point of your (BTRFS) partition.
  • Use -R option with chown and chmod to recursively apply changes to all files and directories within the partition.
  • The /etc/fstab update is optional but recommended to ensure the partition is mounted with the correct permissions on system boot.

Up Next:

  • Extend based file storage (2^64 max file size)

  • Space efficient packing of small files

  • Space efficient indexed directories

  • Dynamic inode allocation

  • Writable snapshots

  • Subvolumes (separate internal filesystem roots)

  • Object level mirroring and striping

  • Checksums on data and metadata (multiple algorithms available)

  • Compression (multiple algorithms available)

  • Reflink, deduplication

  • Scrub (on-line checksum verification)

  • Hierarchical quota groups (subvolume and snapshot support)

  • Integrated multiple device support, with several raid algorithms

  • Offline filesystem check

  • Efficient incremental backup and FS mirroring (send/receive)

  • Trim/discard

  • Online filesystem defragmentation

  • Swapfile support

  • Zoned mode

  • Read/write metadata verification

  • Online resize (shrink, grow)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment