October 28, 2023 – 3:21 pm
Windows11で フォーマットできなくなっていたUSBメモリ をLinux上でフォーマットすることができたので顛末をメモしておいた。
Linux(AlmaLinux9)にUSBを差し込んでlsub コマンドで確認:
$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 018: ID 056e:6015 Elecom Co., Ltd MF-MSU3
Bus 001 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
USBメモリ自体は認識されていることを確認したので、lsblkでこれがどのようにdeviceに接続されているかを確認:
# lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda
├─sda1 vfat FAT32 6B5E-E78C 591.8M 1% /boot/efi
├─sda2 xfs 2ea763d3-92b3-48cd-bc52-fdf11321af4c 720.7M 29% /boot
└─sda3 LVM2_member LVM2 001 EJQKvA-F54L-k4hM-GFxu-YF30-GZpH-s99Eb8
├─almalinux_server02-root xfs bd3938f6-033a-4df6-a89f-d522b375c8a8 62.7G 10% /
├─almalinux_server02-swap swap 1 1ee1771d-b7d1-4585-8974-341375e4651d [SWAP]
└─almalinux_server02-home xfs dfbf7035-0a7b-4e7c-abd6-883aeb8341b0 537G 37% /home
sdb ext4 1.0 ssd 49d29bb1-ec7b-4af6-9051-6c87cf761743
└─sdb1 ext4 1.0 164903b7-64bc-4a00-9289-c5f2abf5e2d4 64.1G 7% /mnt/ssd
sdc
USB は/dev/sdcにあるようだがpartitionされてない状態にある。「コマンドを使ってLinux上でUSBメモリをフォーマットする方法」によると、gdiskでパーティショニングし、フォーマットすることができそう。
そこで、まず、パーティショニングツール gdiskを以下でインストール:
# dnf install gdisk
Last metadata expiration check: 2:28:37 ago on Sat Oct 28 08:52:34 2023.
Dependencies resolved.
=========================================================================================================================================
Package Architecture Version Repository Size
=========================================================================================================================================
Installing:
gdisk x86_64 1.0.7-5.el9 appstream 242 k
Transaction Summary
=========================================================================================================================================
Install 1 Package
Total download size: 242 k
Installed size: 696 k
Is this ok [y/N]: y
Downloading Packages:
gdisk-1.0.7-5.el9.x86_64.rpm 2.1 MB/s | 242 kB 00:00
-----------------------------------------------------------------------------------------------------------------------------------------
Total 260 kB/s | 242 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : gdisk-1.0.7-5.el9.x86_64 1/1
Running scriptlet: gdisk-1.0.7-5.el9.x86_64 1/1
Verifying : gdisk-1.0.7-5.el9.x86_64 1/1
Installed:
gdisk-1.0.7-5.el9.x86_64
Complete!
USB に対応する device file /dev/sdcを gdiskでpartitioning:
# gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.7
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: present
Found valid GPT with corrupt MBR; using GPT and will write new
protective MBR on save.
Warning! Main partition table overlaps the first partition by 34 blocks!
You will need to delete this partition or resize it in another utility.
Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-30310366, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-30310366, default = 30310366) or {+-}size{KMGTP}:
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 0700
Changed type of partition to 'Microsoft basic data'
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/sdc.
The operation has completed successfully.
/dev/sdc1 をfat32でフォーマット:
# mkfs.vfat -v -c -F 32 -n ELECOM /dev/sdc1
mkfs.fat 4.2 (2021-01-31)
/dev/sdc1 has 64 heads and 32 sectors per track,
hidden sectors 0x0800;
logical sector size is 512,
using 0xf8 media descriptor, with 30308288 sectors;
drive number 0x80;
filesystem has 2 32-bit FATs and 16 sectors per cluster.
FAT size is 14800 sectors, and provides 1892416 clusters.
There are 32 reserved sectors.
Volume ID is 6ef93ba8, volume label TRANSCEND.
Searching for bad blocks 81376...
以上でフォーマットしたUSBメモリ をWindows11上に差し込み、空のファイルと認識されていることを確認。
Posted in Serverの構築と運用覚書き | No Comments »