UPWORK/ODESK guru: Tips and Tricks for clients

skype: upwork.link , email: info@upwork.link

Author Archive

MDADM: Resize underlying partitions in mdadm RAID1

without comments

  1. Boot into a rescue CD, like SystemRescueCd, /dev/mdX is not mounted. Use fsck, just to make sure everything is ok with filesystem before any actions.
  2. Make scrabbing of target partition and repairing if will be need.
    A RAID array can suffer from sleeping bad blocks. i.e. blocks that you cannot read, but normally you never do (because they haven’t been allocated to a file yet). When a drive fails, and you are recovering the data onto a spare, hitting that sleeper can kill your array. For this reason it is good to regularly (daily, or weekly, maybe monthly) read through the entire array making sure everything is OK. In 2.6.16 (with complete functionality in 2.6.17) you will be able to trigger a background read-test of the whole array:

    1
    echo check > /sys/block/mdX/md/sync_action

    If you were to create an array with –assume-clean, then whenever you run this it will report lots of errors, though you can fix them with

    1
    echo repair > /sys/block/mdX/md/sync_action

    If you are going to be doing that (and I would recommend it) then you may as well allow the initial sync, especially as you can quite happily ignore the fact that it is happening.

  3. Resize filesystem on the mdadm RAID:

    1
    resize2fs /dev/md0 [size]

    where size is a little larger than the currently used space on the drive in filesystem

  4. After resize2fs, you need to shrink your mdadm array. For example, shrink /dev/md2 to 30GB. The –size value must be in KiBytes (30 x 1024 x 1024 = 31457280); make sure it can be divided by 64:

    1
    2
    mdadm --grow /dev/md2 --size=31457280
    (size FS <-> MD size <-> New partition size)
  5. Remove one of the drives from the RAID:
    1
    mdadm /dev/md0 --fail /dev/XXX1
  6. Resize the removed drive with parted. Add the new partition to the drive with parted
  7. Restore the drive to the RAID:
    mdadm -a /dev/mdX /dev/XXX1
  8. Repeat steps for the other device
  9. Resize the RAID to use the full partition:
    1
    mdadm --grow /dev/mdX -z max
  10. Next we grow the file system to the largest possible value (if you don’t specify a size, resize2fs will use the largest possible value) and check:
    1
    2
    resize2fs /dev/mdX
    e2fsck -f /dev/mdX

Written by spectre

September 23rd, 2018 at 4:06 pm

Posted in Arrays and Disks

[Vim] Удаление повторяющихся строк в vi

without comments

Попробуй это:

1
:%s/^\(.*\)\n\1$/\1/

Сделайте копию, хотя прежде, чем вы попробуете ее. Это непроверено.

Written by spectre

August 22nd, 2018 at 5:22 pm

Posted in Tips and Tricks

VIRSH:KVM – Запуск удаленного доступа VNC для гостевых операционных систем

without comments

Method # 1: Command Line Option

Normally, QEMU (/usr/libexec/qemu-kvm) uses SDL to display the VGA output. With the -vnc option option, you can have QEMU listen on VNC display display and redirect the VGA display over the VNC session. When using the VNC display, you must use the -k parameter to set the keyboard layout if you are not using en-us. Valid syntax for the display is as follows:

Read the rest of this entry »

Written by spectre

February 18th, 2018 at 2:13 pm

VIRSH:KVM – Перемещение дисков в другое хранилище

without comments

Migration of disks around is part of the life cycle of a guest. Disks in the storage pools (local or network) may fail or fill up due to bad capacity management. Ordinarily, one would have to shut down the guest, copy the storage volume file elsewhere (if it is a file), wait, update xML configuration, and launch it again. However, in mission-critical enterprises, this may not always be possible.

To get the source path, need check XML configuration file or storage volume. This requires to know which storage pool in use.

Read the rest of this entry »

Written by spectre

February 11th, 2018 at 4:46 pm

LUKS / dm-crypt and FS images

without comments

LUKS / dm-crypt is also suitable for creating FS images that can be used to store important information:
Read the rest of this entry »

Written by spectre

February 4th, 2018 at 7:25 pm

Posted in Tips and Tricks

OpenStack Neutron: How to change the default security rules in neutron during creation of group?

without comments

Neutron has commands for updating security groups:

1
2
3
4
5
6
7
8
9
  #security-group-create             Create a security group.
  #security-group-delete             Delete a given security group.
  #security-group-list               List security groups that belong to a given tenant.
  #security-group-rule-create        Create a security group rule.
  #security-group-rule-delete        Delete a given security group rule.
  #security-group-rule-list          List security group rules that belong to a given tenant.
  #security-group-rule-show          Show information of a given security group rule.
  #security-group-show               Show information of a given security group.
  #security-group-update             Update a given security group.

Read the rest of this entry »

Written by spectre

February 1st, 2018 at 3:40 pm

Posted in Openstack

Running VPNC and StrongSwan IPsec together – проблемы с Cisco 1941 ISR

without comments

Если в вашей компании или на вашем рабочем месте есть инфраструктура Cisco VPN, но в то же время вам необходимо подключиться к некоторому удаленному сайту с помощью Ipsec, и вы являетесь пользователем Linux на рабочем столе, то это хороший совет, как запустить оба из них на в то же время.

Требования:
– Уже настроен vpnc для подключения к VPN
– Уже настроенный ipsec для подключения к удаленным сайтам
– Уже настроенное подключение к Интернету

Read the rest of this entry »

Written by spectre

January 28th, 2018 at 12:31 pm

Posted in IPSEC

Openstack Neutron: again bugs of python coders – ethernet via infiniband

without comments

If you want use ethernet network on computation nodes via Infiniband network infrastructure for flat type or for bridges, so you will failed.
Obviously, again low level of coders of python of component Neutron.
All code of Neutron (as and all OpenStack) it is just big set of wrapper python scripts around usual linux tools.
In context Neutron and in this particular case python code of ‘linuxbridge’ script just makes primitive “parsing” of standard output of shell commands – ‘ip link show’!!)) . And this code seeks only small string – ‘link/ether’. But it is not correctly!
As transient variant, in this case of architecture, need check also and ‘link/infiniband’ as minimum.

Below small code of patch ))

Read the rest of this entry »

Written by spectre

January 10th, 2018 at 10:34 pm

Posted in Openstack

Openstack Nova: не удается загрузить экземпляр из образа (создать новый том) из-за тайм-аута для больших образов

without comments

Хотя проблема по сути были исправлена в ранних релизах, и жестко закодированные таймауты ожидания готовности блочных криворуким пиностом были устранены, все же хочется напомнить “юным” инсталляторщикам сложных систем вид ошибки, которую они могу встретить и два параметра которые могут помочь.

Итак в лог может вывалиться следующий блок от менеджера Nova на узле виртуализации:

Read the rest of this entry »

Written by spectre

January 2nd, 2018 at 2:54 pm

Posted in Openstack

Как распечатать полную трассировку кода скрипта python без остановки?

without comments

Для отладки можно все увидеть в текущей трассировке стека, вызвав:

1
  traceback.print_stack()

И нет необходимости вручную поднимать исключение, чтобы снова поймать его.

или в подробностях:

https://docs.python.org/2.7/library/traceback.html#traceback.print_stack
https://docs.python.org/3/library/traceback.html#traceback.print_stack

Written by spectre

December 27th, 2017 at 6:36 pm

Posted in Python snake