LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Repartitioning safely (https://www.linuxquestions.org/questions/slackware-14/repartitioning-safely-502246/)

gnashley 11-17-2006 07:30 AM

Yeah that may work if they are exactly the same total size, which is harder than you think... You may need to use sfdisk to make it happen, or at least to find out what the sizes really are. fdisk may not report correctly.
Be sure to do everything at once, though. If you remove sdb1, sdb2 and quit fdisk sdb3 becomes sdb1. Of course the data is not moved on the disk. Instead a hole is left. When you create a new partition then it picks up this space as a starting point for the new partition. Usually lots of sectors get lost.

syg00 11-17-2006 07:33 AM

Presuming primary partitions, no damage will be done by deleting partition(s).
Period.
No if, no but.

Logical partitions can (sometimes) cause renumbering issues, however the data is still safe.

Regardless, take note of my sig.

J.W. 11-17-2006 12:59 PM

I think when gnashley said you'd "lose the info in the partitions" he meant that you'd lose the data in those partitions. That's pretty much a given if you delete a partition.

In any case, as you know, each partition starts and end at a particular point on the drive. Suppose sdb1 is currently defined as cylinders 1 through 100, sdb2 is 101 through 500, and sdb3 is 501 through 1000. (I'm just making up the numbers). If you start cfdisk, then drop sdb1 and sdb2, the result will be free space between cylinders 1 and 500. (This has no effect on sdb3, and you do not want to make any changes to sdb3, so leave it as is.) While still in cfdisk, you can then created two new partitions out of that free space, perhaps such as redefining sdb1 as 1 through 50, and sdb2 as 51 through 500. Be sure to specify the appropriate file system for each new partition (eg, swap, ext3, and so forth)

At this point sdb1 would occupy 1 - 50, sdb2 would occupy 51 - 500, and sdb3 would occupy 501 - 1000. Save your changes, reboot, and the result will be that you have taken space away from sdb1 and given it to sdb2. sdb3 will be the same as it was before. Not to keep repeating the same point, but as sys00's sig reiterates, be sure to make a backup of any important data.

Good luck with it. I've done this exact operation many times in the past, and although it may seem intimidating if you've never done it before, it actually is not that big of a deal.

syg00 11-18-2006 02:50 AM

Quote:

Originally Posted by J.W.
I think when gnashley said you'd "lose the info in the partitions" he meant that you'd lose the data in those partitions. That's pretty much a given if you delete a partition.

Nope.
I don't presume to know what gnashley meant, but deleting partitions does NOT delete any data.
*NONE*.

You may lose the ability to address the data, but it's all still there until you over-write it.
Creating new partitions does not constituing over-writing the data.
Redefining partition(s) to cover the same space makes the data visible again.

gnashley 11-18-2006 08:21 AM

I didn't mean that the data would actually be deleted, just that the pointer to it would be lost in the partition table.
If you deleted sdb2 and sdb3 and close fdisk without creating new ones and reboot, the data is still there. But, sdb4 may become sdb2 meanwhile. Even so, it's data hasn't been moved. Not until you create a new partition and format it will the data be overwritten. If the first partition you create afterwards is larger than the empty space between old sdb1 and sdb4, the partition will use the old space and use new space after the old sdb4 space to finish.
Of course all this means we are still trying to order the partitions physically which is illusion anyway. Still, you can make a mish-mash with uneeded fragmenting of the partitions. Also, as mentioned, because of the different way that different partitioning tools determine the geometry, you may get weird results sometimes and sectors may become lost.
If you know the geometry, using 512*cyl*heads*sectors (multiply by 2 and divide by 1024 twice to get MB) will let you size your partitions so they fall on logical cylinder boundaries and no sectors are unused and fdisk/fsck won't complain.
cfdisk may not be the tool to use for the job. fdisk might do better, though sfdisk is even surer.
For a 2GB difference I wouldn't try what you want.


All times are GMT -5. The time now is 09:48 PM.