I'm trying to create an ext2 filesystem on a usb stick with one guid partition table. After formatting the first partition, gdisk reports that the main header has a bad CRC. The URL links to the original forum post regarding this issue and the formatting there may be easier to read. There's some goofiness when I transfer the usb stick to another linux box (arch linux) where either the previous filesystem (before the mkfs) is still listable (ls) or the files I wrote to the usb stick are missing. I cannot determine whether this bug is the cause, but until I figure otherwise, I'm attributing the loss of data here. Reproducible: Always Steps to Reproduce: My usb stick is /dev/sdc. 1. ============================================= # 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. 2. ============================================= # 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 gdisk -l /dev/sdc reports no errors. 3. ============================================= # 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 4. ============================================= # 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 Actual Results: 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 Expected Results: 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 Pertinent Software: 1. sys-apps/gptfdisk 0.8.4 or 0.8.5 2. sys-apps/util-linux 2.20.1-r1 3. sys-fs/e2fsprogs 1.42 4. sys-fs/e2fsprogs-libs 1.42 5. sys-kernel/gentoo-sources 3.2.12 (self compiled kernel with EFI GUID Partition config) I did a little investigating. My usb stick is /dev/sdc. Using the dd tool as follows: 1. I zeroed the my usb stick with # dd if=/dev/zero of=/dev/sdc 2. I partitioned the usb stick per step 1 in bug repro. 3. I created an image of the usbstick. # dd if=/dev/sdc of=/tmp/001-sdc-new-gpt.img 4. I formatted the usb stick per step 3 in bug repro. 5. I created another image of the usbstick. # dd if=/dev/sdc of=/tmp/002-sdc-new-ext2.img 6. I converted the binary images into hex files using hexdump # hexdump 001-sdc-new-gpt.img > 001-sdc-new-gpt.hex 7. diffing the two hex files reveals that: a. the partition modified bytes 0x200-443, and b. the filesystem cleared bytes 0x200-20F.
Portage 2.1.10.49 (default/linux/x86/10.0/desktop, gcc-4.5.3, glibc-2.14.1-r3, 3.2.12-gentoo i686) ================================================================= System uname: Linux-3.2.12-gentoo-i686-AMD_Athlon-tm-_64_Processor_3500+-with-gentoo-2.1 Timestamp of tree: Tue, 03 Jul 2012 23:00:01 +0000 app-shells/bash: 4.2_p20 dev-java/java-config: 2.1.11-r3 dev-lang/python: 2.4.6, 2.5.4-r3, 2.6.8, 2.7.3-r1, 3.1.3-r1, 3.2.3 dev-util/cmake: 2.8.7-r5 dev-util/pkgconfig: 0.26 sys-apps/baselayout: 2.1-r1 sys-apps/openrc: 0.9.8.4 sys-apps/sandbox: 2.5 sys-devel/autoconf: 2.13, 2.68 sys-devel/automake: 1.4_p6::<unknown repository>, 1.5, 1.6.3::<unknown repository>, 1.7.9-r1, 1.8.5-r3::<unknown repository>, 1.9.6-r3, 1.10.3, 1.11.1 sys-devel/binutils: 2.21.1-r1 sys-devel/gcc: 4.4.5, 4.5.3-r2 sys-devel/gcc-config: 1.5-r2 sys-devel/libtool: 2.4-r1 sys-devel/make: 3.82-r1 sys-kernel/linux-headers: 3.1 (virtual/os-headers) sys-libs/glibc: 2.14.1-r3 Repositories: gentoo seden x-portage ACCEPT_KEYWORDS="x86" ACCEPT_LICENSE="* -@EULA" CBUILD="i686-pc-linux-gnu" CFLAGS="-O2 -march=k8 -pipe -fomit-frame-pointer" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /var/lib/hsqldb" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" CXXFLAGS="-O2 -march=k8 -pipe -fomit-frame-pointer" DISTDIR="/usr/portage/distfiles" FCFLAGS="-O2 -march=i686 -pipe" FEATURES="assume-digests binpkg-logs distlocks ebuild-locks fixlafiles news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch" FFLAGS="-O2 -march=i686 -pipe" GENTOO_MIRRORS="ftp://gentoo.netnitco.net/pub/mirrors/gentoo/source/ http://gentoo.cites.uiuc.edu/pub/gentoo/ http://gentoo.netnitco.net http://chi-10g-1-mirror.fastsoft.net/pub/linux/gentoo/gentoo-distfiles/" LC_ALL="en_US.UTF-8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" PKGDIR="/usr/portage/packages" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/var/lib/layman/seden /usr/local/portage" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="3dnow 3dnowext X a52 aac accessibility acl acpi alsa avahi bash-completion beagle berkdb bluetooth branding bzip2 cairo cdda cdr cli consolekit cracklib crypt cups cxx dbus dnd dri dts dvd dvdr emboss encode exif fam fbcon firefox flac fortran gdbm gif glitz gpm gtk gtk3 inkjar ipv6 jpeg lcms ldap libnotify lua mad mmx mmxext mng modules mozilla mp3 mp4 mpeg mudflap ncurses nls nptl nsplugin ogg openal opengl openmp pam pango pcre pdf png policykit ppds pppd qt4 readline samba sdl session spell sse sse2 ssl startup-notification svg tcpd theora threads tiff truetype udev udisks unicode upower usb vdpau vorbis wifi wxwidgets x264 x86 xcb xine xml xorg xulrunner xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="access auth auth_dbm auth_anon auth_digest authz_host alias file-cache echo charset-lite cache disk-cache mem-cache ext-filter case_filter case-filter-in filter deflate mime-magic cern-meta expires headers usertrack unique_id proxy proxy-connect proxy-ftp proxy-http info include cgi cgid dav dav-fs vhost-alias speling rewrite log_config logio env setenvif mime status autoindex asis negotiation dir imap actions userdir so" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" GRUB_PLATFORMS="efi-64 pc" INPUT_DEVICES="keyboard mouse evdev joystick wacom" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" PHP_TARGETS="php5-3" PYTHON_TARGETS="python3_2 python2_7" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="dummy nvidia vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LINGUAS, MAKEOPTS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Created attachment 317662 [details] 001-sdc-new-gpt.hex hexdump of usbstick after creating the partition table with gdisk.
Created attachment 317664 [details] 002-sdc-new-ext2.hex hexdump after creating the ext2 filesystem on the first/only partition with mkfs.ext2.
Correction to #7 in description investigation: 7. diffing the two hex files reveals that: a. the partition modified bytes 0x200-443, and b. the filesystem cleared bytes 0x200-*443*.
Further analysis shows that /dev/sdc1 overlaps part of the guid partition table. I used gdisk to restore the main header from the backup header. I then performed a hexdump of /dev/sdc and /dev/sdc1 using: # dd if=/dev/sdc | hexdump > 003-sdc-fix-gpt.hex # dd if=/dev/sdc1 | hexdump > 005-sdc1-fix-gpt.hex Attachments to follow. Shouldn't the partition table be excluded from /dev/sd1?
Created attachment 317670 [details] 003-sdc-fix-gpt.hex
Created attachment 317672 [details] 005-sdc1-fix-gpt.hex
Does your kernel have GUID support enabled? Regardless of the userspace program you are using, it's the kernel that looks at the partition table and creates device nodes. Just wanted to double check.
@gokturk you nailed it. originally I checked my /usr/src/linux/.config where the option is enabled. since you asked, I also checked /proc/config.gz where the option is missing. I don't know why those two configs are out of sync, but building a new kernel to test and close this bug. Thanks for asking the obvious question :p
(In reply to comment #9) > @gokturk > you nailed it. originally I checked my /usr/src/linux/.config where the > option is enabled. since you asked, I also checked /proc/config.gz where > the option is missing. > > I don't know why those two configs are out of sync, but building a new > kernel to test and close this bug. > > Thanks for asking the obvious question :p I was about to say sorry for asking the obvious, good timing :) I also tried to reproduce your problem with no success. Can you recompile it with CONFIG_EFI_PARTITION enabled and confirm that it works?
Just finished the recompile. It works when the kernel is compiled with the CONFIG_EFI_PARTITION.
Do you mind closing this bug? I don't see a "Resolved:User Headspace" option, so not sure which is the preferred status. Thanks again :)
Marking as resolved per comment 9.