[quote] Using RAW Devices In VirtualBox VMs

Original URL

http://www.howtoforge.com/using-raw-devices-in-virtualbox-vms-p2

How to access a second .vdi image created in virtualbox stoage tab.

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders, total 10485760 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
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

You can now use this drive as you would normally do, e.g. partition it...

fdisk /dev/sdb

root@vm10:~# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x862fb2cf.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):
 <-- n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
 <-- p
Partition number (1-4, default 1): <-- 1
First sector (2048-10485759, default 2048): <-- ENTER
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759):
 <-- ENTER
Using default value 10485759

Command (m for help):
 <-- t
Selected partition 1
Hex code (type L to list codes):
 <-- 83

Command (m for help): <-- w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
root@vm10:~#

... create a file system on it (e.g. ext4)...

mkfs.ext4 /dev/sdb1

... and mount it:

mount /dev/sdb1 /mnt

原文地址:https://www.cnblogs.com/lake-of-embedded-system/p/3644074.html