{"id":4228,"date":"2024-11-12T06:34:03","date_gmt":"2024-11-11T21:34:03","guid":{"rendered":"https:\/\/matoken.org\/blog\/?p=4228"},"modified":"2024-11-12T06:36:30","modified_gmt":"2024-11-11T21:36:30","slug":"initialize-usb-hdd-with-luks-btrfs","status":"publish","type":"post","link":"https:\/\/matoken.org\/blog\/2024\/11\/12\/initialize-usb-hdd-with-luks-btrfs\/","title":{"rendered":"USB HDD\u3092LUKS&#038;Btrfs\u3067\u521d\u671f\u5316"},"content":{"rendered":"<div id=\"preamble\">\n<div class=\"sectionbody\">\n<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"48\" height=\"48\" viewBox=\"0 0 24 24\"><path fill=\"currentColor\" d=\"m21.983 13.821l-1.851-10.18A2 2 0 0 0 18.165 2H5.835a2 2 0 0 0-1.968 1.643l-1.85 10.178l.019.003c-.012.06-.036.114-.036.176v5c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2v-5c0-.063-.024-.116-.035-.176zM5.835 4h12.331l1.637 9H4.198zM4 19v-4h16l.002 4z\"><\/path><path fill=\"currentColor\" d=\"M17 16h2v2h-2zm-3 0h2v2h-2z\"><\/path><\/svg><!-- https:\/\/icon-sets.iconify.design\/bx\/hdd\/ --><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"48\" height=\"48\" viewBox=\"0 0 32 32\"><path fill=\"currentColor\" d=\"m25 30l-2.1-1c-1.7-.8-2.9-2.6-2.9-4.5V18h10v6.5c0 1.9-1.1 3.7-2.9 4.5zm-3-10v4.5c0 1.2.7 2.2 1.7 2.7l1.3.6l1.3-.6c1-.5 1.7-1.6 1.7-2.7V20z\"><\/path><circle cx=\"22\" cy=\"10\" r=\"2\" fill=\"currentColor\"><\/circle><path fill=\"currentColor\" d=\"M21 2c-5 0-9 4-9 9c0 .9.1 1.8.4 2.6L2 24v6h6l10-10l-1.4-1.4l-2.8 2.8l-1.4-1.4l-1.4 1.4l1.4 1.4l-1.6 1.6L9.4 23L8 24.4l1.4 1.4L7.2 28H4v-3.2l9.8-9.8l.8-.8l-.3-1.2c-.2-.7-.3-1.3-.3-2c0-3.9 3.1-7 7-7s7 3.1 7 7c0 1.5-.5 2.9-1.3 4H29c.6-1.2.9-2.6.9-4C30 6 26 2 21 2\"><\/path><\/svg><!-- https:\/\/icon-sets.iconify.design\/carbon\/ibm-cloud-hyper-protect-crypto-services\/ --><\/p>\n<div class=\"paragraph\">\n<p>USB\u306e\u30b1\u30fc\u30b9\u306b2.5\u30a4\u30f3\u30c1HDD\u3092\u5165\u308c\u3066\u521d\u671f\u5316\u3057\u307e\u3057\u305f\uff0e<br \/>\nLUKS\u3067\u6697\u53f7\u5316\u306e\u305f\u3081\u306bCryptsetup\u3092\uff0c\u900f\u904e\u5727\u7e2e\uff0c\u91cd\u8907\u6392\u9664\u3082\u4f7f\u3044\u305f\u3044\u3068\u3044\u3046\u3053\u3068\u3067BtrFS\u3092\u5229\u7528\u3057\u307e\u3057\u305f\uff0e<\/p>\n<\/div>\n<p><!--more-->\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_\u4f59\u5206\u306a\u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u53d6\u308a\u5916\u3057\">\u4f59\u5206\u306a\u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u53d6\u308a\u5916\u3057<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>\u307e\u305a\uff0c\u4f5c\u696dPC\u304b\u3089\u4f59\u5206\u306aHDD\u3084SD card\u306a\u3069\u306e\u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u53d6\u308a\u5916\u3057\u3066\u304a\u304d\u307e\u3059\uff0e\u3053\u308c\u306f\u8aa4\u3063\u3066\u5bfe\u8c61\u5916\u306e\u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u6d88\u53bb\u3057\u3066\u3057\u307e\u308f\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u3067\u3059\uff0e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_\u4f5c\u696d\u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u53d6\u308a\u4ed8\u3051\u3068\u78ba\u8a8d\">\u4f5c\u696d\u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u53d6\u308a\u4ed8\u3051\u3068\u78ba\u8a8d<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>\u4f5c\u696d\u30cf\u30fc\u30c9\u30c7\u30a3\u30b9\u30af\u3092\u53d6\u308a\u4ed8\u3051\u308b\u524d\u306bdmesg\u30b3\u30de\u30f3\u30c9\u3092 <code>-W, --follow-new<\/code> \u30aa\u30d7\u30b7\u30e7\u30f3\u4ed8\u304d\u3067\u5b9f\u884c\u3057\u3066\u304a\u304d\u307e\u3059\uff0e\u3053\u308c\u306b\u3088\u308a\u65b0\u3057\u3044\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\uff0e\u7d42\u4e86\u6642\u306f <span class=\"keyseq\"><kbd>ctrl<\/kbd>+<kbd>c<\/kbd><\/span> \u3067\u7d42\u4e86\u3067\u304d\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>dmesg\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u5f8cUSB\u63a5\u7d9a\u3057\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u78ba\u8a8d\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>[Nov10 19:51] usb 2-4: new SuperSpeed USB device number 6 using xhci_hcd\n[  +0.031413] usb 2-4: New USB device found, idVendor=0bda, idProduct=9201, bcdDevice=f2.00\n[  +0.000017] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3\n[  +0.000007] usb 2-4: Product: RTL9201\n[  +0.000005] usb 2-4: Manufacturer:-W, --follow-new Realtek\n[  +0.000004] usb 2-4: SerialNumber: 012345679446\n[  +0.000623] usb 2-4: Device is not authorized for usage<\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>\u4eca\u56de\u306f <code>Device is not authorized for usage<\/code> \u3068\u306a\u3063\u3066\u3044\u307e\u3059\uff0eUSBGuard\u3067\u30d6\u30ed\u30c3\u30af\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u8a31\u53ef\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ usbguard list-devices | grep block <b class=\"conum\">(1)<\/b>\n19: block id 0bda:9201 serial \"012345679446\" name \"RTL9201\" hash \"qLSxXWok3I6aK\/Wj7GKQnbe3aTW0PNGtemQcsnWzKfs=\" parent-hash \"prM+Jby\/bFHCn2lNjQdAMbgc6tse3xVx+hZwjOPHSdQ=\" via-port \"2-4\" with-interface { 08:06:50 08:06:62 } with-connect-type \"hotplug\"\n$ usbguard allow-device 19 <b class=\"conum\">(2)<\/b><\/pre>\n<\/div>\n<\/div>\n<div class=\"colist arabic\">\n<ol>\n<li>\n<p>USBGuard\u3067\u30d6\u30ed\u30c3\u30af\u3055\u308c\u3066\u3044\u308b\u30c7\u30d0\u30a4\u30b9\u3092\u8868\u793a<\/p>\n<\/li>\n<li>\n<p>dmesg\u306e\u5185\u5bb9\u3068\u898b\u6bd4\u3079\u3066\u8a31\u53ef\u3059\u308b<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<div class=\"paragraph\">\n<p>USBGuard\u3067\u8a31\u53ef\u3059\u308b\u3068dmesg\u306b\u7d9a\u304d\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\uff0e <code>sda<\/code> \u3068\u3057\u3066\u8a8d\u8b58\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>[ +27.584359] usb 2-4: Enable of device-initiated U1 failed.\n[  +0.000893] usb 2-4: Enable of device-initiated U2 failed.\n[  +0.028833] usb 2-4: Enable of device-initiated U1 failed.\n[  +0.000492] usb 2-4: Enable of device-initiated U2 failed.\n[  +0.002026] scsi host0: uas\n[  +0.000251] usb 2-4: authorized to connect\n[  +0.142409] scsi 0:0:0:0: Direct-Access     HGST HTS 541050A9E680     1.02 PQ: 0 ANSI: 6\n[  +0.033919] sd 0:0:0:0: Attached scsi generic sg0 type 0\n[  +0.280706] sd 0:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB\/466 GiB)\n[  +0.000015] sd 0:0:0:0: [sda] 4096-byte physical blocks\n[  +0.001535] sd 0:0:0:0: [sda] Write Protect is off\n[  +0.000016] sd 0:0:0:0: [sda] Mode Sense: 37 00 00 08\n[  +0.002897] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA\n[  +0.063143] sd 0:0:0:0: [sda] Preferred minimum I\/O size 512 bytes not a multiple of physical block size (4096 bytes)\n[  +0.040509] sd 0:0:0:0: [sda] Attached SCSI disk<\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>dmesg\u306b\u8868\u793a\u3055\u308c\u305fvid\u3067lsusb\u306e\u5185\u5bb9\u3092\u78ba\u8a8d\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ lsusb -d 0bda:\nBus 002 Device 006: ID 0bda:9201 Realtek Semiconductor Corp. RTL9201\n$ lsusb -t\n\/:  Bus 001.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd\/12p, 480M\n    |__ Port 005: Dev 002, If 0, Class=Video, Driver=uvcvideo, 480M\n    |__ Port 005: Dev 002, If 1, Class=Video, Driver=uvcvideo, 480M\n    |__ Port 007: Dev 008, 12M\n    |__ Port 010: Dev 004, If 0, Class=Wireless, Driver=btusb, 12M\n    |__ Port 010: Dev 004, If 1, Class=Wireless, Driver=btusb, 12M\n\/:  Bus 002.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd\/6p, 10000M\n    |__ Port 004: Dev 006, If 0, Class=Mass Storage, Driver=uas, 5000M<\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>lsblk\u3067\u3082\u78ba\u8a8d<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ lsblk\nNAME                   MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS\nsda                      8:0    0 465.8G  0 disk\nnvme0n1                259:0    0 476.9G  0 disk\n|-nvme0n1p1            259:1    0   512M  0 part  \/boot\/efi\n|-nvme0n1p2            259:2    0   488M  0 part  \/boot\n`-nvme0n1p3            259:3    0   476G  0 part\n  `-nvme0n1p3_crypt    254:0    0 475.9G  0 crypt\n    |-tp--l13--vg-swap 254:1    0  16.8G  0 lvm   [SWAP]\n    `-tp--l13--vg-root 254:2    0 459.2G  0 lvm   \/<\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>fdisk\u3067\u5bb9\u91cf\u3084\u30e2\u30c7\u30eb\u540d\u3092\u78ba\u8a8d\u3057\u3066\u8a72\u5f53\u306e\u30c7\u30d0\u30a4\u30b9\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ sudo fdisk -l \/dev\/sda\nDisk \/dev\/sda: 465.76 GiB, 500107862016 bytes, 976773168 sectors\nDisk model: 541050A9E680\nUnits: sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 4096 bytes\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes<\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>\u4e2d\u53e4\u3067\u8cfc\u5165\u3057\u305f\u30c7\u30a3\u30b9\u30af\u3067\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u304c\uff0cphotorec\u3067\u4e2d\u3092\u8997\u3044\u3066\u307f\u308b\u3068Windows\u306e\u30b7\u30b9\u30c6\u30e0\u30d5\u30a1\u30a4\u30eb\u306a\u3069\u304c\u898b\u3048\u307e\u3057\u305f\uff0e\u5fa9\u5143\u306f\u305b\u305a\u306b\u7d42\u4e86\u3057\u3066\u6b21\u306b\u9032\u307f\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ sudo photorec \/dev\/sda<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_\u30c7\u30a3\u30b9\u30af\u306e\u6d88\u53bb\">\u30c7\u30a3\u30b9\u30af\u306e\u6d88\u53bb<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>\u3053\u308c\u306f\u6642\u9593\u3082\u304b\u304b\u308b\u3057\u3084\u3089\u306a\u304f\u3066\u3082\u3044\u3044\u304b\u306a\u3068\u601d\u3046\u306e\u3067\u3059\u304c\u5ff5\u306e\u70ba\u30c7\u30a3\u30b9\u30af\u306e\u5185\u5bb9\u3092\u6d88\u53bb\u3057\u3066\u304a\u304d\u307e\u3059\uff0e1\u56de\u30e9\u30f3\u30c0\u30e0\u3067\u4e0a\u66f8\u304d\u3057\u305f\u5f8c0\u3067\u57cb\u3081\u3066\u3044\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ sudo shred -n1 -z -v \/dev\/sda\nshred: \/dev\/sda: pass 1\/2 (random)...\nshred: \/dev\/sda: pass 1\/2 (random)...402MiB\/466GiB 0%\nshred: \/dev\/sda: pass 1\/2 (random)...869MiB\/466GiB 0%\n  :\nshred: \/dev\/sda: pass 1\/2 (random)...463GiB\/466GiB 99%\nshred: \/dev\/sda: pass 1\/2 (random)...464GiB\/466GiB 99%\nshred: \/dev\/sda: pass 1\/2 (random)...465GiB\/466GiB 99%\nshred: \/dev\/sda: pass 1\/2 (random)...466GiB\/466GiB 100%\nshred: \/dev\/sda: pass 2\/2 (000000)...\nshred: \/dev\/sda: pass 2\/2 (000000)...387MiB\/466GiB 0%\nshred: \/dev\/sda: pass 2\/2 (000000)...854MiB\/466GiB 0%\nshred: \/dev\/sda: pass 2\/2 (000000)...1.2GiB\/466GiB 0%\n  :\nshred: \/dev\/sda: pass 2\/2 (000000)...466GiB\/466GiB 100%<\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>random\u304c2\u6642\u9593\u8fd1\u304f\uff0c0\u304c1.5\u6642\u9593\u3068\u5c11\u3057\u304f\u3089\u3044\u304b\u304b\u308a\u307e\u3057\u305f\uff0e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_cryptsetup\u306e\u30d9\u30f3\u30c1\u30de\u30fc\u30af\">Cryptsetup\u306e\u30d9\u30f3\u30c1\u30de\u30fc\u30af<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>\u30c7\u30a3\u30b9\u30af\u306e\u6d88\u53bb\u4e2d\u6687\u306a\u306e\u3067\u30d9\u30f3\u30c1\u30de\u30fc\u30af\u3092\u3068\u3063\u3066\u307f\u307e\u3057\u305f\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">ThinkPad L13(Intel&#174; Core&#8482; i7-10510U)<\/div>\n<div class=\"content\">\n<pre>$ \/sbin\/cryptsetup benchmark\n# Tests are approximate using memory only (no storage IO).\nPBKDF2-sha1      1034098 iterations per second for 256-bit key\nPBKDF2-sha256    1593580 iterations per second for 256-bit key\nPBKDF2-sha512    1046483 iterations per second for 256-bit key\nPBKDF2-ripemd160  731224 iterations per second for 256-bit key\nPBKDF2-whirlpool  559538 iterations per second for 256-bit key\nargon2i       7 iterations, 1048576 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)\nargon2id      7 iterations, 1048576 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)\n#     Algorithm |       Key |      Encryption |      Decryption\n        aes-cbc        128b      1063.9 MiB\/s      2951.4 MiB\/s\n    serpent-cbc        128b        84.8 MiB\/s       570.7 MiB\/s\n    twofish-cbc        128b       217.5 MiB\/s       322.2 MiB\/s\n        aes-cbc        256b       697.5 MiB\/s      2572.2 MiB\/s\n    serpent-cbc        256b        87.0 MiB\/s       605.4 MiB\/s\n    twofish-cbc        256b       225.6 MiB\/s       288.2 MiB\/s\n        aes-xts        256b      2564.0 MiB\/s      2645.4 MiB\/s\n    serpent-xts        256b       478.9 MiB\/s       527.6 MiB\/s\n    twofish-xts        256b       286.5 MiB\/s       290.9 MiB\/s\n        aes-xts        512b      2470.2 MiB\/s      2223.5 MiB\/s\n    serpent-xts        512b       502.4 MiB\/s       562.8 MiB\/s\n    twofish-xts        512b       312.6 MiB\/s       293.5 MiB\/s<\/pre>\n<\/div>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">RasperryPi model 3B<\/div>\n<div class=\"content\">\n<pre>$ \/sbin\/cryptsetup benchmark\n# Tests are approximate using memory only (no storage IO).\nPBKDF2-sha1        99750 iterations per second for 256-bit key\nPBKDF2-sha256     161617 iterations per second for 256-bit key\nPBKDF2-sha512     126762 iterations per second for 256-bit key\nPBKDF2-ripemd160   81310 iterations per second for 256-bit key\nPBKDF2-whirlpool   23710 iterations per second for 256-bit key\nargon2i       4 iterations, 124356 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)\nargon2id      4 iterations, 115630 memory, 4 parallel threads (CPUs) for 256-bit key (requested 2000 ms time)\n#     Algorithm |       Key |      Encryption |      Decryption\n        aes-cbc        128b        23.9 MiB\/s        48.9 MiB\/s\n    serpent-cbc        128b               N\/A               N\/A\n    twofish-cbc        128b        17.1 MiB\/s        21.4 MiB\/s\n        aes-cbc        256b        20.6 MiB\/s        36.6 MiB\/s\n    serpent-cbc        256b               N\/A               N\/A\n    twofish-cbc        256b        19.2 MiB\/s        20.4 MiB\/s\n        aes-xts        256b        52.6 MiB\/s        46.0 MiB\/s\n    serpent-xts        256b               N\/A               N\/A\n    twofish-xts        256b        18.8 MiB\/s        20.9 MiB\/s\n        aes-xts        512b        42.4 MiB\/s        34.0 MiB\/s\n    serpent-xts        512b               N\/A               N\/A\n    twofish-xts        512b        21.5 MiB\/s        20.5 MiB\/s<\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>RasperryPi 3B\u306b\u3076\u3089\u4e0b\u3052\u305f\u3044\u306a\u3068\u601d\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u306f\u3084\u306f\u308a\u9045\u3044\u3067\u3059\u306d\uff0e<a href=\"https:\/\/qiita.com\/makotaka\/items\/657011dc8cd17a813605\">AES\u652f\u63f4\u306e\u3042\u308bSBC<\/a>\u3060\u3068\u307e\u3057\u306b\u306a\u308b\u3093\u3067\u3057\u3087\u3046\u304c\u624b\u6301\u3061\u304c\u306a\u3044\u306e\u3067\u8ae6\u3081\u307e\u3059\uff0e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_cryptsetup\u3067\u521d\u671f\u5316\">Cryptsetup\u3067\u521d\u671f\u5316<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>luksFormat\u3067\u521d\u671f\u5316\u3057\u307e\u3059\uff0e\u3053\u3053\u3067\u30d1\u30b9\u30d5\u30ec\u30fc\u30ba\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u304c\uff0c\u3053\u308c\u304c\u5f31\u3044\u3068\u610f\u5473\u304c\u306a\u3044\u306e\u3067\u5f37\u3044\u3082\u306e\u306b\u3057\u307e\u3057\u3087\u3046\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ sudo cryptsetup luksFormat \/dev\/sda\n\nWARNING!\n========\nThis will overwrite data on \/dev\/sda irrevocably.\n\nAre you sure? (Type 'yes' in capital letters): YES <b class=\"conum\">(1)<\/b>\nEnter passphrase for \/dev\/sda: <b class=\"conum\">(2)<\/b>\nVerify passphrase:<\/pre>\n<\/div>\n<\/div>\n<div class=\"colist arabic\">\n<ol>\n<li>\n<p>\u5927\u6587\u5b57\u3067 <code>YES<\/code> \u3067\u9032\u3080<\/p>\n<\/li>\n<li>\n<p>\u30d1\u30b9\u30d5\u30ec\u30fc\u30ba\u30922\u56de\u8a2d\u5b9a\uff0cKeyslot 0\u306b\u8a2d\u5b9a\u3055\u308c\u308b<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_\u6697\u53f7\u5316\u60c5\u5831\u78ba\u8a8d\">\u6697\u53f7\u5316\u60c5\u5831\u78ba\u8a8d<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>\u5ff5\u306e\u70ba\u6697\u53f7\u5316LUKS\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u306e\u78ba\u8a8d\u3092\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ sudo cryptsetup luksDump \/dev\/sda\nLUKS header information\nVersion:        2\nEpoch:          3\nMetadata area:  16384 [bytes]\nKeyslots area:  16744448 [bytes]\nUUID:           28dee849-e142-49bc-96c2-be62adfc9309\nLabel:          (no label)\nSubsystem:      (no subsystem)\nFlags:          (no flags)\n\nData segments:\n  0: crypt\n        offset: 16777216 [bytes]\n        length: (whole device)\n        cipher: aes-xts-plain64\n        sector: 4096 [bytes]\n\nKeyslots:\n  0: luks2\n        Key:        512 bits\n        Priority:   normal\n        Cipher:     aes-xts-plain64\n        Cipher key: 512 bits\n        PBKDF:      argon2id\n        Time cost:  6\n        Memory:     1048576\n        Threads:    4\n        Salt:       60 50 4a 09 0d ed 44 1d 53 52 04 f5 71 15 58 40\n                    42 8b 7d 36 8f 7c f7 b5 2f 7f af 79 1f 68 e8 29\n        AF stripes: 4000\n        AF hash:    sha256\n        Area offset:32768 [bytes]\n        Area length:258048 [bytes]\n        Digest ID:  0\nTokens:\nDigests:\n  0: pbkdf2\n        Hash:       sha256\n        Iterations: 63381\n        Salt:       88 19 5e 89 5a 22 dd f5 7e 20 a3 b6 e3 d3 87 1b\n                    f8 ec e0 d9 cc ff 86 01 3b a1 ee 44 8b db 31 e6\n        Digest:     e7 c3 5d 78 d2 9c 51 d8 5b 67 d7 15 27 9d 72 73\n                    91 a1 64 b3 36 cf 16 4b c0 2b 9b 5f b6 0d 05 8d<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_cryptsetup\u3067\u30c7\u30a3\u30b9\u30af\u3092\u30a2\u30f3\u30ed\u30c3\u30af\">Cryptsetup\u3067\u30c7\u30a3\u30b9\u30af\u3092\u30a2\u30f3\u30ed\u30c3\u30af<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>hdd\u3068\u3044\u3046\u30c7\u30d0\u30a4\u30b9\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3057\u3066\u3044\u307e\u3059\uff0e\u65e2\u5b9a\u5024\u3067\u4f5c\u6210\u3057\u305f\u306e\u3067\u7279\u306b\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u306a\u3057\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ sudo cryptsetup open \/dev\/sda hdd\nEnter passphrase for \/dev\/sda:\n$ ls \/dev\/mapper\/hdd\n\/dev\/mapper\/hdd<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u4f5c\u6210\">\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u4f5c\u6210<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>\u3053\u3053\u304b\u3089\u306f\u901a\u5e38\u306e\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3068\u540c\u3058\u3067\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ sudo fdisk \/dev\/mapper\/hdd\n\nWelcome to fdisk (util-linux 2.40.2).\nChanges will remain in memory only, until you decide to write them.\nBe careful before using the write command.\n\nDevice does not contain a recognized partition table.\nCreated a new DOS (MBR) disklabel with disk identifier 0x6407f54a.\n\nCommand (m for help): p\nDisk \/dev\/mapper\/hdd: 465.75 GiB, 500091084800 bytes, 122092550 sectors\nUnits: sectors of 1 * 4096 = 4096 bytes\nSector size (logical\/physical): 4096 bytes \/ 4096 bytes\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\nDisklabel type: dos\nDisk identifier: 0x6407f54a\n\nCommand (m for help): n\nPartition type\n   p   primary (0 primary, 0 extended, 4 free)\n   e   extended (container for logical partitions)\nSelect (default p): p\nPartition number (1-4, default 1):\nFirst sector (256-122092549, default 256):\nLast sector, +\/-sectors or +\/-size{K,M,G,T,P} (256-122092549, default 122092549):\n\nCreated a new partition 1 of type 'Linux' and of size 465.7 GiB.\n\nCommand (m for help): p\nDisk \/dev\/mapper\/hdd: 465.75 GiB, 500091084800 bytes, 122092550 sectors\nUnits: sectors of 1 * 4096 = 4096 bytes\nSector size (logical\/physical): 4096 bytes \/ 4096 bytes\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\nDisklabel type: dos\nDisk identifier: 0x6407f54a\n\nDevice                Boot Start       End   Sectors   Size Id Type\n\/dev\/mapper\/hdd-part1        256 122092549 122092294 465.7G 83 Linux\n\nCommand (m for help): w\nThe partition table has been altered.\nCalling ioctl() to re-read partition table.\nRe-reading the partition table failed.: Invalid argument\n\nThe kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or partx(8).\n\n$ sudo partprobe \/dev\/mapper\/hdd\n$ sudo fdisk -l \/dev\/mapper\/hdd\nDisk \/dev\/mapper\/hdd: 465.75 GiB, 500091084800 bytes, 122092550 sectors\nUnits: sectors of 1 * 4096 = 4096 bytes\nSector size (logical\/physical): 4096 bytes \/ 4096 bytes\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\nDisklabel type: dos\nDisk identifier: 0x6407f54a\n\nDevice           Boot Start       End   Sectors   Size Id Type\n\/dev\/mapper\/hdd1        256 122092549 122092294 465.7G 83 Linux<\/pre>\n<\/div>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">BtrFS\u3067\u521d\u671f\u5316<\/div>\n<div class=\"content\">\n<pre>$ sudo fdisk -l \/dev\/mapper\/hdd\nDisk \/dev\/mapper\/hdd: 465.75 GiB, 500091084800 bytes, 122092550 sectors\nUnits: sectors of 1 * 4096 = 4096 bytes\nSector size (logical\/physical): 4096 bytes \/ 4096 bytes\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes\nDisklabel type: dos\nDisk identifier: 0x6407f54a\n\nDevice           Boot Start       End   Sectors   Size Id Type\n\/dev\/mapper\/hdd1        256 122092549 122092294 465.7G 83 Linux<\/pre>\n<\/div>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">mount<\/div>\n<div class=\"content\">\n<pre>$ sudo mount \/dev\/mapper\/hdd1 \/mnt\n$ mount | grep \/dev\/mapper\/hdd1\n\/dev\/mapper\/hdd1 on \/mnt type btrfs (rw,relatime,space_cache=v2,subvolid=5,subvol=\/)\n$ df \/mnt\nFilesystem       1K-blocks  Used Available Use% Mounted on\n\/dev\/mapper\/hdd1 488369176  5920 486254592   1% \/mnt<\/pre>\n<\/div>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">zstd\u3067\u900f\u904e\u5727\u7e2e\u3059\u308b\u3088\u3046remount<\/div>\n<div class=\"content\">\n<pre>$ sudo mount -o remount,compress=zstd \/dev\/mapper\/hdd1\n$ mount | grep \/dev\/mapper\/hdd1\n\/dev\/mapper\/hdd1 on \/mnt type btrfs (rw,relatime,compress=zstd:3,space_cache=v2,subvolid=5,subvol=\/)<\/pre>\n<\/div>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">\u900f\u904e\u5727\u7e2e\u304c\u52b9\u3044\u3066\u3044\u308b\u306e\u3092\u78ba\u8a8d<\/div>\n<div class=\"content\">\n<pre>$ sudo chown `id -u`:`id -g` \/mnt <b class=\"conum\">(1)<\/b>\n$ dd if=\/dev\/zero of=\/mnt\/zero bs=1M count=2048 <b class=\"conum\">(2)<\/b>\n2048+0 records in\n2048+0 records out\n2147483648 bytes (2.1 GB, 2.0 GiB) copied, 0.979651 s, 2.2 GB\/s\n$ ls -s \/mnt\/zero <b class=\"conum\">(3)<\/b>\n2097152 \/mnt\/zero\n$ df -H \/mnt <b class=\"conum\">(4)<\/b>\nFilesystem        Size  Used Avail Use% Mounted on\n\/dev\/mapper\/hdd1  501G   79M  498G   1% \/mnt<\/pre>\n<\/div>\n<\/div>\n<div class=\"colist arabic\">\n<ol>\n<li>\n<p>\u81ea\u5206\u306e\u6a29\u9650\u306b\u3059\u308b<\/p>\n<\/li>\n<li>\n<p>2GB\u307b\u3069\u306e\u4e2d\u8eab\u304c0\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210<\/p>\n<\/li>\n<li>\n<p>2GB\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u51fa\u6765\u3066\u3044\u308b\u306e\u3092\u78ba\u8a8d<\/p>\n<\/li>\n<li>\n<p>2GB\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u3051\u3069\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306f79MB\u3057\u304b\u4f7f\u3063\u3066\u3044\u306a\u3044\u306e\u3092\u78ba\u8a8d<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_\u30a2\u30f3\u30de\u30a6\u30f3\u30c8\u6697\u53f7\u5316fs\u306e\u30af\u30ed\u30fc\u30ba\">\u30a2\u30f3\u30de\u30a6\u30f3\u30c8\uff0c\u6697\u53f7\u5316FS\u306e\u30af\u30ed\u30fc\u30ba<\/h2>\n<div class=\"sectionbody\">\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ sudo umount \/mnt <b class=\"conum\">(1)<\/b>\n$ sudo cryptsetup close hdd <b class=\"conum\">(2)<\/b>\n$ udisksctl power-off -b \/dev\/sda <b class=\"conum\">(3)<\/b>\n$ ls \/dev\/sda\nls: cannot access '\/dev\/sda': No such file or directory<\/pre>\n<\/div>\n<\/div>\n<div class=\"colist arabic\">\n<ol>\n<li>\n<p>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30a2\u30f3\u30de\u30a6\u30f3\u30c8<\/p>\n<\/li>\n<li>\n<p>\u6697\u53f7\u5316FS\u306e\u30af\u30ed\u30fc\u30ba<\/p>\n<\/li>\n<li>\n<p>\u30c9\u30e9\u30a4\u30d6\u306e\u96fb\u6e90\u30aa\u30d5<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_\u74b0\u5883\">\u74b0\u5883<\/h2>\n<div class=\"sectionbody\">\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ dpkg-query -W cryptsetup fdisk btrfs-progs udisks2\nbtrfs-progs     6.6.3-1.2+b2\ncryptsetup      2:2.7.5-1\nfdisk   2.40.2-10\nudisks2 2.10.1-11\n$ lsb_release -dr\nDescription:    Debian GNU\/Linux trixie\/sid\nRelease:        n\/a\n$ arch\nx86_64<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>USB\u306e\u30b1\u30fc\u30b9\u306b2.5\u30a4\u30f3\u30c1HDD\u3092\u5165\u308c\u3066\u521d\u671f\u5316\u3057\u307e\u3057\u305f\uff0e LUKS\u3067\u6697\u53f7\u5316\u306e\u305f\u3081\u306bCryptsetup\u3092\uff0c\u900f\u904e\u5727\u7e2e\uff0c\u91cd\u8907\u6392\u9664\u3082\u4f7f\u3044\u305f\u3044\u3068\u3044\u3046\u3053\u3068\u3067BtrFS\u3092\u5229\u7528\u3057\u307e\u3057\u305f\uff0e<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"webmentions_disabled_pings":false,"webmentions_disabled":false,"activitypub_content_warning":null,"activitypub_content_visibility":null,"activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"federated","footnotes":""},"categories":[7,6,199],"tags":[163,1136,217,1135],"class_list":["post-4228","post","type-post","status-publish","format-standard","hentry","category-debian-linux","category-linux","category-sid","tag-btrfs","tag-cryptsetup","tag-encryption","tag-luks"],"_links":{"self":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts\/4228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/comments?post=4228"}],"version-history":[{"count":2,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts\/4228\/revisions"}],"predecessor-version":[{"id":4231,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts\/4228\/revisions\/4231"}],"wp:attachment":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/media?parent=4228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/categories?post=4228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/tags?post=4228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}