Bug 174675 - Write ext3 fs to usb hard drive gives invalid partition table
Write ext3 fs to usb hard drive gives invalid partition table
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: e2fsprogs (Show other bugs)
4
i686 Linux
medium Severity high
: ---
: ---
Assigned To: Thomas Woerner
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-12-01 05:31 EST by Mike Cohler
Modified: 2007-11-30 17:11 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-12-01 06:43:29 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Mike Cohler 2005-12-01 05:31:25 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7

Description of problem:
Starting with a re-partitioning of an external USB drive using fdisk and generating a new primary partion gives the following screen output:

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-19456, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-19456, default 19456):
Using default value 19456

Command (m for help): p

Disk /dev/sda1: 160.0 GB, 160039240704 bytes
255 heads, 63 sectors/track, 19456 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

     Device Boot      Start         End      Blocks   Id  System
/dev/sda1p1               1       19456   156280288+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@home1 ~]#

At this point the USB drive was disconnected and the mount point automatically removed. On plugging USB drive back in the mount point /media/usbdisk was created for /dev/sda1 (confirmed watching /var/log/messages at the time)

The partitions were confirmed using fdisk, and then an ext3 file system was written using mkfs.ext3 as follows:

[root@home1 ~]# fdisk -l /dev/sda1

Disk /dev/sda1: 160.0 GB, 160039240704 bytes
255 heads, 63 sectors/track, 19456 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

     Device Boot      Start         End      Blocks   Id  System
/dev/sda1p1               1       19456   156280288+  83  Linux
[root@home1 ~]# mkfs.ext3 /dev/sda1
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
19546112 inodes, 39072080 blocks
1953604 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=41943040
1193 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872

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

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@home1 ~]#

At this point everything seems fine - HOWEVER checking the partitions with fdisk now generates:

[root@home1 ~]# fdisk -l /dev/sda1

Disk /dev/sda1: 160.0 GB, 160039240704 bytes
255 heads, 63 sectors/track, 19456 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sda1 doesn't contain a valid partition table
[root@home1 ~]#

This persists even if the USB drive is removed, and also persists after removing the drive, re-booting the machine and then re-connecting the USB drive.

I have tried to re-read the partition table using sfdisk -R /dev/sda and this makes no difference.

I have also tried to re-boot the machine after generating the partition but before writing the ext3 file system and this problem remains.

How can I get a valid file system on this drive please ? I have seen other postings on the web (but not in bugzilla) mentioning this problem but I have not seen a solution that works.

Thanks
Mike


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Use fdisk to partition the USB hard drive
2. Remove drive (and also tried with re-boot as well)
3. Re-Connect USB drive
4. Check partition table with fdisk - OK.
5. use mkfs.ext3 /dev/sda1 to write file system - appears successful
6. Check with fdisk -l - now there is no valid partition table
  

Actual Results:  The partition table is not valid on the USB hard drive

Expected Results:  There should be a valid partition table

Additional info:
Comment 1 Karel Zak 2005-12-01 06:10:54 EST
Please, be careful with fdisk option. You have to use it for device (/dev/sda)
and no for subset of the device (partitions). For example:

 # fdisk -l /dev/hdb

  Disk /dev/hdb: 41.1 GB, 41174138880 bytes
  16 heads, 63 sectors/track, 79780 cylinders
  Units = cylinders of 1008 * 512 = 516096 bytes

  Device Boot      Start         End      Blocks   Id  System
  /dev/hdb1   *           1       79752    40194598+  83  Linux

 # fdisk -l /dev/hdb1

  Disk /dev/hdb1: 41.1 GB, 41159268864 bytes
  16 heads, 63 sectors/track, 79751 cylinders
  Units = cylinders of 1008 * 512 = 516096 bytes

  Disk /dev/hdb1 doesn't contain a valid partition table
^^^^^^^^^^^^^^
because it isn't disk!


To be honest the (s)fdisk command is deprecated and it's better to use the
parted command:

 # parted /dev/hdb print
  Disk geometry for /dev/hdb: 0.000-39266.718 megabytes
  Disk label type: msdos
  Minor    Start       End     Type      Filesystem  Flags
  1          0.031  39252.568  primary   ext3        boot
  Information: Don't forget to update /etc/fstab, if necessary.

 # parted /dev/hdb1 print
  Disk geometry for /dev/hdb1: 0.000-39252.537 megabytes
  Disk label type: loop
  Minor    Start       End     Filesystem  Flags
  1          0.000  39252.537  ext3
  Information: Don't forget to update /etc/fstab, if necessary.



Comment 2 Thomas Woerner 2005-12-01 06:43:29 EST
Closing as NOTABUG.
Comment 3 Mike Cohler 2005-12-01 07:01:04 EST
Gee, thanks for responding so quickly - I feel duly humbled by my lack of
knowledge on this.  

Best wishes
Mike

Note You need to log in before you can comment on or make changes to this bug.