Labels

Thursday, January 12, 2017

Troubleshooting HDD errors

I found some error messages in a server today regarding ATA channel reset. To identify if it was a HDD I ran: # ls -l /sys/block/sd* | sed -e 's@.*-> \.\..*/ata@/ata@' -e 's@/host@ @' -e 's@/target.*/@ @' Turns out, it belongs to a different channel and not the ones that have the HDDs connected, will have to pay a visit to the Datacenter to check.

Thursday, May 22, 2014

Partition a disk with RAID1 and LVM for MaaS

I have been tasked to try MaaS, I don't like Ubuntu so I am biased on my statements...

The configuration of the preseeding is obfuscated without clear documentation. For the newcomers like me it certainly adds a little bit of frustration. Yes, there are examples and some guides all over the Internet, but they lack quality.

I am posting here a way to modify the preseed of MaaS to partition your disk and use LVM over RAID. The difference with the other guides that you might find is that I am not using static devices names such as /dev/sda or /dev/sdb plus it goes straight to the point.

So here is what you have to do:
Modify the /etc/maas/preseeds/preseed_master locate the partiton section and replace it with the following.

# Partitioning RAID 1
d-i partman/early_command string debconf-set partman-auto/disk `list-devices disk | head -n2`
d-i partman-auto/method string raid
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-auto/choose_recipe select boot-root
d-i partman-auto-lvm/new_vg_name string vg00
d-i partman-auto/expert_recipe string \
boot-root :: \
32 10 32 free \
$gptonly{ } \
$primary{ } \
$bios_boot{ } \
method{ biosgrub } \
. \
150 20 200 raid \
$lvmignore{ } \
$primary{ } method{ raid } \
raidid{ 1 } \
. \
33768 30 -1 raid \
$lvmignore{ } \
$primary{ } method{ raid } \
raidid{ 2 } \
. \
16384 100 200% swap \
$defaultignore{ } \
$lvmok{ } \
lv_name{ swap } \
method{ swap } \
format{ } \
. \
16384 90 32768 ext4 \
$defaultignore{ } \
$lvmok{ } \
lv_name{ root } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
mountpoint{ / } \
.
d-i partman-auto-raid/recipe string \
1 2 0 ext3 /boot \
raidid=1 \
. \
1 2 0 lvm - \
raidid=2 \
.
d-i mdadm/boot_degraded boolean false
d-i partman-md/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select Finish partitioning and write changes to disk
d-i partman/confirm boolean true
d-i partman-md/confirm_nooverwrite boolean true
d-i partman/confirm_nooverwrite boolean true




What is important to point out?
1.- Here you will be creating 4 partitions on each drive:
** BIOS partition (because we need it for devices more than 2Tb long) - 32Mb
** RAID partition for md0 that will be used for /boot - 150Mb
** RAID partition for md1 that will be used for LVM - Rest of the disk
** Two Logical groups SWAP and root (16Gb each)

2.- I am not using the static names of the devices (as many other examples on the Internet do), so let's say I am deploying a machine with IDE drives, I cannot use sda and sdb to define the members of the RAID. Hence note this line 

d-i partman/early_command string debconf-set partman-auto/disk `list-devices disk | head -n2`
Also, note the reference to the raidid parameter over the configuration.

3.- I couldn't understand - because my patience ran short - how the priority works creating a partition, more information on how to play with theses numbers here: http://ftp.dc.volia.com/pub/debian/preseed/partman-auto-recipe.txt. Therefore you will have to play and post a comment if you understand it

Well, I hope it is helpful, since I took several hours to gather the information here displayed. I have to go now, sorry for the lack of quality!! Ahhh like Ubuntu documentation :-D

Monday, May 19, 2014

Export data from MySQL to CSV

I cannot believe I am still using MySQL, after I fell in love with PostgreSQL, but many systems I manage still use MySQL and will stay like that. Today I needed to export data to CSV and I didn't remember how, well this is it.

mysql> SELECT * INTO OUTFILE '/tmp/registro_semanario.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY ‘\\’ LINES TERMINATED BY '\n' FROM registro_semanario ORDER BY e_mail;

Taken from this site: https://ariejan.net/2008/11/27/export-csv-directly-from-mysql/ but it has an error with single quotes.

Added in the cheat sheet to remember.