[Bug 58331] Re: fdisk doesn't write partition table

tushar Insaan 58331 at bugs.launchpad.net
Sat Mar 25 03:01:00 UTC 2017


I think i am facing similar kind of issue where sometimes dd works and sometimes it say read only file system, but not able to alter the partitions on flash drive.
df -Th
Filesystem            Type      Size  Used Avail Use% Mounted on

/dev/sdb1             vfat      3.8G  2.5G  1.4G  65%
/media/tushar/TRANSCEND1

Zeroing out whole disk does not report any I/O issue.

tushar at tushar-Studio-1555:~$ sudo dd if=/dev/zero of=/dev/sdb1 bs=1M count=4096  
dd: error writing ‘/dev/sdb1’: No space left on device
3829+0 records in
3828+0 records out
4014866432 bytes (4.0 GB) copied, 227.406 s, 17.7 MB/s

Specific region doesn't report any issue in dd.
tushar at tushar-Studio-1555:~$ sudo dd if=/dev/zero of=/dev/sdb seek=446 bs=1 count=64
64+0 records in
64+0 records out
64 bytes (64 B) copied, 0.000310444 s, 206 kB/s

removing MBR
tushar at tushar-Studio-1555:~$ sudo dd if=/dev/zero of=/dev/sdb seek=512 bs=1 count=64
64+0 records in
64+0 records out
64 bytes (64 B) copied, 0.000279994 s, 229 kB/s

when i manually mount dd responds as below.
sudo mount | grep sdb
tushar at tushar-Studio-1555:~$ sudo mount -o rw  -force /dev/sdb /media/tushar/TRANSCEND
tushar at tushar-Studio-1555:~$ sudo mount | grep sdb
/dev/sdb on /media/tushar/TRANSCEND type none (rw,rce)
tushar at tushar-Studio-1555:~$ sudo dd if=/dev/zero of=/dev/sdb seek=446 bs=1 count=64
dd: failed to open ‘/dev/sdb’: Read-only file system

tried to repartition on the disk but writing is failing.
 sudo fdisk -l /dev/sdb

Disk /dev/sdb: 4014 MB, 4014997504 bytes
57 heads, 56 sectors/track, 2456 cylinders, total 7841792 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1             256     7841791     3920768    b  W95 FAT32
tushar at tushar-Studio-1555:~$ 
tushar at tushar-Studio-1555:~$ sudo fdisk /dev/sdb

Command (m for help): p

Disk /dev/sdb: 4014 MB, 4014997504 bytes
57 heads, 56 sectors/track, 2456 cylinders, total 7841792 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1             256     7841791     3920768    b  W95 FAT32

Command (m for help): d
Selected partition 1

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

Calling ioctl() to re-read partition table.

Error closing file
tushar at tushar-Studio-1555:~$ sudo fdisk /dev/sdb
You will not be able to write the partition table.

Command (m for help): p

Disk /dev/sdb: 4014 MB, 4014997504 bytes
57 heads, 56 sectors/track, 2456 cylinders, total 7841792 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1             256     7841791     3920768    b  W95 FAT32

Command (m for help): d
Selected partition 1

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-7841791, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-7841791, default 7841791): 
Using default value 7841791

Command (m for help): p

Disk /dev/sdb: 4014 MB, 4014997504 bytes
57 heads, 56 sectors/track, 2456 cylinders, total 7841792 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     7841791     3919872   83  Linux

Command (m for help): w
fdisk: unable to write /dev/sdb: Bad file descriptor
tushar at tushar-Studio-1555:~$ sudo fdisk /dev/sdb
You will not be able to write the partition table.

Command (m for help): p

Disk /dev/sdb: 4014 MB, 4014997504 bytes
57 heads, 56 sectors/track, 2456 cylinders, total 7841792 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1             256     7841791     3920768    b  W95 FAT32

Command (m for help): q
=======================================================================================
=======================================================================================


tushar at tushar-Studio-1555:~$ sudo fdisk -l /dev/sdb

Disk /dev/sdb: 4014 MB, 4014997504 bytes
57 heads, 56 sectors/track, 2456 cylinders, total 7841792 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1             256     7841791     3920768    b  W95 FAT32
tushar at tushar-Studio-1555:~$ sudo parted -l /dev/sdb
Model: ATA WDC WD10JPVT-00A (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos

Number  Start   End     Size   Type      File system  Flags
 1      1049kB  800GB   800GB  primary   ext4         boot
 2      800GB   1000GB  200GB  extended
 5      800GB   801GB   999MB  logical
 6      801GB   1000GB  199GB  logical   ext4


Warning: Unable to open /dev/sdb read-write (Read-only file system).  /dev/sdb
has been opened read-only.
Model: JetFlash Transcend 4GB (scsi)
Disk /dev/sdb: 4015MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End     Size    Type     File system  Flags
 1      131kB  4015MB  4015MB  primary  fat32


Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/cryptswap1: 999MB
Sector size (logical/physical): 512B/4096B
Partition Table: loop

Number  Start  End    Size   File system     Flags
 1      0.00B  999MB  999MB  linux-swap(v1)

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to util-linux in Ubuntu.
https://bugs.launchpad.net/bugs/58331

Title:
  fdisk doesn't write partition table

Status in util-linux package in Ubuntu:
  Expired

Bug description:
  When using a USB 2.0 external hard disc, fdisk does not appear to
  create valid partition tables.

  -------snip--------
  stephan at solaris:~$ sudo fdisk -l /dev/sdc

  Disk /dev/sdc: 300.0 GB, 300069052416 bytes
  255 heads, 63 sectors/track, 36481 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes

  Disk /dev/sdc doesn't contain a valid partition table
  stephan at solaris:~$ sudo fdisk /dev/sdc
  Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
  Building a new DOS disklabel. Changes will remain in memory only,
  until you decide to write them. After that, of course, the previous
  content won't be recoverable.

  
  The number of cylinders for this disk is set to 36481.
  There is nothing wrong with that, but this is larger than 1024,
  and could in certain setups cause problems with:
  1) software that runs at boot time (e.g., old versions of LILO)
  2) booting and partitioning software from other OSs
     (e.g., DOS FDISK, OS/2 FDISK)
  Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

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

  Command (m for help): p

  Disk /dev/sdc: 300.0 GB, 300069052416 bytes
  255 heads, 63 sectors/track, 36481 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes

     Device Boot      Start         End      Blocks   Id  System
  /dev/sdc1               1       36481   293033601   83  Linux

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

  Calling ioctl() to re-read partition table.
  Syncing disks.
  stephan at solaris:~$ sudo fdisk -l /dev/sdc

  Disk /dev/sdc: 300.0 GB, 300069052416 bytes
  255 heads, 63 sectors/track, 36481 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes

  Disk /dev/sdc doesn't contain a valid partition table
  -------snip--------

  /var/log/syslog says:
  -------snip--------
  31.08.2006 13:36:59	localhost	kernel	[17191377.892000] SCSI device sdc: 586072368 512-byte hdwr sectors (300069 MB)
  31.08.2006 13:36:59	localhost	kernel	[17191377.892000] sdc: assuming drive cache: write through
  31.08.2006 13:36:59	localhost	kernel	[17191377.892000]  sdc: unknown partition table
  -------snip--------

  
  The hardware setup is a Lenovo 3000 N100 Laptop, the external USB drive a 300 GB TrekStor.

  Stephan

  Note: the original reporter indicated the bug was in package 'fdisk';
  however, that package was not published in Ubuntu.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/58331/+subscriptions



More information about the foundations-bugs mailing list