Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: how to get & create partition size precisely?

  1. #1
    Join Date
    Jan 2009
    Beans
    98

    how to get & create partition size precisely?

    I'm trying to clone the OS partition to another harddrive of a different size as the original. GParted provides an impresize size of the partition such as "32.63GB", whereas I'm trying to create a new partition of exactly the same size. It does tell me the number of sectors in the old partition but I can't directly use that number to create the new partition in GParted.

    What tools should I use to achieve this?
    Last edited by anon0; January 27th, 2009 at 12:01 PM.

  2. #2
    Join Date
    Apr 2005
    Location
    Finland/UK
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: how to get & create partition size precisely?

    Quote Originally Posted by anon0 View Post
    I'm trying to clone the OS partition to another harddrive of a different size as the original. GParted provides an impresize size of the partition such as "32.63GB", whereas I'm trying to create a new partition of exactly the same size. It does tell me the number of sectors in the old partition but I can't directly use that number to create the new partition in GParted.

    What tools should I use to achieve this?
    you could use fdisk (although it's not for those afraid of command-line..)

  3. #3
    Join Date
    Oct 2007
    Location
    Auckland, New Zealand
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: how to get & create partition size precisely?

    Quote Originally Posted by anon0 View Post
    I'm trying to clone the OS partition to another harddrive of a different size as the original. GParted provides an impresize size of the partition such as "32.63GB", whereas I'm trying to create a new partition of exactly the same size. It does tell me the number of sectors in the old partition but I can't directly use that number to create the new partition in GParted.

    What tools should I use to achieve this?
    Gparted on the live cd (the partition editor in the menu, not the one used in the installer) has the option to select the partition size in mb. That should be as precise as you need.
    First they ignore you, then they laugh at you, then they fight you, then you win ~ Mahatma Gandhi

  4. #4
    Join Date
    Jan 2009
    Beans
    98

    Re: how to get & create partition size precisely?

    Quote Originally Posted by talsemgeest View Post
    Gparted on the live cd (the partition editor in the menu, not the one used in the installer) has the option to select the partition size in mb. That should be as precise as you need.
    The problem is how do you know many megabytes the old partition is? And is that precise enough for RAID1? I would think for RAID1 the two partitions have to be exactly the same size, so wouldn't there be problems if there are fractional differences?

    So how do we use fdisk to:
    1) get the precise size (in bytes perhaps) of a partition, and
    2) create a new partition of the same size?

  5. #5
    Join Date
    Jan 2009
    Beans
    22
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: how to get & create partition size precisely?

    But you want to resize an existent one?
    I think cfdisk is more than enough to do so.

    cfdisk is a curse-based tool that uses fdisk to create partitions.

    The command is:

    Code:
    cfdisk

  6. #6
    Join Date
    Oct 2007
    Location
    Auckland, New Zealand
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: how to get & create partition size precisely?

    Quote Originally Posted by anon0 View Post
    The problem is how do you know many megabytes the old partition is? And is that precise enough for RAID1? I would think for RAID1 the two partitions have to be exactly the same size, so wouldn't there be problems if there are fractional differences?

    So how do we use fdisk to:
    1) get the precise size (in bytes perhaps) of a partition, and
    2) create a new partition of the same size?
    I believe with raid, you must have blank disks as it changes the format of the hdds themselves. In setting up raid1, it should also allow you to create the partition of the same size. (BTW, how are you going to set up raid, with fake raid (ie, motherboard/bios setup), hardware raid or software raid (alternate install cd)?
    First they ignore you, then they laugh at you, then they fight you, then you win ~ Mahatma Gandhi

  7. #7
    Join Date
    Jan 2009
    Beans
    98

    Re: how to get & create partition size precisely?

    Quote Originally Posted by rafaelsousa View Post
    But you want to resize an existent one?
    I think cfdisk is more than enough to do so.

    cfdisk is a curse-based tool that uses fdisk to create partitions.

    The command is:

    Code:
    cfdisk
    Well it's not ideal for me to resize the OS partition unless it's safe and easy to do so. Cfdisk talks about changing cylinder and head parameters which don't exactly sound fool-proof.

    I'm basically just asking how to clone the partition exactly on another drive.

  8. #8
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: how to get & create partition size precisely?

    use this:
    Code:
    sfdisk -d /dev/sdX | sfdisk /dev/sdY
    that will make the same partitions.

  9. #9
    Join Date
    Jan 2009
    Beans
    98

    Re: how to get & create partition size precisely?

    Quote Originally Posted by hyper_ch View Post
    use this:
    Code:
    sfdisk -d /dev/sdX | sfdisk /dev/sdY
    that will make the same partitions.
    is that a disk-wide operation? What if the source disk is larger than the target disk?

  10. #10
    Join Date
    Jan 2009
    Beans
    98

    Re: how to get & create partition size precisely?

    I found out that "sudo parted /dev/sdXY unit B print" will provide the number of bytes in the partition.

    Also parted's mkpart can apparently create a new partition with a certain number of bytes or sectors. However when I did it the result is a sector or two different from the original, not sure why.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •