linux:openwrt:sd_mount

差分

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

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
linux:openwrt:sd_mount [2022/08/21 15:48] – 削除 - 外部編集 (Unknown date) 非ログインユーザーlinux:openwrt:sd_mount [2025/02/09 15:20] (現在) – [ある日突然マウントできなくなったら❓] ともやん
行 1: 行 1:
 +====== SD カードのマウント ======
 +
 +===== パッケージ インストール =====
 +<code>
 +# opkg update && opkg install gdisk block-mount e2fsprogs kmod-fs-ext4
 +# reboot
 +</code>
 +
 +===== LuCI の Mount Points メニュー =====
 +block-mount パッケージを追加すると LuCI から **[System] - [Mount Points]** メニューが利用できるようになる。\\
 +{{hardware:gl-ar750s-ext:luci_mount_points_menu.png?500|Mount Points}}\\
 +
 +===== パーティションの作成 =====
 +<WRAP prewrap 100%>
 +<code>
 +# gdisk /dev/sda
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result_long>
 +<code>
 +GPT fdisk (gdisk) version 1.0.3
 +
 +Partition table scan:
 +  MBR: protective
 +  BSD: not present
 +  APM: not present
 +  GPT: present
 +
 +Found valid GPT with protective MBR; using GPT.
 +
 +Command (? for help): r
 +
 +Recovery/transformation command (? for help): x
 +
 +Expert command (? for help): l
 +Enter the sector alignment value (1-65536, default = 2048): 34
 +
 +Expert command (? for help): m
 +
 +Command (? for help): n
 +Partition number (1-128, default 1):
 +First sector (34-236462046, default = 34) or {+-}size{KMGTP}: 34
 +Last sector (34-236462046, default = 236462046) or {+-}size{KMGTP}:
 +Current type is '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: 236462080 sectors, 112.8 GiB
 +Model: STORAGE DEVICE
 +Sector size (logical/physical): 512/512 bytes
 +Disk identifier (GUID): 98E0A384-FC68-4BAB-BC50-25EFE6988D43
 +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 236462046
 +Partitions will be aligned on 34-sector boundaries
 +Total free space is 0 sectors (0 bytes)
 +
 +Number  Start (sector)    End (sector)  Size       Code  Name
 +                34       236462046   112.8 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.
 +</code>
 +</WRAP>
 +
 +===== パーティションの初期化 =====
 +<WRAP prewrap 100%>
 +<code>
 +# mkfs.ext4 /dev/sda1
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +mke2fs 1.44.1 (24-Mar-2018)
 +/dev/sda1 contains a ext4 file system
 +        created on Sun Jan 12 21:12:35 2020
 +Proceed anyway? (y,N) y
 +Creating filesystem with 29557751 4k blocks and 7397376 inodes
 +Filesystem UUID: fa755a50-bee7-49e8-93f4-50712eb37d58
 +Superblock backups stored on blocks:
 +        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 +        4096000, 7962624, 11239424, 20480000, 23887872
 +
 +Allocating group tables: done
 +Writing inode tables: done
 +Creating journal (131072 blocks):
 +done
 +Writing superblocks and filesystem accounting information: done
 +</code>
 +</WRAP>
 +
 +<WRAP prewrap 100%>
 +<code>
 +# block detect > /etc/config/fstab
 +# vi /etc/config/fstab
 +</code>
 +</WRAP>
 +<WRAP prewrap 100%>
 +<file /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'
 +
 +config 'mount'
 +        option  target  '/mnt/sd128gb'
 +        option  uuid    'fa755a50-bee7-49e8-93f4-50712eb37d58'
 +        option  enabled '1'
 +</file>
 +</WRAP>
 +
 +<WRAP prewrap 100%>
 +<code>
 +# uci show fstab
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +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/sd128gb'
 +fstab.@mount[0].uuid='fa755a50-bee7-49e8-93f4-50712eb37d58'
 +fstab.@mount[0].enabled='1'
 +</code>
 +</WRAP>
 +<WRAP prewrap 100%>
 +<code>
 +# reboot
 +</code>
 +</WRAP>
 +
 +<WRAP prewrap 100%>
 +<code>
 +# mount
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +/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)
 +tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
 +/dev/ubi0_1 on /overlay type ubifs (rw,noatime)
 +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)
 +/dev/sda1 on /mnt/sd128gb type ext4 (rw,relatime,data=ordered)
 +</code>
 +</WRAP>
 +<WRAP prewrap 100%>
 +<code>
 +# df
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +Filesystem           1K-blocks      Used Available Use% Mounted on
 +/dev/root                11776     11776         0 100% /rom
 +tmpfs                    62168       376     61792   1% /tmp
 +/dev/ubi0_1             101840      2824     94180   3% /overlay
 +overlayfs:/overlay      101840      2824     94180   3% /
 +tmpfs                      512               512   0% /dev
 +/dev/sda1            115849188     61496 109859760   0% /mnt/sd128gb
 +</code>
 +</WRAP>
 +
 +===== fstab の再設定などでファイルシステムの UUID を確認したい場合 =====
 +**blkid** コマンドでファイルシステムの **UUID** を確認できる。\\
 +<WRAP prewrap 100%>
 +<code>
 +# blkid
 +</code>
 +**/dev/sda1** の **UUID** は **"fa755a50-bee7-49e8-93f4-50712eb37d58"** である。\\
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +/dev/ubi0_1: UUID="0a2be279-197d-4762-b02d-89a9710ff1fb" TYPE="ubifs"
 +/dev/ubi0_0: TYPE="squashfs"
 +/dev/mtdblock5: UUID="455825797" TYPE="ubi"
 +/dev/ubiblock0_0: TYPE="squashfs"
 +/dev/sda1: UUID="fa755a50-bee7-49e8-93f4-50712eb37d58" TYPE="ext4" PARTUUID="8c7c1ef5-2340-4497-b12d-684a60107cd7"
 +</code>
 +</WRAP>
 +
 +===== トラブルシューティング =====
 +
 +==== ファームウェアの更新でマウントポイントが消える❓❓ ====
 +いつの間にかマウントポイントが無くなっていて、設定も書かれているのにマウントされなくなった。\\
 +<WRAP prewrap 100%>
 +<code>
 +# uci show fstab
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +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].uuid='fa755a50-bee7-49e8-93f4-50712eb37d58'
 +fstab.@mount[0].enabled='1'
 +fstab.@mount[0].target='/mnt/sd128gb'
 +</code>
 +</WRAP>
 +
 +<WRAP prewrap 100%>
 +<code>
 +# gdisk -l /dev/sda
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +GPT fdisk (gdisk) version 1.0.4
 +
 +Partition table scan:
 +  MBR: protective
 +  BSD: not present
 +  APM: not present
 +  GPT: present
 +
 +Found valid GPT with protective MBR; using GPT.
 +Disk /dev/sda: 236462080 sectors, 112.8 GiB
 +Model: STORAGE DEVICE
 +Sector size (logical/physical): 512/512 bytes
 +Disk identifier (GUID): 98E0A384-FC68-4BAB-BC50-25EFE6988D43
 +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 236462046
 +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  236462046   112.8 GiB   8300  Linux Filesystem
 +</code>
 +</WRAP>
 +
 +おまけに、パーティション名が化けて mount されています😅💦\\
 +<WRAP prewrap 100% #mincode>
 +<code>
 +L i n u x  F i l e s y s t e m
 +䰀椀渀甀砀  䘀椀氀攀猀礀猀琀攀洀
 +</code>
 +</WRAP>
 +
 +<WRAP prewrap 100%>
 +<code>
 +# cd /mnt/
 +# ll
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +drwxr-xr-x    1 root     root           272 May 27 23:23 ./
 +drwxr-xr-x    1 root     root           608 May 27 23:23 ../
 +drwxrwxrwx    8 root     root          4096 Jun 30  2020 䰀椀渀甀砀 䘀椀氀攀猀礀猀琀攀洀/
 +</code>
 +</WRAP>
 +
 +<WRAP prewrap 100%>
 +<code>
 +# mount
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +/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)
 +cgroup on /sys/fs/cgroup type cgroup (rw,nosuid,nodev,noexec,relatime,blkio,devices,freezer,net_cls,pids)
 +tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
 +/dev/ubi0_1 on /overlay type ubifs (rw,noatime,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)
 +/dev/sda1 on /mnt/䰀椀渀甀砀 䘀椀氀攀猀礀猀琀攀洀 type ext4 (rw,sync,relatime,data=ordered)
 +</code>
 +</WRAP>
 +
 +マウントポイントを再作成して再マウントします。\\
 +<WRAP prewrap 100%>
 +<code>
 +# mkdir /mnt/sd128gb
 +# mount -t ext4 /dev/sda1 /mnt/sd128gb
 +# mount
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +/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)
 +cgroup on /sys/fs/cgroup type cgroup (rw,nosuid,nodev,noexec,relatime,blkio,devices,freezer,net_cls,pids)
 +tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
 +/dev/ubi0_1 on /overlay type ubifs (rw,noatime,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)
 +/dev/sda1 on /mnt/䰀椀渀甀砀 䘀椀氀攀猀礀猀琀攀洀 type ext4 (rw,sync,relatime,data=ordered)
 +/dev/sda1 on /mnt/sd128gb type ext4 (rw,sync,relatime,data=ordered)
 +</code>
 +</WRAP>
 +
 +様々な設定を有効にするために再起動しておく。\\
 +<WRAP prewrap 100%>
 +<code>
 +# reboot
 +</code>
 +</WRAP>
 +
 +==== ある日突然マウントできなくなったら❓😱 ====
 +fsck して再マウントする...🤔\\
 +<WRAP prewrap 100%>
 +<code>
 +# mkdir /mnt/sd128gb
 +# fsck.ext4 /dev/sda1
 +# mount -t ext4 /dev/sda1 /mnt/sd128gb
 +# mount
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +/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)
 +cgroup on /sys/fs/cgroup type cgroup (rw,nosuid,nodev,noexec,relatime,blkio,devices,freezer,net_cls,pids)
 +tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
 +/dev/ubi0_1 on /overlay type ubifs (rw,noatime,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)
 +/dev/sda1 on /mnt/䰀椀渀甀砀 䘀椀氀攀猀礀猀琀攀洀 type ext4 (rw,sync,relatime,data=ordered)
 +/dev/sda1 on /mnt/sd128gb type ext4 (rw,sync,relatime,data=ordered)
 +</code>
 +</WRAP>