linux - How to move and rearrange partitions in Ubuntu

07
2014-07
  • Supremekhaoz

    I have a mess of partitions. This picture pretty much sums it up. I don't understand why there are small unallocated areas. My goal is to move the whole /dev/sda4 partition to a new hard drive (including swap). Then increase the remaining space in Storage (/dev/sda3).

    Thank you in advance.

    enter image description here

  • Answers
  • Ben West

    You'll want to partition the new drive as you like, then, you can use, for example, a liveUSB or LiveCD to boot the system.

    Copy the files using cp -p (preserve permissions) as root (use sudo) from the old drive to the new.

    Then you'll want to sudo chroot into the environment (this is an advanced topic) and run grub install from within the chroot. (this may be easier if you remove the original drive)

    Then, if you have not already done so, remove the existing drive and confirm the secondary system boots. It may take several attempts to get grub configured properly to do this. confirm you have no data loss on the transferred system.

    Lastly, you may remove the linux system from the old drive. Once done, you can put both drives into the system. Further grub configuration may be required at that time.

    Bonus, resizing the NTFS/Window partitions will best be done with windows disk management

  • Aditya Advani

    I cannot speak to how safe this method is, all I can tell you is that it worked for me like a charm in a similar situation. Your mileage may vary. In my case I was fully backed up and prepared to reinstall from scratch if necessary.

    Reboot your system and boot into an Ubuntu LiveCD ... then just use the graphical GParted Partition Manager to adjust the size of the partitions.

    One gotcha I encountered is that the LiveCD mounts Linux Swap Partitions automatically. So before you can edit those partitions or extended ones they are part of you need to right-click on them and select "Swap Off" for each Linux Swap Partition.

    After doing this I was able to resize and manipulate my root partition. I think attempting my method is quicker than a clean reinstall and restore. Good luck!


  • Related Question

    windows vista - Partition table gone after upgrade to Ubuntu 10.04
  • eaarthman

    After upgrading to Ubuntu 10.04, none of my graphic partition utilities (GParted, KVPM) can detect any partition table. GParted displayes my /dev/sda as "unallocated." I have also run sudo fdisk -l and gotten the following:

    Disk /dev/sda: 120.0 GB, 120034123776 bytes
    255 heads, 63 sectors/track, 14593 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xd8000000
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *       14267       14594     2620416    c  W95 FAT32 (LBA)
    /dev/sda2              10        1315    10485760    7  HPFS/NTFS
    /dev/sda3   *        1315        6276    39852216+   7  HPFS/NTFS
    /dev/sda4            6277       14594    66807327+   f  W95 Extd (LBA)
    /dev/sda5           14267       14594     2620416   dd  Unknown
    /dev/sda6            6277       13935    61520886   83  Linux
    /dev/sda7           13936       14266     2658726   82  Linux swap / Solaris
    
    Partition table entries are not in disk order
    

    To be honest, I am not exactly a superuser (but I know some things), so I'm having trouble understanding just what all that means. My goal is to eliminate all my existing Windows partitions (I currently dual-boot between Ubuntu 10.04 and Windows Vista) to free up space for linux. I tried burning an Ubuntu 10.10 CD and re-booting, hoping that GParted would work then, so I could just graphically destroy Windows and re-size my root partition, but no dice. Same results.

    Any help? What's a good command-line based partition editor that can accomplish my goal of eliminating Windows from my life? Or is there some way to get the graphical ones to work again? And why did upgrading to Ubuntu 10.04 mess with my partition table?


  • Related Answers
  • Chris

    Same upgrade made changes to the partition tables on all my drives, linux could use them, windows could not boot from them, new partitions weren't enough, a clean install of windows to the empty drive didn't boot untill I killed the partition table. I had to rebuild the partition table to get windows working again. You are not alone.

    Symptoms were windows booting to a blinking cursor. Grub was displaying a number of errors before booting.

  • plco

    I don't think your partition table is messed, OTOH I have no idea why the GUI tools don't work. I would try something like SysRescueCD or Trinity Rescue Kit to do the job.

    BTW that's a small disk you have there. With the current prices of storage, I'd recommend getting a larger (and faster!) disk and copying your Ubuntu partition on it, leaving Windows on the old one. As an added benefit you will have a real Windows to go back to in case you need it.

    Judging from your disk, I don't think your PC has the power to run a virtualized guest, so having a native Windows environment could be useful in case you need to use something that just doesn't work with Wine.