linux:openwrt:adding_usb_drive

文書の過去の版を表示しています。


USB ドライブの追加

# opkg update && opkg install block-mount e2fsprogs kmod-fs-ext4 kmod-usb-storage kmod-usb2 kmod-usb3

Downloading https://downloads.openwrt.org/releases/21.02.3/targets/bcm53xx/generic/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_core
Downloading https://downloads.openwrt.org/releases/21.02.3/targets/bcm53xx/generic/packages/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/21.02.3/packages/arm_cortex-a9/base/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_base
Downloading https://downloads.openwrt.org/releases/21.02.3/packages/arm_cortex-a9/base/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/21.02.3/packages/arm_cortex-a9/luci/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_luci
Downloading https://downloads.openwrt.org/releases/21.02.3/packages/arm_cortex-a9/luci/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/21.02.3/packages/arm_cortex-a9/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_packages
Downloading https://downloads.openwrt.org/releases/21.02.3/packages/arm_cortex-a9/packages/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/21.02.3/packages/arm_cortex-a9/routing/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_routing
Downloading https://downloads.openwrt.org/releases/21.02.3/packages/arm_cortex-a9/routing/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/21.02.3/packages/arm_cortex-a9/telephony/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_telephony
Downloading https://downloads.openwrt.org/releases/21.02.3/packages/arm_cortex-a9/telephony/Packages.sig
Signature check passed.
Package block-mount (2021-01-04-c53b1882-1) installed in root is up to date.
Package e2fsprogs (1.45.6-2) installed in root is up to date.
Package kmod-fs-ext4 (5.4.188-1) installed in root is up to date.
Installing kmod-usb-storage (5.4.188-1) to root...
Downloading https://downloads.openwrt.org/releases/21.02.3/targets/bcm53xx/generic/packages/kmod-usb-storage_5.4.188-1_arm_cortex-a9.ipk
Installing kmod-scsi-core (5.4.188-1) to root...
Downloading https://downloads.openwrt.org/releases/21.02.3/targets/bcm53xx/generic/packages/kmod-scsi-core_5.4.188-1_arm_cortex-a9.ipk
Package kmod-usb2 (5.4.188-1) installed in root is up to date.
Installing kmod-usb3 (5.4.188-1) to root...
Downloading https://downloads.openwrt.org/releases/21.02.3/targets/bcm53xx/generic/packages/kmod-usb3_5.4.188-1_arm_cortex-a9.ipk
Installing kmod-phy-bcm-ns-usb3 (5.4.188-1) to root...
Downloading https://downloads.openwrt.org/releases/21.02.3/targets/bcm53xx/generic/packages/kmod-phy-bcm-ns-usb3_5.4.188-1_arm_cortex-a9.ipk
Configuring kmod-scsi-core.
Configuring kmod-usb-storage.
Configuring kmod-phy-bcm-ns-usb3.
Configuring kmod-usb3.

# ls -al /dev/sd*

brw-------    1 root     root        8,   0 Aug 21 06:24 /dev/sda
brw-------    1 root     root        8,   1 Aug 21 06:24 /dev/sda1
brw-------    1 root     root        8,   2 Aug 21 06:24 /dev/sda2

# opkg update && opkg install gdisk

Installing gdisk (1.0.6-1) to root...
Downloading https://downloads.openwrt.org/releases/21.02.3/packages/arm_cortex-a9/packages/gdisk_1.0.6-1_arm_cortex-a9.ipk
Configuring gdisk.

# gdisk /dev/sda

GPT fdisk (gdisk) version 1.0.6

