Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
e2fsprogs mkfs corrupts main gpt header on usb stick
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
charetjc
n00b
n00b


Joined: 21 Jul 2006
Posts: 19

PostPosted: Mon Jul 09, 2012 1:54 am    Post subject: e2fsprogs mkfs corrupts main gpt header on usb stick Reply with quote

I'm trying to create an ext2 filesystem on a usbstick with one guid partition table. After formatting the first partition, gdisk reports that the main header has a bad CRC.

Software:
    sys-apps/gptfdisk 0.8.4 or 0.8.5
    sys-apps/util-linux 2.20.1-r1
    sys-fs/e2fsprogs 1.42
    sys-fs/e2fsprogs-libs 1.42
    sys-kernel/gentoo-sources 3.2.12 (self compiled kernel with EFI GUID Partition config)


Steps to reproduce:

My usb stick is /dev/sdc.

Code:
# gdisk /dev/sdc
Command (? for help): n (accept defaults for other questions)
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.

# gdisk -l /dev/sdc
GPT fdisk (gdisk) version 0.8.5

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sdc: 246272 sectors, 120.2 MiB
Logical sector size: 512 bytes
Disk identifier (GUID): BE3F7105-0FED-4736-9502-276A540B3F0D
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 246238
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          246238   119.2 MiB   8300  Linux filesystem


At this point I can remove and insert the usb stick and the
Code:
gdisk -l /dev/sdc
reports no errors.

