How do I image a 128GB drive to a 120GB one using Linux dd?












1














I have 2 SSD's. My system (Ubuntu 12.04) is installed on one and I want to clone it to another. The problem is that the system is currently on a 128GB drive and the new one is only 120GB. Is it possible to create an image using dd ​​to a drive of smaller capacity?










share|improve this question















migrated from stackoverflow.com Apr 29 '13 at 16:42


This question came from our site for professional and enthusiast programmers.











  • 2




    Try asking on superuser.stackexchange.com or serverfault.stackexchange.com
    – Joe
    Apr 29 '13 at 14:49










  • Can you reword your question, please.
    – jofel
    Apr 29 '13 at 14:50










  • this is not a programing question. By the way, boot with a live system, mount both disks and make a cp -a to copy to a smaller disk.
    – Ottavio Campana
    Apr 29 '13 at 14:54










  • Have a look at this question.
    – Benny Hill
    Apr 29 '13 at 14:58
















1














I have 2 SSD's. My system (Ubuntu 12.04) is installed on one and I want to clone it to another. The problem is that the system is currently on a 128GB drive and the new one is only 120GB. Is it possible to create an image using dd ​​to a drive of smaller capacity?










share|improve this question















migrated from stackoverflow.com Apr 29 '13 at 16:42


This question came from our site for professional and enthusiast programmers.











  • 2




    Try asking on superuser.stackexchange.com or serverfault.stackexchange.com
    – Joe
    Apr 29 '13 at 14:49










  • Can you reword your question, please.
    – jofel
    Apr 29 '13 at 14:50










  • this is not a programing question. By the way, boot with a live system, mount both disks and make a cp -a to copy to a smaller disk.
    – Ottavio Campana
    Apr 29 '13 at 14:54










  • Have a look at this question.
    – Benny Hill
    Apr 29 '13 at 14:58














1












1








1


1





I have 2 SSD's. My system (Ubuntu 12.04) is installed on one and I want to clone it to another. The problem is that the system is currently on a 128GB drive and the new one is only 120GB. Is it possible to create an image using dd ​​to a drive of smaller capacity?










share|improve this question















I have 2 SSD's. My system (Ubuntu 12.04) is installed on one and I want to clone it to another. The problem is that the system is currently on a 128GB drive and the new one is only 120GB. Is it possible to create an image using dd ​​to a drive of smaller capacity?







linux images dd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 29 '13 at 16:57









depquid

315312




315312










asked Apr 29 '13 at 14:47







Aderbal Nunes











migrated from stackoverflow.com Apr 29 '13 at 16:42


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com Apr 29 '13 at 16:42


This question came from our site for professional and enthusiast programmers.










  • 2




    Try asking on superuser.stackexchange.com or serverfault.stackexchange.com
    – Joe
    Apr 29 '13 at 14:49










  • Can you reword your question, please.
    – jofel
    Apr 29 '13 at 14:50










  • this is not a programing question. By the way, boot with a live system, mount both disks and make a cp -a to copy to a smaller disk.
    – Ottavio Campana
    Apr 29 '13 at 14:54










  • Have a look at this question.
    – Benny Hill
    Apr 29 '13 at 14:58














  • 2




    Try asking on superuser.stackexchange.com or serverfault.stackexchange.com
    – Joe
    Apr 29 '13 at 14:49










  • Can you reword your question, please.
    – jofel
    Apr 29 '13 at 14:50










  • this is not a programing question. By the way, boot with a live system, mount both disks and make a cp -a to copy to a smaller disk.
    – Ottavio Campana
    Apr 29 '13 at 14:54










  • Have a look at this question.
    – Benny Hill
    Apr 29 '13 at 14:58








2




2




Try asking on superuser.stackexchange.com or serverfault.stackexchange.com
– Joe
Apr 29 '13 at 14:49




Try asking on superuser.stackexchange.com or serverfault.stackexchange.com
– Joe
Apr 29 '13 at 14:49












Can you reword your question, please.
– jofel
Apr 29 '13 at 14:50




Can you reword your question, please.
– jofel
Apr 29 '13 at 14:50












this is not a programing question. By the way, boot with a live system, mount both disks and make a cp -a to copy to a smaller disk.
– Ottavio Campana
Apr 29 '13 at 14:54




this is not a programing question. By the way, boot with a live system, mount both disks and make a cp -a to copy to a smaller disk.
– Ottavio Campana
Apr 29 '13 at 14:54












Have a look at this question.
– Benny Hill
Apr 29 '13 at 14:58




Have a look at this question.
– Benny Hill
Apr 29 '13 at 14:58










4 Answers
4






active

oldest

votes


















5














How to do what you asked to do:




  1. use gparted to resize your system partition smaller than 120GB... preferably, if possible, considerably smaller than 120GB, to make sure you really do have it below the total size of the target drive.



  2. dd if=/dev/sda bs=8M of=/dev/sdb, assuming your source and target drives are sda and sdb, respectively. do this from safe mode or from a live boot environment, NOT from your source OS running with a normal multiuser login.



    OR, if you have network access in your live boot environment, and universe in your sources: apt-get install pv ; pv < /dev/sda > /dev/sdb. The difference between this command and the dd command,
    for your purposes here, is that this one gives you a P-R-O-G-R-E-S-S
    B-A-R... :)




