{"id":1700,"date":"2019-11-10T12:48:56","date_gmt":"2019-11-10T17:48:56","guid":{"rendered":"http:\/\/www.xavignu.com\/?p=1700"},"modified":"2019-11-10T12:49:59","modified_gmt":"2019-11-10T17:49:59","slug":"resize-sdcard-with-parted","status":"publish","type":"post","link":"https:\/\/www.xavignu.com\/?p=1700","title":{"rendered":"Resize sdcard with parted"},"content":{"rendered":"\n<p>So I had to reinstall <a href=\"https:\/\/www.debian.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Debian<\/a> in the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Secure_Digital\" target=\"_blank\" rel=\"noopener noreferrer\">sdcard<\/a> of my <a href=\"http:\/\/www.orangepi.org\/Orange%20Pi%20Lite%202\/\" target=\"_blank\" rel=\"noopener noreferrer\">Orange Pi Lite<\/a>. Thing is original image \/ fs is only 4Gb, which on a 64Gb sdcard leaves 60Gb unused.<\/p>\n\n\n\n<p>Here is where <a href=\"https:\/\/www.gnu.org\/software\/parted\/\" target=\"_blank\" rel=\"noopener noreferrer\">parted<\/a> comes to the rescue. Easier than fdisk for me. Below example extends ext4 partition to 62Gb and creates a 2Gb swap partition.<\/p>\n\n\n\n<p><p><\/p><pre id=\"terminal\">sudo parted  \/dev\/mmcblk0 \nGNU Parted 3.2 \nUsing \/dev\/mmcblk0 \nWelcome to GNU Parted! Type 'help' to view a list of commands. (parted) print\nModel: SD BC2QT (sd\/mmc) \nDisk \/dev\/mmcblk0: 64,0GB \nSector size (logical\/physical): 512B\/512B \nPartition Table: msdos \nDisk Flags:  \n\nNumber  Start   End     Size    Type     File system  Flags  \n1      21,0MB  73,4MB  52,4MB  primary  fat16        lba  \n2      73,4MB  3743MB  3670MB  primary  ext4 \n\n(parted) resizepart\nPartition number? 2\nEnd?  [3743MB]? 62000MB\n(parted) print\nModel: SD BC2QT (sd\/mmc)\nDisk \/dev\/mmcblk0: 64,0GB \nSector size (logical\/physical): 512B\/512B \nPartition Table: msdos \nDisk Flags:  \n\nNumber  Start   End     Size    Type     File system  Flags  \n1      21,0MB  73,4MB  52,4MB  primary  fat16        lba  \n2      73,4MB  62,0GB  61,9GB  primary  ext4 \n\n(parted) mkpart                                                            Partition type?  primary\/extended? primary\nFile system type?  [ext2]? linux-swap\nStart? 62.0GB\nEnd? 64.0GB\n(parted) print\nModel: SD BC2QT (sd\/mmc)\nDisk \/dev\/mmcblk0: 64,0GB \nSector size (logical\/physical): 512B\/512B \nPartition Table: msdos \nDisk Flags:  \n\nNumber  Start   End     Size    Type     File system     Flags  \n1      21,0MB  73,4MB  52,4MB  primary  fat16           lba  \n2      73,4MB  62,0GB  61,9GB  primary  ext4  \n3      62,0GB  64,0GB  2022MB  primary  linux-swap(v1)  lba \n(parted)  \n(parted) quit \nInformation: You may need to update \/etc\/fstab. <\/pre><\/p>\n\n\n<p><!--more--><\/p>\n\n\n<p><p>Now we only need to execute e2fsck and resize2fs on the extended partition.<\/p><pre id=\"terminal\">sudo e2fsck -f \/dev\/mmcblk0p2  e2fsck 1.44.5 (15-Dec-2018) rootfs: recovering journal \nPass 1: Checking inodes, blocks, and sizes \nPass 2: Checking directory structure \nPass 3: Checking directory connectivity \nPass 4: Checking reference counts \nPass 5: Checking group summary information rootfs: 109610\/225344 files (0.2% non-contiguous), 650426\/896000 blocks \nuser@computer: ~ $ sudo resize2fs  \/dev\/mmcblk0p2  \nresize2fs 1.44.5 (15-Dec-2018) \nResizing the filesystem on \/dev\/mmcblk0p2 to 15118798 (4k) blocks. The filesystem on \/dev\/mmcblk0p2 is now 15118798 (4k) blocks long. <\/pre><\/p>\n\n\n\n<p><p>Afterwards we can insert the sdcard into the OrangePi to have a 60Gb root partition.<\/p>\n<pre id=\"terminal\">sudo fdisk -l  \nDisk \/dev\/mmcblk0: 59.6 GiB, 64021856256 bytes, 125042688 sectors Units: 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: \ndos Disk identifier: 0x00037d04 \n\nDevice         Boot     Start       End   Sectors  Size Id Type\n\/dev\/mmcblk0p1          40960    143359    102400   50M  c W95 FAT32 (LBA) \n\/dev\/mmcblk0p2         143360 121093750 120950391 57.7G 83 Linux \/dev\/mmcblk0p3      121094144 125042687   3948544  1.9G 82 Linux swap \/ Solaris <\/pre><\/p>\n\n\n\n<p><p>After OS boots we need to mkswap, activate and modify \/etc\/fstab.<\/p>\n<pre id=\"terminal\">mkswap \/dev\/mmcblk0p3; swapon \/dev\/mmcblk0p3; free -mt              \ntotal        used        free      shared  buff\/cache   available\nMem:            978         111          12          12         853         838\nSwap:          1927           0        1927\nTotal:         2906         111        1940\n<\/pre>\n[text]\n\/dev\/mmcblk0p3\tnone\tswap\tsw\t\t0\t\t0\n[\/text]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I had to reinstall Debian in the sdcard of my Orange Pi Lite. Thing is original image \/ fs is only 4Gb, which on a 64Gb sdcard leaves 60Gb unused. Here is where parted comes to the rescue. Easier than fdisk for me. Below example extends ext4 partition to 62Gb and creates a 2Gb [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[92],"tags":[56,93,107,108,109],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/pTQgt-rq","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/1700"}],"collection":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1700"}],"version-history":[{"count":20,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/1700\/revisions"}],"predecessor-version":[{"id":1765,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/1700\/revisions\/1765"}],"wp:attachment":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}