RaspberryPI運用 256GBのUSBを使う (fdisk) -備忘録

投稿日: 作成者: ussy
  1. USBを差込み割り当てられているドライブを確認
    fdisk -l

    Disk /dev/sda: 234.4 GiB, 251658240000 bytes, 491520000 sectors
    Disk model: USB DISK
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x00000000

    Device Boot Start End Sectors Size Id Type
    /dev/sda1 4294967295 8589934589 4294967295 2T ff BBT
    /dev/sda2 4294967295 8589934589 4294967295 2T ff BBT
    /dev/sda3 4294967295 8589934589 4294967295 2T ff BBT
    /dev/sda4 4294967295 5035196669 740229375 353G ff BBT

    /dev/sdaに割り当てられていることを確認

  2. /dev/sdaを編集
    fdisk /dev/sda
  3. デリートコマンドで全てのパテーションを削除します
    Command (m for help): d
    Partition number (1-4, default 4):
    ※1から4まで全て消す。4から消していく

    Command (m for help): d
    Partition number (1-4, default 4): 4

    Partition 4 has been deleted.

    Command (m for help): d
    Partition number (1-3, default 3): 3

    Partition 3 has been deleted.

    Command (m for help): d
    Partition number (1,2, default 2): 2

    Partition 2 has been deleted.

    Command (m for help): d
    Selected partition 1
    Partition 1 has been deleted.

  4. 新規にパテーションを作成する
    コマンドはn ※まるごとUSBを使うので全てデフォルト

    Command (m for help): n
    Partition type
    p primary (0 primary, 0 extended, 4 free)
    e extended (container for logical partitions)
    Select (default p): p
    Partition number (1-4, default 1): 1
    First sector (2048-491519999, default 2048):
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-491519999, default 491519999):

    Created a new partition 1 of type ‘Linux’ and of size 234.4 GiB.

    ※内容確認 コマンドはp
    Command (m for help): p

    Disk /dev/sda: 234.4 GiB, 251658240000 bytes, 491520000 sectors
    Disk model: USB DISK
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x00000000

    Device Boot Start End Sectors Size Id Type
    /dev/sda1 2048 491519999 491517952 234.4G 83 Linux

    無事にLINUXパテーションが作成されました。

  5. 確認後よければwコマンドで書込みし完了

    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.

  6. フォーマット
    1. 使えるフォーマットを確認

      root@raspberrypi:/home/pi# ls /sbin/mkfs.*
      /sbin/mkfs.bfs /sbin/mkfs.ext3 /sbin/mkfs.minix /sbin/mkfs.vfat
      /sbin/mkfs.cramfs /sbin/mkfs.ext4 /sbin/mkfs.msdos
      /sbin/mkfs.ext2 /sbin/mkfs.fat /sbin/mkfs.ntfs

    2. フォーマット開始

      mkfs -t ext4 /dev/sdb1
      mke2fs 1.44.5 (15-Dec-2018)
      Creating filesystem with 61439744 4k blocks and 15360000 inodes
      Filesystem UUID: db4c96f7-2ef2-48a4-ae9f-97c343a3d205
      Superblock backups stored on blocks:
      32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
      4096000, 7962624, 11239424, 20480000, 23887872

      Allocating group tables: done
      Writing inode tables: done
      Creating journal (262144 blocks):
      done
      Writing superblocks and filesystem accounting information: done

  7. 完了