Difference between revisions of "Linux/Convert crypted btrfs to crypted LVM"
(→gdsik) |
(→gdsik) |
||
Line 195: | Line 195: | ||
5 477261824 944926719 467664896 223G Linux filesystem d006f732-d3bd-4c15-b942-3880c3e02fb5 |
5 477261824 944926719 467664896 223G Linux filesystem d006f732-d3bd-4c15-b942-3880c3e02fb5 |
||
[root@quadratix ~]# cryptsetup create luks-d006f732-d3bd-4c15-b942-3880c3e02fb5 /dev/sda5 |
[root@quadratix ~]# cryptsetup create luks-d006f732-d3bd-4c15-b942-3880c3e02fb5 /dev/sda5 --type luks |
||
Enter passphrase: |
Enter passphrase: |
Revision as of 19:24, 17 June 2014
[root@querix etc]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 500M 0 part /boot ├─sda3 8:3 0 3.9G 0 part │ └─luks-d8be01e9-ef97-43e4-a8cd-3e40837b4b22 253:0 0 3.9G 0 crypt [SWAP] └─sda4 8:4 0 461.2G 0 part └─luks-dffe4300-4e4e-4571-bb4a-c8a2b033610b 253:1 0 223G 0 crypt /home sr0 11:0 1 1024M 0 rom root@querix etc]# df -h / Filesystem Size Used Avail Use% Mounted on /dev/dm-1 222G 35G 185G 16% /
btrfs filesystem resize -240g /
echo $(( ( 223 * 1024 * 1024 * 1024 ) / 512 ) ))
cryptsetup resize --size 467664896 /dev/dm-1
[root@querix etc]# cryptsetup status /dev/dm-1 /dev/dm-1 is active and is in use. type: LUKS1 cipher: aes-xts-plain64 keysize: 512 bits device: /dev/sda4 offset: 4096 sectors size: 467664896 sectors mode: read/write
[root@querix etc]# gdisk GPT fdisk (gdisk) version 0.8.10
Type device filename, or press <Enter> to exit: [root@querix etc]# gdisk /dev/sda GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: protective BSD: not present APM: not present GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): p Disk /dev/sda: 976773168 sectors, 465.8 GiB Logical sector size: 512 bytes Disk identifier (GUID): E614EACE-CF55-4744-A727-8C9AE50AA0CE Partition table holds up to 128 entries First usable sector is 34, last usable sector is 976773134 Partitions will be aligned on 2048-sector boundaries Total free space is 2029 sectors (1014.5 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 411647 200.0 MiB EF00 EFI System Partition 2 411648 1435647 500.0 MiB 0700 3 1435648 9594879 3.9 GiB 0700 4 9594880 976773119 461.2 GiB 0700
Command (? for help): d Partition number (1-4): 4
Command (? for help): n Partition number (4-128, default 4): First sector (34-976773134, default = 9594880) or {+-}size{KMGTP}: Last sector (9594880-976773134, default = 976773134) or {+-}size{KMGTP}: +467664896 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): p Disk /dev/sda: 976773168 sectors, 465.8 GiB Logical sector size: 512 bytes Disk identifier (GUID): E614EACE-CF55-4744-A727-8C9AE50AA0CE Partition table holds up to 128 entries First usable sector is 34, last usable sector is 976773134 Partitions will be aligned on 2048-sector boundaries Total free space is 499515373 sectors (238.2 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 411647 200.0 MiB EF00 EFI System Partition 2 411648 1435647 500.0 MiB 0700 3 1435648 9594879 3.9 GiB 0700 4 9594880 477259775 223.0 GiB 0700 Microsoft basic data
Command (? for help): d Partition number (1-4): 4
Command (? for help): n Partition number (4-128, default 4): First sector (34-976773134, default = 9594880) or {+-}size{KMGTP}: Last sector (9594880-976773134, default = 976773134) or {+-}size{KMGTP}: +467664897 Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): L 0700 Microsoft basic data 0c01 Microsoft reserved 2700 Windows RE 3000 ONIE boot 3001 ONIE config 4100 PowerPC PReP boot 4200 Windows LDM data 4201 Windows LDM metadata 7501 IBM GPFS 7f00 ChromeOS kernel 7f01 ChromeOS root 7f02 ChromeOS reserved 8200 Linux swap 8300 Linux filesystem 8301 Linux reserved 8302 Linux /home 8400 Intel Rapid Start 8e00 Linux LVM a500 FreeBSD disklabel a501 FreeBSD boot a502 FreeBSD swap a503 FreeBSD UFS a504 FreeBSD ZFS a505 FreeBSD Vinum/RAID a580 Midnight BSD data a581 Midnight BSD boot a582 Midnight BSD swap a583 Midnight BSD UFS a584 Midnight BSD ZFS a585 Midnight BSD Vinum a800 Apple UFS a901 NetBSD swap a902 NetBSD FFS a903 NetBSD LFS a904 NetBSD concatenated a905 NetBSD encrypted a906 NetBSD RAID ab00 Apple boot af00 Apple HFS/HFS+ af01 Apple RAID af02 Apple RAID offline af03 Apple label af04 AppleTV recovery af05 Apple Core Storage be00 Solaris boot bf00 Solaris root bf01 Solaris /usr & Mac Z bf02 Solaris swap bf03 Solaris backup bf04 Solaris /var bf05 Solaris /home bf06 Solaris alternate se bf07 Solaris Reserved 1 bf08 Solaris Reserved 2 bf09 Solaris Reserved 3 bf0a Solaris Reserved 4 bf0b Solaris Reserved 5 c001 HP-UX data c002 HP-UX service ea00 Freedesktop $BOOT eb00 Haiku BFS ed00 Sony system partitio ed01 Lenovo system partit Press the <Enter> key to see more codes: 8300 ef00 EFI System ef01 MBR partition scheme ef02 BIOS boot partition fb00 VMWare VMFS fb01 VMWare reserved fc00 VMWare kcore crash p fd00 Linux RAID Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem'
Command (? for help): p Disk /dev/sda: 976773168 sectors, 465.8 GiB Logical sector size: 512 bytes Disk identifier (GUID): E614EACE-CF55-4744-A727-8C9AE50AA0CE Partition table holds up to 128 entries First usable sector is 34, last usable sector is 976773134 Partitions will be aligned on 2048-sector boundaries Total free space is 499515372 sectors (238.2 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 411647 200.0 MiB EF00 EFI System Partition 2 411648 1435647 500.0 MiB 0700 3 1435648 9594879 3.9 GiB 0700 4 9594880 477259776 223.0 GiB 8300 Linux filesystem
Command (? for help): n Partition number (5-128, default 5): First sector (34-976773134, default = 477261824) or {+-}size{KMGTP}: Last sector (477261824-976773134, default = 976773134) or {+-}size{KMGTP}: +467664896 Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem'
Command (? for help): p Disk /dev/sda: 976773168 sectors, 465.8 GiB Logical sector size: 512 bytes Disk identifier (GUID): E614EACE-CF55-4744-A727-8C9AE50AA0CE Partition table holds up to 128 entries First usable sector is 34, last usable sector is 976773134 Partitions will be aligned on 2048-sector boundaries Total free space is 31850476 sectors (15.2 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 411647 200.0 MiB EF00 EFI System Partition 2 411648 1435647 500.0 MiB 0700 3 1435648 9594879 3.9 GiB 0700 4 9594880 477259776 223.0 GiB 8300 Linux filesystem 5 477261824 944926719 223.0 GiB 8300 Linux filesystem
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!
Do you want to proceed? (Y/N): Your option? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/sda. 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.
gdsik
reboot if partx or partprobe do not work
[root@quadratix ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 500M 0 part /boot ├─sda3 8:3 0 3.9G 0 part │ └─luks-d8be01e9-ef97-43e4-a8cd-3e40837b4b22 253:1 0 3.9G 0 crypt [SWAP] ├─sda4 8:4 0 223G 0 part │ └─luks-dffe4300-4e4e-4571-bb4a-c8a2b033610b 253:0 0 223G 0 crypt /home └─sda5 8:5 0 223G 0 part sr0 11:0 1 1024M 0 rom
[root@quadratix ~]# partx /dev/sda5 NR START END SECTORS SIZE NAME UUID 5 477261824 944926719 467664896 223G Linux filesystem d006f732-d3bd-4c15-b942-3880c3e02fb5
[root@quadratix ~]# cryptsetup create luks-d006f732-d3bd-4c15-b942-3880c3e02fb5 /dev/sda5 --type luks Enter passphrase: