Smokes your problems, coughs fresh air.

Author: halfgaar (Page 13 of 26)

Halfgaar is Wiebe. Wiebe is a contributing author on this weblog. He also has a lot of stuff (such as long, in-depth articles) on his personal website.

Wiebe's day job is as a senior software developer and system administrator at YTEC.

In his free time, he built the free, open-source FlashMQ software. Together with Jeroen and Rowan, he is now building a managed MQTT hosting business around his open masterpiece.

Enabling quota on a journalled ext3 file system on Debian

Source. And a source for non-journalled quotas.

aptitude install quota

Edit fstab to make the proper entry look like this:

/dev/sda2       /               ext3    errors=remount-ro,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 0       1

I don’t know if errors=remount-ro is a default option that will be enabled anyway. I would guess so.

Do this:

touch /aquota.user /aquota.group
chmod 600 /aquota.*
mount -o remount /

Then:

quotacheck -avugm
quotaon -avug

WIth this command, you can set a 1GB quota for a user:

setquota -u $user 0 1000000 0 0  /

Other tools of interest: edquota, repquota. See the seealso for any quata command, I guess.

Xen console name on different kernel versions

I’ve just been struggling to get a xen console working for Ubuntu 8.04 (hardy). By default, xen-create-image uses hvc0, but that’s only since kernel 2.6.26 (don’t know if that’s only pv_ops or xen-patched). Hardy uses 2.6.24 and therefore it’s xvc0. The xen-create-image command or xen-tools.conf config file therefore need a parameter serial_device=xvc0.

Creating iSCSI target and initiator on Debian

This post is even more of a memory aid than normal; it’s really only useful to me.

Source. I assume Ubuntu is similar.

To create an iSCSI target, first install the software:

aptitude install iscsitarget iscsitarget-modules-2.6-amd64

Edit /etc/default/iscsitarget and put in:

ISCSITARGET_ENABLE=true

Edit /etc/ietd.conf and put in something like this (do man ietd.conf for explanation of the parameters):

Target iqn.2010-12.com.example.host:storage.lun1
  # no user based auth (user and pass empty)
  IncomingUser
  # no user based auth (user and pass empty)
  OutgoingUser
  # Path can be any file or block device, also /dev/sdb
  Lun 0 Path=/dev/sdb1,Type=blockio
  Alias LUN1

/etc/initiators.allow and /etc/initiators.deny should both be empty, and therefore allow all. Use iptables to restrict access to hosts.

Then can start /etc/init.d/iscsitarget start

As for the initiator:

aptitude install open-iscsi

Edit /etc/iscsi/iscsid.conf and change the line:

node.startup = automatic

Then tell it to look for volume groups after starting (because when booting, lvm is started before iscsi). Edit /etc/default/open-iscsi:

LVMGROUPS="vgname"

Then start the deamon (wasn’t it active already…?):

/etc/init.d/open-iscsi restart

Then discover and build the node database (in /etc/iscsi/nodes) for your target (when you do that again, it overwrites, so I don’t know what you should do when you’ve added a target on the server):

iscsiadm -m discovery -t st -p ipaddress

Then login:

# You can logout again by using this line and replacing login with logout.
iscsiadm -m node --targetname "iqn.2010-12.com.example.host:storage.lun1" --portal "192.168.0.102" --login

Disk is now available under a device node like /dev/sdb. I don’t know how I could fix this to a specific device, to prevent changes when you change the hard disk configuration. Perhaps I can configure a udev rule for the lun in question.

Installing XML catalogs on Archlinux

It took me forever to find the packages on Archlinux that contained the XML catalogs files for HTML and XHTML. So:

aur/html-docs
aur/xhtml-docs

It installs a file in /etc/profile.d and sets SGML_CATALOG_FILES, so be sure to su – or login again.

Making a Debian Squeeze machine into a Xen virtual machine host

My attempts to get Xen working right on Debian stable (Lenny) were not really successful. Xen has had some interesting developments and the version in Lenny is just too old. Plus, the debian bootstrap scripts used to create images don’t support Ubuntu Maverick… Squeeze (testing) has the newest Xen and deboostrap, so that’s cool. I used the AMD64 architecture.

First install Xen:

aptitude -P install xen-hypervisor-4.0-amd64 linux-image-xen-amd64 xen-tools

Debian Sqeeuze uses Grub 2, and the defaults are wrong for Xen. The Xen hypervisor (and not just a Xen-ready kernel!) should be the first entry, so do this:

mv -i /etc/grub.d/10_linux /etc/grub.d/50_linux

Then, disable the OS prober, so that you don’t get entries for each virtual machine you install on a LVM.

"" >> /etc/default/grub "# Disable OS prober to prevent virtual machines on logical volumes from appearing in the boot menu." >> /etc/default/grub "GRUB_DISABLE_OS_PROBER=true" >> /etc/default/grub
update-grub2

Per default (on Debian anyway), Xen tries to save-state the VM’s upon shutdown. I’ve had some problems with that, so I set these params in /etc/default/xendomains to make sure they get shut down normally:

XENDOMAINS_RESTORE=false
XENDOMAINS_SAVE=""

In /etc/xen/xend-config.sxp I enabled the network bridge (change an existing or commented-out line for this). I also set some other useful params (for me):

(network-script network-bridge)
(dom0-min-mem 196)
(dom0-cpus 0)
(vnc-listen '127.0.0.1')
(vncpasswd '')
(Also, don’t forget to disable ballooning and setting a max memory.)

Then I edited /etc/xen-tools/xen-tools.conf. This config contains default values the xen-create-image script will use. Most important are:

# Virtual machine disks are created as logical volumes in volume group universe (LVM storage is much faster than file)
lvm = universe
 
install-method = debootstrap
 
size   = 50Gb      # Disk image size.
memory = 512Mb    # Memory size
swap   = 2Gb    # Swap size
fs     = ext3     # use the EXT3 filesystem for the disk image.
dist   = `xt-guess-suite-and-mirror --suite` # Default distribution to install.
 
gateway    = x.x.x.x
netmask    = 255.255.255.0
 
# When creating an image, interactively setup root password
passwd = 1
 
# I think this option was this per default, but it doesn't hurt to mention.
mirror = `xt-guess-suite-and-mirror --mirror`
 
mirror_maverick = http://nl.archive.ubuntu.com/ubuntu/
 
# Ext3 had some weird settings per default, like noatime. I don't want that, so I changed it to 'defaults'.
ext3_options     = defaults
ext2_options     = defaults
xfs_options      = defaults
reiserfs_options = defaults
btrfs_options    = defaults
 
# let xen-create-image use pygrub, so that the grub from the VM is used, which means you no longer need to store kernels outside the VM's. Keeps this very flexible.
pygrub=1
 
# scsi is specified because when creating maverick for instance, the xvda disk that is used can't be accessed. 
# The scsi flag causes names like sda to be used.
# scsi=1 # no longer needed 

I created the following script to easily let me make VM’s:

#!/bin/bash
 
# Script to easily create VM's. Hardy, maverick and Lenny are tested
 
dist=$1
hostname=$2
ip=$3
 
if [ -z "$hostname" -o -z "$ip" -o -z "$dist" ]; then
  echo "No dist, hostname or ip specified"
  echo ""
  echo "Usage: $0 dist hostname ip"
  exit 1
fi
 
if [ "$dist" == "hardy" ]; then
  serial_device="--serial_device xvc0"
fi
 
xen-create-image $serial_device --hostname $hostname --ip $ip --vcpus 2 --pygrub --dist $dist

At this point, you can reboot (well, you could earlier, but well…).

Usage of the script should be simple. When creating a VM named ‘machinex’, start it and attach console:

xm create -c /etc/xen/machinex.cfg

You can escape the console with ctrl-]. Place a symlink in /etc/xen/auto to start the VM on boot.

As a sidenote: when creating a lenny, the script installs a xen kernel in the VM. When installing maverick, it installs a normal kernel. Normals kernels since version 2.6.32 (I believe) support pv_ops, meaning they can run on hypervisors like Xen’s.

Configuring a Samba share with unix extensions which all users can write to

Because the unix permission model sucks, it is very hard to have a shared directory where everybody has full access to each others files. The same is true when making a shared samba archive. Luckily, samba has forcing options.

[archief]
  comment = save stuff here
  path = /path
  guest ok = yes
  writeable = yes
  browseable = yes
  force user = samba
  force group = samba
  create mask = 0660
  force create mode = 0660
  directory mask = 0770
  force directory mode = 0770

The key here is the force modes.

Deal Extreme: extreme suck-ass

There is this website, dealextreme.nl, which sells all kinds gadgets for low prices. I bought two SD-to-IDE addapters, so that I could put a solid state disk in my router.

The first one I tried caused the computer not to boot, crash, hang, etc. The second one I tried had the missing pin in the IDE connector in the wrong place, so you couldn’t put an IDE cable in:

Other people I know have ordered things like batteries that can only be charged once.

I’m never buying anything from that piece of shit site again.

Growing a qcow2 image file

First, convert it to raw:

qemu-img convert system.qcow2 -O raw system.raw

Then use DD to append a zero all the way at the end of the new file. It will automatically create a hole in the file:

# Make sure the seek value is bigger than the file size, otherwise it would put a zero somewhere in the middle of the file.
dd if=/dev/zero of=temp.raw bs=1 count=1 seek=100G

Then resize the partition. I did that by binding the image to a loop device:

losetup /dev/loop0 system.raw

Then you can use fdisk on /dev/loop0 to alter the partition table. parted didn’t want to resize my file sytem because it had a journal (argh…) so I just used fdisk and made sure that the start of the partition was the same.

Then you detach the loop device and attach the partition:

losetup -d /dev/loop0
# 32256 is 63*512. 63 is the start sector, which fdisk can tell you (with the u option)
losetup -o 32256 /dev/loop0 system.raw

Then I used resize2fs on /dev/loop0 and detached it again.

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