Openstack

[vm] qemu-nbd 마운트

plastic2113 2024. 6. 23. 08:14
728x90
반응형

nbd 모듈 추가

modprobe nbd max_part=8로 모듈 추가

$ modprobe nbd max_part=8

모듈 관련 명령어는 아래 글 참고

https://plastic2113.tistory.com/entry/Linux-%EB%AA%A8%EB%93%88-%EA%B4%80%EB%A6%AClsmod-modprobe-rmmod

nbd모듈로 디스크 파일 연결

: /dev/nbd0로 [disk_file]을 연결

$ qemu-nbd --connect=/dev/nbd0 [disk_file_path]
or
$ qemu-nbd -c /dev/nbd0 [disk_file_path]

kpartx를 사용한 디바이스 매핑(생략가능)

: kpart를 이용해 nbd0에 대한 파티션 매핑을 추가

$ kpartx -a /dev/nbd0

disk_file 마운트

user@compute:[PATH]$ fdisk /dev/nbd -l
Device      Boot   Start       End   Sectors  Size Id Type
/dev/nbd0p1 *       2048   1126399   1124352  549M  7 HPFS/NTFS/exFAT
/dev/nbd0p2      1126400 104855551 103729152 49.5G  7 HPFS/NTFS/exFAT

user@compute:[PATH]$ mount /dev/nbd0p2 /mnt

: fdisk -l로 마운트 하고자 하는 nbd확인 후 mount

사용 후 마운트 해제는 역순으로 빠르게 가능

user@compute:~$ umount /mnt

user@compute:~$ qemu-nbd --disconnect /dev/nbd0

user@compute:~$ rmmod nbd

 

728x90
반응형