ネットワーク管理者の憂鬱な日常

とある組織でネットワーク管理に携わる管理者の憂鬱な日常を書いてみたりするブログ

FreeBSDでUSBメモリ(FAT32フォーマット)をmountしてみる

f:id:silvernetworks:20160903215952p:plain

何やら、今でも次の記事が参照されているようなので、改めてupdate。

www.silvernetworks.jp

FAT32フォーマットされたUSBメモリをFreeBSDにmountしてみる。一応、実行はFreeBSD 11.0-RC2(amd64)で行った。

1. デバイス名の確認

USBポートにUSBメモリを挿入すると、/var/log/messagesにこんなログが残るはず。

ugen1.2: <GH> at usbus1
umass0: <GH PicoDUAL X, class 0/0, rev 2.00/1.00, addr 2> on usbus1
umass0: SCSI over Bulk-Only; quirks = 0x8100
umass0:3:0: Attached to scbus3
da1 at umass-sim0 bus 0 scbus3 target 0 lun 0
da1: <GH PicoDUAL X PMAP> Removable Direct Access SCSI device
da1: Serial Number 07AB0F0246XXXXXX
da1: 40.000MB/s transfers
da1: 15272MB (31277056 512 byte sectors)
da1: quirks=0x2<NO_6_BYTE>

この場合だと、/dev/da1がデバイス名となる。

2. パーティション情報の確認

fdiskあたりを使うと、セクタサイズやパーティション情報が確認できる。この例だと、パーティション1がFAT32になっている。パーティション識別子(sysid)が12(0x0c)になっていることからも確認可能。

# fdisk /dev/da1
******* Working on device /dev/da1 *******
parameters extracted from in-core disklabel are:
cylinders=1946 heads=255 sectors/track=63 (16065 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=1946 heads=255 sectors/track=63 (16065 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 12 (0x0c),(DOS or Windows 95 with 32 bit FAT (LBA))
start 2048, size 31275008 (15271 Meg), flag 80 (active)
beg: cyl 0/ head 32/ sector 33;
end: cyl 1023/ head 254/ sector 63
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>

あとは、gpartでも確認可能。

# gpart show /dev/da1
=> 63 31276993 da1 MBR (15G)
63 1985 - free - (993K)
2048 31275008 1 !12 [active] (15G)

3. マウントとアンマウント

で、mount_msdosfs(もしくは、mount -t msdosfs)でマウント。mountコマンドで、msdosfsとしてマウントされていることが確認できる。

# mount_msdosfs /dev/da1 /mnt
# mount
/dev/da0p2 on / (ufs, local, journaled soft-updates)
devfs on /dev (devfs, local, multilabel)
/dev/da1 on /mnt (msdosfs, local)

あとは、cpなりでコピーすればいいのだけど、パーミッションが飛んでしまう。まあ、コピー先のファイルシステムがFAT32なので仕方ないのだが...。

# ls -la /bin/tcsh
-r-xr-xr-x 2 root wheel 394744 Aug 24 15:59 /bin/tcsh
# cp -p /bin/tcsh /mnt
# ls -l /mnt
-rwxr-xr-x 1 root wheel 394744 Aug 24 15:59 tcsh

当然最後はアンマウント。

# umount /mnt

で、おしまい。

スポンサーリンク