Temporary Deleting Partition?

If it doesn't relate to Debian, but you still want to share it, please do it here

Temporary Deleting Partition?

Postby bester69 » 2017-11-06 11:44

Hi,
I need to create a new temporary partition, so i could resize one to make free space, and then hide it (temporary delete it) to be able to create the new one in the free space, cos i dont have any free available primary pratitions and also cant use extended partition for it.

Is there any easy way to do this??, I guess i just need some backup of table partition to be able to restore "temporary deleted partition";;

can you please describe me how to do it?, can i do it with gparted?? :roll:
User avatar
bester69
 
Posts: 987
Joined: 2015-04-02 13:15

Re: Temporary Deleting Partition?

Postby p.H » 2017-11-06 13:43

IIUC you want to shrink an existing partition and create a new one in the free space.
Why do you need to create a temporary partition ?
Can you show the current partition table and the expected partition table ?
p.H
 
Posts: 178
Joined: 2017-09-17 07:12

Re: Temporary Deleting Partition?

Postby bester69 » 2017-11-06 14:33

p.H wrote:IIUC you want to shrink an existing partition and create a new one in the free space.
Why do you need to create a temporary partition ?
Can you show the current partition table and the expected partition table ?


Before
Image

After
Image

I will shrink sda1 to make free space and then I want to hide it ("delete temporary that partition" wiihout losing data), and in the space freeded create the temporary partition. I can give a "Margin security space" (green on in pic) to prevent overwritten data between partittions.

Can I bring back the deleted partition In a trusted way one i finish with the temporary partition??
User avatar
bester69
 
Posts: 987
Joined: 2015-04-02 13:15

Re: Temporary Deleting Partition?

Postby andre@home » 2017-11-06 17:55

temporary delete it= delete....
QParted has no "temporary delete it "option.

Qparted has many ways to move / resize etc, so take the that will give you the desired results.

Else: write down here your old en your new wishlist partitions

Old:
sda1 ... GB NTFS for (windows?)
sda2....GB for...........
sda3.....CG NTFS for (windows?)
sda4 extended
sda5 .....GB NTFS for (windows?)
sda 6.... Linux swap

NEW:
sda1.....GB NTFS/ext4... for ....
sda2......GB NTFS/ext4... for ....
sda3......GB NTFS/ext4... for ....
sda4 extended???
sda5 ........GB NTFS/ext4... for .....
sda 6.... Linux swap

or any other way you would like it to become....
andre@home
 
Posts: 275
Joined: 2011-10-02 08:00

Re: Temporary Deleting Partition?

Postby bester69 » 2017-11-06 19:43

I wanted to know if there is any way to undelete a partiton that has not been dirty, this is what im trying to figure it out if its possible;

These are the steps i want to do:
1- Shrink partition to make free space available for a new one.
2- Save "start/end" limits of shrinked partition in order to recovere it later.
3- Delete shrinked partition
4- Create a new partition next to deleted one, using the free space we got in point.1
5- Once Ive finish using the new partiton, delete it and recover the first one by restoring in partition table "Start/end" saved in point 2.

I know testdisk can restore the deleted partitions, Its just i wanted to know if there's a trusted and porperly way to achieve this procedure (Undeleted a not dirty partition). I think testdisk try to guess the best it can, not sure testdisk can manage it always with success.
User avatar
bester69
 
Posts: 987
Joined: 2015-04-02 13:15

Re: Temporary Deleting Partition?

Postby p.H » 2017-11-06 20:35

You can save and restore a partition table with sfdisk.
Code: Select all
sfdisk -d /dev/sda > sda.ptbl # save partition table from /dev/sda
sfdisk /dev/sda < sda.ptbl # restore partition table to /dev/sda

Note : do not save the file on /dev/sda1.
p.H
 
Posts: 178
Joined: 2017-09-17 07:12

Re: Temporary Deleting Partition?

Postby RU55EL » 2017-11-07 03:58

bester69 wrote:[...] then I want to hide it ("delete temporary that partition" wiihout losing data),[...]


Are you saying that you don't want your system to mount it on boot, so that it is "hidden" from the operating system. (Of course, it could be seen by formatting programs such as fdisk, or gparted.)
User avatar
RU55EL
 
Posts: 336
Joined: 2014-04-07 03:42
Location: /home/russel

Re: Temporary Deleting Partition?

Postby dilberts_left_nut » 2017-11-07 04:43

Might work.
Might go badly.

May be extra complications to consider if it's an ssd.
AdrianTM wrote:There's no hacker in my grandma...
User avatar
dilberts_left_nut
 
Posts: 4705
Joined: 2009-10-05 07:54
Location: enzed

Re: Temporary Deleting Partition?

Postby andre@home » 2017-11-07 06:43

The you'v spent here would have been more than enough to start backups of data you might have lost doing this.
After this is finished (preferably 2 backups), you reorganize the disk in the way you like it and then put your data back.
Of course there are tools te recover partitions/data ... but they are there for "accidents" in cases you do not have backups.
The route you want to go we call in our country... "het paard achter de wagen spannen".. as I'm not native English I have to guess for the right translation...
Attempts:
"to come the day after the fair "
and
"to put the cart before the horse"
So not very handy ways to act.

Going the "backup route" is imho THE way to go.
andre@home
 
Posts: 275
Joined: 2011-10-02 08:00

Re: Temporary Deleting Partition?

Postby p.H » 2017-11-07 08:54

