I know this isn't a question that's specific to Unix/Linux, but I think there are people who can answer this question here.

I want to hide my Windows partition from the partition table completely, then later I want it to come back. I'm sure it's something simple to do, but it's safer to ask people who know instead of fiddling with the partition table myself and mistakenly lose my data.

By "hide" I mean I want that area of the disk to appear unallocated. Basically remove the "partition entry" if that makes sense without removing the data itself, so later I can just change the partition table again to make it have a partition entry at the exact location, so I can access it again.

  • Whatever answer you use here, it would be wise to backup your partition table before doing anything. For MBR this is simple - dd if=/dev/sdX of=mbrbackup.bin bs=512 count=1. GPT is more complicated though. – Graeme Feb 22 '14 at 21:55
  • @Graeme To back up a GPT: sgdisk --backup=<file> <device>. I don't think it's more complicated than the dd solution. – Marco Feb 22 '14 at 22:15
  • @Marco simpler than dd! Thank you. – Graeme Feb 22 '14 at 22:29
  • @Graeme That's a bad idea because the MBR doesn't cover the logical volumes. – Hauke Laging Feb 22 '14 at 22:58
  1. Make a backup of the partition table (sfdisk -d /dev/sda >sda.txt (DOS MBR)
    or sgdisk --backup=<file> <device> (GPT)).

  2. Delete the partition.

  3. Restore the partition table from the backup.

Warning: Under certain conditions deleting even an unused partition may prevent your Linux from booting. This can happen if the system has references to a partition with a higher number. GRUB e.g. (I am not familiar enough with GRUB2 to assess that). My distro has been advising against using references like /dev/sda7 in fstab for years. Mounting LVM / MD volumes or partitions by label or UUID is not a problem.

  • Thanks, I will try this on a small test partition first and see if it works. – SpaceMonkey Feb 23 '14 at 22:00
  • @Spacemonkey See the warning I just added. – Hauke Laging Feb 23 '14 at 22:13

You can use TestDisk recovery for this. Get TestDisk livecd or Ubuntu Live CD with TestDisk. Copy it to the flash drive and make it bootable.

After, you can just delete your NTFS partition. Then when you want to recover it, use TestDisk livecd. More information here: https://askubuntu.com/questions/171163/how-to-recover-a-deleted-ntfs-partition-with-data

This will only work if you do not write anything nor create any new partitions on the disk.

  • I won't create any other partitions, but I will write to the other partitions that already exist, I guess that should not matter because they are in a different location. – SpaceMonkey Feb 23 '14 at 21:59
  • True, but now when I think Hauke's solution is way more elegant and easier I guess. – phoops Feb 24 '14 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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