After losing the partition table of a 2TB HDD disk i run gpart to find the lost partition. Immediately after program start, it starts to scan the drive automatically. Since over 30h. So the question is, how long does this scan take? The drive is connected via SATA in System with a 2017 Celeron processor. Thanks in advance
I am looking for a way to list all partitions of a specific type on linux. (Specifically: all EFI system partitions).
I know blkid
can filter on filesystem type: the command blkid -t TYPE=vfat
returns the correct results, but is not very robust: there might be other vfat filesystems which aren't ESPs, or there might be ESPs formatted with a different filesystem.
So, is there an equivalent command that can list devices but filter on partition type?
EDIT
I need a list of all EFI System Partitions (or ESPs). These partitions have partition type EF00
in gdisk or partition type ef
in fdisk. They are most commonly formatted as vfat.
Now, I can use blkid
to list all partitions which are formatted with vfat, but that leaves two problems:
a) There might be EFI partitions not formatted with vfat (or not formatted at all) which would be missing from the list, and
b) there might be regular filesystemes formatted as vfat, which would be included in the list incorrectly.
So matching on filesystem type is not the way to go. That's why I am looking for something that can match on partition type, so EF00
or ef
.
If such a command does not exist, I would probably need to do the following to get at the information I want:
- list all disks
- for each disk, find out if there is an MBR or GPT partition table on it
- list the partition table
- filter the results to only print the ESP partitions
This is cumbersome and error-prone, so if an equivalent of blkid
exists that is able to match partition types, I would like to use that.
I'm tring to back up the partition table of a Linux Ubuntu 10.04 LTS.
Actually I'm making the tests with Virtualized machines (VirtualBox). And I have one source system in a virtual disk, another virtual machine as the rescue system, and another empty virtual disk with the same size exactly than the source system disk.
So, running the rescue system I mount the source system disk and user this command for making the partition table backup:
sfdisk /dev/sdb –d > /backup/sdb-part-table.sf
And the file gets generated and saved with this output message:
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Once I Have the partition table file I unmount the source disk and mount the backup empty disk.
I try to use this command:
sfdisk /dev/sdb < /backup/sdb-part-table.sf
Then I try again to restore the parition table but gives me this error:
Checking that no-one is using this disk right now ...
OK
Disk /dev/sdc: 265 cylinders, 255 heads, 63 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sdc1 * 0+ 245- 246- 1973248 83 Linux
/dev/sdc2 245+ 265- 20- 155649 5 Extended
/dev/sdc3 0 - 0 0 0 Empty
/dev/sdc4 0 - 0 0 0 Empty
/dev/sdc5 245+ 265- 20- 155648 82 Linux swap / Solaris
New situation:
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdc1 * 2048 3948543 3946496 83 Linux
/dev/sdc2 3950590 4261887 311298 5 Extended
/dev/sdc3 0 - 0 0 Empty
/dev/sdc4 0 - 0 0 Empty
/dev/sdc5 3950592 4261887 311296 82 Linux swap / Solaris
Warning: partition 1 does not end at a cylinder boundary
sfdisk: I don't like these partitions - nothing changed.
(If you really want this, use the --force option.)
So Finally I user force to make the restoration and seem to work:
sfdisk --force /dev/sdb < /backup/sdb-part-table.sf
Getting this result:
Checking that no-one is using this disk right now ...
OK
Disk /dev/sdc: 265 cylinders, 255 heads, 63 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sdc1 * 0+ 245- 246- 1973248 83 Linux
/dev/sdc2 245+ 265- 20- 155649 5 Extended
/dev/sdc3 0 - 0 0 0 Empty
/dev/sdc4 0 - 0 0 0 Empty
/dev/sdc5 245+ 265- 20- 155648 82 Linux swap / Solaris
New situation:
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdc1 * 2048 3948543 3946496 83 Linux
/dev/sdc2 3950590 4261887 311298 5 Extended
/dev/sdc3 0 - 0 0 Empty
/dev/sdc4 0 - 0 0 Empty
/dev/sdc5 3950592 4261887 311296 82 Linux swap / Solaris
Warning: partition 1 does not end at a cylinder boundary
Successfully wrote the new partition table
Re-reading the partition table ...
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
But, when I move the backup to the new file system witch seem to be alright, the system do not start, I have a black screen as if no OS where installed in the backup machine, comparative of Partition Tables are equal in the working source disk and in the backup not-working disk.
Mbr backup is already done and installed. I've tried to install after and before the partition table restoration.
So, any idea of how can I make it work?
Thanks in advance, and have a nice week :D
Over three consecutive days, three of our servers have lost their partition tables. Two of the machines were running linux and the third was a windows machine and all of these servers are on an internal network.
It seems unlikely to be the work of a virus or code being executed but I cannot think what else it could be. It's very odd and I cannot work out a connection.
Does any one know what might be causing this? Could this be something to do with power surges?
Update
It seems that the problem does indeed stem from the use of machinery upstairs. After 3 more failures and logging of time, it appears to coincide with the times the machinery was used upstairs. Thanks for your answers.
Accidentally wrote /dev/zero to the first 371MB of a 500GB disk. Is it possible to rebuild the partition table and/or recover what data hasn't been overwritten?