TritonDataCenter / smartos-live

For more information, please see http://smartos.org/ For any questions that aren't answered there, please join the SmartOS discussion list: https://smartos.topicbox.com/groups/smartos-discuss
1.58k stars 248 forks source link

KVM branded zone luks corruption after a reboot #534

Open xtreegpt opened 8 years ago

xtreegpt commented 8 years ago

Live Image version 20151224T060557Z KVM Image Linux Mint 17.3

json for KVM zone { "brand": "kvm", "vcpus": 2, "alias": "Linux Mint", "autoboot": true, "resolvers": ["192.168.1.1", "8.8.8.8", "8.8.4.4"], "ram": 1024, "disks": [{ "boot": true, "model": "virtio", "size": 60000 }], "nics": [{ "nic_tag": "admin", "model": "virtio", "ip": "192.168.1.34", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "primary": true }] Installed Mint, then after the install added a second drive

{ "add_disks": [ { "boot": false, "model": "virtio", "size": 105000 } ] }

Format the disk for luks

mint17 ~ # cryptsetup -y -v luksFormat /dev/vdb

WARNING!

This will overwrite data on /dev/vdb irrevocably.

Are you sure? (Type uppercase yes): YES Enter passphrase: Verify passphrase: Command successful. mint17 ~ #

open drive

mint17 ~ # cryptsetup luksOpen /dev/vdb testluks Enter passphrase for /dev/vdb: mint17 ~ #

gdisk the opened drive

mint17 ~ # gdisk /dev/mapper/testluks GPT fdisk (gdisk) version 0.8.8

Partition table scan: MBR: not present BSD: not present APM: not present GPT: not present

Creating new GPT entries.

Command (? for help): n Partition number (1-128, default 1): First sector (34-215035870, default = 2048) or {+-}size{KMGTP}: Last sector (2048-215035870, default = 215035870) or {+-}size{KMGTP}: Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): 0700 Changed type of partition to 'Microsoft basic data' Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!

Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/mapper/testluks. Warning: The kernel is still using the old partition table. The new table will be used at the next reboot. The operation has completed successfully.

format partition mkfs.ntfs -f -L testluks /dev/testluks1

mount the partition mount /dev/mapper/testluks1 /mnt/vdb1/

write some data mint17 vdb1 # dd if=/dev/urandom of=/mnt/vdb1/test.bin bs=4096 count=100 100+0 records in 100+0 records out 409600 bytes (410 kB) copied, 0.0338612 s, 12.1 MB/s

check out the file od /mnt/vdb1/test.bin |less

0000000 044200 057016 176265 052462 117740 041453 040472 145341 0000020 007001 025400 055050 057630 154416 071542 107570 050455 0000040 151502 144156 024767 113402 130443 067750 053660 017746 0000060 021742 143055 154624 050056 061767 024444 025635 041351

reboot the vm by issuing reboot from inside the vm

mint17 vdb1 # reboot mint17 vdb1 # Broadcast message from greg@mint17 (/dev/pts/3) at 10:09 ...

The system is going down for reboot NOW!

log back into the vm and open luks

mint17 ~ # cryptsetup luksOpen /dev/vdb testluks Enter passphrase for /dev/vdb:

try and mount the partition mint17 ~ # mount /dev/mapper/testluks1 /mnt/vdb1 mount: special device /dev/mapper/testluks1 does not exist

check disk with gdisk

mint17 ~ # gdisk -l /dev/mapper/testluks GPT fdisk (gdisk) version 0.8.8

Partition table scan: MBR: protective BSD: not present APM: not present GPT: present

Found valid GPT with protective MBR; using GPT. Disk /dev/mapper/testluks: 215035904 sectors, 102.5 GiB Logical sector size: 512 bytes Disk identifier (GUID): 004E0D17-93D4-428A-9A84-A3300C480455 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 215035870 Partitions will be aligned on 2048-sector boundaries Total free space is 2014 sectors (1007.0 KiB)

Number Start (sector) End (sector) Size Code Name 1 2048 215035870 102.5 GiB 0700 Microsoft basic data

partition is no longer accessible

nigoroll commented 8 years ago

did you check that vdb didn't get re-provisioned by joyent startup scripts?