Monthly Archives: January 2018

create lvm from loop

cd /root
losetup /dev/loop0 lvm_disk.img


sfdisk /dev/loop0 << EOF ,,8e,, EOF

Checking that no-one is using this disk right now ...
BLKRRPART: Invalid argument
OK
Disk /dev/loop0: cannot get geometry

Disk /dev/loop0: 2871 cylinders, 255 heads, 63 sectors/track
/dev/loop0: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/loop0p1 0+ 2870 2871- 23061307 8e Linux LVM
/dev/loop0p2 0 - 0 0 0 Empty
/dev/loop0p3 0 - 0 0 0 Empty
/dev/loop0p4 0 - 0 0 0 Empty

fdisk -l /dev/loop0
Disk /dev/loop0: 23.6 GB, 23622320128 bytes
255 heads, 63 sectors/track, 2871 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/loop0p1 1 2871 23061307 8e Linux LVM

vi /etc/lvm/lvm.conf
filter = [ "a|/dev/loop.*|", "r/.*/" ]

pvcreate /dev/loop0
Physical volume "/dev/loop0" successfully created

vgcreate testvg /dev/loop0
Volume group "testvg" successfully created

vgdisplay -v
Using volume group(s) on command line.
--- Volume group ---
VG Name testvg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 22.00 GiB
PE Size 4.00 MiB
Total PE 5631
Alloc PE / Size 0 / 0
Free PE / Size 5631 / 22.00 GiB
VG UUID H4ebYh-LzsJ-9LJG-4Bdj-UWig-u7y2-1QAaFX

--- Physical volumes ---
PV Name /dev/loop0
PV UUID JyEC3B-8svS-n8D3-OFgV-Vxwe-llUj-63rGA6
PV Status allocatable
Total PE / Free PE 5631 / 5631

lvcreate -l 100%FREE -ntest_lv testvg
Logical volume "test_lv" created

lvm snapshot to remote server

lvdisplay /dev/lvm-group/lv-name | grep Size
LV Size 60.00 GiB

take 10-20% of this space:
lvcreate –size 7G –snapshot –name lv-name-snap /dev/lvm-group/lv-name

copy and compress:
dd if=/dev/lvm-group/lv-name-snap | gzip -1 - | ssh [email protected] dd of=/backups/lvm-images/lv-name-snap.gz

from backup server:
ssh user@remote "dd if=/dev/lvm-group/lv-name-snap | gzip -1 -" | dd of=/backups/lvm-images/lv-name-snap.gz

remove snapshot image:
lvremove /dev/lvm-group/lv-name-snap

Please be carefully with dd command, this command can be destructive.

Configuration of pmadb… not OK

cd /to/phpmyadmin/dir
find . -name create_tables.sql
mysql < ./sql/create_tables.sql CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapass'; GRANT ALL PRIVILEGES ON `phpmyadmin`.* TO 'pma'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES; /* User used to manipulate with storage */ $cfg['Servers'][$i]['controlhost'] = 'localhost'; // $cfg['Servers'][$i]['controlport'] = ''; $cfg['Servers'][$i]['controluser'] = 'pma'; $cfg['Servers'][$i]['controlpass'] = 'pmapass'; /* Storage database and tables */ $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; $cfg['Servers'][$i]['relation'] = 'pma__relation'; $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords'; $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages'; $cfg['Servers'][$i]['column_info'] = 'pma__column_info'; $cfg['Servers'][$i]['history'] = 'pma__history'; $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs'; $cfg['Servers'][$i]['tracking'] = 'pma__tracking'; $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords'; $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig'; $cfg['Servers'][$i]['recent'] = 'pma__recent'; $cfg['Servers'][$i]['favorite'] = 'pma__favorite'; $cfg['Servers'][$i]['users'] = 'pma__users'; $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups'; $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding'; $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches'; $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns'; $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings'; $cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';