Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
No parts in /dev/nbd* devices
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
jwackito
n00b
n00b


Joined: 31 Jan 2007
Posts: 27

PostPosted: Thu Apr 08, 2010 1:12 pm    Post subject: No parts in /dev/nbd* devices Reply with quote

Hi:

I'm trying to mount a qcow2 kvm image file using qemu-nbd in this way

Code:
#qemu-nbd --connect=/dev/nbd0 live-lihuen-tests.img

After that, I'm able to use fdisk to see the partition table from ndb0 device... this is the output of 'p' fdisk command.
Code:
Disposit. Inicio    Comienzo      Fin      Bloques  Id  Sistema
/dev/nbd0p1   *           1        2496    20049088+  83  Linux
/dev/nbd0p2            2497        2610      915705    5  Extendida
/dev/nbd0p5            2497        2610      915673+  82  Linux swap / Solaris

But when I try to use mount command to mount /dev/nbd0p1 I get an error message indicating the device doesn't exist.
Code:
# mount /dev/nbd0p1 /mnt/cdrom
mount: el dispositivo especial /dev/nbd0p1 no existe

The NBD support is compiled built in the kernel (2.6.32 downloaded manually from kernel.org)
Code:
zcat /proc/config.gz |grep -i nbd
CONFIG_BLK_DEV_NBD=y


qemu-nbd version 0.0.1

If you need more information related to this problem, please let me know.
regards and thanks in advance
_________________
--
Jwackito
Back to top
View user's profile Send private message
Sadako
Advocate
Advocate


Joined: 05 Aug 2004
Posts: 3788
Location: sleeping in the bathtub

PostPosted: Thu Apr 08, 2010 1:34 pm    Post subject: Reply with quote

Try running `partx -a /dev/nbd0`, that should create the /dev/nbd0p* device nodes (assuming they are indeed missing from /dev).
_________________
"You have to invite me in"
Back to top
View user's profile Send private message
jwackito
n00b
n00b


Joined: 31 Jan 2007
Posts: 27

PostPosted: Thu Apr 08, 2010 2:13 pm    Post subject: Reply with quote

I get this error message
Code:
# partx -a /dev/nbd0
HDIO_GETGEO: Inappropriate ioctl for device

_________________
--
Jwackito
Back to top
View user's profile Send private message
b0nafide
Apprentice
Apprentice


Joined: 17 Feb 2008
Posts: 170
Location: ~/

PostPosted: Mon Sep 19, 2011 5:17 am    Post subject: Reply with quote

thread revival...

I can mount virtualbox vdi images now!

It works with some of the /dev/nbd devices, but not all of them. On a different distro I can use any of the /dev/nbds

So, it's working fine using /dev/nbd4 on my gentoo box, so I'm keeping it that way for now. But it doesn't make sense.

Here's the script I chucked together to speed things up for me:

Code:
#!/bin/bash

# vdi mounter v0.0.2 by bonafide a_t martica d_o_t org (sorry about v0.0.1)
# thanks to http://bethesignal.org/blog/2011/01/05/how-to-mount-virtualbox-vdi-image/
#
# requires nbd and qemu
# don't forget to load the nbd module with max_part=8 or so...

# Some important configuration:
nbd="/dev/nbd0"         # default network block device
mntdir="/mnt"           # folder where mount points will be created (and destroyed)
mountoptions="-o ro"    # some paranoia
qemunbdoptions="-r"     # ro also (see above)
verbose=0

# wait for fdisk to see partitions
sleepinterval=0.25      # seconds
sleeptimeout=5          # seconds
iterations=`bc <<< "$sleeptimeout / $sleepinterval"`

blather () {
 if [ $verbose == 1 ]; then
  echo -e -n "$1"
 fi
}

stopit () {
  qemu-nbd -d $nbd > /dev/null
}

getname () {
 partname=$(sed -e "s/\/dev\//`sed -e "s/^.*\///;s/ /_/g" <<< $1`_/" <<< $part)
}

while getopts d:vh options; do   
 case "$options" in
  [?]|h) echo "Usage: $0 [options] [vdi file]"
         echo " -d [network block device] default is $nbd"
         echo " -v Be verbose."
         echo " -h This help text."
         exit 1;;
      v) verbose=1;;
      d) nbd="$OPTARG";;
 esac
done
shift $(( OPTIND - 1 ))

if [ "`file $nbd`" == "${nbd}: block special" ]; then
 error=0
 if ! [ -e "$1" ]; then
  echo "VDI file does not exist."
  error=1
 else
  if [ "`qemu-img check "$1" 2> /dev/null; echo $?`" == "1" ]; then
   echo "VDI file $1 is invalid."
   error=1
  fi
 fi
 if [ $error == 1 ]; then
  echo "Quitting."
  exit 1
 fi
 blather "`qemu-img info "$1"`\n"
 blather "Attaching image $1 to $nbd "
 qemu-nbd $qemunbdoptions -c $nbd "$1"
 timeout=0
 while [ $timeout -le $iterations ]; do
  parts=`fdisk -l $nbd | sed -n -e '/swap\|Extended/d;/^\/dev\//p' | awk '{ print $1 }'`
  if [ "$parts" == "" ]; then
   timeout=$(( $timeout + 1 ))
   blather "."
   sleep $sleepinterval
  else
   break
  fi
 done
 blather "\n"
 if [ $timeout -ge $iterations ]; then
  blather "Can't attach image $1 to $nbd \n"
  stopit
  exit 1
 fi
 for part in $parts; do
  getname "$1"
  blather "Mounting partition $part on $mntdir/$partname\n"
  mkdir $mntdir/$partname
  mount $mountoptions $part $mntdir/$partname
 done
 echo "Done! Press enter to unmount volume(s)."
 read somevalue
 for part in $parts; do
  getname "$1"
  blather "Unmounting partition $part\n"
  umount $part
  rmdir $mntdir/$partname
 done
 blather "Deattaching image $1 from $nbd ... "
 stopit
 blather "Finished.\n"
 exit 0
else
 echo "$nbd is not a block device?"
fi
exit 1


If anybody has run into a similar problem with nbd or has any suggestions I'm all ears. I have no idea what would cause some, but not all of the nbd devices to work with qemu-nbd ...

Edit:
Code:

# ls -l /dev/nbd*
brw-rw---- 1 root disk 43,   0 Sep 18 12:29 /dev/nbd0
brw-rw---- 1 root disk 43,  32 Sep 18 12:29 /dev/nbd1
brw-rw---- 1 root disk 43, 320 Sep 18 12:29 /dev/nbd10
brw-rw---- 1 root disk 43, 352 Sep 18 12:29 /dev/nbd11
brw-rw---- 1 root disk 43, 384 Sep 18 12:29 /dev/nbd12
brw-rw---- 1 root disk 43, 416 Sep 18 12:29 /dev/nbd13
brw-rw---- 1 root disk 43, 448 Sep 18 12:29 /dev/nbd14
brw-rw---- 1 root disk 43, 480 Sep 18 12:29 /dev/nbd15
brw-rw---- 1 root disk 43,  64 Sep 18 12:29 /dev/nbd2
brw-rw---- 1 root disk 43,  96 Sep 18 12:29 /dev/nbd3
brw-rw---- 1 root disk 43, 128 Sep 18 21:40 /dev/nbd4
brw-rw---- 1 root disk 43, 160 Sep 18 12:29 /dev/nbd5
brw-rw---- 1 root disk 43, 192 Sep 18 12:29 /dev/nbd6
brw-rw---- 1 root disk 43, 224 Sep 18 12:29 /dev/nbd7
brw-rw---- 1 root disk 43, 256 Sep 18 12:29 /dev/nbd8
brw-rw---- 1 root disk 43, 288 Sep 18 12:29 /dev/nbd9

# qemu-nbd --version
qemu-nbd version 0.0.1


After poking around some more it appears that nbd0-3 and nbd5 don't work, but the rest do???

Cheers


Last edited by b0nafide on Tue Sep 20, 2011 2:30 am; edited 3 times in total
Back to top
View user's profile Send private message
b0nafide
Apprentice
Apprentice


Joined: 17 Feb 2008
Posts: 170
Location: ~/

PostPosted: Tue Sep 20, 2011 1:49 am    Post subject: Reply with quote

Further observations:

All the /dev/nbd devices work with qemu-0.14.0 on another gentoo box with the same kernel sources.
Back to top
View user's profile Send private message
b0nafide
Apprentice
Apprentice


Joined: 17 Feb 2008
Posts: 170
Location: ~/

PostPosted: Tue Sep 20, 2011 2:14 am    Post subject: Reply with quote

:oops:

This problem is fixed when using qemu >= 0.14.0

Well, it works now!
Back to top
View user's profile Send private message
marsark
n00b
n00b


Joined: 29 Sep 2008
Posts: 33

PostPosted: Thu Jan 12, 2012 11:55 am    Post subject: Reply with quote

Hi, I have also this problem with missing partitions in /dev on nbd device. I'm using nbd-client from sys-block/nbd. After connection I'm able to see partitions in the fdisk. But missing in /dev/nbd0*.

I have tried to create them with partx, but no success.

Code:

partx -a /dev/nbd0
partx: /dev/nbd0: error adding partition 1
partx: /dev/nbd0: error adding partition 3


Block device has following structure:

Code:

Disk identifier: 0xddde93b1

     Device Boot      Start         End      Blocks   Id  System
/dev/nbd0p1   *          63    60597179    30298558+  83  Linux
/dev/nbd0p3        60597180   625137344   282270082+  83  Linux


What's wrong?
Back to top
View user's profile Send private message
nativemad
Developer
Developer


Joined: 30 Aug 2004
Posts: 884
Location: Switzerland

PostPosted: Tue Mar 20, 2012 3:30 pm    Post subject: Reply with quote

I've got the same problem just now...

It worked correctly with nbd as module and "modprobe nbd max_part=16".

Cheers
_________________
Power to the people!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum