4

I'm running MSWindows virtualized with /dev/sda2 as it's primary drive. Consequently, there is a partition table on that partition, shown as:

# fdisk -l /dev/sda2

Disk /dev/sda2: 137.4 GB, 137436203520 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

     Device Boot      Start         End      Blocks   Id  System
/dev/sda2p1   *           1       16708   134206978+   7  HPFS/NTFS

So my question is simply: What are the major/minor numbers to create /dev/sda2p1? What about sda2p2 and sda3p1?

3
  • Running: CentOS release 5.3 (Final), kernel: 2.6.18-128.1.10.el5
    – NVRAM
    Dec 14, 2009 at 21:50
  • What are you using for your virtualization?
    – heavyd
    Dec 14, 2009 at 22:29
  • @heavyd - KVM (version 36)
    – NVRAM
    Dec 15, 2009 at 18:24

3 Answers 3

2

Assuming this is a straight disk image (e.g., your virtualization solution is not adding some extra metadata to things), this document (also here) offers some suggestions for accessing your partitions on /dev/sda2 (summary: use the -o offset option to losetup to create a new block device referencing the appropriate offset into sda2).

You can also use the Network Block Device (NBD) to create a partitioned block device from /dev/sda2, see this LWN article which described the process in detail. And hey, I just learned something new.

1
  • Yes, I realized I could use loopback/offset after I posted and found out that I don't have an NTFS module in my kernel (d'oh). I used the same technique (elsewhere on Ubuntu) to share a "virtual USB flash drive" with the host & a VM. Tedious, but it worked; however I didn't use /etc/fstab then.
    – NVRAM
    Dec 15, 2009 at 18:44
0

What you probably want here is kpartx.

https://nfolamp.wordpress.com/2010/08/16/mounting-raw-image-files-and-kpartx/

Kpartx takes a raw disk image and produces devices in the root file system for each of the partitions found in the disk image, (ie, in it's partition table).

3
  • ps, for added fun and excitement, put your partition table on a partition located on LVM, and nest the LVMs too. unix.stackexchange.com/questions/329343/… Mar 27, 2017 at 21:19
  • 2
    You need to explain some details to help the users understand
    – yass
    Mar 27, 2017 at 21:43
  • Rich, you can also update your own answer in order to add information rather than commenting below it. Mar 27, 2017 at 21:53
0

You can also use losetup -P (--partscan) to access the partitions as /dev/loopXpY without needing to manually pass -o offsets (not sure if this was possible back in 2009):

# losetup -Pf --show /dev/sda2
/dev/loop0
$ ls /dev/loop0p*
/dev/loop0p1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .