파티션 테이블을 다시 읽지 못했습니다. 오류 16: 장치 또는 리소스가 사용 중입니다.

파티션 테이블을 다시 읽지 못했습니다. 오류 16: 장치 또는 리소스가 사용 중입니다.

CentOS 6.x에서 USB 플래시 드라이브를 다시 파티션하는 동안 다음 오류가 발생합니다.

Disk /dev/sdb: 31.5 GB, 31466323968 bytes
255 heads, 63 sectors/track, 3825 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0e693bd9

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        3826    30727808    c  W95 FAT32 (LBA)
[root@csc ~]# fdisk /dev/sdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): d
Selected partition 1

Command (m for help): 1
1: unknown command
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): d   
No partition is defined yet!

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-3825, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-3825, default 3825): 
Using default value 3825

Command (m for help): 
Command (m for help):  
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 86
Changed system type of partition 1 to 86 (NTFS volume set)

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 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

답변1

장치가 이미 설치된 것 같습니다. 실행 umount /dev/sdb1하고 다시 시도하세요.

답변2

expect자동화된(예: 사용 ) fdisk작업 의 결과로 이를 얻는다고 가정합니다 .파티션이 실제로 마운트되지 않았습니다.), 파티션을 수정한 후 파티션에 쓰기 전에 몇 초의 지연 시간을 추가해 보십시오.

Centos 7.6에서 호출을 자동화 하려고 하면 fdisk동일한 오류가 발생합니다.

# (echo "d"; echo "";
        echo "n"; echo ""; echo 3; echo 2001954; echo "";
        echo "w") | fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): Partition number (1-3, default 3): Partition 3 is deleted

Command (m for help): Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): Using default response p
Partition number (3,4, default 3): First sector (2001954-31116287, default 2002944): Last sector, +sectors or +size{K,M,G} (2001954-31116287, default 31116287): Using default value 31116287
Partition 3 of type Linux and of size 13.9 GiB is set

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.


파이프로 연결된 입력 명령 스트림(느린/수동 입력에 의해 트리거되지 않음)에 타이밍 문제가 있는 것으로 의심되어 오류가 사라질 때까지 다양한 입력을 지연시키기 위해 명령을 fdisk분산시키기 시작했습니다 . sleep내 경우의 문제는 w새 파티션을 정의한 직후에 발생했다는 것입니다.

A 만장일치로 성공하기 sleep 5전에 w:

# (echo "d"; echo "";
        echo "n"; echo ""; echo 3; echo 2001954; echo "";
        sleep 5; echo "w") | fdisk /dev/sdb

답변3

이전에 사용된 장치가 이전에 어레이의 구성원이었던 경우 간단히 컴퓨터에 연결한 후에도 사용 중이 되는 경우가 많습니다 mdadm. 이러한 경우인지 확인하려면 cat /proc/mdstat드라이브가 여기에 나열된 어레이 중 하나에 나타나는지 확인하십시오.

하나 이상을 찾으면 다음을 수행하여 이전 어레이 연결에서 해제할 수 있습니다.

mdadm --stop /dev/md1234

/dev/md1234에 표시된 배열은 어디에 있습니까 /proc/mdadm? 다시 분할하려는 드라이브와 관련된 각 어레이에 대해 이 작업을 수행하십시오.위 명령에는 오래되고 더 이상 사용되지 않는 배열만 지정됩니다..

실행하기 전에 이 작업을 한 번 수행 fdisk /dev/sdxy한 다음 후속 fdisk 명령이 커널 테이블을 업데이트하지 못한 후에 다시 수행해야 합니다. 이런 일이 발생했을 때 저는 "mdadm --stop ..." 명령을 다시 실행한 다음 fdisk를 다시 실행했습니다. 단지 "w" 명령만 실행하고 아무런 변경도 하지 않았습니다. 두 번째로 잘 작동했습니다.

답변4

다음 명령을 시도해 보십시오: sudo resize2fs /dev/mmcblk0p2

관련 정보