User Tools

Site Tools


linux:scribble

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
linux:scribble [2017/05/16 13:34] – add tricks for Jenkins styblalinux:scribble [2021/07/01 07:42] – add Move LVM on LUKS to new HDD stybla
Line 110: Line 110:
 data[1] = number >> 0; data[1] = number >> 0;
 </code> </code>
 +
 +===== Exercises ======
 +
 +[[https://www.codingunit.com/category/programming-algorithms|Programming algorithms at CodingUnit]].
  
  
Line 269: Line 273:
 multilibs from time to time), so that might be the issue behind error above. But libvirt  multilibs from time to time), so that might be the issue behind error above. But libvirt 
 is long gone, replaced and forgotten now. is long gone, replaced and forgotten now.
 +
 +===== Move LVM on LUKS to new HDD =====
 +
 +Unfortunately, this is like two years later and all I have are two links - [[https://wiki.deimos.fr/images/f/f1/How_To_Migrate_to_a_full_encrypted_LVM_system.pdf|first]] and [[https://unix.stackexchange.com/questions/379357/best-way-to-move-lvm-on-luks-to-a-new-hdd|second]]. I believe the first one shows how to initialize LUKS at new HDD while the second explains how to move LVM. Shameless copy-paste from the second link. I'm NOT the author of the following:
 +
 +> Ideally, you initialize the new LUKS partition as a LVM PV, add it to your volume group with:
 +
 +<code>vgextend vg1 /path/to/new/LUKS/device</code>
 +
 +> Then use the LVM pvmove command to migrate your data to it like so:
 +
 +<code>pvmove /path/to/old/LUKS/device /path/to/new/LUKS/device</code>
 +
 +> When the data migration is done, be sure to remove the old LUKS partition from the volume group with:
 +
 +<code>vgreduce vg1 /path/to/old/LUKS/device</code>
 +
 +> This can all be done with the system online, although it is marginally safer and probably significantly faster to do it from a LiveCD like SystemRescueCD. Also, if you have a new enough version of LVM, you probably want to use the --atomic option for pvmove, that will ensure that you don't end up with some LV's on the new device and some on the old device if the pvmove command fails.
 +
 +I wish I've documented all the steps I took to move LUKS between HDDs since it might come handy. Also, it's not the first time I did that. Damn!
  
 ===== loop-AES ===== ===== loop-AES =====
Line 301: Line 325:
  
 Funny thing is, it seems much harder to resize encrypted partition via cryptsetup/dm-crypt. Funny thing is, it seems much harder to resize encrypted partition via cryptsetup/dm-crypt.
 +
 +===== MySQL =====
 +
 +==== Convert database to UTF-8 encoding ====
 +
 +Originally found at [[https://www.a2hosting.com/kb/developer-corner/mysql/convert-mysql-database-utf-8|a2hosting.com]]
 +
 +Run mysql and check the encoding:
 +
 +<code>
 +SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "DBNAME";
 +SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA WHERE CCSA.collation_name = T.table_collation AND T.table_schema = "DBNAME" AND T.table_name = "TABLENAME";
 +</code>
 +
 +Change encoding of tables:
 +
 +<code>
 +cat > ~/.my.cnf <<EOF
 +[client]
 +user=USER
 +password=PASSWORD
 +EOF
 +mysql --database=DBNAME -B -N -e "SHOW TABLES" | awk '{print "SET foreign_key_checks = 0; ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; SET foreign_key_checks = 1; "}' | mysql --database=DBNAME
 +</code>
 +
 +Change encoding of DB itself:
 +<code>
 +ALTER DATABASE DBNAME CHARACTER SET utf8 COLLATE utf8_general_ci;
 +</code>
 +
 +Remove ''~/.my.cnf'' or edit out username and password.
 +
  
 ===== OpenOffice/LibreOffice ===== ===== OpenOffice/LibreOffice =====
linux/scribble.txt · Last modified: 2022/07/06 17:27 by stybla