오류 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파티션이 실제로 마운트되지 않았습니다), 파티션을 수정한 후 파티션을 쓰기 전에 몇 초의 지연을 추가해 보십시오.

fdiskCentos 7.6 a la에서 호출을 자동화하려고 할 때 동일한 오류가 발생했습니다 .

# (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새 파티션이 정의된 후 너무 빨리 이런 일이 발생했다는 것입니다.

일관된 성공을 거두기 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

관련 정보