qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-discuss] Issue related to mounting /dev/nbd0p1


From: Pascal
Subject: Re: [Qemu-discuss] Issue related to mounting /dev/nbd0p1
Date: Tue, 4 Dec 2018 14:40:47 +0100

hope this will help you to debug your problem...

# qemu-img create /tmp/test.raw 512M
Formatting '/tmp/test.raw', fmt=raw size=536870912
# qemu-img create -f qcow2 /tmp/test.qcow 512M
Formatting '/tmp/test.qcow', fmt=qcow2 size=536870912 cluster_size=65536
lazy_refcounts=off refcount_bits=16
# ll /tmp/test.*
-rw-r--r-- 1 root   root      196616  4 déc.  14:20 /tmp/test.qcow
-rw-r--r-- 1 pascal pascal 536870912  4 déc.  14:20 /tmp/test.raw
# modprobe nbd
# qemu-nbd -c /dev/nbd0 /tmp/test.raw
WARNING: Image format was not specified for '/tmp/test.raw' and probing
guessed raw.
         Automatically detecting the format is dangerous for raw images,
write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
# qemu-nbd -d /dev/nbd0
/dev/nbd0 disconnected
# qemu-nbd -c /dev/nbd0 -f raw /tmp/test.raw
# qemu-nbd -c /dev/nbd1 /tmp/test.qcow
# fdisk -l /dev/nbd0 /dev/nbd1
Disque /dev/nbd0 : 512 MiB, 536870912 octets, 1048576 secteurs
Unités : secteur de 1 × 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 512 octets
taille d'E/S (minimale / optimale) : 512 octets / 512 octets
Disque /dev/nbd1 : 512 MiB, 536870912 octets, 1048576 secteurs
Unités : secteur de 1 × 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 512 octets
taille d'E/S (minimale / optimale) : 512 octets / 512 octets
# ll /dev/nbd[01]p*
ls: cannot access '/dev/nbd[01]p*': No such file or directory
# echo -e "n\n\n\n\n\nw" | fdisk /dev/nbd0
Welcome to fdisk (util-linux 2.33).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xc2bc7c1e.
Command (m for help): Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):
Partition number (1-4, default 1):
First sector (2048-1048575, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1048575, default
1048575):
Created a new partition 1 of type 'Linux' and of size 511 MiB.
Command (m for help): The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
# ll /dev/nbd[01]p*
brw-rw---- 1 root disk 43, 1 Dec  4 14:25 /dev/nbd0p1
# echo -e 'n\n\n\n\n\nw' | fdisk /dev/nbd1
Welcome to fdisk (util-linux 2.33).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xa0395daf.
Command (m for help): Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-1048575, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1048575, default
1048575):
Created a new partition 1 of type 'Linux' and of size 511 MiB.
Command (m for help): The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
# ll /dev/nbd[01]p*
brw-rw---- 1 root disk 43,  1 Dec  4 14:28 /dev/nbd0p1
brw-rw---- 1 root disk 43, 33 Dec  4 14:28 /dev/nbd1p1
# mkfs.ext4 /dev/nbd0p1
mke2fs 1.44.4 (18-Aug-2018)
Discarding device blocks: done
Creating filesystem with 523264 1k blocks and 131072 inodes
Filesystem UUID: a18b208d-47bf-4b05-b23c-a1527bd732ac
Superblock backups stored on blocks:
    8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
# mkfs.ext4 /dev/nbd1p1
mke2fs 1.44.4 (18-Aug-2018)
Discarding device blocks: done
Creating filesystem with 523264 1k blocks and 131072 inodes
Filesystem UUID: 3bb8fae9-9cb5-4853-bd59-9251a2db6896
Superblock backups stored on blocks:
    8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
# mount /dev/nbd0p1 /cdrom
# ll /cdrom/
total 12
drwx------ 2 root root 12288 Dec  4 14:31 lost+found
# umount /cdrom
# mount /dev/nbd1p1 /cdrom
# touch /cdrom/toto
# umount /cdrom
# qemu-nbd -d /dev/nbd0
/dev/nbd0 disconnected
# qemu-nbd -d /dev/nbd1
/dev/nbd1 disconnected
# ll /dev/nbd[01]p*
ls: cannot access '/dev/nbd[01]p*': No such file or directory
# qemu-nbd -c /dev/nbd1 /tmp/test.qcow
# ll /dev/nbd[01]p*
brw-rw---- 1 root disk 43, 33 Dec  4 14:34 /dev/nbd1p1
# mount /dev/nbd1p1 /cdrom
# ll /cdrom/
total 12
drwx------ 2 root root 12288 Dec  4 14:31 lost+found
-rw-r--r-- 1 root root     0 Dec  4 14:33 toto
# umount /cdrom
# ll /tmp/test.*
-rw-r--r-- 1 root   root    26738688 Dec  4 14:34 /tmp/test.qcow
-rw-r--r-- 1 pascal pascal 536870912 Dec  4 14:32 /tmp/test.raw


reply via email to

[Prev in Thread] Current Thread [Next in Thread]