Increasing partition of a SD card

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have a SD card that has two partitions /dev/sdb1 that holds the boot sector, and /dev/sdb2 that holds the OS. The card still has unpartitioned free space.



How can I take all the unpartitioned free space and add it to /dev/sdb2 without formatting the drive? I want to do this in on command line only










share|improve this question























  • See man resize2fs.
    – goldilocks
    Sep 23 '15 at 19:04










  • The sequence of steps is: 1. resize the partition, using any appropriate tool (fdisk, cfdisk, gdisk, &c.), and 2. resize the filesystem, using resize2fs (most likely; there are different tools for different FSs). If you want, you can use gparted to do it automatically.
    – Tom Hunt
    Sep 23 '15 at 20:17










  • @goldilocks, I did use resize2fs but it says I am already at full block. When I run parted /dev/sdd/ print free, I have a whole chunk of Free Space. I want to allocate that to my parition
    – Kousha
    Sep 23 '15 at 20:48










  • Whoops! You have to increase the partition first w/ fdisk. Resize2fs resizes the filesystem inside. I don't have time to write a complete answer right now, but the fdisk thing means "deleting" the partition then creating it again with the exact same starting block, but then a greater final size. It's pretty straightforward, but you may want to look for an intro to fdisk or something if you haven't used it before.
    – goldilocks
    Sep 23 '15 at 21:14














up vote
0
down vote

favorite












I have a SD card that has two partitions /dev/sdb1 that holds the boot sector, and /dev/sdb2 that holds the OS. The card still has unpartitioned free space.



How can I take all the unpartitioned free space and add it to /dev/sdb2 without formatting the drive? I want to do this in on command line only










share|improve this question























  • See man resize2fs.
    – goldilocks
    Sep 23 '15 at 19:04










  • The sequence of steps is: 1. resize the partition, using any appropriate tool (fdisk, cfdisk, gdisk, &c.), and 2. resize the filesystem, using resize2fs (most likely; there are different tools for different FSs). If you want, you can use gparted to do it automatically.
    – Tom Hunt
    Sep 23 '15 at 20:17










  • @goldilocks, I did use resize2fs but it says I am already at full block. When I run parted /dev/sdd/ print free, I have a whole chunk of Free Space. I want to allocate that to my parition
    – Kousha
    Sep 23 '15 at 20:48










  • Whoops! You have to increase the partition first w/ fdisk. Resize2fs resizes the filesystem inside. I don't have time to write a complete answer right now, but the fdisk thing means "deleting" the partition then creating it again with the exact same starting block, but then a greater final size. It's pretty straightforward, but you may want to look for an intro to fdisk or something if you haven't used it before.
    – goldilocks
    Sep 23 '15 at 21:14












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a SD card that has two partitions /dev/sdb1 that holds the boot sector, and /dev/sdb2 that holds the OS. The card still has unpartitioned free space.



How can I take all the unpartitioned free space and add it to /dev/sdb2 without formatting the drive? I want to do this in on command line only










share|improve this question















I have a SD card that has two partitions /dev/sdb1 that holds the boot sector, and /dev/sdb2 that holds the OS. The card still has unpartitioned free space.



How can I take all the unpartitioned free space and add it to /dev/sdb2 without formatting the drive? I want to do this in on command line only







linux ubuntu partition fsck






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 23 '15 at 19:02

























asked Sep 23 '15 at 18:55









Kousha

285316




285316











  • See man resize2fs.
    – goldilocks
    Sep 23 '15 at 19:04










  • The sequence of steps is: 1. resize the partition, using any appropriate tool (fdisk, cfdisk, gdisk, &c.), and 2. resize the filesystem, using resize2fs (most likely; there are different tools for different FSs). If you want, you can use gparted to do it automatically.
    – Tom Hunt
    Sep 23 '15 at 20:17










  • @goldilocks, I did use resize2fs but it says I am already at full block. When I run parted /dev/sdd/ print free, I have a whole chunk of Free Space. I want to allocate that to my parition
    – Kousha
    Sep 23 '15 at 20:48










  • Whoops! You have to increase the partition first w/ fdisk. Resize2fs resizes the filesystem inside. I don't have time to write a complete answer right now, but the fdisk thing means "deleting" the partition then creating it again with the exact same starting block, but then a greater final size. It's pretty straightforward, but you may want to look for an intro to fdisk or something if you haven't used it before.
    – goldilocks
    Sep 23 '15 at 21:14
















  • See man resize2fs.
    – goldilocks
    Sep 23 '15 at 19:04










  • The sequence of steps is: 1. resize the partition, using any appropriate tool (fdisk, cfdisk, gdisk, &c.), and 2. resize the filesystem, using resize2fs (most likely; there are different tools for different FSs). If you want, you can use gparted to do it automatically.
    – Tom Hunt
    Sep 23 '15 at 20:17










  • @goldilocks, I did use resize2fs but it says I am already at full block. When I run parted /dev/sdd/ print free, I have a whole chunk of Free Space. I want to allocate that to my parition
    – Kousha
    Sep 23 '15 at 20:48










  • Whoops! You have to increase the partition first w/ fdisk. Resize2fs resizes the filesystem inside. I don't have time to write a complete answer right now, but the fdisk thing means "deleting" the partition then creating it again with the exact same starting block, but then a greater final size. It's pretty straightforward, but you may want to look for an intro to fdisk or something if you haven't used it before.
    – goldilocks
    Sep 23 '15 at 21:14















See man resize2fs.
– goldilocks
Sep 23 '15 at 19:04




See man resize2fs.
– goldilocks
Sep 23 '15 at 19:04












The sequence of steps is: 1. resize the partition, using any appropriate tool (fdisk, cfdisk, gdisk, &c.), and 2. resize the filesystem, using resize2fs (most likely; there are different tools for different FSs). If you want, you can use gparted to do it automatically.
– Tom Hunt
Sep 23 '15 at 20:17




The sequence of steps is: 1. resize the partition, using any appropriate tool (fdisk, cfdisk, gdisk, &c.), and 2. resize the filesystem, using resize2fs (most likely; there are different tools for different FSs). If you want, you can use gparted to do it automatically.
– Tom Hunt
Sep 23 '15 at 20:17












@goldilocks, I did use resize2fs but it says I am already at full block. When I run parted /dev/sdd/ print free, I have a whole chunk of Free Space. I want to allocate that to my parition
– Kousha
Sep 23 '15 at 20:48




@goldilocks, I did use resize2fs but it says I am already at full block. When I run parted /dev/sdd/ print free, I have a whole chunk of Free Space. I want to allocate that to my parition
– Kousha
Sep 23 '15 at 20:48












Whoops! You have to increase the partition first w/ fdisk. Resize2fs resizes the filesystem inside. I don't have time to write a complete answer right now, but the fdisk thing means "deleting" the partition then creating it again with the exact same starting block, but then a greater final size. It's pretty straightforward, but you may want to look for an intro to fdisk or something if you haven't used it before.
– goldilocks
Sep 23 '15 at 21:14




Whoops! You have to increase the partition first w/ fdisk. Resize2fs resizes the filesystem inside. I don't have time to write a complete answer right now, but the fdisk thing means "deleting" the partition then creating it again with the exact same starting block, but then a greater final size. It's pretty straightforward, but you may want to look for an intro to fdisk or something if you haven't used it before.
– goldilocks
Sep 23 '15 at 21:14










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










Ended up using the following. Assuming the disk I want to expand is /dev/sdd and has two partitions /dev/sdd1 and /dev/sdd2, and I want to increase /dev/sdd2.



umount /dev/sdd2
sudo parted /dev/sdd resizepart 2 -- -1
sudo e2fsck -f /dev/sdd2
sudo resize2fs /dev/sdd2


In this example, I wanted to increase to the maximum volume (hence -- -1 as argument of resizepart. If you want to resize to a specific size, I suggest you first run



sudo parted /dev/sdd unit s print free


This should print something similar to



Number Start End Size Type File system Flags
63s 2047s 1985s Free Space
1 2048s 32767s 30720s primary fat16 boot, lba
2 32768s 5119999s 5087232s primary ext2
5120000s 15728639s 10608640s Free Space


Say you want to expand to sector 10120000s (that's somewhere between the start/end of my free space 5120000s to 15728639s. In that case you run



umount /dev/sdd2
sudo parted /dev/sdd resizepart 2 10120000s
sudo e2fsck -f /dev/sdd2
sudo resize2fs /dev/sdd2


Hope this helps out somebody else as well.






share|improve this answer






















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f231643%2fincreasing-partition-of-a-sd-card%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    Ended up using the following. Assuming the disk I want to expand is /dev/sdd and has two partitions /dev/sdd1 and /dev/sdd2, and I want to increase /dev/sdd2.



    umount /dev/sdd2
    sudo parted /dev/sdd resizepart 2 -- -1
    sudo e2fsck -f /dev/sdd2
    sudo resize2fs /dev/sdd2


    In this example, I wanted to increase to the maximum volume (hence -- -1 as argument of resizepart. If you want to resize to a specific size, I suggest you first run



    sudo parted /dev/sdd unit s print free


    This should print something similar to



    Number Start End Size Type File system Flags
    63s 2047s 1985s Free Space
    1 2048s 32767s 30720s primary fat16 boot, lba
    2 32768s 5119999s 5087232s primary ext2
    5120000s 15728639s 10608640s Free Space


    Say you want to expand to sector 10120000s (that's somewhere between the start/end of my free space 5120000s to 15728639s. In that case you run



    umount /dev/sdd2
    sudo parted /dev/sdd resizepart 2 10120000s
    sudo e2fsck -f /dev/sdd2
    sudo resize2fs /dev/sdd2


    Hope this helps out somebody else as well.






    share|improve this answer


























      up vote
      1
      down vote



      accepted










      Ended up using the following. Assuming the disk I want to expand is /dev/sdd and has two partitions /dev/sdd1 and /dev/sdd2, and I want to increase /dev/sdd2.



      umount /dev/sdd2
      sudo parted /dev/sdd resizepart 2 -- -1
      sudo e2fsck -f /dev/sdd2
      sudo resize2fs /dev/sdd2


      In this example, I wanted to increase to the maximum volume (hence -- -1 as argument of resizepart. If you want to resize to a specific size, I suggest you first run



      sudo parted /dev/sdd unit s print free


      This should print something similar to



      Number Start End Size Type File system Flags
      63s 2047s 1985s Free Space
      1 2048s 32767s 30720s primary fat16 boot, lba
      2 32768s 5119999s 5087232s primary ext2
      5120000s 15728639s 10608640s Free Space


      Say you want to expand to sector 10120000s (that's somewhere between the start/end of my free space 5120000s to 15728639s. In that case you run



      umount /dev/sdd2
      sudo parted /dev/sdd resizepart 2 10120000s
      sudo e2fsck -f /dev/sdd2
      sudo resize2fs /dev/sdd2


      Hope this helps out somebody else as well.






      share|improve this answer
























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        Ended up using the following. Assuming the disk I want to expand is /dev/sdd and has two partitions /dev/sdd1 and /dev/sdd2, and I want to increase /dev/sdd2.



        umount /dev/sdd2
        sudo parted /dev/sdd resizepart 2 -- -1
        sudo e2fsck -f /dev/sdd2
        sudo resize2fs /dev/sdd2


        In this example, I wanted to increase to the maximum volume (hence -- -1 as argument of resizepart. If you want to resize to a specific size, I suggest you first run



        sudo parted /dev/sdd unit s print free


        This should print something similar to



        Number Start End Size Type File system Flags
        63s 2047s 1985s Free Space
        1 2048s 32767s 30720s primary fat16 boot, lba
        2 32768s 5119999s 5087232s primary ext2
        5120000s 15728639s 10608640s Free Space


        Say you want to expand to sector 10120000s (that's somewhere between the start/end of my free space 5120000s to 15728639s. In that case you run



        umount /dev/sdd2
        sudo parted /dev/sdd resizepart 2 10120000s
        sudo e2fsck -f /dev/sdd2
        sudo resize2fs /dev/sdd2


        Hope this helps out somebody else as well.






        share|improve this answer














        Ended up using the following. Assuming the disk I want to expand is /dev/sdd and has two partitions /dev/sdd1 and /dev/sdd2, and I want to increase /dev/sdd2.



        umount /dev/sdd2
        sudo parted /dev/sdd resizepart 2 -- -1
        sudo e2fsck -f /dev/sdd2
        sudo resize2fs /dev/sdd2


        In this example, I wanted to increase to the maximum volume (hence -- -1 as argument of resizepart. If you want to resize to a specific size, I suggest you first run



        sudo parted /dev/sdd unit s print free


        This should print something similar to



        Number Start End Size Type File system Flags
        63s 2047s 1985s Free Space
        1 2048s 32767s 30720s primary fat16 boot, lba
        2 32768s 5119999s 5087232s primary ext2
        5120000s 15728639s 10608640s Free Space


        Say you want to expand to sector 10120000s (that's somewhere between the start/end of my free space 5120000s to 15728639s. In that case you run



        umount /dev/sdd2
        sudo parted /dev/sdd resizepart 2 10120000s
        sudo e2fsck -f /dev/sdd2
        sudo resize2fs /dev/sdd2


        Hope this helps out somebody else as well.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 23 at 21:28









        Community

        1




        1










        answered Sep 23 '15 at 21:21









        Kousha

        285316




        285316



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f231643%2fincreasing-partition-of-a-sd-card%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown






            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay