WSL2にDiskを増設したいのでいろいろ調べてやりました。とりあえずメモ。詳細はMicrosoftのホームページに書いてあります。
まずUSBのSSDを接続。PowerShell(>でコマンドを書いています。)で、
> GET-CimInstance -query "SELECT * from Win32_DiskDrive"
DeviceID Caption Partitions Size Model
-------- ------- ---------- ---- -----
\\.\PHYSICALDRIVE1 SAMSUNG MZVLB512HBJQ-000H1 3 512105932800 SAMSUNG MZVLB512HBJQ-000H1
\\.\PHYSICALDRIVE0 ST1000LM049-2GH172 1 1000202273280 ST1000LM049-2GH172
\\.\PHYSICALDRIVE2 I-O DATA SSPH-UT USB Device 1 500105249280 I-O DATA SSPH-UT USB Device
接続を確認。ディスクの管理で、ボリュームの削除で切り離す。データは消えるので注意。再度、PowerShellで、
> GET-CimInstance -query "SELECT * from Win32_DiskDrive"
DeviceID Caption Partitions Size Model
-------- ------- ---------- ---- -----
\\.\PHYSICALDRIVE1 SAMSUNG MZVLB512HBJQ-000H1 3 512105932800 SAMSUNG MZVLB512HBJQ-000H1
\\.\PHYSICALDRIVE0 ST1000LM049-2GH172 1 1000202273280 ST1000LM049-2GH172
\\.\PHYSICALDRIVE2 I-O DATA SSPH-UT USB Device 0 500105249280 I-O DATA SSPH-UT USB Device
PHYSICALDRIVE2のPartitionsが、0に。それからWSLを停止。つなげたいDISKを指定しながら、WSLを起動。
> wsl --shutdown
> wsl --mount \\.\PHYSICALDRIVE2 --bare
WSLにアクセスして、ディスクの状況を確認(WSL上のコマンドは、~$の後に書いてあります)。
~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 363.3M 1 disk
sdb 8:16 0 6G 0 disk [SWAP]
sdc 8:32 0 465.8G 0 disk
└─sdc1 8:33 0 128M 0 part
sdd 8:48 0 256G 0 disk /mnt/wslg/distro
diskが準備されていいないので、
~$ sudo fdisk /dev/sdc
Welcome to fdisk (util-linux 2.34).
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/sdc: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: SSPH-UT
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F62941CE-BCB7-48C5-ADE3-B4E6E0F90CC7
Device Start End Sectors Size Type
/dev/sdc1 34 262177 262144 128M Microsoft reserved
Partition 1 does not start on physical sector boundary.
Command (m for help): n
Partition number (2-128, default 2): 2
First sector (262178-976773134, default 264192):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (264192-976773134, default 976773134):
Created a new partition 2 of type 'Linux filesystem' and of size 465.7 GiB.
Partition #2 contains a ntfs signature.
Do you want to remove the signature? [Y]es/[N]o: y
The signature will be removed by a write command.
Command (m for help): p
Disk /dev/sdc: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: SSPH-UT
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F62941CE-BCB7-48C5-ADE3-B4E6E0F90CC7
Device Start End Sectors Size Type
/dev/sdc1 34 262177 262144 128M Microsoft reserved
/dev/sdc2 264192 976773134 976508943 465.7G Linux filesystem
Partition 1 does not start on physical sector boundary.
Filesystem/RAID signature on partition 2 will be wiped.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
パーティションをフォーマット。
~$ sudo mkfs.ext4 /dev/sdc2
PowerShellで、wslを再起動して、再マウント。
> wsl --shutdown
> wsl --mount \\.\PHYSICALDRIVE2 -p 2
コメント