Difference between revisions of "Expand Image to fill SD card"
Line 13: | Line 13: | ||
results in | results in | ||
<pre> | <pre> | ||
− | [sudo] password for | + | [sudo] password for jack: |
Command (m for help): | Command (m for help): | ||
Line 140: | Line 140: | ||
After you enter your password, the resize will take a few minutes. | After you enter your password, the resize will take a few minutes. | ||
<pre> | <pre> | ||
− | [sudo] password for | + | [sudo] password for jack: |
resize2fs 1.41.12 (17-May-2010) | resize2fs 1.41.12 (17-May-2010) | ||
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required | Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required |
Revision as of 13:59, 4 June 2012
Assuming you used a default image and have an SD card larger than the minimum required, the additional space on your card is not available for use by the debian operating system. The following notes show how you can make this space available.
Resources
http://elinux.org/RPi_Easy_SD_Card_Setup#Manually resizing the SD card partitions (Optional)
Expansion via the RPi CLI
sudo fdisk -cu /dev/mmcblk0
results in
[sudo] password for jack: Command (m for help):
enter 'm' to get a list of available commands we are going to use shortly
Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
Enter command: p
Command (m for help): p Disk /dev/mmcblk0: 7822 MB, 7822376960 bytes 4 heads, 32 sectors/track, 119360 cylinders, total 15278080 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: 0x000ee283 Device Boot Start End Blocks Id System /dev/mmcblk0p1 2048 155647 76800 c W95 FAT32 (LBA) /dev/mmcblk0p2 157696 3414015 1628160 83 Linux /dev/mmcblk0p3 3416064 3807231 195584 82 Linux swap / Solaris
Copy or take note on the start and end locations of these partitions.
Delete the Swap partition (3), enter 'd', then 3
Command (m for help): d Partition number (1-4): 3
Enter 'p' again to see the new table, the swap has disappeared. don't panic, none of this is permanent until the table is written
Command (m for help): p Disk /dev/mmcblk0: 7822 MB, 7822376960 bytes 4 heads, 32 sectors/track, 119360 cylinders, total 15278080 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: 0x000ee283 Device Boot Start End Blocks Id System /dev/mmcblk0p1 2048 155647 76800 c W95 FAT32 (LBA) /dev/mmcblk0p2 157696 3414015 1628160 83 Linux
Repeat to delete the main partion, enter 'd', then 2.
Now we are going to update the table with larger partitions. Enter n p 2 to create a new primary partition. When prompted enter the start location to be the same as it was originally. In this case its 157696.
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First sector (155648-15278079, default 155648): 157696 Last sector, +sectors or +size{K,M,G} (157696-15278079, default 15278079): Using default value 15278079 Command (m for help):
Enter 'p' to see the new table
Command (m for help): p Disk /dev/mmcblk0: 7822 MB, 7822376960 bytes 4 heads, 32 sectors/track, 119360 cylinders, total 15278080 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: 0x000ee283 Device Boot Start End Blocks Id System /dev/mmcblk0p1 2048 155647 76800 c W95 FAT32 (LBA) /dev/mmcblk0p2 157696 15278079 7560192 83 Linux
Now we need to write this new partition to the disk. enter 'w'.
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 16: Device or resource busy. 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.
Now you need to reboot.
sudo shutdown -r now
After the reboot, login and expand the partition using
sudo resize2fs /dev/mmcblk0p2
After you enter your password, the resize will take a few minutes.
[sudo] password for jack: resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/mmcblk0p2 to 1890048 (4k) blocks. The filesystem on /dev/mmcblk0p2 is now 1890048 blocks long.
Check the new SD capacity.
df -h
df -h Filesystem Size Used Avail Use% Mounted on tmpfs 94M 0 94M 0% /lib/init/rw udev 10M 168K 9.9M 2% /dev tmpfs 94M 0 94M 0% /dev/shm rootfs 7.2G 1.4G 5.4G 21% / /dev/mmcblk0p1 75M 34M 41M 46% /boot
Note this process deletes the swap partition but this shouldn't impact performance of the RPi.