Is it safe to remove "diag" flagged partitions?

22,021

Solution 1

First, the "diag flag" is (sort of) explained in the parted documentation:

‘DIAG’

    (MS-DOS) - Enable this to indicate that a partition can be used as
 a diagnostics / recovery partition.

I've not seen any evidence that this flag is actually used, but my knowledge of the Windows world is limited. Thus, I wouldn't mess with the flag itself. I also wouldn't use it as an indicator of whether a partition is necessary.

Second, /dev/sda5 and /dev/sda7 are both pretty small -- 471MB and 1074MB, respectively. Your disk is 1000GB, so they consume a total of 0.1545% of your disk's capacity. Given that GPT can take up to 128 partitions by default (and that value can be raised, if necessary), these partitions aren't using up enough space or partition slots to be a concern -- certainly not compared to the risks involved in deleting a partition whose purpose you don't fully understand.

Third and OTOH, a lot of computers today ship with enormous amounts of bloatware, and there's been at least one recent pre-installed malware scare (Superfish). Windows 8 is also rather un-loved compared to its predecessor, Windows 7. Thus, many people prefer to wipe the pre-installed Windows and re-install using a Microsoft-provided image. This will result in a cleaner install, without any manufacturer-provided add-ons. A Web search will turn up plenty of sites describing how to get legal copies of Windows for installation; this is the first page to turn up in my search, but you can find others easily enough. Note that if you plan to install anything but the version that shipped with your computer, you may need to buy it, rather than rely on a free image from Microsoft. It's best to ask on a Windows forum if you need more help with this. The point of this paragraph, though, is that a re-install from a Microsoft image is likely to have a simpler partition layout than what you've got now, since some of those "extra" partitions probably exist to service the manufacturer-specific tools.

Solution 2

If you look at it on Windows, in the Disk Management stuff accessible by right-clicking on 'This Computer', you will immediately find out that those partitions are used for recovery, at least according to Windows.

Personally I don't think doing so is a good idea. If you are really willing to try, mount and see what's in them first. Then you can consider deleting them, which almost certainly makes the recovery from Windows 8 EFI unavilable, or resizing them with gparted so you can gain a little more space.

Share:
22,021

Related videos on Youtube

asac
Author by

asac

Lead Data Scientist in an exciting UK start-up!

Updated on September 18, 2022

Comments

  • asac
    asac over 1 year

    I have a samsung laptop which came with windows 8 on a 1TB HDD.

    I am preparing my disk with gparted. I expected to see 2 or 3 partitions but there are actually 7! Now I've brushed up on UEFI and gpt and I think I understand what these partitions are.

    parted -l yields (I added the labels by hand):

    Model: ATA ST1000LM024 HN-M (scsi)
    Disk /dev/sda: 1000GB
    Sector size (logical/physical): 512B/4096B
    Partition Table: gpt
    
    Number  Start   End     Size    File system  Name                          Flags                Label
     1      1049kB  524MB   523MB   ntfs         Basic data partition          hidden, diag        Windows RE tools
     2      524MB   839MB   315MB   fat32        EFI system partition          boot                 SYSTEM
     3      839MB   973MB   134MB                Microsoft reserved partition  msftres                      
     4      973MB   973GB   972GB   ntfs         Basic data partition          msftdata
     5      973GB   973GB   471MB   ntfs                                       hidden, diag
     6      973GB   999GB   25.8GB  ntfs         Basic data partition          hidden, diag         SAMSUNG_REC2
     7      999GB   1000GB  1074MB  fat32        Basic data partition          hidden, diag         SAMSUNG_REC
    

    I want to keep a usable windows and to keep enough to restore it if need be. My plan is to keep sda1 which apparently is needed for recovery. I obviously keep sda2 since I want my system to boot (although 300MB is a little overkill I'll keep the Microsoft reserved partition since it is small and (apparently?) needed. I will partition sda4 to make room for linux.

    My questions are about sda5, 6 and 7

    What is the purpose of sda5? It is flagged "diag" but it is unlabelled. Do I need to keep it if I want to restore windows to the factory state at some point?

    sda6 (SAMSUNG_REC2) is the recovery partition created (I guess) by a samsung tool which I must have uninstalled as soon as I got the computer. My understanding is that the Windows RE tool (on sda1) will be able to restore Windows from this recovery partition, am I right?

    sda7 (SAMSUNG_REC) is a 1GB FAT32 partition. I don't know if it is important or not since I already have SAMSUNG_REC2...

    Can I safely delete sda5 and sda7? Am I right in keeping the 5 other ones?

    • Rinzwind
      Rinzwind almost 9 years
      All of them are windows partitions... Why should we Ubuntu users know what these partitions are? I myself would have asked this on a Windows forum using the Windows equivalent of gParted.
    • asac
      asac almost 9 years
      Good point. I posted here because all the resources I found on the matter were on askubuntu. It seems the typical windows user do not play with the partitions unless they're installing linux!
    • JdeBP
      JdeBP almost 9 years
      No. Windows users, certainly in my experience, play with partitions a lot even without touching anything Linux. And if you found AskUbuntu when looking for resources on the matter of Windows, you were doing an exceedingly poor job of looking. I for one have written about diskpart numerous times, and superuser.com/questions/765089 is just one of the many other cases where people have discussed this stuff.
    • asac
      asac almost 9 years
      Admittedly, most of my searches involved "dual boot" which in restrospect was indeed a poor choice of keywords for this particular issue.
  • Rinzwind
    Rinzwind almost 9 years
    sda7 is in fat32. That alone makes me think it does something.
  • Pilot6
    Pilot6 almost 9 years
    @Rinzwind I always wipe all recovery staff, but I do not recommend it to others. But with Samsung and their weird UEFI I would keep it.
  • Rinzwind
    Rinzwind almost 9 years
    Me too. My new Asus has 100% Ubuntu on it. Everything else I deleted. I use W in VBox though for 2 things that do not work on Ubuntu and I need for work
  • asac
    asac almost 9 years
    That's what I figured. I am just weirdly put ill-at-ease knowing there are partitions I know nothing about. I know I should leave them alone ;)
  • asac
    asac almost 9 years
    I mounted them and SAMSUNG_REC seems to be a UEFI boot partition, SAMSUNG_REC2 contains a recovery image "install.wim". Interestingly, sda5 contains the same files as sda1 (mostly "winre.wim")...
  • JdeBP
    JdeBP almost 9 years
    The doco that you quote is out of date and wrong. The diag flag isn't limited just to the old MBR partitioning scheme as the quotation says. In 2010, libparted and its doco were patched so that Microsoft Recovery/Utility partitions (type de94bba4-06d1-4d40-a16a-bfd50179d6ac) were listed as "diag".
  • Zanna
    Zanna over 2 years
    Is there any documentation about this? I thought "diag" meant a diagnostic partition. Can you explain more detail what this partition is used for?
  • Abdolrasoul Safaiyan
    Abdolrasoul Safaiyan over 2 years
    I dont know, This is my experience becuse when i removed diag partition i couldnt make repartition(3 partitons) for reinstalling win11 in befor allocated space and i have to delete all other partitions on disk and then allocate necessary partition for win11