Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

/dev/sda is a 400 gig drive. It's partitions WERE: /sda1 - Windows boot partition (100 meg); /sda2 Windows "C:\" (68 gig); /sda3 is Linux boot partition; /sda5 is /home partition; /sda6 is linux-swap.

/sda1 and /sda2 have been deleted and /sda2 expanded into /sda1.

I want to clone /sda3 to /sda1 AND have the 12.04 (precise pangolin) know to boot from /sda1 and not from /sda3.

How do I edit both /etc/fstab and GRUB2 to have proper (I have no idea how to use words to express this idea) UUID? I know that using GParted to "copy" /sda3 to /sda1 requires editing to make the copied partition have a UUID that is not a match (or the same UUID number as) the original partition (/sda3). What other steps must I take to not confuse GRUB2 and the fstab so that they work harmoniously and I don't harm the OS/data/other stuff on the hard drive?

Next, I want to shrink /sda1 to 25 gig (currently 68 gig), and continue /sda1 as boot. Then I want to use 43 gig from shrinking /sda1, and add it to the (to be) unused /sda3 and then to expand /sda5 into the expanded /sda3

I cannot post a screenshot of gparted, so here is fdisk -l in stead:

mark@Lexington-19:~$ sudo fdisk -l
[sudo] password for mark: 

Disk /dev/sda: 400.1 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders, total 781422768 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf3e1e104


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1            2048   143570943    71784448   83  Linux

/dev/sda3   *   143572905   174176729    15301912+  83  Linux

/dev/sda4       174176791   781417664   303620437    5  Extended

/dev/sda5       174176793   764420894   295122051   83  Linux

/dev/sda6       764420958   781417664     8498353+  82  Linux swap / Solaris
share|improve this question

2 Answers 2

The easy way, IMO, is to boot the Ubuntu desktop CD. You can then use gparted to copy-paste your partitions.

The only trick with gparted is that you have to apply the changes one setp at a time.

Delete sda1 -> apply changes -> copy sda3 -> paste -> apply changes.

gparted

Once you have copied the partition you can also use gparted to create a new UUID

Select the partition → New UUID

Mount the partition at /mnt

sudo mount /dev/sda1 /mnt

Edit fstab, enter the new UUID under the entry for the root file system.

List the UUID, if needed, with blkid

blkid

gksu gedit /mnt/etc/fstab

Re-install / update gurb

sudo grub-install --boot-directory=/mnt/boot /dev/sda

See also:

https://help.ubuntu.com/community/MovingLinuxPartition

https://help.ubuntu.com/community/UsingUUID

http://www.youtube.com/watch?v=8BEZJmKqxYs

share|improve this answer
    
Okay, now I see that this way is much easier. I didn't thought of copypasting partitions. –  LiveWireBT Feb 12 '13 at 10:45
    
Thank you, Mr. Zazen. I will use your method. CASE CLOSED. –  Mark Preston Feb 12 '13 at 20:19
    
@MarkPreston Then please accept this answer. –  LiveWireBT Feb 12 '13 at 20:49
    
@Mark Preston hope it works out the way you like. No need to be so formal, lol –  bodhi.zazen Feb 12 '13 at 23:10

Is there a specific reason why you want to move the Linux partition from 3 to 1? Do you aim for a performance gain or is it just out of habit?

The easy way

  1. Shrink the Linux partition from within a Live CD
  2. Delete partition sda1
  3. Move partition sda2 to the very beginning of your hard drive and sda3 right behind
  4. Extend the extended partition that holds sda5 and sda6

The proper way

  1. Shrink the Linux partition to minimum from within a Live CD
  2. Move partitions sda2 and sda3 as far to the end as possible
  3. Resize and format sda1
  4. Copy everything from sda3 to sda1 with rsync --progress -av, modyfiy fstab accordingly on sda1
  5. Reinstall grub with grub-install --boot-directory=/path/to/mounted/sda1 sda
  6. Delete partition sda1
  7. Extend the extended partition that holds sda5 and sda6

Pro: Linux partition is physically in first place (and also defragmented Linux partition)

Con: Involves reinstalling boot loader

The dirty way

  1. Dump partition /dev/sda2 (the device) with dd to a file (like an external hard drive), note down the exact size of the partition an delete it as well as sda1
  2. Resize sda3 to desired size and move it to the very beginning of your hard drive
  3. Recreate the Windows partition and write the dump back to the partition (switch input and output files/devices)
  4. Extend the extended partition that holds sda5 and sda6

Pro: Linux partition is physically in first place, no need to reinstall bootloader

Con: sda3 is still sda3 and what has been sda2 could be sda1, be careful not to write to the wrong partition with dd, dumping takes more time as it copies everything (even files and fragments of files that do no longer exist)

Recommendation

Go the easy way. If performance matters buy a SSD. (I know that this is the most overused phrase these days, but measurably worth the effort.)

share|improve this answer
    
Your answer addressed copying the data, but you did not address grub2 configuration or fstab. –  bodhi.zazen Feb 11 '13 at 23:49
    
That's because I recommend the first method which doesn't require changing the configuration at all. Also I did not explain how to use dd and probably left out many other bits. I just wanted to show off some possibilities, while keeping it as simple as possible. Less is more. –  LiveWireBT Feb 12 '13 at 0:48
    
LiveWireBT asked: "Is there a specific reason why you want to move the Linux partition from 3 to 1? Do you aim for a performance gain or is it just out of habit?" - I'm trying to get some use out of 68gig that had been Win7. I read that cruft grows on linked folders-to-partions, I I want to use the 68gig. I'm uncertain as to what is best (or even good) here. –  Mark Preston Feb 12 '13 at 19:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.