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
Last revisionBoth sides next revision
docs:user-guide:storage:storage:usb-drives-quickstart [2018/02/17 16:45] – ↷ Page moved from docs:user-guide:storage:usb-drives-quickstart to docs:user-guide:storage:storage:usb-drives-quickstart bobafetthotmaildocs:guide-user:storage:usb-drives-quickstart [2024/03/12 17:11] – update intro, add new LuCI section, remove repeated links, note other filesystems palebloodsky
Line 1: Line 1:
-=====Quick Start for Adding a USB drive=====+====== Quick Start for Adding a USB drive ======
  
-Many useful LEDE utilities and packages rely on external storage to hold data files.  +This page describes how to add a USB drive to your OpenWrt device. The example used will result in a USB drive mounted with ext4 filesystem. This is all you'll need for most purposes, however, there are plenty of options described below.
-This guide describes how to add a single USB stick or drive to your LEDE device. +
  
-**Requirements:**+===== Requirements =====
  
-  * Your LEDE device must have at least 8 MB Flash. Lower capacity devices will not be able to hold the required packages. +  * You can use a USB drive of any capacity. 
-  * This procedure will work for the //first// USB device installed in the router. To add more drives, see the  [[docs/user-guide/usb-drives | full USB Drive tutorial. ]] +  * Your computer connected to the network for LuCI/SSH. 
-  * This procedure **WILL ERASE THE USB DRIVE**. Copy any data you care about to another destination.  +  * Your device/router must have at least 8 MB free. Lower capacity devices will not be able to hold the required packages. 
-  * This quickstart requires you to [[docs:guide-quick-start:sshadministration | ssh into the router.]]+  * This procedure **WILL ERASE THE USB DRIVE** unless you skip those steps and just want to mount a preformated driveBackup any data beforehand.
  
-**Procedure:**+===== Procedure =====
  
-  - Connect the USB stick/disk to the router. +USB drives can be installed using either LuCI or the command line as described below.
-  - [[docs:guide-quick-start:sshadministration | SSH into the router.]] +
-  - Enter the following commands by copying and pasting //each separate line// below.+
  
- # Copy/paste each line below, then press Return +==== LuCI ====
- opkg update && opkg install block-mount e2fsprogs kmod-fs-ext4 kmod-usb3 kmod-usb2 kmod-usb-storage +
- mkfs.ext4 /dev/sda1 +
- block detect > /etc/config/fstab  +
- uci set fstab.@mount[0].enabled='1' && uci set fstab.@global[0].check_fs='1' && uci commit  +
- service fstab start && service fstab enable+
  
-The drive will be mounted at **/mnt/sda1** You can change the mount point in the web interfacein **System** -> **Mount Points**.+1. On the Software page, click update, then install the packages below. These can alternatively be pasted into SSH with ''opkg install''**Note**: below uses ext4 filesystem, alternatively you can use any you prefer: kmod-fs-ext4kmod-fs-btrfs, kmod-fs-exfat, ntfs-3g, etc.
  
