I'm trying to format a USB disk which was used as a swap drive on another machine using gparted. It keeps getting stuck at the following screen

enter image description here

iotop -o shows no IO activity. It freezes only when formatting this particular drive. I've tried 2 other sticks and gparted did fine. Anyone know how this can be fixed?


Here's the output of dmesg:

[  352.763146] usb 1-3: new high-speed USB device number 7 using ehci-pci
[  352.912386] usb 1-3: New USB device found, idVendor=090c, idProduct=1000
[  352.912387] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  352.912389] usb 1-3: Product: Flash Drive
[  352.912389] usb 1-3: Manufacturer: Samsung
[  352.912390] usb 1-3: SerialNumber: 0344818020002557
[  352.917347] usb-storage 1-3:1.0: USB Mass Storage device detected
[  352.917542] scsi host8: usb-storage 1-3:1.0
[  354.102796] scsi 8:0:0:0: Direct-Access     Samsung  Flash Drive      1100 PQ: 0 ANSI: 6
[  354.103526] sd 8:0:0:0: Attached scsi generic sg3 type 0
[  354.106521] sd 8:0:0:0: [sdb] 62668800 512-byte logical blocks: (32.1 GB/29.9 GiB)
[  354.108598] sd 8:0:0:0: [sdb] Write Protect is off
[  354.108600] sd 8:0:0:0: [sdb] Mode Sense: 43 00 00 00
[  354.109538] sd 8:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[  354.126159] sd 8:0:0:0: [sdb] Attached SCSI removable disk
[16870.669971] usb 1-3: reset high-speed USB device number 7 using ehci-pci
[17038.471436] INFO: task scsi_eh_8:3326 blocked for more than 120 seconds.
[17038.471440]       Tainted: P           OE   4.13.0-46-generic #51-Ubuntu
[17038.471440] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[17038.471442] scsi_eh_8       D    0  3326      2 0x80000000
[17038.471443] Call Trace:
[17038.471460]  __schedule+0x291/0x8a0
[17038.471461]  schedule+0x2c/0x80
[17038.471462]  schedule_preempt_disabled+0xe/0x10
[17038.471463]  __mutex_lock.isra.2+0x18c/0x4d0
[17038.471465]  __mutex_lock_slowpath+0x13/0x20
[17038.471466]  ? __mutex_lock_slowpath+0x13/0x20
[17038.471467]  mutex_lock+0x2f/0x40
[17038.471472]  device_reset+0x22/0x50 [usb_storage]
[17038.471478]  scsi_eh_ready_devs+0x333/0xbf0
[17038.471481]  ? __pm_runtime_resume+0x5b/0x80
[17038.471483]  ? scsi_try_target_reset+0x90/0x90
[17038.471484]  scsi_error_handler+0x4c3/0x5b0
[17038.471489]  kthread+0x128/0x140
[17038.471491]  ? scsi_eh_get_sense+0x200/0x200
[17038.471492]  ? kthread_create_on_node+0x70/0x70
[17038.471493]  ret_from_fork+0x35/0x40
[17038.471496] INFO: task gpartedbin:29528 blocked for more than 120 seconds.
[17038.471498]       Tainted: P           OE   4.13.0-46-generic #51-Ubuntu
[17038.471499] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[17038.471500] gpartedbin      D    0 29528  29523 0x00000000
[17038.471501] Call Trace:
[17038.471502]  __schedule+0x291/0x8a0
[17038.471506]  ? blk_finish_plug+0x2c/0x40
[17038.471507]  schedule+0x2c/0x80
[17038.471510]  io_schedule+0x16/0x40
[17038.471514]  wait_on_page_bit_common+0xd8/0x160
[17038.471515]  ? page_cache_tree_insert+0xc0/0xc0
[17038.471516]  __filemap_fdatawait_range+0xfe/0x160
[17038.471517]  file_write_and_wait_range+0x60/0xc0
[17038.471521]  blkdev_fsync+0x1b/0x50
[17038.471523]  vfs_fsync_range+0x4e/0xb0
[17038.471524]  do_fsync+0x3d/0x70
[17038.471526]  SyS_fsync+0x10/0x20
[17038.471527]  entry_SYSCALL_64_fastpath+0x24/0xab
[17038.471528] RIP: 0033:0x7f624e231490
[17038.471529] RSP: 002b:00007ffce924b1c0 EFLAGS: 00000293 ORIG_RAX: 000000000000004a
[17038.471530] RAX: ffffffffffffffda RBX: 0000558e5fbd3f20 RCX: 00007f624e231490
[17038.471530] RDX: 0000000000000000 RSI: 0000558e5fc0e330 RDI: 0000000000000006
[17038.471531] RBP: 0000000000000001 R08: 0000558e5fc63d40 R09: 0000000000000000
[17038.471531] R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000000010
[17038.471532] R13: 0000558e5f96c7a0 R14: 0000558e5f96c790 R15: 0000000000000000

