{"id":2946,"date":"2016-05-07T07:34:36","date_gmt":"2016-05-07T13:34:36","guid":{"rendered":"http:\/\/dev.iachieved.it\/iachievedit\/?p=2946"},"modified":"2020-09-05T16:27:03","modified_gmt":"2020-09-05T21:27:03","slug":"expanding-your-beaglebone-microsd-filesystem","status":"publish","type":"post","link":"https:\/\/dev.iachieved.it\/iachievedit\/expanding-your-beaglebone-microsd-filesystem\/","title":{"rendered":"Expanding your BeagleBone microSD Filesystem"},"content":{"rendered":"<p>There are a number of tutorials out there that show you how to expand a BeagleBone Black microSD-based filesystem.  Most of them were written, however, when the delivered image from <a href=\"https:\/\/beagleboard.org\/latest-images\">BeagleBoard.org<\/a> contained two partitions: one a FAT partition, the other your standard Linux partition.<\/p>\n<p>The aim of this post is to show you that indeed, you have nothing to fear expanding your BeagleBone Black partition even though there is only one (if you&#8217;re like us you get a little nervous when someone asks you to delete the partition you booted in).<\/p>\n<p><b>Editor&#8217;s Note:<\/b>  I have updated this post for use with the latest BeagleBone Black IoT images which does require attention to the starting sector.<\/p>\n<p>Let&#8217;s get started.  We&#8217;re using the <a href=\"https:\/\/debian.beagleboard.org\/images\/bone-debian-10.3-iot-armhf-2020-04-06-4gb.img.xz\">Debian 10.3 IoT 2020-04-06 4GB<\/a> image from BeagleBoard.org.  As you can see with <code>df<\/code> it&#8217;s a 4G (3.4G) filesystem, even though we just flashed it onto an 8GB microSD card:<\/p>\n<pre class=\"crayon:false\">\ndebian@beaglebone:~$ df -h \/\nFilesystem      Size  Used Avail Use% Mounted on\n\/dev\/mmcblk0p1  3.4G  1.9G  1.4G  57% \/\n<\/pre>\n<p>The filesystem is on the <code>mmcblk0<\/code> device, so we&#8217;ll use <code>fdisk<\/code> to repartition:<\/p>\n<pre class=\"crayon:false\">\ndebian@beaglebone:~$ sudo fdisk \/dev\/mmcblk0\n\nWelcome to fdisk (util-linux 2.33.1).\nChanges will remain in memory only, until you decide to write them.\nBe careful before using the write command.\n\n<\/pre>\n<p>Use the <b>p<\/b> command to <b>print<\/b> the current partition table.  As expected, we see that the device itself has 8GB of space (well, 7.4), but our only partition is 3.5G.<\/p>\n<pre class=\"crayon:false\">\nCommand (m for help): p\nDisk \/dev\/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 sectors\nUnits: sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisklabel type: dos\nDisk identifier: 0x3244345d\n\nDevice         Boot Start     End Sectors  Size Id Type\n\/dev\/mmcblk0p1 *     8192 7372799 7364608  3.5G 83 Linux\n<\/pre>\n<p>Write down the starting sector as you <em>will<\/em> need it below.  In our case it is 8192.<\/p>\n<p>Now, the &#8220;scary&#8221; part.  Enter <b>d<\/b> to delete your partition.<\/p>\n<pre class=\"crayon:false\">\nCommand (m for help): d\nSelected partition 1\nPartition 1 has been deleted.\n<\/pre>\n<p>Don&#8217;t worry, we&#8217;re adding it right back, with a size larger than the existing one.  Enter <b>n<\/b> for New partition, and then <b>p<\/b> for primary partition.<\/p>\n<pre class=\"crayon:false\">\nCommand (m for help): n\nPartition type\n   p   primary (0 primary, 0 extended, 4 free)\n   e   extended (container for logical partitions)\nSelect (default p): p\n<\/pre>\n<p>At this point hit <b>Enter<\/b> at each prompt to accept the defaults, with the exception of the <b>First Sector<\/b> which you will need the value you wrote down from above.  When prompted whether or not you want to remove the ext4 signature, type <b>N<\/b>.<\/p>\n<pre class=\"crayon:false\">\nPartition number (1-4, default 1): \nFirst sector (2048-15523839, default 2048): 8192\nLast sector, +\/-sectors or +\/-size{K,M,G,T,P} (8192-15523839, default 15523839): \n\nCreated a new partition 1 of type 'Linux' and of size 7.4 GiB.\nPartition #1 contains a ext4 signature.\n\nDo you want to remove the signature? [Y]es\/[N]o: N\n<\/pre>\n<p>Use <b>p<\/b> once more to print out the partition table:<\/p>\n<pre class=\"crayon:false\">\nCommand (m for help): p\nDisk \/dev\/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 sectors\nUnits: sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisklabel type: dos\nDisk identifier: 0x3244345d\n\nDevice         Boot Start      End  Sectors  Size Id Type\n\/dev\/mmcblk0p1       8192 15523839 15515648  7.4G 83 Linux\n<\/pre>\n<p>Now press <b>w<\/b> (for <b>write<\/b>) and get another scary warning:<\/p>\n<pre class=\"crayon:false\">\nThe partition table has been altered.\nCalling ioctl() to re-read partition table.\nRe-reading the partition table failed.: Device or resource busy\n\nThe 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).\n<\/pre>\n<p>You can now use <code>resize2fs<\/code> to resize your partition:<\/p>\n<pre class=\"crayon:false\">\ndebian@beaglebone:~$ sudo resize2fs \/dev\/mmcblk0p1\nresize2fs 1.42.12 (29-Aug-2014)\nFilesystem at \/dev\/mmcblk0p1 is mounted on \/; on-line resizing required\nold_desc_blocks = 1, new_desc_blocks = 1\nThe filesystem on \/dev\/mmcblk0p1 is now 1940224 (4k) blocks long.\n<\/pre>\n<p>Use <code>df -h \/<\/code> again and verify that you have reclaimed the unused space on your SD card.<\/p>\n<pre class=\"crayon:false\">\nFilesystem      Size  Used Avail Use% Mounted on\n\/dev\/mmcblk0p1  7.3G  1.9G  5.1G  27% \/\n<\/pre>\n<p>And that&#8217;s it!  No reboot required, and you can enjoy the full capacity of your microSD card.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are a number of tutorials out there that show you how to expand a BeagleBone Black microSD-based filesystem. Most of them were written, however, when the delivered image from BeagleBoard.org contained two partitions: one a FAT partition, the other your standard Linux partition. The aim of this post is to show you that indeed, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2944,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-2946","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-beaglebone"],"_links":{"self":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/2946"}],"collection":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/comments?post=2946"}],"version-history":[{"count":13,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/2946\/revisions"}],"predecessor-version":[{"id":4179,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/2946\/revisions\/4179"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media\/2944"}],"wp:attachment":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media?parent=2946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/categories?post=2946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/tags?post=2946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}