# Raspberry Pi Disk Drives

The output from the <mark style="color:yellow;">`sudo fdisk -l`</mark> command you provided displays detailed information about all the disk drives currently recognized by your Raspberry Pi's operating system.&#x20;

```bash
sudo fdisk -l
```

Here's a breakdown of what this output tells you:

### <mark style="color:blue;">RAM Disks</mark>

* <mark style="color:green;">**/dev/ram0 to /dev/ram15**</mark><mark style="color:green;">:</mark> These entries represent RAM disks, which are block devices mapped to segments of your system's RAM. They are shown with a size of 4 MiB each, and a total of 16 such devices are listed. These are used by the system for operations that require fast data access, temporary storage, or testing purposes. Each RAM disk has:
  * **Sector size (logical/physical)**: 512 bytes / 16384 bytes
  * **I/O size (minimum/optimal)**: 16384 bytes
  * **Total sectors**: 8192 sectors

### <mark style="color:blue;">microSD Card</mark>

* <mark style="color:green;">**/dev/mmcblk0**</mark><mark style="color:green;">:</mark> This device represents your microSD card, which is the primary storage device for Raspberry Pi. It is shown with a total size of 238.75 GiB.&#x20;
* This is typical for a Raspberry Pi setup as the microSD card often contains the operating system and user data.
  * **Sector size (logical/physical)**: 512 bytes
  * **I/O size (minimum/optimal)**: 512 bytes
  * **Total sectors**: 500695040 sectors
  * This suggests that the <mark style="color:yellow;">entire microSD card is treated as a single block device without separate partitions listed under it,</mark> which might mean it has a basic data layout or is being read as a whole unit.

### <mark style="color:blue;">USB Flash Drive</mark>

* <mark style="color:green;">**/dev/sda**</mark><mark style="color:green;">:</mark> This is a USB Flash Drive connected to the Raspberry Pi, showing a total capacity of 28.91 GiB. This drive has a DOS disklabel type and contains two partitions:
  * <mark style="color:green;">**/dev/sda1**</mark><mark style="color:green;">:</mark>
    * **Type**: W95 FAT32 (LBA)
    * **Size**: 512M
    * This is likely a boot partition, formatted with the FAT32 filesystem, commonly used for Raspberry Pi boot partitions or for general compatibility with various operating systems.
  * <mark style="color:green;">**/dev/sda2**</mark><mark style="color:green;">:</mark>
    * **Type**: Linux
    * **Size**: 28.4G
    * This is a larger partition likely used for Linux files and data storage.

### <mark style="color:blue;">MicroSD Card</mark>

To properly analyse the microSD card on your Raspberry Pi, you can use the <mark style="color:yellow;">`sudo fdisk -l`</mark> command to identify the device name and then use additional commands to gather more information.&#x20;

Here's how you can analyse the microSD card:

Identify the microSD card device:

```bash
sudo fdisk -l 
```

#### <mark style="color:purple;">Output</mark>

```
Disk /dev/mmcblk0: 238.75 GiB, 256355860480 bytes, 500695040 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
```

Based on the output you provided, the microSD card is represented by the device <mark style="color:yellow;">`/dev/mmcblk0`</mark>.&#x20;

It has a total size of 238.75 GiB.

#### <mark style="color:green;">Find Partition Numbers</mark>

To find the actual partition numbers for your microSD card, you can use the `lsblk` command, which lists block devices and their partitions. Here's how you can find the partition numbers:

Run the following command:

```sh
lsblk
```

This command will <mark style="color:yellow;">display a tree-like output showing the block devices and their partitions</mark>.

Look for the entry corresponding to your microSD card (usually `/dev/mmcblk0`).

#### <mark style="color:purple;">Output</mark>

```sh
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda       8:0    1  28.9G  0 disk 
├─sda1    8:1    1   512M  0 part /boot/firmware
└─sda2    8:2    1  28.4G  0 part /
mmcblk0 179:0    0 238.8G  0 disk   
```

Check the <mark style="color:yellow;">partition layout</mark>

```bash
sudo parted /dev/mmcblk0 print
```

#### <mark style="color:purple;">Output</mark>

```basic
Model: SD EE4S5 (sd/mmc)
Disk /dev/mmcblk0: 256GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End    Size   File system  Flags
 1      0.00B  256GB  256GB  ext4
```

This command displays the <mark style="color:yellow;">partition table of the microSD card,</mark> showing the partition numbers, start and end positions, sizes, and file system types.

Check the file system usage:

```bash
df -h /dev/mmcblk0*
```

#### <mark style="color:purple;">Output</mark>

```bash
Filesystem      Size  Used Avail Use% Mounted on
udev            3.8G     0  3.8G   0% /dev
```

This command displays the file system disk space usage for partitions on the microSD card.

It shows the <mark style="color:yellow;">total size, used space, available space, and mount points of each partition.</mark>

Check the file system type:

```bash
sudo blkid /dev/mmcblk0*
```

This command displays the <mark style="color:yellow;">file system type and UUID</mark> (Universally Unique Identifier) of each partition on the microSD card.

Check the file system health (this is if your MicroSD card has partitions)

```bash
sudo fsck /dev/mmcblk0p1
sudo fsck /dev/mmcblk0p2
```

Replace `mmcblk0p1` and `mmcblk0p2` with the actual partition numbers of your microSD card.&#x20;

The `fsck` command checks the file system integrity and can fix minor issues.

Analyse disk usage visually:

<pre class="language-bash"><code class="lang-bash"><strong>sudo apt install ncdu
</strong></code></pre>

```bash
sudo ncdu /mount/point
```

Replace <mark style="color:yellow;">`/mount/point`</mark> with the actual mount point of the microSD card partition you want to analyse.&#x20;

<mark style="color:yellow;">`ncdu`</mark> provides an interactive way to explore the disk usage of directories and files on the microSD card.

Check for bad blocks

```sh
sudo badblocks -v /dev/mmcblk0
```

This command scans the microSD card for bad blocks, which are physical defects on the storage media. It's a destructive test, so make sure to have a backup of your data before running it.

By following these steps, you can gather detailed information about your microSD card, including its partitions, file system types, disk space usage, and health status. This information can help you understand how your Raspberry Pi's storage is organized and identify any potential issues.

Remember to be cautious when running commands with `sudo` and double-check the device names and mount points to avoid accidentally modifying or damaging your system.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://education.raspberrypiaustralia.online/storage/raspberry-pi-disk-drives.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
