1 (edited by g.fink 2015-02-08 21:59:18)

Topic: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

I test with systenrescuecd 4.5.0 and gparted-live-0.21.0-1-i586.iso

GParted 0.21.0 --enable-online-resize
Libparted 3.2

After a shrink the the FAT32 filesystem it is full working with linux.
WinXP/Vista show the "bad filesystem,want format" dialog.

This happens every time i try to shrink a FAt32 filesysten on a USB stick.

A crosscheck with an old system show minor differences, but i dont know what is going wrong.

One different thing is the root directory start:

bad try:
Root directory start at cluster 489 (arbitrary size)
good try, old gparted:
Root directory start at cluster 7 (arbitrary size)

Here are some details:
gparted log:

GParted 0.21.0 --enable-online-resize

Libparted 3.2
Shrink /dev/sdb1 from 1.93 GiB to 1000.00 MiB  00:00:11    ( SUCCESS )
         
calibrate /dev/sdb1  00:00:00    ( SUCCESS )
         
path: /dev/sdb1
start: 2048
end: 4050943
size: 4048896 (1.93 GiB)
check file system on /dev/sdb1 for errors and (if possible) fix them  00:00:02    ( SUCCESS )
         
fsck.fat -a -w -v /dev/sdb1
         
fsck.fat 3.0.26 (2014-03-07)
fsck.fat 3.0.26 (2014-03-07)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "mkfs.fat"
Media byte 0xf8 (hard disk)
512 bytes per logical sector
4096 bytes per cluster
32 reserved sectors
First FAT starts at byte 16384 (sector 32)
2 FATs, 32 bit entries
2020864 bytes per FAT (= 3947 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 4058112 (sector 7926)
505121 data clusters (2068975616 bytes)
62 sectors/track, 64 heads
2048 hidden sectors
4048896 sectors total
/
Bad short file name ().
Auto-renaming it.
Renamed to
Reclaiming unconnected clusters.
Checking free cluster summary.
/dev/sdb1: 1 files, 1/505121 clusters
shrink file system  00:00:08    ( SUCCESS )
         
using libparted
shrink partition from 1.93 GiB to 1000.00 MiB  00:00:01    ( SUCCESS )
         
old start: 2048
old end: 4050943
old size: 4048896 (1.93 GiB)
new start: 2048
new end: 2050047
new size: 2048000 (1000.00 MiB)

========================================

bad /dev/sdb1 dump

00000000  28 66 c0 4d 53 57 49 4e  34 2e 31 00 02 08 28 00  |(f.MSWIN4.1...(.|
00000010  02 00 00 00 00 f8 00 00  3e 00 40 00 00 08 00 00  |........>.@.....|
00000020  00 40 1f 00 cf 07 00 00  00 00 00 00 02 00 00 00  |.@..............|
00000030  01 00 06 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  80 00 29 13 f2 81 1f 4e  4f 20 4e 41 4d 45 20 20  |..)....NO NAME  |
00000050  20 20 46 41 54 33 32 20  20 20 09 09 01 01 01 01  |  FAT32   ......|
00000060  01 01 01 02 3a 3a 3a 31  39 33 31 00 18 00 00 00  |....:::1931.....|
00000070  18 00 00 00 01 00 00 00  48 00 00 00 88 00 00 00  |........H.......|
00000080  01 00 10 00 00 00 00 00  01 00 00 00 00 00 00 00  |................|
00000090  06 00 10 00 00 00 00 00  a8 03 7c 08 00 00 00 00  |..........|.....|
000000a0  07 00 10 00 00 00 00 00  d8 05 7c 08 00 00 00 00  |..........|.....|
000000b0  0b 00 10 00 00 00 00 00  08 0f 7d 08 00 00 00 00  |..........}.....|
000000c0  0c 00 10 00 00 00 00 00  58 08 7d 08 00 00 00 00  |........X.}.....|
000000d0  0e 00 10 00 00 00 00 00  81 44 00 00 00 00 00 00  |.........D......|
000000e0  01 00 60 00 00 00 00 00  8f 34 cf 54 00 00 00 00  |..`......4.T....|
000000f0  01 00 20 01 00 00 00 00  01 00 00 00 00 00 00 00  |.. .............|
00000100  08 01 00 00 88 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

working reference dump:

00000000  eb 58 90 4d 53 57 49 4e  34 2e 31 00 02 08 28 00  |.X.MSWIN4.1...(.|
00000010  02 00 00 00 00 f8 00 00  3e 00 40 00 00 08 00 00  |........>.@.....|
00000020  00 60 1f 00 d7 07 00 00  00 00 00 00 02 00 00 00  |.`..............|
00000030  01 00 06 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  80 00 29 f5 45 1d 1e 4e  4f 20 4e 41 4d 45 20 20  |..).E..NO NAME  |
00000050  20 20 46 41 54 33 32 20  20 20 0e 1f be 77 7c ac  |  FAT32   ...w|.|
00000060  22 c0 74 0b 56 b4 0e bb  07 00 cd 10 5e eb f0 32  |".t.V.......^..2|
00000070  e4 cd 16 cd 19 eb fe 54  68 69 73 20 69 73 20 6e  |.......This is n|
00000080  6f 74 20 61 20 62 6f 6f  74 61 62 6c 65 20 64 69  |ot a bootable di|
00000090  73 6b 2e 20 20 50 6c 65  61 73 65 20 69 6e 73 65  |sk.  Please inse|
000000a0  72 74 20 61 20 62 6f 6f  74 61 62 6c 65 20 66 6c  |rt a bootable fl|
000000b0  6f 70 70 79 20 61 6e 64  0d 0a 70 72 65 73 73 20  |oppy and..press |
000000c0  61 6e 79 20 6b 65 79 20  74 6f 20 74 72 79 20 61  |any key to try a|
000000d0  67 61 69 6e 20 2e 2e 2e  20 0d 0a 00 00 00 00 00  |gain ... .......|
000000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*

