메뉴 닫기

qemu-nbd를 이용한 qcow2 file badblock 발생 시 해결 방법

가상서버 생성 후 device sda1  I/O error 발생  (block bitmap and bg descriptor inconsistent) 

  • qcow2 file 가상 nbd로 만들기 

root@:~# qemu-nbd –connect=/dev/nbd0 /var/lib/libvirt/images/file.qcow2 ( 마스터 서버에서 가상서버 file.qcow2 경로 )

root@:~# fdisk /dev/nbd0 -l
Disk /dev/nbd0: 25 GiB, 26843545600 bytes, 52428800 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
Disklabel type: dos
Disk identifier: 0xfed18b11

Device Boot Start End Sectors Size Id Type
/dev/nbd0p1 * 2048 52428766 52426719 25G 83 Linux

  • 바로 진행 시 아래와 같은 에러 발생

root@:~# e2fsck -vycf /dev/nbd0p1
e2fsck 1.42.13 (17-May-2015)
/dev/nbd0p1 is in use.
e2fsck: Cannot continue, aborting.

  • partx -a /dev/nbd0 명령어로 위와 같은 에러 해결 

root@:~# partx -a /dev/nbd0

root@:~# !find
find /dev/ |grep nbd
/dev/nbd0p1
/dev/nbd15
/dev/nbd14
/dev/nbd13
/dev/nbd12
/dev/nbd11
/dev/nbd10
/dev/nbd9
/dev/nbd8
/dev/nbd7
/dev/nbd6
/dev/nbd5
/dev/nbd4
/dev/nbd3
/dev/nbd2
/dev/nbd1
/dev/nbd0

  • 문제가 발생한 qcow2 파일 파일시스템 검사 시작 

root@:~# e2fsck -vycf /dev/nbd0p1
e2fsck 1.42.13 (17-May-2015)
Checking for bad blocks (read-only test): done
cloudimg-rootfs: Updating bad block inode.
Pass 1: Checking inodes, blocks, and sizes
Inode 136, i_blocks is 1296, should be 1304. Fix? yes

Inodes that were part of a corrupted orphan linked list found. Fix? yes

Inode 3848 was part of the orphaned inode list. FIXED.
Inode 3849 was part of the orphaned inode list. FIXED.
Inode 3853 was part of the orphaned inode list. FIXED.
Inode 256155, end of extent exceeds allowed value
(logical block 159200, physical block 2363193, len 2)
Clear? yes

Inode 256155, i_blocks is 1275192, should be 1275216. Fix? yes

Inode 257572, i_blocks is 178776, should be 178784. Fix? yes

Inode 263183, i_blocks is 241728, should be 241744. Fix? yes

Inode 2304319, i_blocks is 32, should be 16. Fix? yes

Inode 2304326, i_blocks is 32, should be 16. Fix? yes

Inode 2304333, i_blocks is 32, should be 16. Fix? yes

Inode 2304340, i_blocks is 32, should be 16. Fix? yes

Inode 2304347, i_blocks is 32, should be 16. Fix? yes

Inode 2304354, i_blocks is 32, should be 16. Fix? yes

Inode 2305468, i_blocks is 32, should be 16. Fix? yes

Inode 2305475, i_blocks is 32, should be 16. Fix? yes

….

  • 파일 시스템 검사 확인 후 정상적으로 vm 운영 가능 

cloudimg-rootfs: ***** FILE SYSTEM WAS MODIFIED *****

705492 inodes used (22.05%, out of 3200000)
1517 non-contiguous files (0.2%)
153 non-contiguous directories (0.0%)
# of inodes with ind/dind/tind blocks: 0/0/0
Extent depth histogram: 697665/53/11
3971943 blocks used (60.61%, out of 6553339)
0 bad blocks
2 large files

680174 regular files
17372 directories
55 character device files
25 block device files
0 fifos
125 links
7860 symbolic links (7678 fast symbolic links)
2 sockets

  • 완료 후 /dev/nbd0 제거 

root@:~# partx -d /dev/nbd0

root@:~# qemu-nbd –disconnect /dev/nbd0
/dev/nbd0 disconnected

root@:~# fdisk -l
Disk /dev/sda: 232.9 GiB, 250059350016 bytes, 488397168 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
Disklabel type: dos
Disk identifier: 0x8929b36b

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 15624191 15622144 7.5G 82 Linux swap / Solaris
/dev/sda2 * 15624192 488396799 472772608 225.4G 83 Linux

 

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x