How to change default permission for usb devices filesystem

 To change the default permissions for USB devices' filesystems in Linux, you can use a combination of udev rules and mounting options. Here's how to do it:


1. **Identify the USB Device**:

   Plug in the USB device and note its properties, such as the vendor ID and product ID. You can use the `lsusb` command to list connected USB devices and get this information.


2. **Create a Custom udev Rule**:

   You can create a custom udev rule to specify the permissions and ownership for the device when it's connected. For example, create a file in the `/etc/udev/rules.d/` directory, such as `/etc/udev/rules.d/99-usb-permissions.rules`, and add the following content:


   ```bash

   SUBSYSTEMS=="usb", ATTRS{idVendor}=="your_vendor_id", ATTRS{idProduct}=="your_product_id", MODE:="0666"

   ```


   Replace `"your_vendor_id"` and `"your_product_id"` with the actual values from the `lsusb` output for your USB device. The `MODE:="0666"` sets read and write permissions for everyone.


3. **Reload udev Rules**:

   After creating the custom rule, you need to reload the udev rules:


   ```bash

   sudo udevadm control --reload

   sudo udevadm trigger

   ```


4. **Unmount and Reconnect the USB Device**:

   Unmount the USB device (if it's already mounted), and then disconnect and reconnect it.


5. **Adjust Mounting Options**:

   Depending on how you mount the USB device, you can also set the permissions and ownership at the mounting stage. For example, you can modify your `/etc/fstab` file to specify the `umask`, `uid`, and `gid` options for the device. Here's an example entry in `/etc/fstab`:


   ```

   UUID=your_device_UUID /mount/point ntfs-3g defaults,uid=1000,gid=1000,umask=0022 0 0

   ```


   In this example, replace `your_device_UUID` with the actual UUID of the USB device, `/mount/point` with the desired mount point, and `uid` and `gid` with the user and group IDs you want to assign to the mounted filesystem. The `umask` value specifies the permissions mask.


6. **Remount the USB Device**:

   After making changes to `/etc/fstab`, you can remount the USB device using the `mount` command:


   ```bash

   sudo mount -a

   ```


These steps should help you change the default permissions for USB devices' filesystems on your Linux system. Be careful when modifying udev rules and `/etc/fstab`, as incorrect settings can cause issues.

Comments

Popular posts from this blog

bad character U+002D '-' in my helm template

GitLab pipeline stopped working with invalid yaml error

How do I add a printer in OpenSUSE which is being shared by a CUPS print server?