Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Temporary Deleting Partition?

Off-Topic discussions about science, technology, and non Debian specific topics.
Message
Author
User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Temporary Deleting Partition?

#1 Post by bester69 »

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:
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Temporary Deleting Partition?

#2 Post by p.H »

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 ?

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: Temporary Deleting Partition?

#3 Post by bester69 »

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??
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

andre@home
Posts: 398
Joined: 2011-10-02 08:00

Re: Temporary Deleting Partition?

#4 Post by andre@home »

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....

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: Temporary Deleting Partition?

#5 Post by bester69 »

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.
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Temporary Deleting Partition?

#6 Post by p.H »

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.

User avatar
RU55EL
Posts: 546
Joined: 2014-04-07 03:42
Location: /home/russel

Re: Temporary Deleting Partition?

#7 Post by RU55EL »

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
dilberts_left_nut
Administrator
Administrator
Posts: 5346
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 12 times
Been thanked: 66 times

Re: Temporary Deleting Partition?

#8 Post by dilberts_left_nut »

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...

andre@home
Posts: 398
Joined: 2011-10-02 08:00

Re: Temporary Deleting Partition?

#9 Post by andre@home »

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.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Temporary Deleting Partition?

#10 Post by p.H »

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
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Temporary Deleting Partition?

#11 Post by p.H »

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.

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: Temporary Deleting Partition?

#12 Post by bester69 »

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
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: Temporary Deleting Partition?

#13 Post by bester69 »

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
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Temporary Deleting Partition?

#14 Post by p.H »

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.

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: Temporary Deleting Partition?

#15 Post by bester69 »

p.H wrote:
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.
ok, Installation is in sda2 so there is boot image. I checked partition table is MSDOS, I think there's no problem with sfdisk, im about to commit ,. lets cross the fingers :mrgreen:
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: Temporary Deleting Partition?

#16 Post by bester69 »

This disk is currently in use - it is not advisable to recreate partitions. Unmount all file systems and undo all the sharing partitions on this disk. use the --no-reread indicator to eliminate this check.
Is there much risks by commiting in live session??, I already did it, but i'd like to know for the next one. :mrgreen:
sudo sfdisk /dev/sda < sda.ptbl --no-reread
failure to read the partition table again .: device or resource occupied the kernel still uses the old table. the new table will be used at the next restart or after you execute partprobe (8) or kpartx (8).
I executed partprobe to load the new table, and everything seems ok.
Last edited by bester69 on 2017-11-07 14:15, edited 1 time in total.
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: Temporary Deleting Partition?

#17 Post by bester69 »

sfdisk WORKS like a charm!!!

I did it with success, I didnt see mayor risks in using sfdisk in live session, I did many tests, and kernel didnt explode in the way, so my conclusion is THIS IS a GREAT procedure!! I will document it for myself, We can use this workaround to bypass a temporary 4 partitions limitation.

The only care i see we must take, is not to overlap the "deleted partition" with the "temporary new one", So i'd recommend to leave a gap of 1Gb between both adjacent partitions.

As for me, Its a fixed case. :D

Thanks to all, for your help.
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Temporary Deleting Partition?

#18 Post by p.H »

wizard10000 wrote:You could also do it with dd
Yes in the specific case of this thread because you only touch the primary partition table which is stored in the MBR.

But not in the general case if you touch a logical partition. Each logical partition entry is in a separate extended partition table stored in a different sector, the first one being the EBR at the beginning of the extended partition. So with dd you would need to save the MBR and all these sectors (after determining their positions, which is not trivial).
bester69 wrote:We can use this workaround to bypass a temporary 4 partitions limitation.
By the way, may I ask why you need a primary partition and not a logical partition ?

PS : I just remembered that recent fdisk has interactive commands to save/restore the partition layout with the same format as sfdisk.

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: Temporary Deleting Partition?

#19 Post by bester69 »

p.H wrote:...
By the way, may I ask why you need a primary partition and not a logical partition ?

PS : I just remembered that recent fdisk has interactive commands to save/restore the partition layout with the same format as sfdisk.
I dont have enought free space in my hard disk, so i have to play with additional partitions, The extended partition is well defined as you can see in the picture, and everytime i wanted to install something I needed to use the extended partition to create a logic one,. Now thanks to your help, i can make use of the windows partition (sda1), to make free temporary space for a testing installation., or i could use free space of sda2 (system installation) to use it for a testing installation as I can delete sda1 for a while and bright it back eventually. Its really great!!, I was missing this workaround for long, ill write it down in my personal How-book.

Thanks, p.H. :wink:
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

andre@home
Posts: 398
Joined: 2011-10-02 08:00

Re: Temporary Deleting Partition?

#20 Post by andre@home »

Taking a temporally (cheap) disk would have been a lot more comfortable.
The limits of only 4 partitions is a very known issue, and if you wanna go beyond that limit you need partition manager that can handle that.
Even if you do know that on before that, I would advise not to use that route, as any change of partions is a risk of loosing data.
So whatever you you ... you will need that extra disk anyhow. So the workaround seems a more theoretical and not a very practical route to be advised. I hope you saved all your data from your disk that you wanna change on at least 1 preferably 2 backups disks. Else you're playing with fire... "
and we might have expected a new question from you...: "Help I lost my data while I tried to delete and later recover a partition....
You were lucky..... all went ok...

Post Reply