Archive

Archive for the ‘Linux’ Category

Ubuntu Grub2 Refresh Rate Problems

May 20th, 2014 No comments

I had to make a few changes to /etc/default/grub to get Ubuntu 14.04 to boot with a working console. Initially, my monitor just went dark.

Changes with reasons:

GRUB_HIDDEN_TIMEOUT: if you want to see the Grub menu, this must be commented out.

GRUB_CMDLINE_LINUX: allows passing parameters to the linux startup command. Newer kernels (>3.5? or so) reinitialize the graphics card. My AMD Radeon something-or-other didn’t like this at all. nomodeset forces linux to use/keep BIOS graphics settings.

GRUB_GFXMODE: select resolution for Grub graphical starup. 1280×1024 works on my aging ViewSonic. This setting is for the Grub menu.

GRUB_GFXPAYLOAD_LINUX: specifying keep, causes Grub to keep using the previous resolution (from GRUB_GFXMODE) for the rest of the boot. 

NB: after making any changes, remember to update-grub (or nothing will happen).

Contents of my /etc/default/grub after making required changes:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=”splash”
GRUB_CMDLINE_LINUX=”nomodeset”
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD …)
#GRUB_BADRAM=”0x01234567,0xfefefefe,0x89abcdef,0xefefefef”

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo’
#GRUB_GFXMODE=640×480
GRUB_GFXMODE=1280×1024
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you don’t want GRUB to pass “root=UUID=xxx” parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY=”true”

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE=”480 440 1″

Categories: Linux Tags: , , , , , , ,

Disable IPv6 in Ubuntu 14.04 (and others)

May 19th, 2014 No comments

My ISP (ding, dong) is stupid, so I need to disable IPv6.

sudo vim /etc/sysctl.conf

Add these four lines:

# No IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Categories: Linux Tags: , , , , ,

Proxmox: Adding Existing Logical Volumes

February 11th, 2014 No comments

Adding existing logical volumes to the list of virtual disks is non-obvious.
First add the VG to Proxmox using the “Storage|Add” UI. Once done, adding existing LV to Proxmox must be done via LVM command line tools.
A logical volume needs to have the correct naming, and (surprise!) an LVM tag set. For the correct tag (and LV name) format, use the UI to create a sample volume (VM|Hardware|Add|Hard Disk).
Note: LV names must fit a certain pattern. However, names like this seem to work: vm-110-timemachine.
The example below shows a pre-existing LV (vg1/vm-110-disk-2) without the “pve-vm-110” tag Proxmox requires.
Subsequent steps add the tag, after which the volume appears in Proxmox.

# lvs -o vg_name,lv_name,lv_tags
VG     LV              LV Tags
pve    data
pve    root
pve    swap
vg0    vm-110-disk-1   pve-vm-110
vg0    vm-110-disk-2   pve-vm-110
vg1    vm-110-disk-1   pve-vm-110
vg1    vm-110-disk-2

To see LV tags:

# lvs @pve-vm-110
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
vm-110-disk-1 vg0 -wi-ao--- 500.00g
vm-110-disk-2 vg0 -wi-ao--- 750.00g
vm-110-disk-1 vg1 -wi-ao--- 750.00g

To add missing tags:

# lvchange --addtag pve-vm-110 /dev/vg1/vm-110-disk-2

Refresh the Proxmox Storage UI to see the new LV.

Categories: Linux Tags: , , , , , ,

Raspberry Pi & Cubieboard Benchmarks

January 17th, 2013 No comments
Simple write test: dd bs=1M count=1000 if=/dev/zero of=test
Ignore first run results
Copy of 13,000+ files: cp -a /var/* …
O/S
Test
Raspberry Pi
Cubieboard
android (busybox to nvram)
4.8 M/B/s
berryboot (raspbian squashfs) 4G(c4)
200M 16 +/- .5MB/s 7.8 +/- .1 MB/s
1G 11 +/- .5MB/s 8.3 +/- 1 MB/s
200M to SATA HD 63 +/- 2MB/s
1G to SATA HDD 45 +/- 2MB/s
13,727 files (/usr) from SD -> HDD (ext4) 9.2 sec
13,727 files (/usr) from HDD -> SD 38 sec
debian (drazbian) 16G(c10)
200M 22 +/- 2 MB/s
1G 7.6 +/- .5 MB/s
Categories: Linux Tags: , , , ,

Make squashfs Disk Image

January 17th, 2013 1 comment

Raspberry Pi (and Cubieboard) SD disk images typically have two (or three) partitions: the first is Fat32 (50-100MB) and includes the boot files, while the second (>1GB) contains the main Linux image. With compression, the combined image can be reduced from several GB (of mostly empty space) to a couple hundred MB.

With a regular Linux desktop computer that has kpartx and mksquashfs installed, you can convert the second partition to SquashFS like this:

$ sudo kpartx -av image_you_want_to_convert.img
add map loop0p1 (252:5): 0 117187 linear /dev/loop0 1
add map loop0p2 (252:6): 0 3493888 linear /dev/loop0 118784
$ sudo mount /dev/mapper/loop0p2 /mnt
$ sudo mksquashfs /mnt converted_image.img -comp lzo -e lib/modules
$ sudo umount /mnt
$ sudo kpartx -d image_you_want_to_convert.img

dd with gzip

January 16th, 2013 No comments

You can save a lot of space by compressing dd image files.
These examples use gzip but many other compression apps will work just as well.

backup with dd and gzip

dd if=/dev/wd0a | gzip -9 > /mnt/backup.gz

restore backup

gunzip /mnt/backup.gz – | dd of=/dev/wd0a

Categories: Linux, OS X Tags: , , , , , ,

Mysterious MiniDLNA Ports

January 16th, 2013 No comments

MiniDLNA – Ports ssdp (1900/udp) and trivnet1 (8200/tcp) are proper of this service.
The other port (37167/udp) varies in every execution.

Categories: Linux Tags: , , ,

Nginx with PHP on CentOS 6

January 16th, 2013 No comments

from Black-Pixel.net:

If you haven’t already done it, you have to set up the EPEL repository.

For 32bit:

rpm -Uvh https://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm

For 64bit:

rpm -Uvh https://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm

Next install Nginx and spawn-fcgi, I assume you have already installed PHP and all the modules you need.

yum install nginx spawn-fcgi

Now it’s time for the spawn-fcgi configuration. The config should be at /etc/sysconfig/spawn-fcgi.

vim /etc/sysconfig/spawn-fcgi

# You must set some working options before the “spawn-fcgi” service will work.
# If SOCKET points to a file, then this file is cleaned up by the init script.
#
# See spawn-fcgi(1) for all possible options.
#
# Example :
#SOCKET=/var/run/php-fcgi.sock
OPTIONS=”-a 127.0.0.1 -p 9000 -u nginx -g nginx -C 32 -F 1 -P /var/run/spawn-fcgi.pid — /usr/bin/php-cgi”

It’s very important that you remember the port, you’ll have to set the same in the nginx configuration. You should also use the same username and group as nginx.
To play it safe, make sure the following line is not commented in the file /etc/init.d/spawn-fcgi:

config=”/etc/sysconfig/spawn-fcgi”

Now let’s make sure that spawn-fcgi and nginx automatically start after a reboot.

chkconfig –level 2345 nginx on
chkconfig –level 2345 spawn-fcgi on

For more information about chkconfig check this site:https://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-services-chkconfig.html

Next up we have to fix a folder permission. The group of the session cookies folder, the address can be found in the php.ini (session.save_path = “/var/lib/php/session”). The folder group has to be changed from apache to whatever you use, e. g. nginx. You should check this after every php update.

As a last step, just add the following line to the /etc/nginx.conf and/or your custom domain configuration in /etc/nginx/conf.d/yourdomain.conf.

location ~ .php$ {
include        fastcgi_params;
fastcgi_pass   localhost:9000;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
}

You should also make some additional changes in your configuration.

Categories: Development, Linux Tags: , , , ,

LVM Tricks with a Little Help from kpartx

January 16th, 2013 No comments

Or perhaps it should be: how to retrieve an lvm partition from an xvda partition within an lvm partition.

Quite some time ago, I built a CentOS Xen DomU using lvm within an xvda partition. And the whole VM was hosted in yet another lvm partition. While lvm is easy to manage and physical backup and restore is straightforward, accessing the contents of the embedded partition without the VM running is tricky. Luckily, device mapping in Linux is very powerful and can be used recursively (not quite like Haskell or OCaml, but impressive none the less).

This recipe can be applied multiple times to dig deeper into your embedded file systems.

Add the device mappings (assuming the device created is /dev/xvda ):

kpartx -a /dev/VolGroupXX/LogVolxx

Kpartx is amazing as it will scan all your lvm volumes and create device mapper entries, which are required for the lvm tools to do their thing.

Scan for physical volumes:

pvscan

The above should tell you the physical volumes with LVM partitions (the PV column) along with the volume groups on it (the VG column). Activate the volume group:

vgchange -ay {VG name from previous step}

If you have additional embedded LVM, run vgscan to discover these, and vgchange -ay as required. You may need to repeat the kpartx and pvscan too.

When you eventually get to the volume required, mount it with :

mount /dev/{VG name}/{LV name} /mnt/xxx ;

The folks at Citrix have more detail here, especially if you’re running Xen.

Disable IPv6 in RHEL/CentOS 6

January 16th, 2013 No comments

from linuxnet.ch

To disable IPv6 in RHEL/CentOS 6.x:

Edit /etc/sysconfig/network
Change the following:

NETWORKING_IPV6=yes to

NETWORKING_IPV6=no

Edit /etc/modprobe.conf
If not present, add the following:

alias net-pf-10 off

alias ipv6 off

Stop the ipv6tables service

service ip6tables stop

Disable the ipv6tables service

chkconfig ip6tables off

After rebooting, IPv6 will be disabled.

Categories: Linux Tags: , , , , , , , , ,