Warning: Partition table header claims that the size of partition table
entries is 0 bytes, but this program  supports only 128-byte entries.
Adjusting accordingly, but partition table may be garbage.
Warning: Partition table header claims that the size of partition table
entries is 0 bytes, but this program  supports only 128-byte entries.
Adjusting accordingly, but partition table may be garbage.
Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Warning! Secondary partition table overlaps the last partition by
14 blocks!
Try reducing the partition table size by 56 entries.
(Use the 's' item on the experts' menu.)

Command (? for help): p
Disk /dev/sda: 15433728 sectors, 7.4 GiB
Model: Transcend 8GB   
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 85CEDCED-CE42-4423-8E5D-FA5A84A30F51
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 15433694
Partitions will be aligned on 1-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        11239420   5.4 GiB     0700  Microsoft basic data
   2        11239421        15433708   2.0 GiB     8300  Linux filesystem

Command (? for help): d
Partition number (1-2): 2

Command (? for help): d
Using 1

Command (? for help): n
Partition number (1-128, default 1): 
First sector (34-15433694, default = 34) or {+-}size{KMGTP}: 
Last sector (34-15433694, default = 15433694) or {+-}size{KMGTP}: 
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): p
Disk /dev/sda: 15433728 sectors, 7.4 GiB
Model: Transcend 8GB   
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 85CEDCED-CE42-4423-8E5D-FA5A84A30F51
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 15433694
Partitions will be aligned on 1-sector boundaries
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34        15433694   7.4 GiB     8300  Linux filesystem

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.
root@OpenWrt:~# mkfs.ext
mkfs.ext2  mkfs.ext3  mkfs.ext4
root@OpenWrt:~# mkfs.ext4 /dev/sda
sda   sda1
root@OpenWrt:~# mkfs.ext4 /dev/sda1
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 1929207 4k blocks and 482384 inodes
Filesystem UUID: 941c47f3-f75e-4ff1-9875-858deacd2332
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

root@OpenWrt:~# block detect
config 'global'
	option	anon_swap	'0'
	option	anon_mount	'0'
	option	auto_swap	'1'
	option	auto_mount	'1'
	option	delay_root	'5'
	option	check_fs	'0'

config 'mount'
	option	target	'/mnt/sda1'
	option	uuid	'941c47f3-f75e-4ff1-9875-858deacd2332'
	option	enabled	'0'

root@OpenWrt:~# gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.6

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 15433728 sectors, 7.4 GiB
Model: Transcend 8GB   
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 85CEDCED-CE42-4423-8E5D-FA5A84A30F51
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 15433694
Partitions will be aligned on 2-sector boundaries
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34        15433694   7.4 GiB     8300  Linux filesystem
root@OpenWrt:~# cat /etc/config/fstab
config 'global'
	option	anon_swap	'0'
	option	anon_mount	'0'
	option	auto_swap	'1'
	option	auto_mount	'1'
	option	delay_root	'5'
	option	check_fs	'0'

root@OpenWrt:~# block detect | uci import fstab
root@OpenWrt:~# uci show fstab
fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].anon_mount='0'
fstab.@global[0].auto_swap='1'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='0'
fstab.@mount[0]=mount
fstab.@mount[0].target='/mnt/sda1'
fstab.@mount[0].uuid='941c47f3-f75e-4ff1-9875-858deacd2332'
fstab.@mount[0].enabled='0'
root@OpenWrt:~# uci set fstab.@mount[0].enabled='1' && uci set fstab.@global[0].anon_mount='1' && uci commit fst
ab
root@OpenWrt:~# uci show fstab
fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].auto_swap='1'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='0'
fstab.@global[0].anon_mount='1'
fstab.@mount[0]=mount
fstab.@mount[0].target='/mnt/sda1'
fstab.@mount[0].uuid='941c47f3-f75e-4ff1-9875-858deacd2332'
fstab.@mount[0].enabled='1'
root@OpenWrt:~# /etc/init.d/fstab boot
block: No "mount.ubi" utility available
block: mounting /dev/mtdblock4 (ubi) as /mnt/mtdblock4 failed (2) - No such file or directory
root@OpenWrt:~# mount
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/ubi0_1 on /overlay type ubifs (rw,noatime,assert=read-only,ubi=0,vol=1)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)
/dev/sda1 on /mnt/sda1 type ext4 (rw,relatime)
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 3.3M      3.3M         0 100% /rom
tmpfs                   123.5M      1.1M    122.4M   1% /tmp
/dev/ubi0_1              16.8M      2.1M     13.8M  13% /overlay
overlayfs:/overlay       16.8M      2.1M     13.8M  13% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1                 7.2G     33.1M      6.8G   0% /mnt/sda1

  • linux/openwrt/adding_usb_drive.1661065146.txt.gz
  • 最終更新: 2022/08/21 15:59
  • by ともやん