ユーザ用ツール

サイト用ツール


usbメモリのマウント先固定

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

次のリビジョン
前のリビジョン
usbメモリのマウント先固定 [2023/06/17 08:48] – 作成 Minoru Kijimausbメモリのマウント先固定 [2023/08/12 08:28] (現在) – [マウントポイントの設定2] Minoru Kijima
行 23: 行 23:
 devtmpfs         430M      430M    0% /dev devtmpfs         430M      430M    0% /dev
 tmpfs            462M      462M    0% /dev/shm tmpfs            462M      462M    0% /dev/shm
-tmpfs            462M   49M  414M   11% /run+tmpfs            462M  7.6M  455M    2% /run
 tmpfs            5.0M  4.0K  5.0M    1% /run/lock tmpfs            5.0M  4.0K  5.0M    1% /run/lock
 tmpfs            462M      462M    0% /sys/fs/cgroup tmpfs            462M      462M    0% /sys/fs/cgroup
 /dev/mmcblk0p1   253M   49M  204M   20% /boot /dev/mmcblk0p1   253M   49M  204M   20% /boot
 tmpfs             93M  4.0K   93M    1% /run/user/1000 tmpfs             93M  4.0K   93M    1% /run/user/1000
-/dev/sda1         29G   74M   29G    1% /media/usb1+/dev/sda1         29G  1.6M   29G    1% /media/usb02 
 +pi@raspberrypi:~ $ 
 pi@raspberrypi:~ $ ls -al /dev/disk/by-path pi@raspberrypi:~ $ ls -al /dev/disk/by-path
 合計 0 合計 0
-drwxr-xr-x 2 root root 140  4月 28 06:53 +drwxr-xr-x 2 root root 140  7月  5 13:08 
-drwxr-xr-x 7 root root 140  4月 28 06:53 .. +drwxr-xr-x 7 root root 140  7月  5 13:08 .. 
-lrwxrwxrwx 1 root root  13  4月 28 06:53 platform-3f202000.mmc -> ../../mmcblk0 +lrwxrwxrwx 1 root root  13  7月  5 13:08 platform-3f202000.mmc -> ../../mmcblk0 
-lrwxrwxrwx 1 root root  15  4月 28 06:53 platform-3f202000.mmc-part1 -> ../../mmcblk0p1 +lrwxrwxrwx 1 root root  15  7月  5 13:08 platform-3f202000.mmc-part1 -> ../../mmcblk0p1 
-lrwxrwxrwx 1 root root  15  4月 28 06:53 platform-3f202000.mmc-part2 -> ../../mmcblk0p2 +lrwxrwxrwx 1 root root  15  7月  5 13:08 platform-3f202000.mmc-part2 -> ../../mmcblk0p2 
-lrwxrwxrwx 1 root root   9  4月 28 06:53 platform-3f980000.usb-usb-0:1.4:1.0-scsi-0:0:0:0 -> ../../sda +lrwxrwxrwx 1 root root   9  7月  5 13:08 platform-3f980000.usb-usb-0:1.2:1.0-scsi-0:0:0:0 -> ../../sda 
-lrwxrwxrwx 1 root root  10  4月 28 06:53 platform-3f980000.usb-usb-0:1.4:1.0-scsi-0:0:0:0-part1 -> ../../sda1+lrwxrwxrwx 1 root root  10  7月  5 13:08 platform-3f980000.usb-usb-0:1.2:1.0-scsi-0:0:0:0-part1 -> ../../sda1
 </code> </code>
  
-===== マウントポイントの設定 =====+<del>===== マウントポイントの設定 =====</del> 
 + 
 +残念ながらこの設定は**<color #ed1c24>OSを起動不能</color>**にする場合がある。\\  
 by-pathをfstabに設定する。 by-pathをfstabに設定する。
 <file fstab /etc/fstab> <file fstab /etc/fstab>
-/dev/disk/by-path/platform-3f980000.usb-usb-0:1.4:1.0-scsi-0:0:0:0-part1  /media/usb1 vfat defaults,user 0 0+/dev/disk/by-path/platform-3f980000.usb-usb-0:1.2:1.0-scsi-0:0:0:0-part1  /media/usb1 vfat defaults,umask=000 0 0
 </file> </file>
 +  * USBメモリはVFATフォーマットで市販されていることが多く、VFATファイルシステムではパーミッション設定はできないため、umaskオプションで、マウント時のパーミッションを設定する。
 +
 +===== マウントポイントの設定2 =====
 +もっと単純な方法がある。\\ 
 +  - USBメモリにラベルを付ける。
 +  - ラベルでfstabにマウントポイントを設定する。
 +    - ただし起動時のマウントではなく、systemd.automountにマウントしてもらう。(noauto)
 +    - VFATなのでchmod/chownはできないので、マウントポイントにumaskでパーミッションを設定する。
 +
 +まずはラベル設定ツールを導入する。
 +<code>
 +$ sudo apt search mtools
 +$ sudo apt-get install mtools
 +</code>
 +
 +デバイス情報を調べてラベルを設定する。
 +<code>
 +$ sudo fdisk -l
 +Disk /dev/sda: 28.7 GiB, 30765219840 bytes, 60088320 sectors
 +Disk model:  SanDisk 3.2Gen1
 +Units: sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 512 bytes
 +I/O size (minimum/optimal): 512 bytes / 512 bytes
 +Disklabel type: dos
 +Disk identifier: 0x00000000
 +
 +Device     Boot Start      End  Sectors  Size Id Type
 +/dev/sda1          32 60088319 60088288 28.7G  c W95 FAT32 (LBA)
 +
 +$ sudo mlabel -i /dev/sda1 ::BACKUP
 +</code>
 +
 +fstabにマウントポイントやオプションを設定する。
 +<file fstab /etc/fstab>
 +LABEL=BACKUP /media/pi/BACKUP   vfat    defaults,noauto,user,rw,noexec,umask=000 0 0
 +</file>
 +
 +再起動してマウントされるかどうかを確認する。
 +<code>
 +$ df -h
 +ファイルシス   サイズ  使用  残り 使用% マウント位置
 +/dev/root         29G  8.7G   20G   32% /
 +devtmpfs         430M      430M    0% /dev
 +tmpfs            462M      462M    0% /dev/shm
 +tmpfs            462M  7.6M  455M    2% /run
 +tmpfs            5.0M  4.0K  5.0M    1% /run/lock
 +tmpfs            462M      462M    0% /sys/fs/cgroup
 +/dev/mmcblk0p1   253M   49M  204M   20% /boot
 +tmpfs             93M  4.0K   93M    1% /run/user/1000
 +/dev/sdb1         29G  125M   29G    1% /media/pi/LEXAR
 +/dev/sda1         29G  132M   29G    1% /media/pi/BACKUP
 +</code>
 +
 +===== ext4ディスクのボリュームラベル設定 =====
  
 +  * [[usbメモリのext4フォーマット|]]
 +    * ボリュームラベルの変更
  
usbメモリのマウント先固定.1686991696.txt.gz · 最終更新: by Minoru Kijima