开发者

kpartx in a bash loop

开发者 https://www.devze.com 2023-03-31 10:42 出处:网络
I\'m trying to execute the following lines within a bash script: for i in `ls/dev/kvm-space/*-backup` do

I'm trying to execute the following lines within a bash script:

for i in `ls  /dev/kvm-space/*-backup`
do 
 kpartx -dv "$i"
done

But the script doesn't work as expected. The output looks like:

failed to stat() /dev/kvm-space/sp-test.disk-backup
failed to stat() /dev/kvm-space/sp-web.disk-backup
failed to stat() /dev/kvm-space/tp-web.disk-backup

When I try to execute the kpartx command with a path from the output above manually, kpartx works as expected.

Does anybody has an idea whats going wrong?

Best regards Thomas

Edit: I'开发者_运维技巧m using Debian Squeeze an the kpartx version 0.4.8 provided via apt.


Consider isolating the problem using the below technique:

for i in `ls  /dev/kvm-space/*-backup`
do 
    echo kpartx -dv "$i"
done

If your output matches what you would have expected Bash to invoke for you, then the problem really lies with kpartx. I suspect it does.

0

精彩评论

暂无评论...
验证码 换一张
取 消