Wednesday, July 31, 2013

Gnome Shell Theme Customization

# vim /usr/share/gnome-shell/theme/gnome-shell.css

/* PopupMenu */

.popup-menu-boxpointer,

.candidate-popup-boxpointer {
-arrow-border-radius: 8px;
-arrow-background-color: rgba(0,0,0,0.9); # Panel popup menu background and transparency
-arrow-border-width: 1px; # Panel popup menu border width
-arrow-border-color: black;
-arrow-base: 24px;
-arrow-rise: 11px;

#panel {
background-color: rgba(0,0,0,0.5); # Panel background and transparency
font-weight: bold;
height: 1.8em; # Panel height


Friday, April 26, 2013

LVM : How to extend an active logical volume?

Important: This is not a definite guide. Use LVM tools with caution and always have a backup before you modify anything. Improper use of those tools may destroy all your data and I do not take any responsibility of that. You were warned.  

In this case we will add new PV (physical volume) to the existing VG (volume group) to extend an existing LV (logical volume) containing user home directories and mounted under /home. Both, the existing and a new PV are LUKS encrypted partitions. See my previous post LUKS : How to encrypt a partition? if you need to prepare the LUKS encrypted device first.

Check the current LVM setup

[root@cmstorm home]# lvs
  LV   VG      Attr     LSize   Pool Origin Data%  Move Log Copy%  Convert
  home vg_home -wi-ao-- 232.88g                                          
  root vg_root -wi-ao-- 347.62g                                          
  swap vg_root -wi-ao--  17.62g 


[root@cmstorm home]# lvdisplay vg_home
  --- Logical volume ---
  LV Path                /dev/vg_home/home
  LV Name                home
  VG Name                vg_home
  LV UUID                hd4N00-VKbv-47Hh-pTQ3-VH1m-6dEf-uukfDp
  LV Write Access        read/write
  LV Creation host, time cmstorm.localdomain, 2012-10-06 04:22:45 +0100
  LV Status              available
  # open                 1
  LV Size                232.88 GiB
  Current LE             7452
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3


[root@cmstorm home]# vgdisplay vg_home
  --- Volume group ---
  VG Name               vg_home
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               232.88 GiB
  PE Size               32.00 MiB
  Total PE              7452
  Alloc PE / Size       7452 / 232.88 GiB
  Free  PE / Size       0 / 0  
  VG UUID               IuoMBo-r2OD-D7Sg-U9dl-TbS6-3rFj-pcX5P7



[root@cmstorm home]# pvs
  PV                                                    VG      Fmt  Attr PSize   PFree
  /dev/mapper/luks-e78b92c8-26a5-415b-9f95-c56aa9e511ca vg_home lvm2 a--  232.88g    0
  /dev/sdb5                                             vg_root lvm2 a--  365.25g    0
 

[root@cmstorm home]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdb5
  VG Name               vg_root
  PV Size               365.27 GiB / not usable 22.00 MiB
  Allocatable           yes (but full)
  PE Size               32.00 MiB
  Total PE              11688
  Free PE               0
  Allocated PE          11688
  PV UUID               OUOFIT-KRPR-qnOK-yeKC-Me2y-NGn4-WeWqyR
  
  --- Physical volume ---
  PV Name               /dev/mapper/luks-e78b92c8-26a5-415b-9f95-c56aa9e511ca
  VG Name               vg_home
  PV Size               232.88 GiB / not usable 8.00 MiB
  Allocatable           yes (but full)
  PE Size               32.00 MiB
  Total PE              7452
  Free PE               0
  Allocated PE          7452
  PV UUID               Er1gKd-L20a-320j-EdGy-lbcl-szwz-hpVvDe


[root@cmstorm home]# pvdisplay /dev/mapper/luks-e78b92c8-26a5-415b-9f95-c56aa9e511ca
  --- Physical volume ---
  PV Name               /dev/mapper/luks-e78b92c8-26a5-415b-9f95-c56aa9e511ca
  VG Name               vg_home
  PV Size               232.88 GiB / not usable 8.00 MiB
  Allocatable           yes (but full)
  PE Size               32.00 MiB
  Total PE              7452
  Free PE               0
  Allocated PE          7452
  PV UUID               Er1gKd-L20a-320j-EdGy-lbcl-szwz-hpVvDe
  
[root@cmstorm home]# ls /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae 
luks-e78b92c8-26a5-415b-9f95-c56aa9e511ca


Create a new physical volume (PV) from the LUKS encrypted device

[root@cmstorm home]# pvcreate /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae
  Writing physical volume data to disk "/dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae"
  Physical volume "/dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae" successfully created


[root@cmstorm home]# pvs
  PV                                                    VG      Fmt  Attr PSize   PFree 
  /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae         lvm2 a--  931.51g 931.51g
  /dev/mapper/luks-e78b92c8-26a5-415b-9f95-c56aa9e511ca vg_home lvm2 a--  232.88g      0
  /dev/sdb5                                             vg_root lvm2 a--  365.25g      0
 

[root@cmstorm home]# pvdisplay /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae
  "/dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae" is a new physical volume of "931.51 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae
  VG Name              
  PV Size               931.51 GiB
  Allocatable           NO
  PE Size               0  
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               8VRooy-YVJ1-KDqU-QFhk-GnvF-VbJt-uEbhRS


Add the new physical volume (PV) to the volume group (VG)

[root@cmstorm home]# vgextend vg_home /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae
  Volume group "vg_home" successfully extended


[root@cmstorm home]# pvs
  PV                                                    VG      Fmt  Attr PSize   PFree 
  /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae vg_home lvm2 a--  931.50g 931.50g
  /dev/mapper/luks-e78b92c8-26a5-415b-9f95-c56aa9e511ca vg_home lvm2 a--  232.88g      0
  /dev/sdb5                                             vg_root lvm2 a--  365.25g      0


[root@cmstorm home]# pvdisplay /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae
  --- Physical volume ---
  PV Name               /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae
  VG Name               vg_home
  PV Size               931.51 GiB / not usable 6.00 MiB
  Allocatable           yes
  PE Size               32.00 MiB
  Total PE              29808
  Free PE               29808
  Allocated PE          0
  PV UUID               8VRooy-YVJ1-KDqU-QFhk-GnvF-VbJt-uEbhRS


Extend the logical volume (LV)

[root@cmstorm home]# lvextend -l +100%FREE /dev/vg_home/home
  Extending logical volume home to 1.14 TiB
  Logical volume home successfully resized
[root@cmstorm home]#



[root@cmstorm home]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdb5
  VG Name               vg_root
  PV Size               365.27 GiB / not usable 22.00 MiB
  Allocatable           yes (but full)
  PE Size               32.00 MiB
  Total PE              11688
  Free PE               0
  Allocated PE          11688
  PV UUID               OUOFIT-KRPR-qnOK-yeKC-Me2y-NGn4-WeWqyR
  
  --- Physical volume ---
  PV Name               /dev/mapper/luks-e78b92c8-26a5-415b-9f95-c56aa9e511ca
  VG Name               vg_home
  PV Size               232.88 GiB / not usable 8.00 MiB
  Allocatable           yes (but full)
  PE Size               32.00 MiB
  Total PE              7452
  Free PE               0
  Allocated PE          7452
  PV UUID               Er1gKd-L20a-320j-EdGy-lbcl-szwz-hpVvDe
  
  --- Physical volume ---
  PV Name               /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae
  VG Name               vg_home
  PV Size               931.51 GiB / not usable 6.00 MiB
  Allocatable           yes (but full)
  PE Size               32.00 MiB
  Total PE              29808
  Free PE               0
  Allocated PE          29808
  PV UUID               8VRooy-YVJ1-KDqU-QFhk-GnvF-VbJt-uEbhRS


[root@cmstorm home]# lvdisplay vg_home
  --- Logical volume ---
  LV Path                /dev/vg_home/home
  LV Name                home
  VG Name                vg_home
  LV UUID                hd4N00-VKbv-47Hh-pTQ3-VH1m-6dEf-uukfDp
  LV Write Access        read/write
  LV Creation host, time cmstorm.localdomain, 2012-10-06 04:22:45 +0100
  LV Status              available
  # open                 1
  LV Size                1.14 TiB
  Current LE             37260
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3


[root@cmstorm home]# df -h
Filesystem                Size  Used Avail Use% Mounted on
devtmpfs                  7.9G     0  7.9G   0% /dev
tmpfs                     7.9G  448K  7.9G   1% /dev/shm
tmpfs                     7.9G  2.0M  7.9G   1% /run
/dev/mapper/vg_root-root  343G   12G  314G   4% /
tmpfs                     7.9G     0  7.9G   0% /sys/fs/cgroup
tmpfs                     7.9G     0  7.9G   0% /media
/dev/sdd1                 459G  244G  192G  57% /mnt/WD10EAVS-EXT4
/dev/sdd2                 466G  114G  352G  25% /mnt/WD10EAVS-NTFS
/dev/sdb3                 477M   93M  359M  21% /boot
/dev/mapper/vg_home-home  230G   95G  123G  44% /home


The logical volume size is now 1.14TiB, but the /dev/mapper/vg_home-home filesystem is still 230G, so now you need to resize the file system to start using the new space.

 [root@cmstorm home]# resize2fs /dev/vg_home/home

Thursday, April 25, 2013

LUKS : How to encrypt a partition?

Important: This is not a definite guide. Use LUKS with caution and always have a backup before you modify anything. Improper use of LUKS may destroy all your data and I do not take any responsibility of that. You were warned.


Check if a partition is already encrypted with LUKS

[root@cmstorm home]# cryptsetup isLuks /dev/sda1 && echo Yes
[root@cmstorm home]#

Fill the device with random data

# dd if=/dev/urandom of=/dev/sda1
or
# badblocks -c 10240 -s -w -t random -v /dev/sda1


Encrypt the partition

[root@cmstorm home]# cryptsetup luksFormat /dev/sda1

WARNING!
========
This will overwrite data on /dev/sda1 irrevocably.

Are you sure? (Type uppercase yes): YES
Enter LUKS passphrase:
Verify passphrase:

[root@cmstorm home]# cryptsetup isLuks /dev/sda1 && echo Yes
Yes


[root@cmstorm home]# cryptsetup luksDump /dev/sda1
LUKS header information for /dev/sda1

Version:           1
Cipher name:       aes
Cipher mode:       cbc-essiv:sha256
Hash spec:         sha1
Payload offset:    4096
MK bits:           256
MK digest:         b9 2d fd e6 d2 ab 1b 83 9c 4e 26 36 ba b7 a0 62 a9 49 b7 59
MK salt:           35 79 84 53 ce 26 0a 3c da 1a cc a0 c0 fc 4f 1f
                   c1 82 91 2e 3c df f2 44 63 e7 f2 b6 42 a6 11 3b
MK iterations:     72875
UUID:              cba6febb-91cb-456e-afcf-0a16e89e4cae
Key Slot 0: ENABLED
    Iterations:             291655
    Salt:                   fd e6 dc 28 4f 68 ed 56 10 19 80 2c 74 33 1b 55
                              e9 8e 12 7c 08 be 24 0d 97 f5 f2 fd fb 21 65 01
    Key material offset:    8
    AF stripes:                4000
Key Slot 1: DISABLED
Key Slot 2: DISABLED
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED


Open the encrypted device and create mapping

[root@cmstorm home]# cryptsetup luksUUID /dev/sda1
cba6febb-91cb-456e-afcf-0a16e89e4cae


[root@cmstorm home]# cryptsetup luksOpen /dev/sda1 luks-cba6febb-91cb-456e-afcf-0a16e89e4cae
Enter passphrase for /dev/sda1:
 

[root@cmstorm home]# ll /dev/mapper/luks-*
lrwxrwxrwx. 1 root root 7 Apr 25 23:40 /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae -> ../dm-4
lrwxrwxrwx. 1 root root 7 Apr 25 22:54 /dev/mapper/luks-e78b92c8-26a5-415b-9f95-c56aa9e511ca -> ../dm-2
 

[root@cmstorm home]# dmsetup info luks-cba6febb-91cb-456e-afcf-0a16e89e4cae
Name:              luks-cba6febb-91cb-456e-afcf-0a16e89e4cae
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        0
Event number:      0
Major, minor:      253, 4
Number of targets: 1
UUID: CRYPT-LUKS1-cba6febb91cb456eafcf0a16e89e4cae-luks-cba6febb-91cb-456e-afcf-0a16e89e4cae


[root@cmstorm ~]# vim /etc/crypttab
luks-e78b92c8-26a5-415b-9f95-c56aa9e511ca UUID=e78b92c8-26a5-415b-9f95-c56aa9e511ca none
luks-cba6febb-91cb-456e-afcf-0a16e89e4cae UUID=cba6febb-91cb-456e-afcf-0a16e89e4cae none


Now you can use your newly encrypted device, in this case /dev/mapper/luks-cba6febb-91cb-456e-afcf-0a16e89e4cae, to create file system or use it with LVM for instance.