R.A. Epigonos et al.

[debian] USBメモリのフォーマットとマウント

USBメモリをフォーマットしてマウントするまでの記録。

USBメモリをマシンにつけるとdmesgに以下のようなログが流れる。sddでデバイスファイルができたことがわかる。

[627615.624065] usb 1-2: new full speed USB device using uhci_hcd and address 2
[627616.744081] usb 1-2: New USB device found, idVendor=1307, idProduct=0163
[627616.744091] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[627616.744096] usb 1-2: Product: Flash Disk
[627616.744100] usb 1-2: Manufacturer: USB 2.0
[627616.744104] usb 1-2: SerialNumber: 79c5f4d19de16a
[627616.744377] usb 1-2: configuration #1 chosen from 1 choice
[627617.173776] Initializing USB Mass Storage driver...
[627617.174058] scsi4 : SCSI emulation for USB Mass Storage devices
[627617.174480] usbcore: registered new interface driver usb-storage
[627617.174488] USB Mass Storage support registered.
[627617.177363] usb-storage: device found at 2
[627617.177371] usb-storage: waiting for device to settle before scanning
[627622.200844] usb-storage: device scan complete
[627622.448159] scsi 4:0:0:0: Direct-Access     USB 2.0  Flash Disk       0.00 PQ: 0 ANSI: 2
[627622.768255] sd 4:0:0:0: [sdd] 3948543 512-byte logical blocks: (2.02 GB/1.88 GiB)
[627622.968117] sd 4:0:0:0: [sdd] Write Protect is off
[627622.968127] sd 4:0:0:0: [sdd] Mode Sense: 00 00 00 00
[627622.968132] sd 4:0:0:0: [sdd] Assuming drive cache: write through
[627624.068129] sd 4:0:0:0: [sdd] Assuming drive cache: write through
[627624.068169]  sdd: sdd1
[627625.068240] sd 4:0:0:0: [sdd] Assuming drive cache: write through
[627625.068278] sd 4:0:0:0: [sdd] Attached SCSI removable disk

自動マウントされないことを確認。

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             259M  123M  123M  50% /
tmpfs                 125M     0  125M   0% /lib/init/rw
udev                  121M  180K  120M   1% /dev
tmpfs                 125M     0  125M   0% /dev/shm
/dev/sda9             2.1G  1.5G  472M  77% /home
/dev/sda8             183M  5.6M  168M   4% /tmp
/dev/sda5             2.2G  1.9G  142M  94% /usr
/dev/sda6             996M  403M  544M  43% /var
/dev/sdb1             459G  436G   52M 100% /****************
/dev/sdc1              74G   70G  223M 100% /****************

パーティションテーブルの確認。どうやらFATフォーマットみたい。

# fdisk -l /dev/sdd

WARNING: GPT (GUID Partition Table) detected on '/dev/sdd'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sdd: 2021 MB, 2021654016 bytes
255 heads, 63 sectors/track, 245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa594fcbc

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *           1         246     1974271    b  W95 FAT32
Partition 1 has different physical/logical beginnings (non-Linux?):
     phys=(1023, 254, 63) logical=(0, 0, 2)
Partition 1 has different physical/logical endings:
     phys=(1023, 254, 63) logical=(245, 200, 18)

fat32ならマウントできるので、マウントしてみる。マウントは問題なく終了。lsでなかも見れる。

# mount /dev/sdd1 /mnt/
# ls /mnt/ -la
total 51105
drwxr-xr-x  3 root root     4096 Jan  1  1970 .
drwxr-xr-x 22 root root     1024 Feb 19  2011 ..
drwxr-xr-x  3 root root     4096 Aug 22 05:15 boot
-r-xr-xr-x  1 root root    32768 Aug 22 05:16 ldlinux.sys
-rwxr-xr-x  1 root root    60928 Aug 22 05:16 menu.c32
-rwxr-xr-x  1 root root     2608 Aug 22 05:16 syslinux.cfg
-rwxr-xr-x  1 root root      239 Aug 22 05:16 ubnfilel.txt
-rwxr-xr-x  1 root root 51206265 Oct 27  2007 ubninit
-rwxr-xr-x  1 root root  1005209 Oct 25  2007 ubnkern
-rwxr-xr-x  1 root root       21 Aug 22 05:15 ubnpathl.txt

パーティションテーブルの書き換えとフォーマットをするためにアンマウントする。

# umount /mnt/

パーティションテーブルを書き換える。最初のパーティションを削除して、新しいパーティションを作成して、テーブルを更新する。

# fdisk /dev/sdd

WARNING: GPT (GUID Partition Table) detected on '/dev/sdd'! The util fdisk doesn't support GPT. Use GNU Parted.


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-245, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-245, default 245):
Using default value 245

Command (m for help): p

Disk /dev/sdd: 2021 MB, 2021654016 bytes
255 heads, 63 sectors/track, 245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa594fcbc

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         245     1967931   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

ext3でフォーマット。読みテストは-cオプション、読み書きテストは-c -cオプション(-cを2回)。テストにはそれなりの時間がかかる。

# mkfs.ext3 /dev/sdd1
mke2fs 1.41.12 (17-May-2010)
warning: 462 blocks unused.

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
123120 inodes, 491520 blocks
24599 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=503316480
15 block groups
32768 blocks per group, 32768 fragments per group
8208 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

読み込みチェックを行う-cオプションの場合

# mkfs -t ext3 -c /dev/sdd1
mke2fs 1.41.12 (17-May-2010)
warning: 462 blocks unused.

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
123120 inodes, 491520 blocks
24599 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=503316480
15 block groups
32768 blocks per group, 32768 fragments per group
8208 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Checking for bad blocks (read-only test): done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

-ccはダメ。

# mkfs -t ext3 -cc /dev/sdd1
mke2fs 1.41.12 (17-May-2010)
mkfs.ext3: invalid blocks count - /dev/sdd1

読み込み書き込みチェックを行う-c -cオプションの場合。2GBのUSBメモリをUSB1.0ポートにつなげた場合15時間程度かかった。

# mkfs -t ext3 -c -c /dev/sdd1
mke2fs 1.41.12 (17-May-2010)
warning: 462 blocks unused.

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
123120 inodes, 491520 blocks
24599 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=503316480
15 block groups
32768 blocks per group, 32768 fragments per group
8208 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Testing with pattern 0xaa:  done
Reading and comparing: done
Testing with pattern 0x55: done
Reading and comparing: done
Testing with pattern 0xff: done
Reading and comparing: done
Testing with pattern 0x00: done
Reading and comparing: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

マウントして、読み書きテストしてみる。

# mount /dev/sdd1 /mnt/
# ls /mnt/ -la
total 21
drwxr-xr-x  3 root root  4096 Nov  4 02:28 .
drwxr-xr-x 22 root root  1024 Feb 19  2011 ..
drwx------  2 root root 16384 Nov  4 02:28 lost+found
# touch /mnt/test
# ls /mnt/ -la
total 21
drwxr-xr-x  3 root root  4096 Nov  4 02:36 .
drwxr-xr-x 22 root root  1024 Feb 19  2011 ..
drwx------  2 root root 16384 Nov  4 02:28 lost+found
-rw-r--r--  1 root root     0 Nov  4 02:36 test

別のUSBメモリ18BGでフォーマットの時間測定。接続はUSB1.0。

# time mkfs -t ext3 /dev/sdd1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
991232 inodes, 3963782 blocks
198189 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4060086272
121 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

real    17m36.189s
user    0m0.108s
sys     0m2.852s

読み込みチェックオプションを有効にすると6時間程度

# time mkfs -t ext3 -c /dev/sdd1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
991232 inodes, 3963782 blocks
198189 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4060086272
121 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Checking for bad blocks (read-only test): done
Warning: the backup superblock/group descriptors at block 1867776 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 1900544 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 1933312 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 1966080 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 1998848 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2031616 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2064384 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2097152 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2129920 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2162688 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2195456 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2228224 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2260992 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2293760 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2326528 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2359296 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2392064 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2424832 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2457600 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2490368 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2523136 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2555904 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2588672 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2621440 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2654208 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2686976 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2719744 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2752512 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2785280 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2818048 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2850816 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2883584 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2916352 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2949120 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 2981888 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3014656 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3047424 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3080192 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3112960 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3145728 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3178496 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3211264 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3244032 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3276800 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3309568 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3342336 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3375104 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3407872 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3440640 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3473408 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3506176 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3538944 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3571712 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3604480 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3637248 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3670016 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3702784 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3735552 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3768320 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3801088 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3833856 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3866624 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3899392 contain
        bad blocks.

Warning: the backup superblock/group descriptors at block 3932160 contain
        bad blocks.

mkfs.ext3: Could not allocate block in ext2 filesystem while trying to allocate filesystem tables

real    399m51.580s
user    0m30.602s
sys     2m47.670s

リファレンス

  1. Man page of MOUNT
  2. Man page of FDISK
  3. Manpage of MKFS
  4. mkfs.ext3(8): create ext2/ext3 filesystem - Linux man page
  5. mkfs cc - Google 検索
  6. mkfs read write - Google 検索
  7. mkfs "-c -c" - Google 検索

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2010-03-04T09:45:46+09:00
  2. Modified: 2010-03-04T09:45:46+09:00
  3. Generated: 2024-11-18T23:09:14+09:00