# [SOLVED] Block device with GPT - accessing partitions

## manwe_

Hi *.

I have SSD drive [/dev/sdb] with one partition [/dev/sdb1]. This partition is LUKS-crypted. While decrypted, it's mapped to device /dev/mapper/ntfs, which then is passed to Qemu for Windows10 virtual machine [-drive format=raw,file=/dev/mapper/ntfs,...]. On that drive Windows created GPT with few partitions, including main one with all the data. 

My question is, how can I force Gentoo to read partition table on that /dev/mapper/ntfs and create "sub-devices". Somethin like /dev/mapper/ntfs1, ntfs2, etc. What for? I'd like to be able sometimes to mount that main windows partition with ntfs3g and access some files.Last edited by manwe_ on Mon Dec 07, 2015 7:45 pm; edited 1 time in total

----------

## khayyam

 *manwe_ wrote:*   

> My question is, how can I force Gentoo to read partition table on that /dev/mapper/ntfs and create "sub-devices". Somethin like /dev/mapper/ntfs1, ntfs2, etc. What for? I'd like to be able sometimes to mount that main windows partition with ntfs3g and access some files.

 

manwe_ ... /dev/mapper/ntfs is a block device, so you could use a loop, and have losetup '-P,--partscan' provide the partition table ... you would then mount these onto /mnt/* or what-have-you. See: man mount | less -p '^THE LOOP DEVICE' and 'man losetup'.

HTH & best ... khay

----------

## manwe_

OK, thanks, we're getting somewhere.

```
# losetup -f --show -P /dev/mapper/ntfs 

/dev/loop0

# ls -l /dev/loop0*

brw-rw---- 1 root disk   7, 0 12-06 20:48 /dev/loop0

brw-rw---- 1 root disk 259, 0 12-06 20:48 /dev/loop0p1

```

So there is a partition, but only one. Should be 4.

```
Disk /dev/loop0: 119.2 GiB, 128032530432 bytes, 250063536 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

Disklabel type: gpt

Disk identifier: 21333FDF-2F72-47BF-B849-014B4CAC368E

Device         Start       End   Sectors   Size Type

/dev/loop0p1    2048    923647    921600   450M Windows recovery environment

/dev/loop0p2  923648   1126399    202752    99M EFI System

/dev/loop0p3 1126400   1159167     32768    16M Microsoft reserved

/dev/loop0p4 1159168 250062847 248903680 118.7G Microsoft basic data

```

----------

## NeddySeagoon

manwe_,

I bet /dev/loop0p1 is the protective MSDOS partition. 

I would guess that -P does not find the GPT table.

There is another way.  You know the start addresses of the partitions

```
Device         Start      

/dev/loop0p1    2048 

/dev/loop0p2  923648 

/dev/loop0p3 1126400

/dev/loop0p4 1159168
```

You can mount them with the offset= option.  Convert the above block addresses to bytes by multiplying by 512. 

```
mount -t <FSTYPE> -o ro,offset=X /dev//mapper/ntfs /mnt/<someplace>
```

for a read only mount.

Rinse and repeat for various values of X and <someplace>

----------

## khayyam

 *manwe_ wrote:*   

> So there is a partition, but only one. Should be 4.

 

manwe_ ... ummmm, not sure why that would be the case, I might speculate that an --offset is required, try setting LOOPDEV_DEBUG=all and see if this provides some clue. You might also search for examples using the search terms 'losetup, gpt, loop0p1, etc'. Sorry, not something I've done for a windows image, so there may be something I'm not aware of ITR.

best ... khay

----------

## manwe_

 *NeddySeagoon wrote:*   

> You can mount them with the offset= option.  Convert the above block addresses to bytes by multiplying by 512. 

 

Works like a charm. Thanks a lot  :Smile:  It's a pity though, that --partscan does not support GPT.

----------

## NeddySeagoon

manwe_,

You can add entries to fstab if you wish, with the noauto option, so you need to use the lazy form of mount to mount those partition without remembering the offset values.

----------

