Created
August 20, 2020 02:43
-
-
Save orimanabu/8b7f793446597eaf1db4eb12dcd3d51c to your computer and use it in GitHub Desktop.
How to mount rhcos qcow2 root partition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo qemu-nbd --connect /dev/nbd0 rhcos-4.5.2-x86_64-openstack.x86_64.qcow2 | |
$ lsblk /dev/nbd0 | |
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT | |
nbd0 43:0 0 16G 0 disk | |
├─nbd0p1 43:1 0 384M 0 part | |
├─nbd0p2 43:2 0 127M 0 part | |
├─nbd0p3 43:3 0 1M 0 part | |
└─nbd0p4 43:4 0 3G 0 part | |
$ sudo parted /dev/nbd0 print | |
Model: Unknown (unknown) | |
Disk /dev/nbd0: 17.2GB | |
Sector size (logical/physical): 512B/512B | |
Partition Table: gpt | |
Disk Flags: | |
Number Start End Size File system Name Flags | |
1 1049kB 404MB 403MB ext4 boot | |
2 404MB 537MB 133MB fat16 EFI-SYSTEM boot, esp | |
3 537MB 538MB 1049kB BIOS-BOOT bios_grub | |
4 538MB 3752MB 3214MB luks_root | |
$ part_id=$(sudo parted /dev/nbd0 print | awk '/luks_root/ {print $1}') | |
$ echo ${part_id} | |
4 | |
$ dev=/dev/nbd0p${part_id} | |
$ echo $dev | |
/dev/nbd0p4 | |
[ori@pooh work]$ sudo cryptsetup luksDump ${dev} | |
LUKS header information | |
Version: 2 | |
Epoch: 5 | |
Metadata area: 16384 [bytes] | |
Keyslots area: 16744448 [bytes] | |
UUID: 00000000-0000-4000-a000-000000000002 | |
Label: crypt_rootfs | |
Subsystem: (no subsystem) | |
Flags: (no flags) | |
Data segments: | |
0: crypt | |
offset: 16777216 [bytes] | |
length: (whole device) | |
cipher: cipher_null-ecb | |
sector: 512 [bytes] | |
Keyslots: | |
0: luks2 | |
Key: 256 bits | |
Priority: normal | |
Cipher: cipher_null-ecb | |
Cipher key: 256 bits | |
PBKDF: argon2i | |
Time cost: 4 | |
Memory: 524288 | |
Threads: 1 | |
Salt: 4a 07 0a 88 f3 d5 fb aa 97 72 b5 c1 be 85 08 f7 | |
67 8d c3 99 e9 34 95 bc a5 dc cb 36 5a 44 7c 3a | |
AF stripes: 4000 | |
AF hash: sha256 | |
Area offset:32768 [bytes] | |
Area length:131072 [bytes] | |
Digest ID: 0 | |
Tokens: | |
9: coreos | |
Keyslot: 0 | |
Digests: | |
0: pbkdf2 | |
Hash: sha256 | |
Iterations: 238312 | |
Salt: 60 b5 67 87 39 cc 53 e7 f8 ea 83 50 ac 0f 9d b5 | |
04 9c dd be 4b 6f 03 89 ab 95 cc 3a 48 3d 64 0c | |
Digest: 1a 4d 8b 3c 19 26 10 d8 0f 1b d4 68 5b 10 ea 71 | |
23 0d f4 c9 d0 bb a0 f3 34 95 ba f7 73 7b de 7a | |
$ cipher=$(sudo cryptsetup luksDump ${dev} | awk '/cipher/{print$NF;exit}') | |
$ echo "${cipher}" | |
cipher_null-ecb | |
$ LUKS_HEADER_OFFSET_SECTORS=32768 | |
$ dev_size=$(($(sudo blockdev --getsize ${dev}) - ${LUKS_HEADER_OFFSET_SECTORS})) | |
$ echo "${dev_size}" | |
6244352 | |
$ echo "0 ${dev_size} linear ${dev} ${LUKS_HEADER_OFFSET_SECTORS}" | sudo dmsetup create coreos-luks-root-nocrypt | |
$ ls -l /dev/mapper/coreos-luks-root-nocrypt | |
lrwxrwxrwx. 1 root root 7 Aug 20 11:39 /dev/mapper/coreos-luks-root-nocrypt -> ../dm-2 | |
$ sudo mount /dev/mapper/coreos-luks-root-nocrypt /mnt | |
$ df /mnt | |
Filesystem 1K-blocks Used Available Use% Mounted on | |
/dev/mapper/coreos-luks-root-nocrypt 3111936 2307512 804424 75% /mnt | |
$ ls /mnt | |
boot ostree |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment