Setup Partitions: Difference between revisions

From www.deloptes.org
Jump to navigation Jump to search
No edit summary
Line 8: Line 8:


  # mdadm --create /dev/md7 --level=1 --raid-devices=2 /dev/sdg1 /dev/sdh1
  # mdadm --create /dev/md7 --level=1 --raid-devices=2 /dev/sdg1 /dev/sdh1
* for non bootable partition use v1.2
# mdadm --create /dev/md2 --metadata=1.2 --level=1 --raid-devices=2 /dev/sda5 /dev/sdb5
* for bootable partition use v0.90
# mdadm --create /dev/md0 --metadata=0.90 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
* install grub in the master boot sector on both disks
# grub-install --force --no-floppy --root-directory=/mnt/target/ /dev/sda
# grub-install --force --no-floppy --root-directory=/mnt/target/ /dev/sdb
* [[Chroot|chroot as described]] and install a device map followed by update initramfs and grub
# update-initramfs -u -k `uname -r`
# update-grub
* now system should be bootable from the raid disk


= CRYPTSETUP =
= CRYPTSETUP =

Revision as of 19:21, 4 April 2015

FDISK

  • create partitions

RAID

  • create raid1/mirror device
# mdadm --create /dev/md7 --level=1 --raid-devices=2 /dev/sdg1 /dev/sdh1
  • for non bootable partition use v1.2
# mdadm --create /dev/md2 --metadata=1.2 --level=1 --raid-devices=2 /dev/sda5 /dev/sdb5
  • for bootable partition use v0.90
# mdadm --create /dev/md0 --metadata=0.90 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
  • install grub in the master boot sector on both disks
# grub-install --force --no-floppy --root-directory=/mnt/target/ /dev/sda
# grub-install --force --no-floppy --root-directory=/mnt/target/ /dev/sdb
# update-initramfs -u -k `uname -r`
# update-grub
  • now system should be bootable from the raid disk

CRYPTSETUP

WARNING! The following command will remove all data on the partition that you are encrypting. You WILL lose all your information! So make sure you backup your data to an external source such as NAS or hard disk before typing any one of the following command.

In this example, I'm going to encrpt /dev/sdb7. Type the following command:

 # cryptsetup -y -v luksFormat /dev/sdb7
  • Open the crypted device
 # cryptsetup luksOpen /dev/sdb7 backup
  • Check the dm device
 # ls -l /dev/mapper/backup

or use following command

 # cryptsetup -v status backup

You can dump LUKS headers using the following command:

 # cryptsetup luksDump /dev/sdb7
  • Close a dm device after unmounting it
 # cryptsetup luksClose backup

LVM setup

  • Create physical volumes
 # pvcreate /dev/mapper/backup
  • Create a volume group
 # vgcreate G750lvm /dev/mapper/backup
  • After rebooting the system or running vgchange -an, you will not be able to access your VGs and LVs. To reactivate the volume group, run:
 # vgchange -a y G750lvm
       
  • Creating a logical volume
 # lvcreate -L50G -nroot G750lvm
 # lvcreate -L150G -nhome G750lvm
 # lvcreate -L200G -ncustom G750lvm
 # lvcreate -L150G -ndata G750lvm
 # lvcreate -L2G -nswap1 G750lvm
 # lvcreate -L2G -nswap2 G750lvm

Format the volumes

 # mkfs.ext3 /dev/mapper/G750lvm-root
 # mkfs.ext3 /dev/mapper/G750lvm-home
 # mkfs.ext3 /dev/mapper/G750lvm-custom
 # mkfs.ext3 /dev/mapper/G750lvm-data
 # mkswap /dev/mapper/G750lvm-swap1
 # mkswap /dev/mapper/G750lvm-swap2

copy data

 cd /mnt
 test -d target || mkdir target
 test -d source || mkdir source
 # mount ...(source) /mnt/source
 # mount /dev/mapper/G750lvm-root /mnt/target
 # tar cf - . | (cd /mnt/target/; tar xvf -)
  • umount and done

remove logical volume

  • umount the partition
  • close the volume
# lvchange -an /dev/vgcrypt/software
  • remove the volume
# lvremove /dev/vgcrypt/software

Sources

[1]

[2]

[3]