However, a probably better way to do what you really WANT to do:




  1. do a bare install of Ubuntu on the target drive. (there are more efficient ways to get a boot sector on a new drive, but I'm going for "noob-friendly" here.)


  2. mount both drives from a live boot environment, and rsync -harv --progress /path/to/source/ /path/to/target/. Note that you REALLY want to be in a live boot environment here, not in a running system, otherwise you'll have to deal with stuff like devfs, procfs, and so forth - not to mention files potentially altering/disappearing while you rsync.







share|improve this answer





























    1














    STEPS




    1. If at all possible, make a backup of the source drive (128 Gb).



    2. Use Gparted USB to boot, then use it to shrink your partition of source drive (128 Gb) to less than the target drive size (120 Gb). 
      If you have a full drive, let's say
      128 Gb with no space at all, then you may need to compress (zip) some of the data files, or copy to another temporary USB
      to achieve less than 120 Gb (size of target drive). Otherwise you can't
      fit the source contents into the target drive. It simply won't fit.



      Leave some extra free space just in case (1 Gb maybe, for geometry translations or whatever. My drive is one size, but dd and Gparted displayed a different size, slightly different).




    3. Once the partition of the source drive has been shrunk
      to less than the size of
      target drive, then you can perform the dd. Make sure you are copying
      source to target, otherwise you will end up very unhappy. (If the source
      is /dev/sda make sure is the 128 Gb drive now with partition less
      than 120 Gb
      ... Your target is /dev/sdb new 120 Gb drive.)



      dd if=/dev/sda of=/dev/sdb bs=4096 conv=notrunc,noerror



    4. Now, if you want, you can go back to Gparted and on the source drive,
      extend the full size of the partition to max allowed.



    Gparted makes a great job shrinking partitions and shows you space used, so you can shrink to whatever size above the used space. I have tried to copy and paste partitions using Gparted but did NOT work for me. Only use Gparted to shrinking partitions, then use dd to do the copying.



    Once it finishes, it may tell you that you ran out of space. It's normal; you are copying onto a smaller disk. But since you are copying a smaller partition, then all data gets copied. dd tries to copy all the 128 Gb onto the 120 Gb and throws an error. Don't worry; no damage to drives. Now remove the Gparted USB, remove the source drive and boot to the new 120 Gb disk, check for contents, and if you have any space left, you may unzip those previously zipped files.






    share|improve this answer























    • This is very similar to Jim Salter's answer, with only slightly more detail.
      – Scott
      Dec 4 at 2:09










    • Indeed, try to comment on that post, but Im new, the system does not allowed me. I did exactly that procedure yesterday, backing up my server. So the procedure is the correct. Regards.
      – Luis H Cabrejo
      Dec 4 at 5:45



















    0














    I'm assuming each drive has/will have only one partition.



    dd cannot be used the way you want to because it will copy each block of data that is physically on one drive to the other, including data defining the partition and filesystem as using 128GB. And any blocks of data stored at the end of the first drive will be lost.



    One simple solution, alluded to by Ottavio Campana in the comments:




    1. Boot the system using a LiveCD

    2. Create the filesystem on the new drive

    3. Mount both drives and copy the old to the new using cp -a


    You will then have to install a bootloader (e.g. GRUB) on the new drive if it will be your main drive.



    Benny Hill's comment provides a link to a similar question with answers offering other solutions.






    share|improve this answer





























      0














      The only viable option that I could think of is if you resized the ext4 partition so that you have 119gb of data and 9 gb of free space trailing at the end. Then you could use the DD with the bs= and count= commands to copy 120 gb of data to the drive. (You will have 1 gb leftover of free space which you can then resize again (I only did that to be safe))






      share|improve this answer





















        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%2f589262%2fhow-do-i-image-a-128gb-drive-to-a-120gb-one-using-linux-dd%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown
























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        5














        How to do what you asked to do:




        1. use gparted to resize your system partition smaller than 120GB... preferably, if possible, considerably smaller than 120GB, to make sure you really do have it below the total size of the target drive.



        2. dd if=/dev/sda bs=8M of=/dev/sdb, assuming your source and target drives are sda and sdb, respectively. do this from safe mode or from a live boot environment, NOT from your source OS running with a normal multiuser login.



          OR, if you have network access in your live boot environment, and universe in your sources: apt-get install pv ; pv < /dev/sda > /dev/sdb. The difference between this command and the dd command,
          for your purposes here, is that this one gives you a P-R-O-G-R-E-S-S
          B-A-R... :)




        However, a probably better way to do what you really WANT to do:




        1. do a bare install of Ubuntu on the target drive. (there are more efficient ways to get a boot sector on a new drive, but I'm going for "noob-friendly" here.)


        2. mount both drives from a live boot environment, and rsync -harv --progress /path/to/source/ /path/to/target/. Note that you REALLY want to be in a live boot environment here, not in a running system, otherwise you'll have to deal with stuff like devfs, procfs, and so forth - not to mention files potentially altering/disappearing while you rsync.







        share|improve this answer


























          5














          How to do what you asked to do:




          1. use gparted to resize your system partition smaller than 120GB... preferably, if possible, considerably smaller than 120GB, to make sure you really do have it below the total size of the target drive.



          2. dd if=/dev/sda bs=8M of=/dev/sdb, assuming your source and target drives are sda and sdb, respectively. do this from safe mode or from a live boot environment, NOT from your source OS running with a normal multiuser login.



            OR, if you have network access in your live boot environment, and universe in your sources: apt-get install pv ; pv < /dev/sda > /dev/sdb. The difference between this command and the dd command,
            for your purposes here, is that this one gives you a P-R-O-G-R-E-S-S
            B-A-R... :)




          However, a probably better way to do what you really WANT to do:




          1. do a bare install of Ubuntu on the target drive. (there are more efficient ways to get a boot sector on a new drive, but I'm going for "noob-friendly" here.)


          2. mount both drives from a live boot environment, and rsync -harv --progress /path/to/source/ /path/to/target/. Note that you REALLY want to be in a live boot environment here, not in a running system, otherwise you'll have to deal with stuff like devfs, procfs, and so forth - not to mention files potentially altering/disappearing while you rsync.







          share|improve this answer
























            5












            5








            5






            How to do what you asked to do:




            1. use gparted to resize your system partition smaller than 120GB... preferably, if possible, considerably smaller than 120GB, to make sure you really do have it below the total size of the target drive.



            2. dd if=/dev/sda bs=8M of=/dev/sdb, assuming your source and target drives are sda and sdb, respectively. do this from safe mode or from a live boot environment, NOT from your source OS running with a normal multiuser login.



              OR, if you have network access in your live boot environment, and universe in your sources: apt-get install pv ; pv < /dev/sda > /dev/sdb. The difference between this command and the dd command,
              for your purposes here, is that this one gives you a P-R-O-G-R-E-S-S
              B-A-R... :)




            However, a probably better way to do what you really WANT to do:




            1. do a bare install of Ubuntu on the target drive. (there are more efficient ways to get a boot sector on a new drive, but I'm going for "noob-friendly" here.)


            2. mount both drives from a live boot environment, and rsync -harv --progress /path/to/source/ /path/to/target/. Note that you REALLY want to be in a live boot environment here, not in a running system, otherwise you'll have to deal with stuff like devfs, procfs, and so forth - not to mention files potentially altering/disappearing while you rsync.







            share|improve this answer












            How to do what you asked to do:




            1. use gparted to resize your system partition smaller than 120GB... preferably, if possible, considerably smaller than 120GB, to make sure you really do have it below the total size of the target drive.



            2. dd if=/dev/sda bs=8M of=/dev/sdb, assuming your source and target drives are sda and sdb, respectively. do this from safe mode or from a live boot environment, NOT from your source OS running with a normal multiuser login.



              OR, if you have network access in your live boot environment, and universe in your sources: apt-get install pv ; pv < /dev/sda > /dev/sdb. The difference between this command and the dd command,
              for your purposes here, is that this one gives you a P-R-O-G-R-E-S-S
              B-A-R... :)




            However, a probably better way to do what you really WANT to do:




            1. do a bare install of Ubuntu on the target drive. (there are more efficient ways to get a boot sector on a new drive, but I'm going for "noob-friendly" here.)


            2. mount both drives from a live boot environment, and rsync -harv --progress /path/to/source/ /path/to/target/. Note that you REALLY want to be in a live boot environment here, not in a running system, otherwise you'll have to deal with stuff like devfs, procfs, and so forth - not to mention files potentially altering/disappearing while you rsync.








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 29 '13 at 20:16









            Jim Salter

            22815




            22815

























                1














                STEPS




                1. If at all possible, make a backup of the source drive (128 Gb).



                2. Use Gparted USB to boot, then use it to shrink your partition of source drive (128 Gb) to less than the target drive size (120 Gb). 
                  If you have a full drive, let's say
                  128 Gb with no space at all, then you may need to compress (zip) some of the data files, or copy to another temporary USB
                  to achieve less than 120 Gb (size of target drive). Otherwise you can't
                  fit the source contents into the target drive. It simply won't fit.



                  Leave some extra free space just in case (1 Gb maybe, for geometry translations or whatever. My drive is one size, but dd and Gparted displayed a different size, slightly different).




                3. Once the partition of the source drive has been shrunk
                  to less than the size of
                  target drive, then you can perform the dd. Make sure you are copying
                  source to target, otherwise you will end up very unhappy. (If the source
                  is /dev/sda make sure is the 128 Gb drive now with partition less
                  than 120 Gb
                  ... Your target is /dev/sdb new 120 Gb drive.)



                  dd if=/dev/sda of=/dev/sdb bs=4096 conv=notrunc,noerror



                4. Now, if you want, you can go back to Gparted and on the source drive,
                  extend the full size of the partition to max allowed.



                Gparted makes a great job shrinking partitions and shows you space used, so you can shrink to whatever size above the used space. I have tried to copy and paste partitions using Gparted but did NOT work for me. Only use Gparted to shrinking partitions, then use dd to do the copying.



                Once it finishes, it may tell you that you ran out of space. It's normal; you are copying onto a smaller disk. But since you are copying a smaller partition, then all data gets copied. dd tries to copy all the 128 Gb onto the 120 Gb and throws an error. Don't worry; no damage to drives. Now remove the Gparted USB, remove the source drive and boot to the new 120 Gb disk, check for contents, and if you have any space left, you may unzip those previously zipped files.






                share|improve this answer























                • This is very similar to Jim Salter's answer, with only slightly more detail.
                  – Scott
                  Dec 4 at 2:09










                • Indeed, try to comment on that post, but Im new, the system does not allowed me. I did exactly that procedure yesterday, backing up my server. So the procedure is the correct. Regards.
                  – Luis H Cabrejo
                  Dec 4 at 5:45
















                1














                STEPS




                1. If at all possible, make a backup of the source drive (128 Gb).



                2. Use Gparted USB to boot, then use it to shrink your partition of source drive (128 Gb) to less than the target drive size (120 Gb). 
                  If you have a full drive, let's say
                  128 Gb with no space at all, then you may need to compress (zip) some of the data files, or copy to another temporary USB
                  to achieve less than 120 Gb (size of target drive). Otherwise you can't
                  fit the source contents into the target drive. It simply won't fit.



                  Leave some extra free space just in case (1 Gb maybe, for geometry translations or whatever. My drive is one size, but dd and Gparted displayed a different size, slightly different).




                3. Once the partition of the source drive has been shrunk
                  to less than the size of
                  target drive, then you can perform the dd. Make sure you are copying
                  source to target, otherwise you will end up very unhappy. (If the source
                  is /dev/sda make sure is the 128 Gb drive now with partition less
                  than 120 Gb
                  ... Your target is /dev/sdb new 120 Gb drive.)



                  dd if=/dev/sda of=/dev/sdb bs=4096 conv=notrunc,noerror



                4. Now, if you want, you can go back to Gparted and on the source drive,
                  extend the full size of the partition to max allowed.



                Gparted makes a great job shrinking partitions and shows you space used, so you can shrink to whatever size above the used space. I have tried to copy and paste partitions using Gparted but did NOT work for me. Only use Gparted to shrinking partitions, then use dd to do the copying.



                Once it finishes, it may tell you that you ran out of space. It's normal; you are copying onto a smaller disk. But since you are copying a smaller partition, then all data gets copied. dd tries to copy all the 128 Gb onto the 120 Gb and throws an error. Don't worry; no damage to drives. Now remove the Gparted USB, remove the source drive and boot to the new 120 Gb disk, check for contents, and if you have any space left, you may unzip those previously zipped files.






                share|improve this answer























                • This is very similar to Jim Salter's answer, with only slightly more detail.
                  – Scott
                  Dec 4 at 2:09










                • Indeed, try to comment on that post, but Im new, the system does not allowed me. I did exactly that procedure yesterday, backing up my server. So the procedure is the correct. Regards.
                  – Luis H Cabrejo
                  Dec 4 at 5:45














                1












                1








                1






                STEPS




                1. If at all possible, make a backup of the source drive (128 Gb).



                2. Use Gparted USB to boot, then use it to shrink your partition of source drive (128 Gb) to less than the target drive size (120 Gb). 
                  If you have a full drive, let's say
                  128 Gb with no space at all, then you may need to compress (zip) some of the data files, or copy to another temporary USB
                  to achieve less than 120 Gb (size of target drive). Otherwise you can't
                  fit the source contents into the target drive. It simply won't fit.



                  Leave some extra free space just in case (1 Gb maybe, for geometry translations or whatever. My drive is one size, but dd and Gparted displayed a different size, slightly different).




                3. Once the partition of the source drive has been shrunk
                  to less than the size of
                  target drive, then you can perform the dd. Make sure you are copying
                  source to target, otherwise you will end up very unhappy. (If the source
                  is /dev/sda make sure is the 128 Gb drive now with partition less
                  than 120 Gb
                  ... Your target is /dev/sdb new 120 Gb drive.)



                  dd if=/dev/sda of=/dev/sdb bs=4096 conv=notrunc,noerror



                4. Now, if you want, you can go back to Gparted and on the source drive,
                  extend the full size of the partition to max allowed.



                Gparted makes a great job shrinking partitions and shows you space used, so you can shrink to whatever size above the used space. I have tried to copy and paste partitions using Gparted but did NOT work for me. Only use Gparted to shrinking partitions, then use dd to do the copying.



                Once it finishes, it may tell you that you ran out of space. It's normal; you are copying onto a smaller disk. But since you are copying a smaller partition, then all data gets copied. dd tries to copy all the 128 Gb onto the 120 Gb and throws an error. Don't worry; no damage to drives. Now remove the Gparted USB, remove the source drive and boot to the new 120 Gb disk, check for contents, and if you have any space left, you may unzip those previously zipped files.






                share|improve this answer














                STEPS




                1. If at all possible, make a backup of the source drive (128 Gb).



                2. Use Gparted USB to boot, then use it to shrink your partition of source drive (128 Gb) to less than the target drive size (120 Gb). 
                  If you have a full drive, let's say
                  128 Gb with no space at all, then you may need to compress (zip) some of the data files, or copy to another temporary USB
                  to achieve less than 120 Gb (size of target drive). Otherwise you can't
                  fit the source contents into the target drive. It simply won't fit.



                  Leave some extra free space just in case (1 Gb maybe, for geometry translations or whatever. My drive is one size, but dd and Gparted displayed a different size, slightly different).




                3. Once the partition of the source drive has been shrunk
                  to less than the size of
                  target drive, then you can perform the dd. Make sure you are copying
                  source to target, otherwise you will end up very unhappy. (If the source
                  is /dev/sda make sure is the 128 Gb drive now with partition less
                  than 120 Gb
                  ... Your target is /dev/sdb new 120 Gb drive.)



                  dd if=/dev/sda of=/dev/sdb bs=4096 conv=notrunc,noerror



                4. Now, if you want, you can go back to Gparted and on the source drive,
                  extend the full size of the partition to max allowed.



                Gparted makes a great job shrinking partitions and shows you space used, so you can shrink to whatever size above the used space. I have tried to copy and paste partitions using Gparted but did NOT work for me. Only use Gparted to shrinking partitions, then use dd to do the copying.



                Once it finishes, it may tell you that you ran out of space. It's normal; you are copying onto a smaller disk. But since you are copying a smaller partition, then all data gets copied. dd tries to copy all the 128 Gb onto the 120 Gb and throws an error. Don't worry; no damage to drives. Now remove the Gparted USB, remove the source drive and boot to the new 120 Gb disk, check for contents, and if you have any space left, you may unzip those previously zipped files.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 4 at 2:35









                Scott

                15.5k113889




                15.5k113889










                answered Dec 4 at 0:50









                Luis H Cabrejo

                114




                114












                • This is very similar to Jim Salter's answer, with only slightly more detail.
                  – Scott
                  Dec 4 at 2:09










                • Indeed, try to comment on that post, but Im new, the system does not allowed me. I did exactly that procedure yesterday, backing up my server. So the procedure is the correct. Regards.
                  – Luis H Cabrejo
                  Dec 4 at 5:45


















                • This is very similar to Jim Salter's answer, with only slightly more detail.
                  – Scott
                  Dec 4 at 2:09










                • Indeed, try to comment on that post, but Im new, the system does not allowed me. I did exactly that procedure yesterday, backing up my server. So the procedure is the correct. Regards.
                  – Luis H Cabrejo
                  Dec 4 at 5:45
















                This is very similar to Jim Salter's answer, with only slightly more detail.
                – Scott
                Dec 4 at 2:09




                This is very similar to Jim Salter's answer, with only slightly more detail.
                – Scott
                Dec 4 at 2:09












                Indeed, try to comment on that post, but Im new, the system does not allowed me. I did exactly that procedure yesterday, backing up my server. So the procedure is the correct. Regards.
                – Luis H Cabrejo
                Dec 4 at 5:45




                Indeed, try to comment on that post, but Im new, the system does not allowed me. I did exactly that procedure yesterday, backing up my server. So the procedure is the correct. Regards.
                – Luis H Cabrejo
                Dec 4 at 5:45











                0














                I'm assuming each drive has/will have only one partition.



                dd cannot be used the way you want to because it will copy each block of data that is physically on one drive to the other, including data defining the partition and filesystem as using 128GB. And any blocks of data stored at the end of the first drive will be lost.



                One simple solution, alluded to by Ottavio Campana in the comments:




                1. Boot the system using a LiveCD

                2. Create the filesystem on the new drive

                3. Mount both drives and copy the old to the new using cp -a


                You will then have to install a bootloader (e.g. GRUB) on the new drive if it will be your main drive.



                Benny Hill's comment provides a link to a similar question with answers offering other solutions.






                share|improve this answer


























                  0














                  I'm assuming each drive has/will have only one partition.



                  dd cannot be used the way you want to because it will copy each block of data that is physically on one drive to the other, including data defining the partition and filesystem as using 128GB. And any blocks of data stored at the end of the first drive will be lost.



                  One simple solution, alluded to by Ottavio Campana in the comments:




                  1. Boot the system using a LiveCD

                  2. Create the filesystem on the new drive

                  3. Mount both drives and copy the old to the new using cp -a


                  You will then have to install a bootloader (e.g. GRUB) on the new drive if it will be your main drive.



                  Benny Hill's comment provides a link to a similar question with answers offering other solutions.






                  share|improve this answer
























                    0












                    0








                    0






                    I'm assuming each drive has/will have only one partition.



                    dd cannot be used the way you want to because it will copy each block of data that is physically on one drive to the other, including data defining the partition and filesystem as using 128GB. And any blocks of data stored at the end of the first drive will be lost.



                    One simple solution, alluded to by Ottavio Campana in the comments:




                    1. Boot the system using a LiveCD

                    2. Create the filesystem on the new drive

                    3. Mount both drives and copy the old to the new using cp -a


                    You will then have to install a bootloader (e.g. GRUB) on the new drive if it will be your main drive.



                    Benny Hill's comment provides a link to a similar question with answers offering other solutions.






                    share|improve this answer












                    I'm assuming each drive has/will have only one partition.



                    dd cannot be used the way you want to because it will copy each block of data that is physically on one drive to the other, including data defining the partition and filesystem as using 128GB. And any blocks of data stored at the end of the first drive will be lost.



                    One simple solution, alluded to by Ottavio Campana in the comments:




                    1. Boot the system using a LiveCD

                    2. Create the filesystem on the new drive

                    3. Mount both drives and copy the old to the new using cp -a


                    You will then have to install a bootloader (e.g. GRUB) on the new drive if it will be your main drive.



                    Benny Hill's comment provides a link to a similar question with answers offering other solutions.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 29 '13 at 16:59









                    depquid

                    315312




                    315312























                        0














                        The only viable option that I could think of is if you resized the ext4 partition so that you have 119gb of data and 9 gb of free space trailing at the end. Then you could use the DD with the bs= and count= commands to copy 120 gb of data to the drive. (You will have 1 gb leftover of free space which you can then resize again (I only did that to be safe))






                        share|improve this answer


























                          0














                          The only viable option that I could think of is if you resized the ext4 partition so that you have 119gb of data and 9 gb of free space trailing at the end. Then you could use the DD with the bs= and count= commands to copy 120 gb of data to the drive. (You will have 1 gb leftover of free space which you can then resize again (I only did that to be safe))






                          share|improve this answer
























                            0












                            0








                            0






                            The only viable option that I could think of is if you resized the ext4 partition so that you have 119gb of data and 9 gb of free space trailing at the end. Then you could use the DD with the bs= and count= commands to copy 120 gb of data to the drive. (You will have 1 gb leftover of free space which you can then resize again (I only did that to be safe))






                            share|improve this answer












                            The only viable option that I could think of is if you resized the ext4 partition so that you have 119gb of data and 9 gb of free space trailing at the end. Then you could use the DD with the bs= and count= commands to copy 120 gb of data to the drive. (You will have 1 gb leftover of free space which you can then resize again (I only did that to be safe))







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Apr 29 '13 at 17:22









                            agz

                            3,376145296




                            3,376145296






























                                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.





                                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%2fsuperuser.com%2fquestions%2f589262%2fhow-do-i-image-a-128gb-drive-to-a-120gb-one-using-linux-dd%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

                                Сан-Квентин

                                8-я гвардейская общевойсковая армия

                                Алькесар