Code:
# mkfs.ext2 /dev/sdc1
mke2fs 1.42 (29-Nov-2011)
warning: 251 blocks unused.

Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
30840 inodes, 122881 blocks
6156 blocks (5.01%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
15 block groups
8192 blocks per group, 8192 fragments per group
2056 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729

Allocating group tables: done                           
Writing inode tables: done                           
Writing superblocks and filesystem accounting information: done

# gdisk -l /dev/sdc
GPT fdisk (gdisk) version 0.8.5

Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!

Caution! After loading partitions, the CRC doesn't check out!
Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!

Warning! One or more CRCs don't match. You should repair the disk!

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************
Disk /dev/sdc: 246272 sectors, 120.2 MiB
Logical sector size: 512 bytes
Disk identifier (GUID): BE3F7105-0FED-4736-9502-276A540B3F0D
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 246238
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          246238   119.2 MiB   8300  Linux filesystem


And now the main GPT header is corrupted. This bug/feature/"f*&! up on my part" is 100% reproducible on my gentoo box.

I can easily restore the main GPT header with gdisk, but this problem shouldn't be occurring in the first place. On top of that, the data I save on this usb stick disappears when I try to mount it on my other linux box (arch linux). I'm not sure if this data loss is related, but trying to solve one problem at a time.

Anyone know why this "just doesn't work"?

Thanks
Back to top
View user's profile Send private message
nlsa8z6zoz7lyih3ap
Apprentice
Apprentice


Joined: 25 Sep 2007
Posts: 287
Location: Canada

PostPosted: Sun Jul 15, 2012 2:22 pm    Post subject: Reply with quote

I am unable to replicate your problem. Perhaps the problem is with that particular USB stick.
Have your tried this with another one or even a different brand?
After making the ext2 file system I get
Quote:
gdisk -l /dev/sdb
GPT fdisk (gdisk) version 0.8.4

Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sdb: 31326208 sectors, 14.9 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 157C2DE5-3C81-4663-A4BB-CE8EFD6E2358
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 31326174
Partitions will be aligned on 64-sector boundaries
Total free space is 30 sectors (15.0 KiB)

Number Start (sector) End (sector) Size Code Name
1 64 31326174 14.9 GiB 8300 Linux filesystem
Back to top
View user's profile Send private message
piedar
Tux's lil' helper
Tux's lil' helper


Joined: 09 Aug 2010
Posts: 80

PostPosted: Fri Jul 27, 2012 11:26 pm    Post subject: Reply with quote

I just ran into this on a new SSD that I'm preparing with an external eSATA connector.

Code:
system76-pc ~ # gdisk -l /dev/sdb
GPT fdisk (gdisk) version 0.8.4

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sdb: 241612976 sectors, 115.2 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 3B2B8F2A-E6AF-4608-B0C7-432F1E294C2E
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 241612942
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        52430847   25.0 GiB    8300  Linux filesystem
   2        52430848       241612942   90.2 GiB    8300  Linux filesystem

system76-pc ~ # mkfs.ext4 /dev/sdb1
mke2fs 1.42 (29-Nov-2011)
Discarding device blocks: done                           
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
7553024 inodes, 30201621 blocks
1510081 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
922 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
   32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
   4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

system76-pc ~ # gdisk -l /dev/sdb
GPT fdisk (gdisk) version 0.8.4

Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!

Caution! After loading partitions, the CRC doesn't check out!
Warning! Main and backup partition tables differ! Use the 'c' and 'e' options
on the recovery & transformation menu to examine the two tables.

Warning! One or more CRCs don't match. You should repair the disk!

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

Warning! Secondary partition table overlaps the last partition by
2305983746473025938 blocks!
You will need to delete this partition or resize it in another utility.
Disk /dev/sdb: 241612976 sectors, 115.2 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 3B2B8F2A-E6AF-4608-B0C7-432F1E294C2E
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 241612942
Partitions will be aligned on 1-sector boundaries
Total free space is 241612909 sectors (115.2 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   5  140737488388096            8192   8.0 ZiB     FFFF  
   7  140733208100864  63331865464930305   28.1 EiB    FFFF 
  29   4475355923458  2305979344360572449   1.0 ZiB     FFFF 
  30   4492535792646  2305979344360574497   1.0 ZiB     FFFF 
  31   4509715661834  2305979344360576545   1.0 ZiB     FFFF 
  32   4526895531022  2305983746702056993   1.0 ZiB     FFFF 
  33  2251872828653569  2305983746702574112   1023.1 EiB  FFFF 
  34  2251890008522757  2305983746702576160   1023.1 EiB  FFFF 
  35  2251907188391945  2305979344361099808   1023.1 EiB  FFFF 
  36  2251924368261133  2305983746702580256   1023.1 EiB  FFFF 
  37  4503672642863105  2305983746703098400   1022.1 EiB  FFFF 
  38  4503689822732293  2305983746703100448   1022.1 EiB  FFFF 
  39  4503707002601481  2305983746703102496   1022.1 EiB  FFFF 
  40  4503724182470669  2305983746703104544   1022.1 EiB  FFFF 
  41  6755472457072641  2305979344362144288   1021.1 EiB  FFFF 
  42  6755489636941829  2305983746703624736   1021.1 EiB  FFFF 
  43  6755506816811017  2305983746703626784   1021.1 EiB  FFFF 
  44  6755523996680205  2305983746703628832   1021.1 EiB  FFFF 
  45  9007272271282177  2305983746704146976   1020.1 EiB  FFFF 
  46  9007289451151365  2305983746704149024   1020.1 EiB  FFFF 
  47  9007306631020553  2305983746704151072   1020.1 EiB  FFFF 
  48  9007323810889741  2305983746704153120   1020.1 EiB  FFFF 
  49  11259072085491713  2305979344363192864   1019.1 EiB  FFFF 
  50  11259089265360901  2305983746704673312   1019.1 EiB  FFFF 
  51  11259106445230089  2305983746704675360   1019.1 EiB  FFFF 
  52  11259123625099277  2305983746704677408   1019.1 EiB  FFFF 
  53  13510871899701249  2305983746705195552   1018.1 EiB  FFFF 
  54  13510889079570437  2305983746705197600   1018.1 EiB  FFFF 
  55  13510906259439625  2305983746705199648   1018.1 EiB  FFFF 
  56  13510923439308813  2305983746705201696   1018.1 EiB  FFFF 
  57  15762671713910785  2305983746705719840   1017.1 EiB  FFFF 
  58  15762688893779973  2305983746705721888   1017.1 EiB  FFFF 
  59  15762706073649161  2305983746705723936   1017.1 EiB  FFFF 
  60  15762723253518349  2305979344364247584   1017.1 EiB  FFFF 
  61  18014471528120321  2305983746706244128   1016.1 EiB  FFFF 
  62  18014488707989509  2305983746706246176   1016.1 EiB  FFFF 
  63  18014505887858697  2305983746706248224   1016.1 EiB  FFFF 
  64  18014523067727885  2305983746706250272   1016.1 EiB  FFFF 
  65  20266271342329857  2305983746706768416   1015.1 EiB  FFFF 
  66  20266288522199045  2305983746706770464   1015.1 EiB  FFFF 
  67  20266305702068233  2305983746706772512   1015.1 EiB  FFFF 
  68  20266322881937421  2305983746706774560   1015.1 EiB  FFFF 
  69  22518071156539393  2305983746707292704   1014.1 EiB  FFFF 
  70  22518088336408581  2305983746707294752   1014.1 EiB  FFFF 
  71  22518105516277769  2305983746707296800   1014.1 EiB  FFFF 
  72  22518122696146957  2305983746707298848   1014.1 EiB  FFFF 
  73  24769870970748929  2305983746707816992   1013.1 EiB  FFFF 
  74  24769888150618117  2305983746707819040   1013.1 EiB  FFFF 
  75  24769905330487305  2305983746707821088   1013.1 EiB  FFFF 
  76  24769922510356493  2305983746707823136   1013.1 EiB  FFFF 
  77  27021670784958465  2305983746708341280   1012.1 EiB  FFFF 
  78  27021687964827653  2305983746708343328   1012.1 EiB  FFFF 
  79  27021705144696841  2305983746708345376   1012.1 EiB  FFFF 
  80  27021722324566029  2305983746708347424   1012.1 EiB  FFFF 
  81  29273470599168001  2305983746708865568   1011.1 EiB  FFFF 
  82  29273487779037189  2305983746708867616   1011.1 EiB  FFFF 
  83  29273504958906377  2305983746708869664   1011.1 EiB  FFFF 
  84  29273522138775565  2305983746708871712   1011.1 EiB  FFFF 
  85  31525270413377537  2305983746709389856   1010.1 EiB  FFFF 
  86  31525287593246725  2305983746709391904   1010.1 EiB  FFFF 
  87  31525304773115913  2305983746709393952   1010.1 EiB  FFFF 
  88  31525321952985101  2305983746709396000   1010.1 EiB  FFFF 
  89  33777070227587073  2305983746709914144   1009.1 EiB  FFFF 
  90  33777087407456261  2305983746709916192   1009.1 EiB  FFFF 
  91  33777104587325449  2305983746709918240   1009.1 EiB  FFFF 
  92  33777121767194637  2305983746709920288   1009.1 EiB  FFFF 
  93  36028870041796609  2305983746710438432   1008.1 EiB  FFFF 
  94  36028887221665797  2305983746710440480   1008.1 EiB  FFFF 
  95  36028904401534985  2305983746710442528   1008.1 EiB  FFFF 
  96  36028921581404173  2305983746710444576   1008.1 EiB  FFFF 
  97  38280669856006145  2305983746710962720   1007.1 EiB  FFFF 
  98  38280687035875333  2305983746710964768   1007.1 EiB  FFFF 
  99  38280704215744521  2305983746710966816   1007.1 EiB  FFFF 
 100  38280721395613709  2305983746710968864   1007.1 EiB  FFFF 
 101  40532469670215681  2305983746711487008   1006.1 EiB  FFFF 
 102  40532486850084869  2305983746711489056   1006.1 EiB  FFFF 
 103  40532504029954057  2305983746711491104   1006.1 EiB  FFFF 
 104  40532521209823245  2305983746711493152   1006.1 EiB  FFFF 
 105  42784269484425217  2305983746712011296   1005.1 EiB  FFFF 
 106  42784286664294405  2305983746712013344   1005.1 EiB  FFFF 
 107  42784303844163593  2305983746712015392   1005.1 EiB  FFFF 
 108  42784321024032781  2305983746712017440   1005.1 EiB  FFFF 
 109  45036069298634753  2305983746712535584   1004.1 EiB  FFFF 
 110  45036086478503941  2305983746712537632   1004.1 EiB  FFFF 
 111  45036103658373129  2305983746712539680   1004.1 EiB  FFFF 
 112  45036120838242317  2305983746712541728   1004.1 EiB  FFFF 
 113  47287869112844289  2305983746713059872   1003.1 EiB  FFFF 
 114  47287886292713477  2305983746713061920   1003.1 EiB  FFFF 
 115  47287903472582665  2305983746713063968   1003.1 EiB  FFFF 
 116  47287920652451853  2305983746713066016   1003.1 EiB  FFFF 
 117  49539668927053825  2305983746713584160   1002.1 EiB  FFFF 
 118  49539686106923013  2305983746713586208   1002.1 EiB  FFFF 
 119  49539703286792201  2305983746713588256   1002.1 EiB  FFFF 
 120  49539720466661389  2305983746713590304   1002.1 EiB  FFFF 
 121  51791468741263361  2305983746714108448   1001.1 EiB  FFFF 
 122  51791485921132549  2305983746714110496   1001.1 EiB  FFFF 
 123  51791503101001737  2305983746714112544   1001.1 EiB  FFFF 
 124  51791520280870925  2305983746714114592   1001.1 EiB  FFFF 
 125  54043268555472897  2305983746714632736   1000.1 EiB  FFFF 
 126  54043285735342085  2305983746714634784   1000.1 EiB  FFFF 
 127  54043302915211273  2305983746714636832   1000.1 EiB  FFFF 
 128  54043320095080461  2305983746714638880   1000.1 EiB  FFFF


I'm not really interested enough in GPT to futz with it, so I've just used MBR and fdisk instead.
Back to top
View user's profile Send private message
okel
n00b
n00b


Joined: 04 Nov 2004
Posts: 38

PostPosted: Thu Sep 05, 2013 11:13 am    Post subject: Reply with quote

I have this problem on my machine. The drive is a 3 TB external hard disk, connected with eSATA II.

After having created a single partition with default values using gdisk /dev/sda, I create the file system:

Quote:
borg ~ # mkfs.ext4 -m 0 /dev/sda1
mke2fs 1.42.7 (21-Jan-2013)
Die Ausrichtung von /dev/sda1 ist um 3584 Bytes verschoben.
Das könnte zu sehr schlechter Leistung führen. Eine (Neu-)Partionierung
wird empfohlen.
Dateisystem-Label=
OS-Typ: Linux
Blockgröße=4096 (log=2)
Fragmentgröße=4096 (log=2)
Stride=0 Blöcke, Stripebreite=0 Blöcke
134217728 Inodes, 536870911 Blöcke
0 Blöcke (0.00%) reserviert für den Superuser
Erster Datenblock=0
Maximale Dateisystem-Blöcke=0
16384 Blockgruppen
32768 Blöcke pro Gruppe, 32768 Fragmente pro Gruppe
8192 Inodes pro Gruppe
Superblock-Sicherungskopien gespeichert in den Blöcken:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000

Platz für Gruppentabellen wird angefordert: erledigt
Inode-Tabellen werden geschrieben: erledigt
Erstelle Journal (32768 Blöcke): erledigt
Schreibe Superblöcke und Dateisystem-Accountinginformationen: erledigt


Seems fine except for the bad alignment.

Then the gpt is damaged:
Quote:
borg ~ # gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.6

Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!

Caution! After loading partitions, the CRC doesn't check out!
Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!

Warning! One or more CRCs don't match. You should repair the disk!

Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

Command (? for help):


I appreciate any ideas.

Stefan
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum