Raspberry Pi Custom Installation/Preparations

From JMK Wiki
Jump to navigation Jump to search

Partition the SD card

root@localhost ~ # parted -a optimal /dev/mmcblk0

Create GPT partition table, set unit, and list partitions

mklabel gpt
unit mib

Create new primary partition for boot and another one for LVM with the rest of the card

mkpart primary fat16 4Mib 132Mib
set 1 boot on
name 1 boot
mkpart primary 132Mib -1
set 2 lvm on
name 2 lvm

The partitions should look like this

Number  Start    End        Size       File system  Name  Flags
 1      4.00MiB  132MiB     128MiB     fat16        boot  boot, esp
 2      132MiB   122622MiB  122490MiB               lvm   lvm

Create physical volume and volume group

root@localhost ~ # pvcreate /dev/mmcblk0p2
root@localhost ~ # vgcreate rpi /dev/mmcblk0p2

Create swap partition and raspbian root

root@localhost ~ # lvcreate -L1G -nswap /dev/rpi
root@localhost ~ # lvcreate -L10G -nraspbian /dev/rpi

Format the partitions

root@localhost ~ # mkfs.vfat -nboot /dev/mmcblk0p1
root@localhost ~ # mkswap -Lswap /dev/rpi/swap
root@localhost ~ # mkfs.ext4 -Lraspbian /dev/rpi/raspbian

Double check if all is right

root@localhost ~ # pvs
  PV             VG      Fmt  Attr PSize   PFree
  /dev/mmcblk0p2 rpi     lvm2 a--  119.62g 108.62g
root@localhost ~ # vgs
  VG      #PV #LV #SN Attr   VSize   VFree
  rpi       1   2   0 wz--n- 119.62g 108.62g
root@localhost ~ # lvs
  LV       VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  raspbian rpi     -wi-a-----  10.00g
  swap     rpi     -wi-a-----   1.00g
root@localhost ~ # lsblk
mmcblk0             179:0    0 119.8G  0 disk
├─mmcblk0p1         179:1    0   128M  0 part
└─mmcblk0p2         179:2    0 119.6G  0 part
  ├─rpi-swap        253:4    0     1G  0 lvm
  └─rpi-raspbian    253:5    0    10G  0 lvm