Raspberry pi 4にUSB-SSDを接続する話
今日はRaspberry piにUSB-SSDを接続しました!
んで?と思われるでしょうが、それだけです!
早速作業です!
はじめに用意したのはこちら、jet何チャラです!
はい、超古いですw Macbook air(初代)のSSDを置換したときのあまりです。
つまり!遅いですw
次に、USB接続して…
接続確認しました!
動作チェック…
$ dmesg [1162842.357277] usb 2-1: USB disconnect, device number 2 [1198968.533898] usb 2-2: new SuperSpeed Gen 1 USB device number 3 using xhci_hcd [1198968.564887] usb 2-2: New USB device found, idVendor=174c, idProduct=07d1, bcdDevice=10.00 [1198968.564902] usb 2-2: New USB device strings: Mfr=2, Product=3, SerialNumber=1 [1198968.564915] usb 2-2: Product: JetDrive [1198968.564927] usb 2-2: Manufacturer: Transcend [1198968.564939] usb 2-2: SerialNumber: 20150124B986691169AE [1198968.604739] scsi host0: uas [1198968.607078] scsi 0:0:0:0: Direct-Access JetDrive Transcend 0 PQ: 0 ANSI: 6 [1198968.608767] sd 0:0:0:0: [sda] 118489088 512-byte logical blocks: (60.7 GB/56.5 GiB) [1198968.608924] sd 0:0:0:0: [sda] Write Protect is off [1198968.608938] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00 [1198968.609235] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA [1198968.609863] sd 0:0:0:0: [sda] Optimal transfer size 33553920 bytes [1198968.612801] sd 0:0:0:0: Attached scsi generic sg0 type 0 [1198968.675119] sda: sda1 [1198968.676833] sd 0:0:0:0: [sda] Attached SCSI disk
sdaで正常にアクセス出来ました!
にしても、60GBってw
今入っている不要なパーティションを削除!
$ 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): d Selected partition 1 Partition 1 has been deleted. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
次に、ext4のパーティションを作ります
$ 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: 56.5 GiB, 60666413056 bytes, 118489088 sectors Disk model: Transcend Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33553920 bytes Disklabel type: dos Disk identifier: 0x4e8f88fb 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 Partition number (1-4, default 1): First sector (65535-118489087, default 65535): Last sector, +/-sectors or +/-size{K,M,G,T,P} (65535-118489087, default 118489087): Created a new partition 1 of type 'Linux' and of size 56.5 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
つぎ、フォーマット!
$ sudo mkfs.ext4 /dev/sda1 mke2fs 1.44.5 (15-Dec-2018) Creating filesystem with 14802944 4k blocks and 3702784 inodes Filesystem UUID: bf1640a7-baae-4174-802b-0f005f54fc53 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424 Allocating group tables: done Writing inode tables: done Creating journal (65536 blocks): done Writing superblocks and filesystem accounting information: done
マウント先のディレクトリを作成と、マウントテスト!
$ sudo mkdir /mnt/ssd $ sudo mount /dev/sda1 /mnt/ssd $ sudo unmount /mnt/ssd
次に自動マウントさせたいので、UUIDを調査します
$ sudo blkid /dev/sda /dev/sda: PTUUID="4e8f88fb" PTTYPE="dos"
UUID分かったので、マウントファイル fstabを編集します
$ sudo vi /etc/fstab proc /proc proc defaults 0 0 /dev/mmcblk0p6 /boot vfat defaults 0 2 /dev/mmcblk0p7 / ext4 defaults,noatime 0 1 # a swapfile is not a swap partition, no line here # use dphys-swapfile swap[on|off] for that PARTUUID=4e8f88fb /mnt/ssd ext4 defaults,nofail 0 0
最後の一行が今回追加した内容です
そして、自動マウントテスト…
$ sudo mount -a $ sudo df -l ファイルシス 1K-ブロック 使用 使用可 使用% マウント位置 /dev/root 58681532 10846596 44831032 20% / devtmpfs 1827796 0 1827796 0% /dev tmpfs 1959892 16 1959876 1% /dev/shm tmpfs 1959892 190536 1769356 10% /run tmpfs 5120 4 5116 1% /run/lock tmpfs 1959892 0 1959892 0% /sys/fs/cgroup /dev/mmcblk0p6 258094 55170 202925 22% /boot tmpfs 391976 0 391976 0% /run/user/1000 /dev/sda1 58019852 53272 54989608 1% /mnt/ssd
はい、これで、sda1が/mnt/ssdにマウントされました!
んで、なんでこんなサーバ管理の基礎を?と思われるでしょう…
大昔(Linux3.0位)は毎日HDDフォーマットして、マウントしてを繰り返していましたが、最近ご無沙汰で結構抜けてましたw
df/mount/fdiskまでは覚えていましたが、ボリューム調べるときにfdisk -lだったりフォーマット方法を忘れていたり…
ちょっぴり凹みました;;
なので、今回は自分の覚え書き、戒めも兼ねましてわざわざ書きました、Try and ErrorsのDXはローカルのGitLabのISSUEに残しています。
そこには細かいどのサイト見たか、どの部分参考になったかなど激烈恥ずかしいメモを取っております。
ちなみに、ソースのないプロジェクトだったりします(自分のTODOのISSUEと掲示板って感じです)
な感じで今回はちょっぴり甘酸っぱい恥ずかしいメモでしたw