posted on 2016-08-24 20:58
Don't overwrite your devices via
But we've all been there, done that.
If you don't want to reinstall 'just because', an idea might be to use
testdisk depending on what you did.
Getting nice partition layout I tend to use
parted (see below), for creating partitions
cgdisk (for GPT stuff) or
cfdisk (for MBR creation only IIRC) are decent choices.
Back on topic.
Partitions were still present in my cause, so no need create them anew.
If you have to, do
parted /dev/sda p and
parted /dev/sdX u b p and use your phone to make photos, in case you have to redo something.
Create and open the cryptocontainer to hold the complete partition, wherein the LVM and your filesystems will lie.
cryptsetup --cipher=aes-xts-plain64 luksFormat /dev/sdXN --force-password cryptsetup open /dev/sdXN sdXN_crypt
Did you really type an uppercased YES when you were promted? The password you were prompted for is the one you will have to enter in the future.
In case you did something wrong:
cryptsetup close cryptsetup erase /dev/sdaX
Then start by recreating the container. Did you really type an uppercased YES when you were promted?
After the crypto device was opened, you can reference it through the device mapper. Now create the physical volume (PV), volume group (VG) and logical volumes (LV's) where your system will be installed later on:
pvcreate /dev/mapper/sdXN_crypt vgcreate `hostname` /dev/mapper/sdXN_crypt lvcreate -L 2G -n swap `hostname` lvcreate -l 100%FREE -n root `hostname`
Here is a catch: I did not have to recreate a separate
/boot partition, as I already had one.
If you don't create one first.
It has to be located outside the crypto container, else you won't be able too boot after your installation.
If something went wrong, here's how to delete things, too. Choose what you need in particular:
pvremove /dev/sdXN_crypt vgremove `hostname` lvremove /dev/`hostname`/<LVname>
Create root filesystem:
mkfs -t ext4 /dev/mapper/`hostname`-root
This is pretty much it.
From here on you can
chroot or do whatever else you want.
Maybe you only want the container for data but for installing a system on there. In that case not calling the LV 'root' and omitting the swap partition up there would have been a wise choice.
posted on 2016-03-13 20:37:55
When fixing more complex linux installations, you may come across LUKS partitions. Here is the workflow for a luks + lvm + btrfs setup:
# first identify your partition lsblk -f # open the encrypted container # tabbing helps, if you tend to forget commands cryptsetup luksOpen /dev/sdX1 my_encrypted_partition # now after you entered the password, it should pop up under /dev/mapper/my_encrypted_partition # activate all the volume groups vgchange -aay # create your mount destinations mkdir /mnt/asdf mkdir /mnt/qwer # mount the lvm partitions, so you can work with them # VGname = your LVM volume group # LVname = your LVM logical volume # SVname = your btrfs subvolume name mount /dev/mapper/VGname/LVname /mnt/asdf mount /dev/mapper/VGname/LVname /mnt/qwer -o subvol=@SVname
That should be all you need to fix things, in case you need it. If it is useful to have both LVM and btrfs, may be doubted. btrfs does handle volume management by itself, too.
View posts from 2017-07, 2017-05, 2017-04, 2017-03, 2017-02, 2017-01, 2016-12, 2016-11, 2016-10, 2016-09, 2016-08, 2016-07, 2016-06, 2016-05, 2016-04, 2016-03, 2016-02, 2016-01, 2015-12, 2015-11, 2015-10, 2015-09, 2015-08, 2015-07, 2015-06, 2015-05, 2015-04, 2015-03, 2015-02, 2015-01, 2014-12, 2014-11, 2014-10, 2014-09, 2014-08, 2014-07, 2014-06, 2014-05, 2014-04, 2014-03, 2014-01, 2013-12, 2013-11, 2013-10