-If you want more information about this procedure,  +''block-mount e2fsprogs kmod-usb-storage-uas kmod-usb3 luci-app-hd-idle kmod-fs-ext4'' 
-or you want to add or configure more than a single USB drive + 
-see the [[docs/user-guide/usb-drives | full USB Drive tutorial ]].+2. Plug in your USB drive, it will be detected automatically as **/dev/sdXX** depending on the drive and partition numbers. 
 + 
 +3. Go to the **System -> Mount Points** page and click on the drive to mount, click save & apply. 
 + 
 +4. Go to the **Services -> HDD Idle** page and enable to idle the drive to save power and lifespan, click save & apply. 
 + 
 +You're done! The drive is ready to read/write data. 
 + 
 + 
 +==== Command Line ==== 
 + 
 +1. Use a computer to format your USB drive using the default options. This prepares the drive for the process below, which will erase those settings. //Warning: This initial formatting will erase the entire USB drive.//  
 + 
 +2. SSH into your device and enter the following commands. ++More...| The [[docs:guide-quick-start:sshadministration | SSH Access for Newcomers]] page tells how to install and use a terminal emulator on your computer.++ 
 + 
 +3. Install the required packages. **Note**: below uses ext4 filesystem, alternatively you can use any you prefer (kmod-fs-ext4, kmod-fs-btrfs, kmod-fs-exfat, ntfs-3g, etc). ++More...|You may see error messages about installing kmod-usb3 on certain routers. These can be ignored if the hardware does not support USB3.++ 
 +<code>opkg update && opkg install block-mount e2fsprogs kmod-usb-storage-uas kmod-usb3 kmod-fs-ext4</code> 
 + 
 +4. Enter '' ls -al /dev/sd* '' to show the name of all attached USB devices. The list may be empty if there are no USB devices.   ++More...|**/dev/sda** is the first USB device; **/dev/sdb** is the second, and so on. **/dev/sda1** is the first partition on the first device; **/dev/sda2** is the second partition, etc.++ 
 + 
 +5. Insert the USB drive into your router. Enter '' ls -al /dev/sd* '' again, and this time you should see a new **/dev/sdXX** device. **sdXX** is the //device name// of your new USB device. ++More...|If you do not see ''/dev/sda'' AND ''/dev/sda1'' listedbe sure to format the USB device on your computer beforehand.++ 
 + 
 +<code> 
 +    root@OpenWrt:~# ls -al /dev/sd* 
 +    brw-------    1 root     root        8,   0 Feb  4 15:13 /dev/sda 
 +    brw-------    1 root     root        8,   1 Feb  4 14:06 /dev/sda1 
 +</code> 
 + 
 +6. Make an ext4 filesystem on the USB device using the device name you just discovered. **Note**: Be certain you enter the proper device name - this step will completely erase the device. ++More...|This command creates an ext4 file system on the first partition of the first USB device - /dev/sda1.++ 
 +<code>mkfs.ext4 /dev/sda1</code> 
 + 
 +7. Create the fstab config file based on all the block devices found. ++More...|This command writes the current state of all block devices, including USB drives, into the '' /etc/config/fstab '' file.++ 
 +<code>block detect | uci import fstab</code> 
 + 
 +8. Update the fstab config file to mount all drives at startup. ++More...|**/dev/sda** is mount[0], **/dev/sdb** is mount[1], etc. If you have more than one USB device attachedsubstitute the proper index (0 or 1 or ...) as needed. This command mounts all drives - named or anonymous.++ 
 +<code>uci set fstab.@mount[0].enabled='1' && uci set fstab.@global[0].anon_mount='1' && uci commit fstab</code> 
 + 
 +9. Mount the device. ++More...|Automount is enabled on boot.++ 
 +<code>/etc/init.d/fstab boot</code> 
 + 
 +You're done! The drive is ready to read/write data.  
 + 
 + 
 +===== More Details ===== 
 + 
 +More information on this procedure and USB drives: 
 + 
 +  * You can mount from the web interface, in the **System** -> **Mount Points** menu. 
 +  * [[:docs:guide-user:services:nas:cifs.server|Samba]] can be used to share (read/write) the drive over your network.  
 +  * The [[docs:guide-user:storage:usb-drives| full USB Drive tutorial]] has much more about USB drives. 
 +  * For NTFS disks, refer to [[docs:guide-user:storage:writable_ntfs|Writable NTFS]] 
 +  * Look at the [[docs/guide-user/storage/fstab|fstab documentation]] to configure from the command line 
 +  * This Forum thread has a lot of background information: [[https://forum.openwrt.org/t/more-on-usb-drive-installation/30695/2]] 
 +  * If you want to temporarily mount the drive (say, for testing), you can simply enter: '' mkdir /tmp/MyDrive; mount /dev/sda1 /tmp/MyDrive'', after finishing the test reading/writing the drive: ''umount /tmp/MyDrive'' 
  
  • Last modified: 2024/11/21 18:29
  • by palebloodsky