前回128GBのUSBメモリーをストレージとして導入しました。
・・・見直します。ちょっと変更します。
容量を4倍の512GBにして更にWindowsともフォルダ共有します。
fstabを戻してumount
前回/dataにUSBメモリをmountする設定を/etc/fstabに記載しました。
これをコメントアウトします。
pi@raspberrypi:~ $ sudo vim /etc/fstab proc /proc proc defaults 0 0 PARTUUID=738a4d67-01 /boot vfat defaults 0 2 PARTUUID=738a4d67-02 / ext4 defaults,noatime 0 1 # a swapfile is not a swap partition, no line here # use dphys-swapfile swap[on|off] for that #UUID="A560-633B" /data ext4 defaults,noatime 0 0 # ←コメントアウト
そしたら、sudo reboot nowで再起動してUSBメモリが/dataにmountされているか確認します。
pi@raspberrypi:~ $ sudo df -h Filesystem Size Used Avail Use% Mounted on /dev/root 29G 2.4G 25G 9% / devtmpfs 1.8G 0 1.8G 0% /dev tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 2.0G 9.4M 1.9G 1% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/mmcblk0p1 253M 52M 202M 21% /boot tmpfs 391M 0 391M 0% /run/user/1000
/dataが無くなりました。unmountされている証拠。OKです。
新USBメモリーを挿す!
128GBのUSBメモリーを抜いたら、新しく買った512GBのUSBメモリーをRaspberryPi4のUSB3.0端子に挿してみます。
挿す前から/var/log/messagesの内容をtailで確認していたので、それが以下。
pi@raspberrypi:~ $ sudo tail -f /var/log/messages : Jun 27 05:47:19 raspberrypi kernel: [ 233.852073] usb 2-2: USB disconnect, device number 2 Jun 27 05:48:05 raspberrypi kernel: [ 280.604012] usb 2-2: new SuperSpeed Gen 1 USB device number 3 using xhci_hcd Jun 27 05:48:05 raspberrypi kernel: [ 280.635173] usb 2-2: New USB device found, idVendor=0781, idProduct=5583, bcdDevice= 1.00 Jun 27 05:48:05 raspberrypi kernel: [ 280.635188] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 Jun 27 05:48:05 raspberrypi kernel: [ 280.635201] usb 2-2: Product: Ultra Fit Jun 27 05:48:05 raspberrypi kernel: [ 280.635214] usb 2-2: Manufacturer: SanDisk Jun 27 05:48:05 raspberrypi kernel: [ 280.635227] usb 2-2: SerialNumber: 0101c08d49a14d3ece9c7e85983deb3546f0624c88dce6098c7816fe71e569a79431000000000000000000008023a44c00882e00835581075e28ac0e Jun 27 05:48:05 raspberrypi kernel: [ 280.637539] usb-storage 2-2:1.0: USB Mass Storage device detected Jun 27 05:48:05 raspberrypi kernel: [ 280.639591] scsi host0: usb-storage 2-2:1.0 Jun 27 05:48:05 raspberrypi mtp-probe: checking bus 2, device 3: "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb2/2-2" Jun 27 05:48:05 raspberrypi mtp-probe: bus: 2, device: 3 was not an MTP device Jun 27 05:48:05 raspberrypi mtp-probe: checking bus 2, device 3: "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb2/2-2" Jun 27 05:48:05 raspberrypi mtp-probe: bus: 2, device: 3 was not an MTP device Jun 27 05:48:06 raspberrypi kernel: [ 281.684916] scsi 0:0:0:0: Direct-Access SanDisk Ultra Fit 1.00 PQ: 0 ANSI: 6 Jun 27 05:48:06 raspberrypi kernel: [ 281.685804] sd 0:0:0:0: [sda] 965246976 512-byte logical blocks: (494 GB/460 GiB) Jun 27 05:48:06 raspberrypi kernel: [ 281.685817] sd 0:0:0:0: Attached scsi generic sg0 type 0 Jun 27 05:48:06 raspberrypi kernel: [ 281.686469] sd 0:0:0:0: [sda] Write Protect is off Jun 27 05:48:06 raspberrypi kernel: [ 281.687143] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA Jun 27 05:48:06 raspberrypi kernel: [ 281.725350] sda: sda1 Jun 27 05:48:06 raspberrypi kernel: [ 281.728521] sd 0:0:0:0: [sda] Attached SCSI removable disk
上記1行目は128GBのUSBメモリーを抜いた際のログ。
2行目以降は新しい512GBのUSBメモリーを挿した際のログ。494GB、sda1で認識されているっぽい。
新USBメモリーの設定
まずはfdiskでUSBメモリー上の現在のパーティション情報を見ていく。
pi@raspberrypi:~ $ sudo fdisk /dev/sda Welcome to fdisk (util-linux 2.33.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p # ←パーティション情報を表示 Disk /dev/sda: 460.3 GiB, 494206451712 bytes, 965246976 sectors Disk model: Ultra Fit 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 965246975 965246944 460.3G c W95 FAT32 (LBA) Command (m for help): q # ※都合上、一回抜ける。
FAT32でパーティション(/dev/sda1)が切られているのが分かる。
今回はWindows10からも見ることが出来るようにしたいので、そちらとも親和性の高いファイルシステムであるNTFSにしようと思っています。
なので、現在のパーティションを削除してNTFSで全容量で作り直そう。
ただ、その前にNTFSをRaspberryPi4で扱うことができるようにドライバー「ntfs-3g」をインストールする。
インストールは以下の通り。
pi@raspberrypi:~ $ sudo apt-get -y install ntfs-3g
そしたら、またfdiskでパーティションを一旦削除後に新しくNTFSでパーティションを作成していきます。
pi@raspberrypi:~ $ sudo fdisk /dev/sda Welcome to fdisk (util-linux 2.33.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p # ←パーティション情報を表示 Disk /dev/sda: 460.3 GiB, 494206451712 bytes, 965246976 sectors Disk model: Ultra Fit 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 965246975 965246944 460.3G c W95 FAT32 (LBA) Command (m for help): d # ←パーティションを削除(確認とかなくサクッと削除されるので注意!w) Selected partition 1 Partition 1 has been deleted. Command (m for help): p # ←パーティション情報を表示(/dev/sda1が表示されないことを確認) Disk /dev/sda: 460.3 GiB, 494206451712 bytes, 965246976 sectors Disk model: Ultra Fit 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 Command (m for help): n # ←パーティションを作成 Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p # ←全容量を割り当てるのでPrimaryでOK Partition number (1-4, default 1): # ←1つしか作らないので1または未入力(defaultで1)でOK First sector (2048-965246975, default 2048): # ←開始セクタはdefaultの2048なので未入力でOK Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-965246975, default 965246975): # ←全容量割り当てるので、終了セクタもdefaultのままでOK Created a new partition 1 of type 'Linux' and of size 460.3 GiB. Command (m for help): t # ←Typeを'Linux'からNTFSへ変更したい! Selected partition 1 Hex code (type L to list all codes): L # ←Typeの一覧を表示 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Rufus alignment e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT 10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/ 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto 1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep 1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT Hex code (type L to list all codes): 7 # ←86または87もイケるのかもしれんがネット情報から7を選択 Changed type of partition 'Linux' to 'HPFS/NTFS/exFAT'. Command (m for help): p # ←パーティション情報を表示(/dev/sda1が'HPFS/NTFS/exFAT'で作成されていることを確認) Disk /dev/sda: 460.3 GiB, 494206451712 bytes, 965246976 sectors Disk model: Ultra Fit 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 2048 965246975 965244928 460.3G 7 HPFS/NTFS/exFAT Command (m for help): w # パーティションテーブル情報を書き込んで終了 The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
パーティションは作成できたので、次はNTFS形式でフォーマットを実行する。
pi@raspberrypi:~ $ sudo mkfs.ntfs -Q /dev/sda1 Cluster size has been automatically set to 4096 bytes. Creating NTFS volume structures. mkntfs completed successfully. Have a nice day.
ちなみに-Q
はクイックフォーマットのオプション。これ付けないとディスク0埋めにめっちゃ時間かかってヤバい。
新USBメモリーをマウント
パーティションに対するUUIDを調べる。
pi@raspberrypi:~ $ sudo blkid /dev/sda1 /dev/sda1: UUID="3ADDCAF9419D38D4" TYPE="ntfs" PTTYPE="dos"
このUUIDを指定してmountする。またTypeもntfs-3gに変更する。
pi@raspberrypi:~ $ sudo vi /etc/fstab proc /proc proc defaults 0 0 PARTUUID=738a4d67-01 /boot vfat defaults 0 2 PARTUUID=738a4d67-02 / ext4 defaults,noatime 0 1 # a swapfile is not a swap partition, no line here # use dphys-swapfile swap[on|off] for that UUID="3ADDCAF9419D38D4" /data ntfs-3g defaults,noatime 0 0
そしたら、sudo reboot nowで再起動してUSBメモリが/dataにmountされているか確認します。
pi@raspberrypi:~ $ sudo df -h Filesystem Size Used Avail Use% Mounted on /dev/root 29G 2.4G 25G 9% / devtmpfs 1.8G 0 1.8G 0% /dev tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 2.0G 18M 1.9G 1% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/sda1 461G 79M 461G 1% /data /dev/mmcblk0p1 253M 52M 202M 21% /boot tmpfs 391M 0 391M 0% /run/user/1000
/dataに/dev/sda1が461GBでmountされているのが確認出来たらOKです。
Sambaのインストールと設定
Windowsと/dataを共有できるようにSambaをインストールします。
pi@raspberrypi:~ $ sudo apt-get install samba
続いて/dataを共有できるように設定ファイルの最後に必要事項を書いていく。
pi@raspberrypi:~ $ sudo vi /etc/samba/smb.conf : [raspi4] path = /data public = Yes read only = No browsable = Yes guest ok = Yes force user = pi
上記の設定で大丈夫かテストするコマンドが以下。
pi@raspberrypi:~ $ sudo testparm rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) Registered MSG_REQ_POOL_USAGE Registered MSG_REQ_DMALLOC_MARK and LOG_CHANGED Load smb config files from /etc/samba/smb.conf rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) Processing section "[homes]" Processing section "[printers]" Processing section "[print$]" Processing section "[raspi4]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions
「Loaded services file OK.」と出ていればOKみたい。
OKならsambaデーモンを再起動。
pi@raspberrypi:~ $ sudo systemctl restart smbd
Windows10のエクスプローラーからラズパイのIPアドレスでアクセス。
見えてるね。
更にエクスプローラー上のraspi4フォルダに入ってテキストファイルを作ってみる。
ラズパイに接続中のTeraTerm上でファイルが見えるか確認。
まとめ
よし、今日は終了。
コメント