2

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

There are several steps involved in resizing the file system.  One of the first steps is to check the file system to see if there are any problems.

From the log you provided, I noticed there appears to be some issues in the output from the "fsck.fat -a -w -v /dev/sdb1".

Bad short file name ().
Auto-renaming it.
Renamed to
Reclaiming unconnected clusters.

Prior to resizing, would you be able to run a "chkdsk /f" from Windows on the USB flash drive?

3

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

I made now a clean test with the same bad result.

Zero out the USB stick.
Boot gparted-live-0.21.0-1-i586.iso from CD
Use gparted to create a MS partitiontable and a fullsize FAT32 partition.
Mount and copy a testfile on the new partition.
Unmount the partition.
Shrink and check the new partition.
Boot vista: "you have to format the device before using"
Boot Win7: "you have to format the device before using"
Boot debian7: device work well

gparted log
################################
 GParted 0.21.0 --enable-online-resize

libparted 3.2
/dev/sdb1 von 1.93 GiB auf 1000.00 MiB verkleinern  00:00:02    ( ERFOLG )
        
/dev/sdb1 kalibrieren  00:00:00    ( ERFOLG )
        
Pfad: /dev/sdb1
Anfang: 2048
Ende: 4050943
Größe: 4048896 (1.93 GiB)
Dateisystem auf /dev/sdb1 auf Fehler überprüfen und (falls möglich) diese beheben  00:00:00    ( ERFOLG )
        
fsck.fat -a -w -v /dev/sdb1
        
fsck.fat 3.0.27 (2014-11-12)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "mkfs.fat"
Media byte 0xf8 (hard disk)
512 bytes per logical sector
4096 bytes per cluster
32 reserved sectors
First FAT starts at byte 16384 (sector 32)
2 FATs, 32 bit entries
2020864 bytes per FAT (= 3947 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 4058112 (sector 7926)
505121 data clusters (2068975616 bytes)
62 sectors/track, 64 heads
2048 hidden sectors
4048896 sectors total
Reclaiming unconnected clusters.
Checking free cluster summary.
/dev/sdb1: 2 files, 2/505121 clusters
Dateisystem verkleinern  00:00:02    ( ERFOLG )
        
libparted wird verwendet
Partition von 1.93 GiB auf 1000.00 MiB verkleinern  00:00:00    ( ERFOLG )
        
Alter Anfang: 2048
Altes Ende: 4050943
Alte Größe: 4048896 (1.93 GiB)
Neuer Anfang: 2048
Neues Ende: 2050047
Neue Größe: 2048000 (1000.00 MiB)

========================================
Dateisystem (fat32) auf /dev/sdb1 überprüfen und reparieren  00:00:02  ( ERFOLG )
        
/dev/sdb1 kalibrieren  00:00:01    ( ERFOLG )
        
Pfad: /dev/sdb1
Anfang: 2048
Ende: 2050047
Größe: 2048000 (1000.00 MiB)
Dateisystem auf /dev/sdb1 auf Fehler überprüfen und (falls möglich) diese beheben  00:00:00    ( ERFOLG )
        
fsck.fat -a -w -v /dev/sdb1
        
fsck.fat 3.0.27 (2014-11-12)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "MSWIN4.1"
Media byte 0xf8 (hard disk)
512 bytes per logical sector
4096 bytes per cluster
40 reserved sectors
First FAT starts at byte 20480 (sector 40)
2 FATs, 32 bit entries
1023488 bytes per FAT (= 1999 sectors)
Root directory start at cluster 490 (arbitrary size)
Data area starts at byte 2067456 (sector 4038)
255495 data clusters (1046507520 bytes)
62 sectors/track, 64 heads
2048 hidden sectors
2048000 sectors total
Reclaiming unconnected clusters.
Checking free cluster summary.
/dev/sdb1: 2 files, 2/255495 clusters
Dateisystem bis zum Auffüllen der Partition vergrößern  00:00:01    ( ERFOLG )
        
libparted wird verwendet

========================================

##############################
fdisk -l

Disk /dev/sdb: 2074 MB, 2074607616 bytes
156 heads, 28 sectors/track, 927 cylinders, total 4051968 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x020e2e06

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2050047     1024000    b  W95 FAT32

Here is the Hexdump of /dev/sdb1
I wonder a bit about byte 2c. This points to the the first "masterdictionary?" cluster say wikipedia.

00000000  20 87 95 4d 53 57 49 4e  34 2e 31 00 02 08 28 00  | ..MSWIN4.1...(.|
00000010  02 00 00 00 00 f8 00 00  3e 00 40 00 00 08 00 00  |........>.@.....|
00000020  00 40 1f 00 cf 07 00 00  00 00 00 00 02 00 00 00  |.@..............|
00000030  01 00 06 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  80 00 29 8e e0 a8 6b 4e  4f 20 4e 41 4d 45 20 20  |..)...kNO NAME  |
00000050  20 20 46 41 54 33 32 20  20 20 65 09 00 00 00 00  |  FAT32   e.....|
00000060  00 00 00 00 00 00 00 00  ff ff ff ff 00 00 00 00  |................|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000090  00 00 00 00 a0 7a 95 b6  00 00 00 00 00 00 00 00  |.....z..........|
000000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000150  00 00 00 00 00 00 00 00  00 00 00 00 e0 77 95 b6  |.............w..|
00000160  00 00 00 00 89 08 00 00  30 84 95 b6 30 84 95 b6  |........0...0...|
00000170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200  52 52 61 41 00 00 00 00  00 00 00 00 00 00 00 00  |RRaA............|
00000210  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000003e0  00 00 00 00 72 72 41 61  05 e6 03 00 03 00 00 00  |....rrAa........|
000003f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000400  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000c00  20 87 95 4d 53 57 49 4e  34 2e 31 00 02 08 28 00  | ..MSWIN4.1...(.|
00000c10  02 00 00 00 00 f8 00 00  3e 00 40 00 00 08 00 00  |........>.@.....|
00000c20  00 40 1f 00 cf 07 00 00  00 00 00 00 02 00 00 00  |.@..............|
00000c30  01 00 06 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000c40  80 00 29 8e e0 a8 6b 4e  4f 20 4e 41 4d 45 20 20  |..)...kNO NAME  |
00000c50  20 20 46 41 54 33 32 20  20 20 65 09 00 00 00 00  |  FAT32   e.....|
00000c60  00 00 00 00 00 00 00 00  ff ff ff ff 00 00 00 00  |................|
00000c70  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000c90  00 00 00 00 a0 7a 95 b6  00 00 00 00 00 00 00 00  |.....z..........|
00000ca0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000d50  00 00 00 00 00 00 00 00  00 00 00 00 e0 77 95 b6  |.............w..|
00000d60  00 00 00 00 89 08 00 00  30 84 95 b6 30 84 95 b6  |........0...0...|
00000d70  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000df0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000e00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00004000  f8 ff ff 0f ff ff ff 0f  f8 ff ff 0f ff ff ff 0f  |................|
00004010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00005000  f8 ff ff 0f ff ff ff 0f  ff ff ff 0f 00 00 00 00  |................|
00005010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000057a0  00 00 00 00 ff ff ff 0f  00 00 00 00 00 00 00 00  |................|
000057b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000fee00  f8 ff ff 0f ff ff ff 0f  ff ff ff 0f 00 00 00 00  |................|
000fee10  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000ff5a0  00 00 00 00 ff ff ff 0f  00 00 00 00 00 00 00 00  |................|
000ff5b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
001f8c00  20 20 20 20 20 20 20 20  20 20 20 08 00 00 51 47  |           ...QG|
001f8c10  49 46 49 46 00 00 51 47  49 46 00 00 00 00 00 00  |IFIF..QGIF......|
001f8c20  41 74 00 65 00 73 00 74  00 66 00 0f 00 78 69 00  |At.e.s.t.f...xi.|
001f8c30  6c 00 65 00 2e 00 74 00  78 00 00 00 74 00 00 00  |l.e...t.x...t...|
001f8c40  54 45 53 54 46 49 4c 45  54 58 54 20 00 00 02 48  |TESTFILETXT ...H|
001f8c50  49 46 49 46 00 00 02 48  49 46 e9 01 e4 01 00 00  |IFIF...HIF......|
001f8c60  e5 2e 00 73 00 77 00 70  00 00 00 0f 00 54 ff ff  |...s.w.p.....T..|
001f8c70  ff ff ff ff ff ff ff ff  ff ff 00 00 ff ff ff ff  |................|
001f8c80  e5 2e 00 74 00 65 00 73  00 74 00 0f 00 54 66 00  |...t.e.s.t...Tf.|
001f8c90  69 00 6c 00 65 00 2e 00  74 00 00 00 78 00 74 00  |i.l.e...t...x.t.|
001f8ca0  e5 45 53 54 46 49 7e 31  53 57 50 20 00 00 c2 48  |.ESTFI~1SWP ...H|
001f8cb0  49 46 49 46 00 00 c2 48  49 46 03 00 00 10 00 00  |IFIF...HIF......|
001f8cc0  e5 2e 00 73 00 77 00 78  00 00 00 0f 00 5c ff ff  |...s.w.x.....\..|
001f8cd0  ff ff ff ff ff ff ff ff  ff ff 00 00 ff ff ff ff  |................|
001f8ce0  e5 2e 00 74 00 65 00 73  00 74 00 0f 00 5c 66 00  |...t.e.s.t...\f.|
001f8cf0  69 00 6c 00 65 00 2e 00  74 00 00 00 78 00 74 00  |i.l.e...t...x.t.|
001f8d00  e5 45 53 54 46 49 7e 31  53 57 58 20 00 00 c2 48  |.ESTFI~1SWX ...H|
001f8d10  49 46 49 46 00 00 c2 48  49 46 00 00 00 00 00 00  |IFIF...HIF......|
001f8d20  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
001f9c00  62 30 56 49 4d 20 37 2e  33 00 00 00 00 10 00 00  |b0VIM 7.3.......|
001f9c10  04 69 d8 54 97 00 00 00  80 0f 00 00 67 61 72 66  |.i.T........garf|
001f9c20  69 65 6c 64 00 00 00 00  00 00 00 00 00 00 00 00  |ield............|
001f9c30  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
001f9c40  00 00 00 00 67 61 72 76  00 00 00 00 00 00 00 00  |....garv........|
001f9c50  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
001f9c60  00 00 00 00 00 00 00 00  00 00 00 00 2f 6d 65 64  |............/med|
001f9c70  69 61 2f 36 42 41 38 2d  45 30 38 45 2f 74 65 73  |ia/6BA8-E08E/tes|
001f9c80  74 66 69 6c 65 2e 74 78  74 00 00 00 00 00 00 00  |tfile.txt.......|
001f9c90  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
001f9fe0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 0d 00  |................|
001f9ff0  33 32 31 30 23 22 21 20  13 12 55 00 00 00 00 00  |3210#"! ..U.....|
001fa000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
003dec00  20 20 20 20 20 20 20 20  20 20 20 08 00 00 51 47  |           ...QG|
003dec10  49 46 49 46 00 00 51 47  49 46 00 00 00 00 00 00  |IFIF..QGIF......|
003dec20  41 74 00 65 00 73 00 74  00 66 00 0f 00 78 69 00  |At.e.s.t.f...xi.|
003dec30  6c 00 65 00 2e 00 74 00  78 00 00 00 74 00 00 00  |l.e...t.x...t...|
003dec40  54 45 53 54 46 49 4c 45  54 58 54 20 00 00 02 48  |TESTFILETXT ...H|
003dec50  49 46 49 46 00 00 02 48  49 46 03 00 e4 01 00 00  |IFIF...HIF......|
003dec60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
003dfc00  31 32 33 34 35 36 37 38  39 30 0a 31 32 33 34 35  |1234567890.12345|
003dfc10  36 37 38 39 30 0a 31 32  33 34 35 36 37 38 39 30  |67890.1234567890|
003dfc20  0a 31 32 33 34 35 36 37  38 39 30 0a 31 32 33 34  |.1234567890.1234|
003dfc30  35 36 37 38 39 30 0a 31  32 33 34 35 36 37 38 39  |567890.123456789|
003dfc40  30 0a 31 32 33 34 35 36  37 38 39 30 0a 31 32 33  |0.1234567890.123|
003dfc50  34 35 36 37 38 39 30 0a  31 32 33 34 35 36 37 38  |4567890.12345678|
003dfc60  39 30 0a 31 32 33 34 35  36 37 38 39 30 0a 31 32  |90.1234567890.12|
003dfc70  33 34 35 36 37 38 39 30  0a 31 32 33 34 35 36 37  |34567890.1234567|
003dfc80  38 39 30 0a 31 32 33 34  35 36 37 38 39 30 0a 31  |890.1234567890.1|
003dfc90  32 33 34 35 36 37 38 39  30 0a 31 32 33 34 35 36  |234567890.123456|
003dfca0  37 38 39 30 0a 31 32 33  34 35 36 37 38 39 30 0a  |7890.1234567890.|
003dfcb0  31 32 33 34 35 36 37 38  39 30 0a 31 32 33 34 35  |1234567890.12345|
003dfcc0  36 37 38 39 30 0a 31 32  33 34 35 36 37 38 39 30  |67890.1234567890|
003dfcd0  0a 31 32 33 34 35 36 37  38 39 30 0a 31 32 33 34  |.1234567890.1234|
003dfce0  35 36 37 38 39 30 0a 31  32 33 34 35 36 37 38 39  |567890.123456789|
003dfcf0  30 0a 31 32 33 34 35 36  37 38 39 30 0a 31 32 33  |0.1234567890.123|
003dfd00  34 35 36 37 38 39 30 0a  31 32 33 34 35 36 37 38  |4567890.12345678|
003dfd10  39 30 0a 31 32 33 34 35  36 37 38 39 30 0a 31 32  |90.1234567890.12|
003dfd20  33 34 35 36 37 38 39 30  0a 31 32 33 34 35 36 37  |34567890.1234567|
003dfd30  38 39 30 0a 31 32 33 34  35 36 37 38 39 30 0a 31  |890.1234567890.1|
003dfd40  32 33 34 35 36 37 38 39  30 0a 31 32 33 34 35 36  |234567890.123456|
003dfd50  37 38 39 30 0a 31 32 33  34 35 36 37 38 39 30 0a  |7890.1234567890.|
003dfd60  31 32 33 34 35 36 37 38  39 30 0a 31 32 33 34 35  |1234567890.12345|
003dfd70  36 37 38 39 30 0a 31 32  33 34 35 36 37 38 39 30  |67890.1234567890|
003dfd80  0a 31 32 33 34 35 36 37  38 39 30 0a 31 32 33 34  |.1234567890.1234|
003dfd90  35 36 37 38 39 30 0a 31  32 33 34 35 36 37 38 39  |567890.123456789|
003dfda0  30 0a 31 32 33 34 35 36  37 38 39 30 0a 31 32 33  |0.1234567890.123|
003dfdb0  34 35 36 37 38 39 30 0a  31 32 33 34 35 36 37 38  |4567890.12345678|
003dfdc0  39 30 0a 31 32 33 34 35  36 37 38 39 30 0a 31 32  |90.1234567890.12|
003dfdd0  33 34 35 36 37 38 39 30  0a 31 32 33 34 35 36 37  |34567890.1234567|
003dfde0  38 39 30 0a 00 00 00 00  00 00 00 00 00 00 00 00  |890.............|
003dfdf0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
003e0c00  20 20 20 20 20 20 20 20  20 20 20 08 00 00 51 47  |           ...QG|
003e0c10  49 46 49 46 00 00 51 47  49 46 00 00 00 00 00 00  |IFIF..QGIF......|
003e0c20  41 74 00 65 00 73 00 74  00 66 00 0f 00 78 69 00  |At.e.s.t.f...xi.|
003e0c30  6c 00 65 00 2e 00 74 00  78 00 00 00 74 00 00 00  |l.e...t.x...t...|
003e0c40  54 45 53 54 46 49 4c 45  54 58 54 20 00 00 02 48  |TESTFILETXT ...H|
003e0c50  49 46 49 46 00 00 02 48  49 46 e9 01 e4 01 00 00  |IFIF...HIF......|
003e0c60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
3e800000


Need you more information?

Gernot

4

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

Ah, now I think I see the problem.

If the FAT file system partition is marked to be used to boot an operating system, then the Linux utilities that create FAT file systems do not perform the action in a way that Windows requires.  By this I mean that any FAT file system created using dosfstools will not be recognized as bootable by Windows.

I think the problem has to do with hidden sectors before the partition starts, or something like that.  It was reported as a problem a long time ago.
See gparted: parted's method should be used to create FAT fs.
Newer versions of libparted have dropped support for creating FAT file systems, so currently there is no tool on GNU/Linux that can create bootable Windows FAT file systems.

5

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

I made a new test.

Format the USB stick with XP.
Shrink the partition with gparted live.

Windows don't  accept the shrinked partition.
Linux work well.

I think this can be a libparted bug because also an other user at sysrecuecd forum tell about the same problem with a corrupted USB stick.

Gernot

6 (edited by ottavio 2015-02-11 17:12:01)

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

gedakc wrote:

Newer versions of libparted have dropped support for creating FAT file systems, so currently there is no tool on GNU/Linux that can create bootable Windows FAT file systems.

Curtis,

please allow me to jump in this thread unannounced.

I'm the user who reported this issue on the System Rescue CD forum.

I appreciated that newer versions of libparted have dropped support for creating FAT file systems.

I know that I have to look elsewhere or use other methods, however I find it bizarre that Gparted offers no warning when trying to resize an active fat partition.

If there is a risk of FS corruption, Gparted should refuse to resize to operate and issue a fatal warning.

What is your view about that?

7 (edited by gedakc 2015-02-11 19:27:32)

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

In order to determine if a file system is in good shape, GParted uses the fsck.fat or dosfsck command.  If the command returns with an error, then GParted will halt and not perform the resize.  If the command returns okay, then GParted continues with operations.

Hence whether GParted proceeds with resize is dependent on what value is returned from the command used to check the status of the file system.

So if there is a way for dosfstools to determine this situation, then you might wish to follow up with the issue upstream.  However I think the file system data integrity is okay.

More specifically from the description, it seems that the file system is okay according to GNU/Linux.  For some reason though, Windows prompts to reformat.

As far as I know, the file system and it's data are okay, and files can be read from and written to the file system.  Hence it doesn't sound like any data is lost, and hence no file system corruption.

EDIT:

To summarize:

If the issue is that the original file system is corrupt or lacking data integrity, then the issue belongs with upstream dosfstools.

If the issue is that after resizing, the file system is corrupt or lacking data integrity, then the issue belongs with upstream libparted.

The issue would belong to GParted if there is a logic error in how GParted uses dosfstools and/or libparted.

From the description of the issue in this thread it appears that file system data integrity is okay before the resize and okay after the resize.

The problem is that Windows prompts to reformat.  As far as I know, there are no GNU/Linux tools that will format a bootable FAT file system that Windows likes.


EDIT 2:

There is one thing I can think of to try.  That is to use a hex editor, like hexedit, and specify the number of hidden sectors (those before the start of the partition) at offset 1C hex in the partition boot record (not the Master Boot Record).

For details on this see:
MSWIN4.1 OS Boot Record
and if you are curious:
The FAT32 Boot Record under Windows™ 2000, XP and 7

8 (edited by ottavio 2015-02-11 19:34:03)

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

Curtis, I get your logic and I appreciate that.

I still think that at least a warning should be issued in this case, because although the issue doesn't exist under Linux, I would expect the majority of Gparted users would use the tool from a sort of live cd, and then return to their main OS, a consistent part of them being any flavour of Windows.

I am no developer but a simple warning message that the drive might not be visible under Windows is, I think, courtesy and politeness to the non-technical user (and even the technical user who cannot be bothered with reading all the bugs before using the tool).


Having said that, what could be a temporary hack to solve the problem?
If I removed the bootable flag before resizing, would then Gparted apply the correct settings? If this is the case, Gparted could be configured to:
1) remove bootable flag on fat partitions;
2) apply changes;
3) restore the bootable flag.

Please let me know.

9 (edited by gedakc 2015-02-11 19:45:34)

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

You might try removing the boot flag from the partition to see if Windows will then like the partition.

ottavio wrote:

Having said that, what could be a temporary hack to solve the problem?
If I removed the bootable flag before resizing, would then Gparted apply the correct settings? If this is the case, Gparted could be configured to:
1) remove bootable flag on fat partitions;
2) apply changes;
3) restore the bootable flag.

You could certainly try that (you could manually remove the BOOT flag, resize the partition, and then restore the BOOT flag).  As far as I know this will have exactly the same result.

I would appreciate if you could try the hexeditor suggestion too.  If that works, then we could add a step in GParted to specify the number of hidden sectors independent of all the other tools.

EDIT:
With regard to a warning, we first need to confirm if this is indeed the issue, and if the situation can be detected beforehand.  The better approach is to come up with a solution.  For that we need the further tests that you suggested and I suggested.

10 (edited by g.fink 2015-02-11 19:54:43)

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

I dont think its a bootflag problem.

I read in the link you posted:

2Ch     Double Word     00000002     2      First Cluster in the Root
 Directory
Reference        " This is set to the cluster number of the first cluster of the root directory, usually 2 but not
required to be 2. NOTE: Disk utilities that change the location of the root directory should make every effort to 
place the first cluster of the root directory in the first non-bad cluster on the drive (i.e., in cluster 2, unless it’s
marked bad). This is specified so that disk repair utilities can easily find the root directory if this field accidentally gets zeroed." 

My hexdump target to cluster 02 for the root directory.  If i count right the root directory is moved while shrinking.

The next days i try to check this comparing old working libparted /failing new libparted.

I dont think that the filesystem is corrupted, but windows  use not the same structures as linux with a shrinked partition.

EDIT:
confirming the problem is easy because every time i shrink a working 2G size Fat32 partition to 1G windows fails.





Gernot

11

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

@gedakc:
Thanks for your help. Unfortunately I don't have much time at the moment. I'll try shortly and I will get back to the forum. For the time being, I'd have to use an older version of Gparted because with that I had no problems.

@g.fink:
The first time I shrank the partition, I did fsck under Linux and it gave no error, but then I checked some of the files and they were unreadable (I lost a few pdf which unfortunately I didn't back up).

The second time I couldn't check because the drive was blank.

(Incidentally, are there any issue with NTFS? Because I need to shrink my Windows partition, and I have nowhere to back it up).

12 (edited by gedakc 2015-02-11 20:05:17)

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

@Gernot.  The value I mentioned was at offset 1C.

Does Windows like the file system before resize?

EDIT:
I just checked your earlier post of the bad partition boot sector.  The value at 1C is set to 0800 Hex which is 2048 Decimal.  Hence this would not be the issue.

13 (edited by gedakc 2015-02-11 20:08:48)

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

ottavio wrote:

@gedakc:
Thanks for your help. Unfortunately I don't have much time at the moment. I'll try shortly and I will get back to the forum. For the time being, I'd have to use an older version of Gparted because with that I had no problems.

@Ottavio: It would help if you could determine which version works, and which version does not.

ottavio wrote:

(Incidentally, are there any issue with NTFS? Because I need to shrink my Windows partition, and I have nowhere to back it up).

Regarding NTFS, if you do not have a backup, then you are taking a risk.  For example what happens if the power goes out while you are resizing?  You would then have much work to do in order to recover the data.  There is always risk involved in resizing any partition and file system.

14

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

gedakc wrote:

@Ottavio: It would help if you could determine which version works, and which version does not.

The last one I've used was gparted-0.21.0, contained in sysresccd v. 4.5.0.

The one I had no problem with was GParted 0.16.2 in Sysrescd 3.8.1.

I am not sure what customization sysresccd applies, Gernot will probably know more than me.

15

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

gedakc wrote:

@Gernot.  The value I mentioned was at offset 1C.
Does Windows like the file system before resize?
EDIT:
I just checked your earlier post of the bad partition boot sector.  The value at 1C is set to 0800 Hex which is 2048 Decimal.  Hence this would not be the issue.

Yes windows like the partitions before resize. I tried also Filesystem created by Windows.

Its not 1C but 2C (start of root directory Fat 32) who is suspect.

Gernot

16

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

From looking at the ChangeLog for SysRescCd, I determined the following:

SysRescCd 4.5.0 uses:
  GParted 0.21.0
  Parted/libparted 3.2

SysRescCd 3.8.1 uses:
  GParted 0.16.2
  Parted/libparted < 3.2 (Probably 2.3, but could be 3.0 or 3.1)

@Ottavio, would you please run GParted from a terminal window using SysRescCd 3.8.1 and make note of the libparted version that GParted says it is using?

Since Gernot said the original file system was liked by windows, and because libparted is the library that performs the actual resize of FAT file systems, I am beginning to suspect might be a problem in the library.

17

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

Sysrescuecd 3.8.1 use gparted 0.16.2 with libparted 3.1

Gernot

18

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

g.fink wrote:

Sysrescuecd 3.8.1 use gparted 0.16.2 with libparted 3.1

Thank you for checking this.

Would you be able to compile the latest GParted using the older libparted 3.1 and test again?

This would confirm if the problem is with a change in the libparted library from 3.1 to 3.2.

19 (edited by g.fink 2015-02-13 14:26:19)

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

Now i compiled gparted and libparted on my debian 7... many libs..... ;-)

Windows is now happy with the parted 3.1 shrinked partition.

I think libparted 3.2 makes something wrong.
EDIT:
To check this i update to parted 3.2. Now windows refuse the partition.
I wrote a big file to the parition to find the actual used fat. I think i found one fat at the wrong place after! the root directory. Linux fsck show no problem.

Edit 2:
I think that the problem is not in the first 0x58 bytes of the partition.
Except the first 3 bytes the values from 3.1 and 3.2 are equal.

should i remove the old dumps from the postings and add 3.1 and 3.2 dumps without recompiling gparted?


GParted 0.21.0

libparted 3.1
/dev/sdg1 von 1.93 GiB auf 1000.00 MiB verkleinern  00:00:03    ( ERFOLG )
         
/dev/sdg1 kalibrieren  00:00:00    ( ERFOLG )
         
Pfad: /dev/sdg1
Anfang: 2048
Ende: 4050943
Größe: 4048896 (1.93 GiB)
Dateisystem auf /dev/sdg1 auf Fehler überprüfen und (falls möglich) diese beheben  00:00:01    ( ERFOLG )
         
dosfsck -a -w -v /dev/sdg1
         
dosfsck 3.0.13 (30 Jun 2012)
dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "mkdosfs"
Media byte 0xf8 (hard disk)
512 bytes per logical sector
4096 bytes per cluster
32 reserved sectors
First FAT starts at byte 16384 (sector 32)
2 FATs, 32 bit entries
2023424 bytes per FAT (= 3952 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 4063232 (sector 7936)
505120 data clusters (2068971520 bytes)
62 sectors/track, 64 heads
0 hidden sectors
4048896 sectors total
Reclaiming unconnected clusters.
Checking free cluster summary.
/dev/sdg1: 1 files, 2/505120 clusters
Dateisystem verkleinern  00:00:01    ( ERFOLG )
         
libparted wird verwendet
Partition von 1.93 GiB auf 1000.00 MiB verkleinern  00:00:01    ( ERFOLG )
         
Alter Anfang: 2048
Altes Ende: 4050943
Alte Größe: 4048896 (1.93 GiB)
Neuer Anfang: 2048
Neues Ende: 2050047
Neue Größe: 2048000 (1000.00 MiB)

========================================
Dateisystem (fat32) auf /dev/sdg1 überprüfen und reparieren  00:00:01    ( ERFOLG )
         
/dev/sdg1 kalibrieren  00:00:00    ( ERFOLG )
         
Pfad: /dev/sdg1
Anfang: 2048
Ende: 2050047
Größe: 2048000 (1000.00 MiB)
Dateisystem auf /dev/sdg1 auf Fehler überprüfen und (falls möglich) diese beheben  00:00:00    ( ERFOLG )
         
dosfsck -a -w -v /dev/sdg1
         
dosfsck 3.0.13 (30 Jun 2012)
dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "MSWIN4.1"
Media byte 0xf8 (hard disk)
512 bytes per logical sector
4096 bytes per cluster
42 reserved sectors
First FAT starts at byte 21504 (sector 42)
2 FATs, 32 bit entries
1023488 bytes per FAT (= 1999 sectors)
Root directory start at cluster 490 (arbitrary size)
Data area starts at byte 2068480 (sector 4040)
255495 data clusters (1046507520 bytes)
62 sectors/track, 64 heads
2048 hidden sectors
2048000 sectors total
Reclaiming unconnected clusters.
Checking free cluster summary.
/dev/sdg1: 1 files, 2/255495 clusters
Dateisystem bis zum Auffüllen der Partition vergrößern  00:00:01    ( ERFOLG )
         
libparted wird verwendet

========================================

Gernot

20 (edited by gedakc 2015-02-16 19:02:35)

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

Thank you Gernot for testing the two libparted versions and finding there is a problem between libparted 3.1 and 3.2.

Since this appears to be a problem with libparted, would you be able to raise this issue on the bug-parted@gnu.org mailing list?

EDIT:
I have emailed Phillip Susi to see if he can look into this as well (he also works on Parted/libparted).

21

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

So you are saying the only difference is the location of the root directory, and this changes between libparted 3.1 and 3.2?

22 (edited by g.fink 2015-02-17 19:25:45)

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

psusi wrote:

So you are saying the only difference is the location of the root directory, and this changes between libparted 3.1 and 3.2?

No. The location depend some other things.
I don't know where the problem is.
In some tests all values betwen the bytes 0x03 to 0x57 of working and bad filesystems are equal.

Edit: First test, blank device,shrink empty, add file: Linux OK Win bad. optical all well.. Next test come... 
Edit2: I find nothing looking bad, but Windows dont accept the partition after shrinking.

Gernot

23

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

Any developments? Has anybody tried to remove the boot flag, write changes and then apply a resize? Does it work? If so, at least we have a workaround for the time being.

24

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

Ottavio, I'm not sure that the work-around has been tested.

Can you test to confirm?

25

Re: Vista/XP dont accept a shrinked Fat32 partition (USB-stick)

I can't confirm right now as I have no backup drives to sacrifice at the moment.