How to move a partition in GNU/Linux?












14















How to move a partition to the beginning of the disk a bit? Parted wants a filesystem for some reason (I don't know why), I want just to shift all sectors left...



r@l:15:32:45:~# parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: HGST HTS 541010A9E680 (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 1049kB 32.2GB 32.2GB primary fat32
2 32.2GB 37.6GB 5360MB primary
3 37.6GB 1000GB 963GB primary

(parted) move 3
WARNING: you are attempting to use parted to operate on (move) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs. We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Error: Could not detect file system.









share|improve this question

























  • Are you using the partitions without FS? You can just set the FS to anyone with fdisk and then move them.

    – Peter
    Jan 24 '13 at 13:10











  • Thus is actually a LUKS container. But I don't think a partition mover should ever look inside the filesystem.

    – Vi.
    Jan 24 '13 at 13:25











  • gparted did it well for me in a simular situation.

    – palacsint
    Oct 11 '17 at 11:49











  • Maybe finally the in the end they have implemented this?

    – Vi.
    Oct 11 '17 at 17:18











  • @Vi. I don't think gparted can do this yet (no LUKS support afaik), however KDE Partition Manager can and it's fantastically simple these days, see here

    – Sam3000
    Jul 28 '18 at 21:47


















14















How to move a partition to the beginning of the disk a bit? Parted wants a filesystem for some reason (I don't know why), I want just to shift all sectors left...



r@l:15:32:45:~# parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: HGST HTS 541010A9E680 (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 1049kB 32.2GB 32.2GB primary fat32
2 32.2GB 37.6GB 5360MB primary
3 37.6GB 1000GB 963GB primary

(parted) move 3
WARNING: you are attempting to use parted to operate on (move) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs. We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Error: Could not detect file system.









share|improve this question

























  • Are you using the partitions without FS? You can just set the FS to anyone with fdisk and then move them.

    – Peter
    Jan 24 '13 at 13:10











  • Thus is actually a LUKS container. But I don't think a partition mover should ever look inside the filesystem.

    – Vi.
    Jan 24 '13 at 13:25











  • gparted did it well for me in a simular situation.

    – palacsint
    Oct 11 '17 at 11:49











  • Maybe finally the in the end they have implemented this?

    – Vi.
    Oct 11 '17 at 17:18











  • @Vi. I don't think gparted can do this yet (no LUKS support afaik), however KDE Partition Manager can and it's fantastically simple these days, see here

    – Sam3000
    Jul 28 '18 at 21:47
















14












14








14


6






How to move a partition to the beginning of the disk a bit? Parted wants a filesystem for some reason (I don't know why), I want just to shift all sectors left...



r@l:15:32:45:~# parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: HGST HTS 541010A9E680 (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 1049kB 32.2GB 32.2GB primary fat32
2 32.2GB 37.6GB 5360MB primary
3 37.6GB 1000GB 963GB primary

(parted) move 3
WARNING: you are attempting to use parted to operate on (move) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs. We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Error: Could not detect file system.









share|improve this question
















How to move a partition to the beginning of the disk a bit? Parted wants a filesystem for some reason (I don't know why), I want just to shift all sectors left...



r@l:15:32:45:~# parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: HGST HTS 541010A9E680 (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 1049kB 32.2GB 32.2GB primary fat32
2 32.2GB 37.6GB 5360MB primary
3 37.6GB 1000GB 963GB primary

(parted) move 3
WARNING: you are attempting to use parted to operate on (move) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs. We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Error: Could not detect file system.






linux partitioning






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 24 '13 at 13:09









Hennes

59k792141




59k792141










asked Jan 24 '13 at 12:35









Vi.Vi.

7,7691982163




7,7691982163













  • Are you using the partitions without FS? You can just set the FS to anyone with fdisk and then move them.

    – Peter
    Jan 24 '13 at 13:10











  • Thus is actually a LUKS container. But I don't think a partition mover should ever look inside the filesystem.

    – Vi.
    Jan 24 '13 at 13:25











  • gparted did it well for me in a simular situation.

    – palacsint
    Oct 11 '17 at 11:49











  • Maybe finally the in the end they have implemented this?

    – Vi.
    Oct 11 '17 at 17:18











  • @Vi. I don't think gparted can do this yet (no LUKS support afaik), however KDE Partition Manager can and it's fantastically simple these days, see here

    – Sam3000
    Jul 28 '18 at 21:47





















  • Are you using the partitions without FS? You can just set the FS to anyone with fdisk and then move them.

    – Peter
    Jan 24 '13 at 13:10











  • Thus is actually a LUKS container. But I don't think a partition mover should ever look inside the filesystem.

    – Vi.
    Jan 24 '13 at 13:25











  • gparted did it well for me in a simular situation.

    – palacsint
    Oct 11 '17 at 11:49











  • Maybe finally the in the end they have implemented this?

    – Vi.
    Oct 11 '17 at 17:18











  • @Vi. I don't think gparted can do this yet (no LUKS support afaik), however KDE Partition Manager can and it's fantastically simple these days, see here

    – Sam3000
    Jul 28 '18 at 21:47



















Are you using the partitions without FS? You can just set the FS to anyone with fdisk and then move them.

– Peter
Jan 24 '13 at 13:10





Are you using the partitions without FS? You can just set the FS to anyone with fdisk and then move them.

– Peter
Jan 24 '13 at 13:10













Thus is actually a LUKS container. But I don't think a partition mover should ever look inside the filesystem.

– Vi.
Jan 24 '13 at 13:25





Thus is actually a LUKS container. But I don't think a partition mover should ever look inside the filesystem.

– Vi.
Jan 24 '13 at 13:25













gparted did it well for me in a simular situation.

– palacsint
Oct 11 '17 at 11:49





gparted did it well for me in a simular situation.

– palacsint
Oct 11 '17 at 11:49













Maybe finally the in the end they have implemented this?

– Vi.
Oct 11 '17 at 17:18





Maybe finally the in the end they have implemented this?

– Vi.
Oct 11 '17 at 17:18













@Vi. I don't think gparted can do this yet (no LUKS support afaik), however KDE Partition Manager can and it's fantastically simple these days, see here

– Sam3000
Jul 28 '18 at 21:47







@Vi. I don't think gparted can do this yet (no LUKS support afaik), however KDE Partition Manager can and it's fantastically simple these days, see here

– Sam3000
Jul 28 '18 at 21:47












3 Answers
3






active

oldest

votes


















1














sfdisk, which intents to be a scriptable fdisk, has since some version the --move-data option. Example from their man page:



echo '+100M,' | sfdisk --move-data /dev/sdc -N 1





share|improve this answer































    14














    Manual way with dd and fdisk:



    # fdisk -l /dev/sdb | grep sdb3
    /dev/sdb3 73402368 1953525167 940061400 83 Linux

    # fdisk /dev/sdb
    Command (m for help): d
    Partition number (1-4): 3
    Command (m for help): n
    Partition number (1-4, default 3): 3
    First sector (73385984-1953525167, default 73385984):
    Using default value 73385984
    Last sector, +sectors or +size{K,M,G} (73385984-1953525167, default 1953525167):
    Using default value 1953525167
    Command (m for help): w
    The partition table has been altered!

    # fdisk -l /dev/sdb | grep sdb3
    /dev/sdb3 73385984 1953525167 940069592 83 Linux

    # dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 count=100 skip=$((73402368-73385984)) seek=0 2> /dev/null | file -s -
    /dev/stdin: LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f

    # dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 skip=$((73402368-73385984)) seek=0 of=/dev/sdb3

    # file -s /dev/sdb3
    /dev/sdb3: sticky LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f


    Now waiting for about 2h. (more looks more like 18h...)



    Note: this only moves data back, not forward.



    Pausing:



    # pidof dd
    907
    # kill -STOP 907
    # cat /proc/907/fdinfo/1
    pos: 586921398272
    flags: 0100001

    # kill -9 907

    remember 586921398272/512 = 1146330856


    Resuming:



    dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3  skip=$((1146330856+73402368-73385984)) seek=1146330856 of=/dev/sdb3





    share|improve this answer





















    • 2





      Lifesaver! Did anyone try to use a larger bs value (for speed reasons)?

      – David Balažic
      Nov 22 '13 at 0:24











    • Ensure you recalculated the values appropriately in case of other bs size.

      – Vi.
      Nov 25 '13 at 12:33






    • 3





      why not dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb skip=73402368 seek=0 of=/dev/sdb3 ? this way it, should work even f start of old sdb3 in not inside new sdb3

      – solsTiCe
      Jun 10 '15 at 14:27













    • @solsTiCe, What is the difference between your command and my command?

      – Vi.
      Jun 10 '15 at 16:36






    • 3





      A larger bs didn't help me on its own, however bs=1M iflag=direct oflag=direct did. Went from 40 MB/s to 400 MB/s on my SSD. Also, use status=progress

      – Aleksandr Dubinsky
      Mar 23 '17 at 9:42





















    2














    You can always use dd.




    • Boot from a liveCD (or any other way which makes sure the partition is not mounted)


    • dd if=/dev/sdc2 of=somefile bs=1M to create a copy of the partition on a file.

    • fdisk (or whatever you like) to delete the partition

    • fdisk (or whatever you like) to create the partition in your desired place.


    • dd of=/dev/sdc2 if=somefile bs=1M to restore the contents from file.






    share|improve this answer
























    • How to do it in-place? This partition is almost as large as all other HDDs in my home taked together.

      – Vi.
      Jan 24 '13 at 13:24













    • Can I do something like dd if=/dev/sdb of=/dev/sdb bs=512 skip=N seek=M?

      – Vi.
      Jan 24 '13 at 13:26











    • Might be able tom but test it first. Esp. if you have no backup of the data on the partition. (Also note that if you do have a backup then there are way simpler solutions).

      – Hennes
      Jan 24 '13 at 13:40






    • 3





      @Vi. This correct, first response of an answer deserves no one's down-vote because this "do it in place" requirement exists nowhere in the question.

      – zero2cx
      Jan 15 '17 at 16:40











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fsuperuser.com%2fquestions%2f541067%2fhow-to-move-a-partition-in-gnu-linux%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    sfdisk, which intents to be a scriptable fdisk, has since some version the --move-data option. Example from their man page:



    echo '+100M,' | sfdisk --move-data /dev/sdc -N 1





    share|improve this answer




























      1














      sfdisk, which intents to be a scriptable fdisk, has since some version the --move-data option. Example from their man page:



      echo '+100M,' | sfdisk --move-data /dev/sdc -N 1





      share|improve this answer


























        1












        1








        1







        sfdisk, which intents to be a scriptable fdisk, has since some version the --move-data option. Example from their man page:



        echo '+100M,' | sfdisk --move-data /dev/sdc -N 1





        share|improve this answer













        sfdisk, which intents to be a scriptable fdisk, has since some version the --move-data option. Example from their man page:



        echo '+100M,' | sfdisk --move-data /dev/sdc -N 1






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 5 at 17:11









        gimpfgimpf

        1262




        1262

























            14














            Manual way with dd and fdisk:



            # fdisk -l /dev/sdb | grep sdb3
            /dev/sdb3 73402368 1953525167 940061400 83 Linux

            # fdisk /dev/sdb
            Command (m for help): d
            Partition number (1-4): 3
            Command (m for help): n
            Partition number (1-4, default 3): 3
            First sector (73385984-1953525167, default 73385984):
            Using default value 73385984
            Last sector, +sectors or +size{K,M,G} (73385984-1953525167, default 1953525167):
            Using default value 1953525167
            Command (m for help): w
            The partition table has been altered!

            # fdisk -l /dev/sdb | grep sdb3
            /dev/sdb3 73385984 1953525167 940069592 83 Linux

            # dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 count=100 skip=$((73402368-73385984)) seek=0 2> /dev/null | file -s -
            /dev/stdin: LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f

            # dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 skip=$((73402368-73385984)) seek=0 of=/dev/sdb3

            # file -s /dev/sdb3
            /dev/sdb3: sticky LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f


            Now waiting for about 2h. (more looks more like 18h...)



            Note: this only moves data back, not forward.



            Pausing:



            # pidof dd
            907
            # kill -STOP 907
            # cat /proc/907/fdinfo/1
            pos: 586921398272
            flags: 0100001

            # kill -9 907

            remember 586921398272/512 = 1146330856


            Resuming:



            dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3  skip=$((1146330856+73402368-73385984)) seek=1146330856 of=/dev/sdb3





            share|improve this answer





















            • 2





              Lifesaver! Did anyone try to use a larger bs value (for speed reasons)?

              – David Balažic
              Nov 22 '13 at 0:24











            • Ensure you recalculated the values appropriately in case of other bs size.

              – Vi.
              Nov 25 '13 at 12:33






            • 3





              why not dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb skip=73402368 seek=0 of=/dev/sdb3 ? this way it, should work even f start of old sdb3 in not inside new sdb3

              – solsTiCe
              Jun 10 '15 at 14:27













            • @solsTiCe, What is the difference between your command and my command?

              – Vi.
              Jun 10 '15 at 16:36






            • 3





              A larger bs didn't help me on its own, however bs=1M iflag=direct oflag=direct did. Went from 40 MB/s to 400 MB/s on my SSD. Also, use status=progress

              – Aleksandr Dubinsky
              Mar 23 '17 at 9:42


















            14














            Manual way with dd and fdisk:



            # fdisk -l /dev/sdb | grep sdb3
            /dev/sdb3 73402368 1953525167 940061400 83 Linux

            # fdisk /dev/sdb
            Command (m for help): d
            Partition number (1-4): 3
            Command (m for help): n
            Partition number (1-4, default 3): 3
            First sector (73385984-1953525167, default 73385984):
            Using default value 73385984
            Last sector, +sectors or +size{K,M,G} (73385984-1953525167, default 1953525167):
            Using default value 1953525167
            Command (m for help): w
            The partition table has been altered!

            # fdisk -l /dev/sdb | grep sdb3
            /dev/sdb3 73385984 1953525167 940069592 83 Linux

            # dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 count=100 skip=$((73402368-73385984)) seek=0 2> /dev/null | file -s -
            /dev/stdin: LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f

            # dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 skip=$((73402368-73385984)) seek=0 of=/dev/sdb3

            # file -s /dev/sdb3
            /dev/sdb3: sticky LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f


            Now waiting for about 2h. (more looks more like 18h...)



            Note: this only moves data back, not forward.



            Pausing:



            # pidof dd
            907
            # kill -STOP 907
            # cat /proc/907/fdinfo/1
            pos: 586921398272
            flags: 0100001

            # kill -9 907

            remember 586921398272/512 = 1146330856


            Resuming:



            dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3  skip=$((1146330856+73402368-73385984)) seek=1146330856 of=/dev/sdb3





            share|improve this answer





















            • 2





              Lifesaver! Did anyone try to use a larger bs value (for speed reasons)?

              – David Balažic
              Nov 22 '13 at 0:24











            • Ensure you recalculated the values appropriately in case of other bs size.

              – Vi.
              Nov 25 '13 at 12:33






            • 3





              why not dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb skip=73402368 seek=0 of=/dev/sdb3 ? this way it, should work even f start of old sdb3 in not inside new sdb3

              – solsTiCe
              Jun 10 '15 at 14:27













            • @solsTiCe, What is the difference between your command and my command?

              – Vi.
              Jun 10 '15 at 16:36






            • 3





              A larger bs didn't help me on its own, however bs=1M iflag=direct oflag=direct did. Went from 40 MB/s to 400 MB/s on my SSD. Also, use status=progress

              – Aleksandr Dubinsky
              Mar 23 '17 at 9:42
















            14












            14








            14







            Manual way with dd and fdisk:



            # fdisk -l /dev/sdb | grep sdb3
            /dev/sdb3 73402368 1953525167 940061400 83 Linux

            # fdisk /dev/sdb
            Command (m for help): d
            Partition number (1-4): 3
            Command (m for help): n
            Partition number (1-4, default 3): 3
            First sector (73385984-1953525167, default 73385984):
            Using default value 73385984
            Last sector, +sectors or +size{K,M,G} (73385984-1953525167, default 1953525167):
            Using default value 1953525167
            Command (m for help): w
            The partition table has been altered!

            # fdisk -l /dev/sdb | grep sdb3
            /dev/sdb3 73385984 1953525167 940069592 83 Linux

            # dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 count=100 skip=$((73402368-73385984)) seek=0 2> /dev/null | file -s -
            /dev/stdin: LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f

            # dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 skip=$((73402368-73385984)) seek=0 of=/dev/sdb3

            # file -s /dev/sdb3
            /dev/sdb3: sticky LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f


            Now waiting for about 2h. (more looks more like 18h...)



            Note: this only moves data back, not forward.



            Pausing:



            # pidof dd
            907
            # kill -STOP 907
            # cat /proc/907/fdinfo/1
            pos: 586921398272
            flags: 0100001

            # kill -9 907

            remember 586921398272/512 = 1146330856


            Resuming:



            dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3  skip=$((1146330856+73402368-73385984)) seek=1146330856 of=/dev/sdb3





            share|improve this answer















            Manual way with dd and fdisk:



            # fdisk -l /dev/sdb | grep sdb3
            /dev/sdb3 73402368 1953525167 940061400 83 Linux

            # fdisk /dev/sdb
            Command (m for help): d
            Partition number (1-4): 3
            Command (m for help): n
            Partition number (1-4, default 3): 3
            First sector (73385984-1953525167, default 73385984):
            Using default value 73385984
            Last sector, +sectors or +size{K,M,G} (73385984-1953525167, default 1953525167):
            Using default value 1953525167
            Command (m for help): w
            The partition table has been altered!

            # fdisk -l /dev/sdb | grep sdb3
            /dev/sdb3 73385984 1953525167 940069592 83 Linux

            # dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 count=100 skip=$((73402368-73385984)) seek=0 2> /dev/null | file -s -
            /dev/stdin: LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f

            # dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 skip=$((73402368-73385984)) seek=0 of=/dev/sdb3

            # file -s /dev/sdb3
            /dev/sdb3: sticky LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f


            Now waiting for about 2h. (more looks more like 18h...)



            Note: this only moves data back, not forward.



            Pausing:



            # pidof dd
            907
            # kill -STOP 907
            # cat /proc/907/fdinfo/1
            pos: 586921398272
            flags: 0100001

            # kill -9 907

            remember 586921398272/512 = 1146330856


            Resuming:



            dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3  skip=$((1146330856+73402368-73385984)) seek=1146330856 of=/dev/sdb3






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 25 '13 at 8:32

























            answered Jan 24 '13 at 21:40









            Vi.Vi.

            7,7691982163




            7,7691982163








            • 2





              Lifesaver! Did anyone try to use a larger bs value (for speed reasons)?

              – David Balažic
              Nov 22 '13 at 0:24











            • Ensure you recalculated the values appropriately in case of other bs size.

              – Vi.
              Nov 25 '13 at 12:33






            • 3





              why not dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb skip=73402368 seek=0 of=/dev/sdb3 ? this way it, should work even f start of old sdb3 in not inside new sdb3

              – solsTiCe
              Jun 10 '15 at 14:27













            • @solsTiCe, What is the difference between your command and my command?

              – Vi.
              Jun 10 '15 at 16:36






            • 3





              A larger bs didn't help me on its own, however bs=1M iflag=direct oflag=direct did. Went from 40 MB/s to 400 MB/s on my SSD. Also, use status=progress

              – Aleksandr Dubinsky
              Mar 23 '17 at 9:42
















            • 2





              Lifesaver! Did anyone try to use a larger bs value (for speed reasons)?

              – David Balažic
              Nov 22 '13 at 0:24











            • Ensure you recalculated the values appropriately in case of other bs size.

              – Vi.
              Nov 25 '13 at 12:33






            • 3





              why not dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb skip=73402368 seek=0 of=/dev/sdb3 ? this way it, should work even f start of old sdb3 in not inside new sdb3

              – solsTiCe
              Jun 10 '15 at 14:27













            • @solsTiCe, What is the difference between your command and my command?

              – Vi.
              Jun 10 '15 at 16:36






            • 3





              A larger bs didn't help me on its own, however bs=1M iflag=direct oflag=direct did. Went from 40 MB/s to 400 MB/s on my SSD. Also, use status=progress

              – Aleksandr Dubinsky
              Mar 23 '17 at 9:42










            2




            2





            Lifesaver! Did anyone try to use a larger bs value (for speed reasons)?

            – David Balažic
            Nov 22 '13 at 0:24





            Lifesaver! Did anyone try to use a larger bs value (for speed reasons)?

            – David Balažic
            Nov 22 '13 at 0:24













            Ensure you recalculated the values appropriately in case of other bs size.

            – Vi.
            Nov 25 '13 at 12:33





            Ensure you recalculated the values appropriately in case of other bs size.

            – Vi.
            Nov 25 '13 at 12:33




            3




            3





            why not dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb skip=73402368 seek=0 of=/dev/sdb3 ? this way it, should work even f start of old sdb3 in not inside new sdb3

            – solsTiCe
            Jun 10 '15 at 14:27







            why not dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb skip=73402368 seek=0 of=/dev/sdb3 ? this way it, should work even f start of old sdb3 in not inside new sdb3

            – solsTiCe
            Jun 10 '15 at 14:27















            @solsTiCe, What is the difference between your command and my command?

            – Vi.
            Jun 10 '15 at 16:36





            @solsTiCe, What is the difference between your command and my command?

            – Vi.
            Jun 10 '15 at 16:36




            3




            3





            A larger bs didn't help me on its own, however bs=1M iflag=direct oflag=direct did. Went from 40 MB/s to 400 MB/s on my SSD. Also, use status=progress

            – Aleksandr Dubinsky
            Mar 23 '17 at 9:42







            A larger bs didn't help me on its own, however bs=1M iflag=direct oflag=direct did. Went from 40 MB/s to 400 MB/s on my SSD. Also, use status=progress

            – Aleksandr Dubinsky
            Mar 23 '17 at 9:42













            2














            You can always use dd.




            • Boot from a liveCD (or any other way which makes sure the partition is not mounted)


            • dd if=/dev/sdc2 of=somefile bs=1M to create a copy of the partition on a file.

            • fdisk (or whatever you like) to delete the partition

            • fdisk (or whatever you like) to create the partition in your desired place.


            • dd of=/dev/sdc2 if=somefile bs=1M to restore the contents from file.






            share|improve this answer
























            • How to do it in-place? This partition is almost as large as all other HDDs in my home taked together.

              – Vi.
              Jan 24 '13 at 13:24













            • Can I do something like dd if=/dev/sdb of=/dev/sdb bs=512 skip=N seek=M?

              – Vi.
              Jan 24 '13 at 13:26











            • Might be able tom but test it first. Esp. if you have no backup of the data on the partition. (Also note that if you do have a backup then there are way simpler solutions).

              – Hennes
              Jan 24 '13 at 13:40






            • 3





              @Vi. This correct, first response of an answer deserves no one's down-vote because this "do it in place" requirement exists nowhere in the question.

              – zero2cx
              Jan 15 '17 at 16:40
















            2














            You can always use dd.




            • Boot from a liveCD (or any other way which makes sure the partition is not mounted)


            • dd if=/dev/sdc2 of=somefile bs=1M to create a copy of the partition on a file.

            • fdisk (or whatever you like) to delete the partition

            • fdisk (or whatever you like) to create the partition in your desired place.


            • dd of=/dev/sdc2 if=somefile bs=1M to restore the contents from file.






            share|improve this answer
























            • How to do it in-place? This partition is almost as large as all other HDDs in my home taked together.

              – Vi.
              Jan 24 '13 at 13:24













            • Can I do something like dd if=/dev/sdb of=/dev/sdb bs=512 skip=N seek=M?

              – Vi.
              Jan 24 '13 at 13:26











            • Might be able tom but test it first. Esp. if you have no backup of the data on the partition. (Also note that if you do have a backup then there are way simpler solutions).

              – Hennes
              Jan 24 '13 at 13:40






            • 3





              @Vi. This correct, first response of an answer deserves no one's down-vote because this "do it in place" requirement exists nowhere in the question.

              – zero2cx
              Jan 15 '17 at 16:40














            2












            2








            2







            You can always use dd.




            • Boot from a liveCD (or any other way which makes sure the partition is not mounted)


            • dd if=/dev/sdc2 of=somefile bs=1M to create a copy of the partition on a file.

            • fdisk (or whatever you like) to delete the partition

            • fdisk (or whatever you like) to create the partition in your desired place.


            • dd of=/dev/sdc2 if=somefile bs=1M to restore the contents from file.






            share|improve this answer













            You can always use dd.




            • Boot from a liveCD (or any other way which makes sure the partition is not mounted)


            • dd if=/dev/sdc2 of=somefile bs=1M to create a copy of the partition on a file.

            • fdisk (or whatever you like) to delete the partition

            • fdisk (or whatever you like) to create the partition in your desired place.


            • dd of=/dev/sdc2 if=somefile bs=1M to restore the contents from file.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 24 '13 at 13:12









            HennesHennes

            59k792141




            59k792141













            • How to do it in-place? This partition is almost as large as all other HDDs in my home taked together.

              – Vi.
              Jan 24 '13 at 13:24













            • Can I do something like dd if=/dev/sdb of=/dev/sdb bs=512 skip=N seek=M?

              – Vi.
              Jan 24 '13 at 13:26











            • Might be able tom but test it first. Esp. if you have no backup of the data on the partition. (Also note that if you do have a backup then there are way simpler solutions).

              – Hennes
              Jan 24 '13 at 13:40






            • 3





              @Vi. This correct, first response of an answer deserves no one's down-vote because this "do it in place" requirement exists nowhere in the question.

              – zero2cx
              Jan 15 '17 at 16:40



















            • How to do it in-place? This partition is almost as large as all other HDDs in my home taked together.

              – Vi.
              Jan 24 '13 at 13:24













            • Can I do something like dd if=/dev/sdb of=/dev/sdb bs=512 skip=N seek=M?

              – Vi.
              Jan 24 '13 at 13:26











            • Might be able tom but test it first. Esp. if you have no backup of the data on the partition. (Also note that if you do have a backup then there are way simpler solutions).

              – Hennes
              Jan 24 '13 at 13:40






            • 3





              @Vi. This correct, first response of an answer deserves no one's down-vote because this "do it in place" requirement exists nowhere in the question.

              – zero2cx
              Jan 15 '17 at 16:40

















            How to do it in-place? This partition is almost as large as all other HDDs in my home taked together.

            – Vi.
            Jan 24 '13 at 13:24







            How to do it in-place? This partition is almost as large as all other HDDs in my home taked together.

            – Vi.
            Jan 24 '13 at 13:24















            Can I do something like dd if=/dev/sdb of=/dev/sdb bs=512 skip=N seek=M?

            – Vi.
            Jan 24 '13 at 13:26





            Can I do something like dd if=/dev/sdb of=/dev/sdb bs=512 skip=N seek=M?

            – Vi.
            Jan 24 '13 at 13:26













            Might be able tom but test it first. Esp. if you have no backup of the data on the partition. (Also note that if you do have a backup then there are way simpler solutions).

            – Hennes
            Jan 24 '13 at 13:40





            Might be able tom but test it first. Esp. if you have no backup of the data on the partition. (Also note that if you do have a backup then there are way simpler solutions).

            – Hennes
            Jan 24 '13 at 13:40




            3




            3





            @Vi. This correct, first response of an answer deserves no one's down-vote because this "do it in place" requirement exists nowhere in the question.

            – zero2cx
            Jan 15 '17 at 16:40





            @Vi. This correct, first response of an answer deserves no one's down-vote because this "do it in place" requirement exists nowhere in the question.

            – zero2cx
            Jan 15 '17 at 16:40


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • 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%2fsuperuser.com%2fquestions%2f541067%2fhow-to-move-a-partition-in-gnu-linux%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

            Plaza Victoria

            In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

            How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...