LVM - operacje na wolumenach

Inne-Opisy

  1. Kasowanie

    lvremove -f vg/LTSP-home
    
  2. Tworzenie wolumenu

    lvcreate --name LTSP-home --size 4G vg
    
  3. Zmiana rozmiaru:

root@xen:~# lvresize -L8G /dev/vg/xen-var 
  Extending logical volume xen-var to 8,00 GiB
  Logical volume xen-var successfully resized
root@xen:~# resize2fs /dev/vg/xen-var 
resize2fs 1.41.12 (17-May-2010)
System plików /dev/vg/xen-var jest zamontowany pod /var; wymagana zmiana rozmiaru w locie
old desc_blocks = 1, new_desc_blocks = 1
Wykonywanie zmiany rozmiaru w locie /dev/vg/xen-var na 2097152 (4k) bloków.
System plików na /dev/vg/xen-var ma teraz 2097152 bloków.

Crypto (zaszyfrowana partycja) kopiowanie danych

# cryptsetup luksOpen /dev/sdc7 moj_dysk# vgscan
Reading all physical volumes.  This may take a while...
Found volume group "Linux" using metadata type lvm2
Found volume group "VG" using metadata type lvm2# vgchange -ay Linux# lvs
File descriptor 7 (pipe:[27367]) leaked on lvs invocation. Parent PID 16363: bash
LV        VG    Attr   LSize   Origin Snap%  Move Log Copy%  Convert
home      Linux -wi-a-  52,95g                                      
root      Linux -wi-a-  18,62g                                      
swap      Linux -wi-a-   1,86g                                      
LTSP-home VG    -wi-a-  20,00g                                      
LTSP-opt  VG    -wi-a-   4,00g                                      
LTSP-root VG    -wi-ao   4,00g                                      
LTSP-swap VG    -wi-ao   4,00g                                      
LTSP-tmp  VG    -wi-a-   4,00g                                      
LTSP-usr  VG    -wi-a-   4,00g                                      
LTSP-var  VG    -wi-a-  10,00g                                      
dom0_root VG    -wi-ao 952,00m                                      
dom0_swap VG    -wi-ao   3,72g                                      
dom0_tmp  VG    -wi-ao   3,72g                                      
dom0_usr  VG    -wi-ao   3,72g                                      
dom0_var  VG    -wi-ao   3,72g                                      
windows   VG    -wi-ao  18,62g       
# root@dom0:~# mount -t ext3 /dev/mapper/Linux-root /mnt/root/
# root@dom0:~# mount -t ext3 /dev/mapper/Linux-home /mnt/home/# rsync -avz ........# umount /dev/mapper/moj_dysk-*# vgchange -an Linux# cryptsetup luksClose moj_dysk

http://en.gentoo-wiki.com/wiki/Root_filesystem_over_LVM2,DM-Cryptand_RAID

Partycja

root@Y510P:/etc# blkid | grep crypt
/dev/sdb7: UUID="f815fb52-2a7d-4c82-9142-4053b43ff6a4" TYPE="crypto_LUKS" PARTUUID="912ef0f1-f88e-4081-bfc4-5e263777be12"root@Y510P:/etc# dd if=/dev/random of=/root/.keys/dysk bs=1 count=32
32+0 przeczytanych rekordow
32+0 zapisanych rekordow
skopiowane 32 bajty, 0,000234995 s, 136 kB/sroot@Y510P:/etc#  cryptsetup luksAddKey /dev/sdb7 /root/.keys/dyskumieszczasz wpis w /etc/crypttab
db1_crypt UUID=5ca81c75-7e67-4548-b016-dcdaa0579b03 /root/.keys/dysk luksroot@Y510P:/etc# cryptsetup luksDump /dev/sdb7
LUKS header information for /dev/sdb7Version:        1
Cipher name:    aes
Cipher mode:    xts-plain64
Hash spec:      sha256
Payload offset: 4096
MK bits:        256
MK digest:      8b 49 e3 f1 41 48 5e 11 42 5f c9 66 f3 7d 1a 6b dc d8 60 db 
MK salt:        a2 d6 83 5b d9 1e 6c 05 18 94 79 22 b4 2d 70 ff 
                96 71 6f 44 73 89 de ab 1d b4 d6 a2 58 2b 5c 87 
MK iterations:  340250
UUID:           f815fb52-2a7d-4c82-9142-4053b43ff6a4Key Slot 0: ENABLED
    Iterations:             2752687
    Salt:                   4a e6 e7 8e 75 f8 a5 8c fc c5 b5 7b d2 07 66 6c 
                            db ca 17 50 fb 47 f6 3d a6 1a 39 d7 5e 41 be 56 
    Key material offset:    8
    AF stripes:             4000
Key Slot 1: ENABLED
    Iterations:             2767566
    Salt:                   1e 3d 04 68 84 af 18 4d 6f 33 2a bb 0b cc 2d 1a 
                            bb ec 03 9f e4 90 f8 ae e2 eb 0f 4f 9a 16 85 36 
    Key material offset:    264
    AF stripes:             4000
Key Slot 2: DISABLED
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED
root@Y510P:/etc# 

Zmiana nazwy grupy woluminów, na której jest root

  1. Rename volume group:

    vgrename oldname newname
    
  2. Edit /etc/fstab to replace the old name with the new one everywhere in that file

    vi /etc/fstab
    
  3. Edit /boot/grub/grub.cfg and do the same thing

    perl -i.old -npe 's/oldname/newname/g' /boot/grub/grub.cfg
    
  4. Update the image ram disk:

    update-initramfs -u   (this updates the current version)
    
  5. Reboot

Zmiana rozmiaru dysku

https://pve.proxmox.com/wiki/Resize_disks

root@ejbca:~# vgs
  VG    #PV #LV #SN Attr   VSize  VFree
  vgsys   1   8   0 wz--n- 10.00g 4.82gZmienic w proxmox rozmair dyskuW systemie 
parted /dev/sda(parted) print                                                            
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 34.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: Number  Start   End     Size    Type     File system  Flags
 1      1049kB  10.7GB  10.7GB  primary               boot, lvm(parted) resizepart 3 100%
(parted) quitroot@ejbca:~# pvresize /dev/sda1
  Physical volume "/dev/sda1" changed
  1 physical volume(s) resized / 0 physical volume(s) not resizedroot@ejbca:~# vgs
  VG    #PV #LV #SN Attr   VSize  VFree 
  vgsys   1   8   0 wz--n- 32.00g 26.82g
(15:53:53) lisu@jabber.linseco.pl/Y510P: Cześć Ian
(15:54:24) lisu@jabber.linseco.pl/Y510P: Mam pytanko jaki pliczek się tworzyło w partycji żeby przeskanował partycję?
(15:56:40) Ian LSLTD: Wybierzesz sobie partycja i "touch forcefsck"  Wiec jezeli chcesz na / to wtedy touch /forcefsck, jezeli /var - touch /var/forcefsck itd
(15:57:06) Ian LSLTD: po reboot to wtedy odpali fsck
(15:59:49) lisu@jabber.linseco.pl/Y510P: ok dzuieki
(16:03:29) Ian LSLTD: A jezeli cos zwiazane z selinux, trzeba touch .autorelabel zeby zaczelo proces naprawienie konteksty selinux, ale jesli to nie uzywasz, to spoko.