smartctl gives the following:

$ sudo smartctl --all /dev/sdb -d sat -T permissive
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.13.0-46-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

Read Device Identity failed: scsi error unsupported scsi opcode

Device Model:     [No Information Found]
Serial Number:    [No Information Found]
Firmware Version: [No Information Found]
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   [No Information Found]
Local Time is:    Fri Apr 26 12:57:58 2019 AEST
SMART support is: Ambiguous - ATA IDENTIFY DEVICE words 82-83 don't show if SMART supported.
SMART support is: Ambiguous - ATA IDENTIFY DEVICE words 85-87 don't show if SMART is enabled.
A mandatory SMART command failed: exiting. To continue, add one or more '-T permissive' options.
  • What does the “Details” section show? – Stephen Kitt Apr 24 at 10:32
  • @StephenKitt It can't be expanded because it's frozen. – John M. Apr 24 at 10:53
  • Probably not a good idea to use a usb drive for swap - can you test the USB drive, it might be damaged. Then again, I do not think that swap in this day and age is useful, worse, what is the point to swap to a sloooow usb drive ? Can you open a terminal and issue dmesg ? We should see any IO errors, there ... – thecarpy Apr 24 at 13:09
  • 1
    @thecarpy I understand that. I'm just using this as swap for a raspberry pi. I've pasted output of dmesg in my question now. – John M. Apr 24 at 13:38

Use different software that gives you a better view.

In the lines below starting with # means running as root First, check this is the correct disk !!!IMPORTANT!!! If you lose all data because of these instructions, you are on your own. I'd use testdisk or photorec to recover what I can.

# parted /dev/sdb
Model: Some disk model
Disk: /dev/sdb : 29.9GB
Sector Size: 512B/4096B
Partition Table: msdos
Disk Flags

Create a partition table and swap partition

# parted /dev/sdb mklabel gpt #!!!ACHTUNG! This will erase ALL partitions on disk /dev/sdb!!!
# parted /dev/sdb mkpart primary linux-swap 512B 29.9GB
# parted print
Model: Some disk model
Disk: /dev/sdb : 29.9GB
Sector Size: 512B/4096B
Partition Table: mbr
Disk Flags
Number    Start    End    Size    File System    Name    Flags
 1        512B     29.9Gb 29.9Gb                 primary

Format the partition for swap

# mkswap /dev/sdb1

If it fails, you're more likely to see the reason why. But from the look of your dmesg output, it looks like you have a corrupt device.

You should consider using smartctl to check the SMART status of your drive. To install, you need smartmontools (debian, ubuntu, mint, devuan ...)

  • I get mkswap: /dev/sdb: warning: don't erase bootbits sectors (gpt partition table detected). Use -f to force. Setting up swapspace version 1, size = 29.9 GiB (32086421504 bytes) no label, UUID=3d13f2a8-a754-4377-bac6-a361594a60f7 I suppose it worked? – John M. Apr 25 at 9:18
  • You see that message because you should use a swap partition not the whole drive. – thecarpy Apr 25 at 12:55
  • @thecarpy mkswap /dev/sdb1 gives cannot open /dev/sdb1: No such file or directory. It seems to "work" on /dev/sdb though. I've also added the output from smartctl. This is a USB stick, so I'm not sure if it supports SMART. – John M. Apr 26 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.