Raspberry pi の外部記憶追加

  • 投稿日:
  • by
  • カテゴリ:

PCデポでSDHC-mini 32GBを買って、同時に購入したUSBアダプターを介し、
/homeにマウントするようにする。

要は、
8GBSDHCを本体に挿し、/と/bootに。
USBアダプタを介して32GBSDHCを/homeに。

大事なデータ部は別メディアにして、安心しようという作戦だ。

PT370106.JPG


以下作業メモ。

piに $sudo su した状態で、SDHC-miniは吊るし(たぶんFAT32)の状態とする。

使用したアダプターは ELECOM MR-SMC07BK である


# fdisk sda1
n押下
p押下
1押下
w押下


これでext2にはなる。

# mkfs.ext4 /dev/sda1

ext4に進化させる

# blkid /dev/sda1
/dev/sda1: UUID="5641c037-9c89-4865-bb7c-9fe65643c901" TYPE="ext4"

UUIDの"~~~"をコピーする。
(SDHCの固有ID)

# vi /etc/fstab

proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
UUID="5641c037-9c89-4865-bb7c-9fe65643c901" /home ext4 defaults,noatime 0 1

(手順ここまで)

root@ocean:/dev# fdisk sda1

Command (m for help): p

Disk sda1: 31.7 GB, 31686918144 bytes
64 heads, 32 sectors/track, 30219 cylinders, total 61888512 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6f20736b

Device Boot Start End Blocks Id System

Command (m for help): n

Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-61888511, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-61888511, default 61888511):
Using default value 61888511

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: 無効な引数です.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
root@ocean:/dev# fdisk sda1

Command (m for help): p

Disk sda1: 31.7 GB, 31686918144 bytes
64 heads, 32 sectors/track, 30219 cylinders, total 61888512 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6f20736b

Device Boot Start End Blocks Id System
sda1p1 2048 61888511 30943232 83 Linux

Command (m for help): q

root@ocean:/dev# mkfs.ext4 /dev/sda1
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1937712 inodes, 7736064 blocks
386803 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
237 block groups
32768 blocks per group, 32768 fragments per group
8176 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

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

root@ocean:/dev#
root@ocean:/# blkid /dev/sda1
/dev/sda1: UUID="5641c037-9c89-4865-bb7c-9fe65643c901" TYPE="ext4"