Skip to content

4. Prepare SD card

Frank1119 edited this page Apr 6, 2019 · 7 revisions

Repartitioning the SD card

Resizing the root partition

By default, when the Pi boots for the first time, it claims all space there is on the SD card using /usr/lib/raspi-config/init_resize.sh which is run by the init= instruction in /boot/cmdline.txt, but this instruction was removed from cmdline.txt as stated in page 2 of this manual, because an extra partition has to be created. To do this, perform the following steps:

sudo sfdisk -d /dev/mmcblk0 > /tmp/partitions.txt
sudo nano /tmp/partitions.txt
sudo sed -i "/mmcblk0p2.*size/s/size=.*,/size=     8388608,/g" /tmp/partitions.txt
sudo sfdisk -n /dev/mmcblk0 < /tmp/partitions.txt
sudo partprobe /dev/mmcblk0
sudo resize2fs /dev/mmcblk0p2

This will resize the root file system to 4GB. Check with df -h

Install necessary software

sudo apt-get update sudo apt-get install ntfs-3g

Add an NTFS partition

Start fdisk interactive: sudo fdisk /dev/mmcblk0

  1. Print the existing partition table with p
  2. Create a new partition with n
  3. Make this an primary partition by entering p
  4. Accept the default partition number (3)
  5. Enter the first sector number. This is the number of the End sector of /dev/mmcblk0p2 increased by 1
  6. Accept the default last sector number. This will fill up your SD card completely
  7. Change the partition type by entering t
  8. Choose partition 3 to alter
  9. Type 7 to mak this a NTFS partition
  10. Enter w to write the partition information to disk
  11. Update the kernel tables: sudo partprobe /dev/mmcblk0

Format the newly created partition:

sudo mkntfs -Q -L CD-berry /dev/mmcblk0p3

Mount and check the partition:

sudo mount /dev/mmcblk0p3 /mnt
sudo df -h
sudo umount /mnt

On a 16GB SD card, you will see a NTFS partition with a size of about 11GB