RU55EL wrote:Are you saying that you don't want your system to mount it on boot, so that it is "hidden" from the operating system.

No. If I understand correctly, the OP needs to create a new temporary primary partition for whatever untold purpose but there are already 4 primary/extended partitions, so no more can be added. The suggested workaround is to delete an existing primary partition and re-use the free partition table entry to create the temporary primary partition in unused disk space. When the temporary partition is not needed any more, it will be deleted and the original partition with its original position, size, type and flags will be restored in the partition table entry.

I advise not to use Gparted to do these operations because it is too smart and may do other things transparently, and to use simpler tools such as fdisk.
p.H
 
Posts: 178
Joined: 2017-09-17 07:12

Re: Temporary Deleting Partition?

Postby wizard10000 » 2017-11-07 09:51

p.H wrote:...I advise not to use Gparted to do these operations because it is too smart and may do other things transparently, and to use simpler tools such as fdisk.


This.

What bester is trying to do isn't rocket science but I wouldn't do it without an excellent backup :mrgreen:

Use fdisk. See output of fdisk -l below:
Code: Select all
Device     Boot    Start       End   Sectors   Size Id Type
/dev/sdb1  *        2048  32155647  32153600  15.3G 83 Linux
/dev/sdb2       32155648  40552447   8396800     4G 82 Linux swap / Solaris
/dev/sdb3       40552448 468860927 428308480 204.2G 83 Linux


Write down the start and end sectors of the partition you want to delete. Go ahead and do your thing with creating a temporary partition and when you're ready to recreate the original partition use the start and end sectors, partition type and boot flag you wrote down earlier. Use fdisk to re-create the partition, not gparted.

Note that the UUID of the re-created partition will most likely change and you'll need to account for that in fstab.
we see things not as they are, but as we are.
-- anais nin
User avatar
wizard10000
 
Posts: 1224
Joined: 2011-05-09 20:02
Location: everywhere i go, there i am!

Re: Temporary Deleting Partition?

Postby p.H » 2017-11-07 11:36

wizard10000 wrote:Write down the start and end sectors of the partition you want to delete. Go ahead and do your thing with creating a temporary partition and when you're ready to recreate the original partition use the start and end sectors, partition type and boot flag you wrote down earlier. Use fdisk to re-create the partition, not gparted.

This is exactly what sfdisk does, in a format that can be used to restore the original partition layout without the need for any tedious and error-prone manual operation.

wizard10000 wrote:Note that the UUID of the re-created partition will most likely change and you'll need to account for that in fstab.

No. The filesystem UUID is not stored in the partition table entry but in the partition data area, which is untouched.

On GPT partition scheme a partition UUID (also called GUID) and a partition label are stored in the partition table entry and can be used with PARTUUID= and PARTLABEL=, but this drive has an MSDOS partition scheme, which does not store any partition UUID or label.
The Linux kernel only creates synthetic partition UUIDs from the disk identifier in the MBR and the partition numbers, but this won't change as the partition number does not change.
p.H
 
Posts: 178
Joined: 2017-09-17 07:12

Re: Temporary Deleting Partition?

Postby bester69 » 2017-11-07 12:08

p.H wrote:
RU55EL wrote:Are you saying that you don't want your system to mount it on boot, so that it is "hidden" from the operating system.

No. If I understand correctly, the OP needs to create a new temporary primary partition for whatever untold purpose but there are already 4 primary/extended partitions, so no more can be added. The suggested workaround is to delete an existing primary partition and re-use the free partition table entry to create the temporary primary partition in unused disk space. When the temporary partition is not needed any more, it will be deleted and the original partition with its original position, size, type and flags will be restored in the partition table entry.

I advise not to use Gparted to do these operations because it is too smart and may do other things transparently, and to use simpler tools such as fdisk.

You understand it, very well, that's exactlly what I'm looking for (A workaround)...

p.H wrote:You can save and restore a partition table with sfdisk.
Code: Select all
sfdisk -d /dev/sda > sda.ptbl # save partition table from /dev/sda
sfdisk /dev/sda < sda.ptbl # restore partition table to /dev/sda

Note : do not save the file on /dev/sda1.

This Solution seems truted and secure,
I think I will try it, I wont commit any backup. :shock: One thing, Ive the grub installed in /dev/sda; deleting sda1 I suppose there's not problem and I suppose once I restore table partition I wont lose grub neither.

Thanks p.H
User avatar
bester69
 
Posts: 987
Joined: 2015-04-02 13:15

Re: Temporary Deleting Partition?

Postby bester69 » 2017-11-07 12:12

wizard10000 wrote:....
Note that the UUID of the re-created partition will most likely change and you'll need to account for that in fstab.

Ok,Got it.

Thanks
User avatar
bester69
 
Posts: 987
Joined: 2015-04-02 13:15

Re: Temporary Deleting Partition?

Postby p.H » 2017-11-07 12:21

bester69 wrote:One thing, Ive the grub installed in /dev/sda; deleting sda1 I suppose there's not problem and I suppose once I restore table partition I wont lose grub neither.

I guess you mean that GRUB boot image is installed in the MBR of /dev/sda. But where are GRUB core image and the /boot/grub directory ?
If either is in the partition /dev/sda1, then GRUB won't work when the partition is deleted.
In any case, you won't lose GRUB after the partition table is restored unless you messed with GRUB parts.
p.H
 
Posts: 178
Joined: 2017-09-17 07:12

Next

Return to Offtopic

Who is online

Users browsing this forum: stevepusser and 4 guests

fashionable