Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:storage:usb-drives [2019/02/14 07:26] – [Automount the partition] improved config generation method vgaeteradocs:guide-user:storage:usb-drives [2022/04/10 09:15] – hdparm rc.local autostart ivanmara
Line 25: Line 25:
   - Start by refreshing the list of available software packages:<code>opkg update</code>   - Start by refreshing the list of available software packages:<code>opkg update</code>
   - The typical OpenWrt package already has core USB device drivers installed (if your device has USB ports at all), but might not yet have an USB storage device driver installed. Install this storage driver first (if it is already installed, the following command will just say "is already installed": <code>opkg install kmod-usb-storage</code>   - The typical OpenWrt package already has core USB device drivers installed (if your device has USB ports at all), but might not yet have an USB storage device driver installed. Install this storage driver first (if it is already installed, the following command will just say "is already installed": <code>opkg install kmod-usb-storage</code>
 +  - Some USB storage devices may require the UAS driver: <code>opkg install kmod-usb-storage-uas</code>
   - To check, if the whole USB driver chain is working correctly, install the optional **usbutils** package:<code>opkg install usbutils</code>   - To check, if the whole USB driver chain is working correctly, install the optional **usbutils** package:<code>opkg install usbutils</code>
   - Now connect your USB disk/stick and list your connected devices with a command from these **usbutils**: <code>lsusb -t</code>   - Now connect your USB disk/stick and list your connected devices with a command from these **usbutils**: <code>lsusb -t</code>
Line 32: Line 33:
     |__ Port 1: Dev 5, If 0, Class=Mass Storage, Driver=usb-storage, 480M     |__ Port 1: Dev 5, If 0, Class=Mass Storage, Driver=usb-storage, 480M
 </code> </code>
-  * "Bus..."-Lines represent the host chip. Here, the "Driver" will be xhcifor USB3.0, "ehcifor USB2.0 and "uhcior "ohcifor USB1.1. +  * "Bus..."-Lines represent the host chip. Here, the "Driver" will be ''xhci'' for USB3.0, ''ehci'' for USB2.0 and ''uhci'' or ''ohci'' for USB1.1. 
-  * Lines with "Class=Mass Storage" represent connected USB devices. Here the "Driver" is either "usb-storagefor storage of type [[https://en.wikipedia.org/wiki/USB_mass_storage_device_class|Bulk only Transport]] or "usb-storage-uasfor storage of type [[https://en.wikipedia.org/wiki/USB_Attached_SCSI|USB_Attached_SCSI]] +  * Lines with "Class=Mass Storage" represent connected USB devices. Here the "Driver" is either ''usb-storage'' for storage of type [[wp>USB_mass_storage_device_class|Bulk only Transport]] or ''usb-storage-uas'' for storage of type [[wp>USB_Attached_SCSI|USB_Attached_SCSI]] 
  
-In step 3, verify that the output prints no error and has at least one output line for **root_hub** and **Mass Storage** and that each **Driver=** lists a driver name. If not, then refer to [[docs:guide-user:storage:usb-installing|the Installing USB Drivers]] for more suggestions on drivers.+In step 5, verify that the output prints no error and has at least one output line for **root_hub** and **Mass Storage** and that each **Driver=** lists a driver name. If not, then refer to [[docs:guide-user:storage:usb-installing|the Installing USB Drivers]] for more suggestions on drivers.
  
 ===== Verify that the OS recognizes the attached disk and partitions ===== ===== Verify that the OS recognizes the attached disk and partitions =====
Line 44: Line 45:
   - This should now show a list of block devices known to the OS<code>brw-------    1 root     root        8,   0 Oct 30 12:49 /dev/sda   - This should now show a list of block devices known to the OS<code>brw-------    1 root     root        8,   0 Oct 30 12:49 /dev/sda
 brw-------    1 root     root        8,   1 Oct 30 12:49 /dev/sda1</code>This should print at least a connected disk like "/dev/sda" or "/dev/sdb". If no disk at all is listed, recheck USB driver installation and reboot your OpenWrt device once. brw-------    1 root     root        8,   1 Oct 30 12:49 /dev/sda1</code>This should print at least a connected disk like "/dev/sda" or "/dev/sdb". If no disk at all is listed, recheck USB driver installation and reboot your OpenWrt device once.
-  - Install the **block** tool to get more info about existing partitions<code>opkg install block-mount</code>+  - Install the **block** tool to get more info about existing partitions<code>opkg install block-mount</code> for exFAT you also need libblkid <code>opkg install libblkid</code>
   - Run the **block** tool:<code>block info | grep "/dev/sd"</code>and you should see output like this, if your disk already has partitions:<code>/dev/sda1: UUID="2eb39413-83a4-4bae-b148-34fb03a94e89" VERSION="1.0" TYPE="ext4"</code>   - Run the **block** tool:<code>block info | grep "/dev/sd"</code>and you should see output like this, if your disk already has partitions:<code>/dev/sda1: UUID="2eb39413-83a4-4bae-b148-34fb03a94e89" VERSION="1.0" TYPE="ext4"</code>
  
Line 73: Line 74:
 opkg install kmod-fs-ext4 opkg install kmod-fs-ext4
 mkfs.ext4 /dev/sda1</code> mkfs.ext4 /dev/sda1</code>
 +  * For USB drives formatted as NTFS see [[docs:guide-user:storage:filesystems-and-partitions#setup_ntfs|Filesystems]] and [[docs:guide-user:storage:writable_ntfs|Writable NTFS]]
   * For SSD drives and thumb drives,  install F2FS file system and use F2FS to format the partition (in this example '/dev/sda1'): <code>opkg install f2fs-tools   * For SSD drives and thumb drives,  install F2FS file system and use F2FS to format the partition (in this example '/dev/sda1'): <code>opkg install f2fs-tools
 opkg install kmod-fs-f2fs opkg install kmod-fs-f2fs
Line 82: Line 84:
  
   - Generate a config entry for the fstab file:<code>block detect | uci import fstab</code>   - Generate a config entry for the fstab file:<code>block detect | uci import fstab</code>
-  - Now enable automount on that config entry:<code>uci set fstab.@mount[0].enabled='1' +  - Now enable automount on that config entry:<code>uci set fstab.@mount[-1].enabled='1' 
-uci commit</code>+uci commit fstab</code>
   - Optionally enable autocheck of the file system each time the OpenWrt device powers up:<code>uci set fstab.@global[0].check_fs='1'   - Optionally enable autocheck of the file system each time the OpenWrt device powers up:<code>uci set fstab.@global[0].check_fs='1'
-uci commit</code>+uci commit fstab</code>
   - Reboot your OpenWrt device (to verify that automount works)   - Reboot your OpenWrt device (to verify that automount works)
   - After the reboot, check your results: Run <code>uci show fstab</code>to see something like this<code>fstab.@global[0]=global   - After the reboot, check your results: Run <code>uci show fstab</code>to see something like this<code>fstab.@global[0]=global
Line 97: Line 99:
 fstab.@mount[0].target='/mnt/sda1' fstab.@mount[0].target='/mnt/sda1'
 fstab.@mount[0].uuid='49c35b1f-a503-45b1-a953-56707bb84968' fstab.@mount[0].uuid='49c35b1f-a503-45b1-a953-56707bb84968'
-fstab.@mount[0].enabled='0'</code>+fstab.@mount[0].enabled='1'</code> 
 +  - Check the "enabled" entry. It should be '1'.
   - Note the "target" entry. This is the file path, where your attached USB storage drive can be accessed from now on. E.g. you can now list files from your external disk:<code>ls -l /mnt/sda1</code>   - Note the "target" entry. This is the file path, where your attached USB storage drive can be accessed from now on. E.g. you can now list files from your external disk:<code>ls -l /mnt/sda1</code>
   - Run the following command, to verify that the disk is properly mounted at this path<code>block info</code>The result will be:<code>...   - Run the following command, to verify that the disk is properly mounted at this path<code>block info</code>The result will be:<code>...
 /dev/sda1: UUID="2eb39413-83a4-4bae-b148-34fb03a94e89" VERSION="1.0" MOUNT="/mnt/sda1" TYPE="ext4"</code> /dev/sda1: UUID="2eb39413-83a4-4bae-b148-34fb03a94e89" VERSION="1.0" MOUNT="/mnt/sda1" TYPE="ext4"</code>
-  - Your external storage is now ready for further usage +  - Your external storage is now ready for further usage:<code> 
-   +service fstab boot</code>
 ===== Optional: Idle spindown timeout on disks for NAS usage ===== ===== Optional: Idle spindown timeout on disks for NAS usage =====
 Optional step for hard disks. Optional step for hard disks.
Line 130: Line 132:
  
 Of course you can always change the timeout or disable auto-spindown again later on. Depending on your harddisk, the value may be active until the next reset or permanently stored on the harddisk. Of course you can always change the timeout or disable auto-spindown again later on. Depending on your harddisk, the value may be active until the next reset or permanently stored on the harddisk.
-The harddisk firmware itself manages the spindown timeout, not a OpenWrt service.+The harddisk firmware itself manages the spindown timeout, not a OpenWrt service. For persistent changes use ''/etc/rc.local'' file, like: 
 +<code bash> 
 +# set timeout to put the drive into idle (low-power) mode 
 +/sbin/hdparm -S 240 /dev/sda2 
 + 
 +exit 0 
 +</code> 
  
  
Line 141: Line 150:
 </code> </code>
 To configure it, use the "Services" menu of the LuCi web GUI of your device. To configure it, use the "Services" menu of the LuCi web GUI of your device.
 +
 +\\
 +To install the CLI package (without LuCi):
 +<code>
 +opkg update && opkg install hd-idle
 +</code>
 +To configure it, you can edit the ''/etc/config/hd-idle'' file and then autostart and run the hd-idle service ''service hd-idle enable && service hd-idle start''.
 +
 +Options to configure:
 +^ Name     ^ Type    ^ Default ^ Description                                   ^
 +| ''disk''               | string   | ''sda''      | Replace ''sda'' with your device's identifier |
 +| ''enabled''            | boolean  | ''0''        | Enable hd-idle operation |
 +| ''idle_time_unit''     | string   | ''minutes''  | The unit of time used in the ''idle_time_interval'' option |
 +| ''idle_time_interval'' | integer  | ''10''       | How much idle time before spindown |
 +:!: Notice that you have to enable it since it isn't by default.
  • Last modified: 2023/03/30 21:01
  • by stokito