step 1 : SD card format and partition ===================================== .. tab-set:: .. tab-item:: SD card format and partition * In this section, you are going to learn .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow * How to find the SD card device name ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow * How to delete existing partitions ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow * How to add two partitions ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow * How to format the partitons ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow * How to mount the partitons ? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Find the SD card device name ` * :ref:`Delete existing partitions ` * :ref:`Add two partitions ` * :ref:`Format the partitions ` * :ref:`Mount the partitions ` .. _prplos_rpi_3b_step1_0: .. tab-set:: .. tab-item:: Find the SD card device name * Clear the dmesg .. code-block:: c $ sudo dmesg -c * After inserting the SD card reader to the Linux desktop machine, find its device name by dmesg. .. code-block:: c $ dmesg | tail [20194.951893] usb 1-3: Manufacturer: Prolific Technology Inc. [20194.953283] pl2303 1-3:1.0: pl2303 converter detected [20194.953986] usb 1-3: pl2303 converter now attached to ttyUSB0 [20195.422420] pl2303 ttyUSB0: pl2303_get_line_request - failed: -32 [20195.422975] pl2303 ttyUSB0: pl2303_get_line_request - failed: -32 [20213.618087] mmc0: cannot verify signal voltage switch [20213.743845] mmc0: new ultra high speed SDR104 SDHC card at address aaaa [20213.744562] mmcblk0: mmc0:aaaa SC16G 14.8 GiB $ ls /dev/mmcblk0 /dev/mmcblk0 * Remove and Add SD card and check the dmesg, do ls /dev/, check output and confirm your device ID .. _prplos_rpi_3b_step1_1: .. tab-set:: .. tab-item:: Delete existing partitions * Startup fdisk in the administrative mode with the command ``sudo fdisk /dev/mmcblk0`` .. code-block:: c $ sudo fdisk /dev/mmcblk0 Welcome to fdisk (util-linux 2.31.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): * Enter ``d`` to delete any given partition name from the system. .. code-block:: c Command (m for help): d Partition number (1,2, default 2): * The next prompt will ask for the Partition number. Just press Enter to accept the default value. .. code-block:: c Partition number (1,2, default 2): Partition 2 has been deleted. Command (m for help): * Enter ``d`` to delete any given partition name from the system. .. code-block:: c Command (m for help): d Selected partition 1 Partition 1 has been deleted. Command (m for help): * Now, use the ``p`` command to print the partitions to verify. .. code-block:: c Command (m for help): p Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 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 Disklabel type: dos Disk identifier: 0x5452574f Command (m for help): * Finally, enter the ``w`` command to write the partitions out. .. code-block:: c Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. .. _prplos_rpi_3b_step1_2: .. tab-set:: .. tab-item:: Add two partitions * Startup fdisk in the administrative mode with the command ``sudo fdisk /dev/mmcblk0`` .. code-block:: c $ sudo fdisk /dev/mmcblk0 Welcome to fdisk (util-linux 2.34). Changes will remain in memory only, until you decide to write them. Be careful before using t1he write command. Command (m for help): * Within fdisk, use the ``n`` command to create a new partition. .. code-block:: c Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): * Then we enter ``p`` to specify that the new partition will be a primary partition. .. code-block:: c Select (default p): Using default response p. Partition number (1-4, default 1): * Next we select ``1`` to specify the partition number. .. code-block:: c Partition number (1-4, default 1): First sector (2048-31116287, default 2048): * The next prompt will ask for the first sector. Just press Enter to accept the default value. .. code-block:: c First sector (2048-31116287, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-31116287, default 31116287): * After that it will ask for the last sector. Give the value as 512M .. code-block:: text Last sector, +sectors or +size{K,M,G,T,P} (2048-31116287, default 31116287): +512M Created a new partition 1 of type Linux and of size 512 MiB. Partition #1 contains a vfat signature. Do you want to remove the signature? [Y]es/[N]o: Y The signature will be removed by a write command. Command (m for help): * Now you have to type ``n`` to create new partition. .. code-block:: c Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): * Then type ``p`` for making a primary partition .. code-block:: c Select (default p): Using default response p. Partition number (2-4, default 2): * Next we select ``2`` to specify the partition number. .. code-block:: c Partition number (2-4, default 2): First sector (1050624-31116287, default 1050624): * The next prompt will ask for the first sector. Just press Enter to accept the default value. .. code-block:: c First sector (1050624-31116287, default 1050624): Last sector, +sectors or +size{K,M,G,T,P} (1050624-31116287, default 31116287): * After that it will ask for the last sector. Give the value as ``512M``. .. code-block:: text Last sector, +sectors or +size{K,M,G,T,P} (1050624-31116287, default 31116287): +512M Created a new partition 2 of type 'Linux' and of size 512 MiB. Partition #2 contains a ext4 signature. Do you want to remove the signature? [Y]es/[N]o: Y The signature will be removed by a write command. Command (m for help): * Enter ``t`` to recognize specified partition table type. .. code-block:: c Command (m for help): t Partition number (1,2, default 2): * Next we select ``1`` to specify the partition number. .. code-block:: c Partition number (1,2, default 2): 1 Hex code (type L to list all codes): * Enter ``b`` to change type of partition from Linux to FAT32. .. code-block:: text Hex code (type L to list all codes): b Changed type of partition 'Linux' to 'W95 FAT32'. Command (m for help): * Now, use the ``p`` command to print the partitions to verify. .. code-block:: c Command (m for help): p Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 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 Disklabel type: dos Disk identifier: 0x5452574f Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 2048 1050623 1048576 512M b W95 FAT32 /dev/mmcblk0p2 1050624 2099199 1048576 512M 83 Linux Filesystem/RAID signature on partition 1 will be wiped. Filesystem/RAID signature on partition 2 will be wiped. Command (m for help): * Finally, enter the ``w`` command to write the partitions out. .. code-block:: c Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. .. _prplos_rpi_3b_step1_3: .. tab-set:: .. tab-item:: Format the partitions * FAT32 for boot partition .. code-block:: c $ sudo mkfs.vfat -F 32 -n boot /dev/mmcblk0p1 mkfs.fat 4.1 (2017-01-24) mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows * ext4 for root partition .. code-block:: c $ sudo mkfs.ext4 -L root /dev/mmcblk0p2 mke2fs 1.44.1 (24-Mar-2018) Discarding device blocks: done Creating filesystem with 131072 4k blocks and 32768 inodes Filesystem UUID: a88d6d66-108a-40de-b740-7c55b4850db1 Superblock backups stored on blocks: 32768, 98304 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done .. _prplos_rpi_3b_step1_4: .. tab-set:: .. tab-item:: Mount the partitions * Mount both partitions so that we can write to them. .. code-block:: c $ sudo mount /dev/mmcblk0p1 /mnt/boot $ sudo mount /dev/mmcblk0p2 /mnt/root .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Is fdisk the only command for managing partitions in Linux? .. dropdown:: See Answer * ?? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow How do I start fdisk in Linux? .. dropdown:: See Answer * ?? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow How to see the size of your Partition? .. dropdown:: See Answer * ?? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow What are all file systems that is supported by u-boot? .. dropdown:: See Answer * ?? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Why we are using the FAT32 file system here? .. dropdown:: See Answer * ?? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Can we use any other file system instead of FAT32? .. dropdown:: See Answer * ?? .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow What is the purpose of mounting ? .. dropdown:: See Answer * ??