BigSmoke

Smokes your problems, coughs fresh air.

Page 29 of 52

Aligning partitions with RAID and LVM on drives with 4 kB sectors

Hard disks are being released that abandon the long-established standard of 512 byte sectors. I just got two Western Digital WD15EARS ones, which uses 4 kB sectors. Western Digital Refers to this as “Advanced Format”. This poses some serious problems. I will describe those, and what I did to ‘solve’ it.

This article is as much for myself as for other people correcting me. So, if you see faults, let me know 🙂

First, you may want to read this IBM article and this LWN article. Reading these articles is important to understand this issue. Too summarize a bit, hard disks can’t really have 4 kB sectors, because then BIOS, bootloaders, operating systems, partition software and who knows what will just go beserk. So, they still report a sector size of 512 bytes. This emulation presents certain performance issues (explained in the links), which can only be avoided by aligning the filesystems on disk, which the IBM article explains well. In short, I configured fdisk to 224 heads and 56 sectors. This aligns the partitions properly. Do remember, however, to start at cylinder 2 for your first partition, otherwise there isn’t enough space for the bootloader.

Now, what happens if you don’t put a file system on your partition, but make a software RAID1+LVM out of it? It gets a lot more complicated to align the filesystem blocks this way, because of all the layers. I did the following:

First I created the aligned partition with fdisk on two disks. Then I made a RAID1 array out of it. Luckily, Linux MD has the ability to store the RAID superblock at the end of the partition. It can also store it at the beginning, but you shouldn’t do that! The RAID superblock is 256 bytes + 2 bytes per drive long, which means one logical sectors, which in turn means that the start of the MD partition is in the middle of a 4 kB sector on disk. You can use metadata format 1.0 or 0.9 to put the superblock at the end of the disk (see mdadm man page).

Then it’s time to create the logical volume. When preparing the RAID1 partition for use in the volume group, give pvcreate the –dataalignment 4096 option. Then, with “pvs -o +pe_start”, you should be able to see where the first PE (physical extent) starts. I accidentally created mine with alignment 8, but the first extent is at 136.00 kB (139264 bytes), which is divisable by 4096.

Then, I created the volume group with an extent size of 4MB. 4 MB is also divisible by 4096. Logical volumes are created as multiples of the extent size, so you can now create them at will, and they will be aligned.

When creating a RAID array that deals with striping, be sure to make the stripe size a multiple of 4 kB. I guess this also applies to logical volumes with striping.

What I still would like to know, is whether the file system journal is also made up of 4 kb blocks. Also, the RAID array’s write intent bitmap (if you have one) is also still unclear to me. Where is that stored? Does it write in multiples of 4k?

Installing Arch Linux on RAID+LVM

I just installed Arch Linux on a RAID1+LVM, which involved some work. There already is a nice article about it, but I wanted to summarize for myself.

Arch has no GUI or menu for you to do this. So, when the installer has started, just go to another VT and create the RAID+LVM.

In my first attempt, I created one RAID partition with LVM, from which I intended to boot using Grub2, since it understands LVM and RAID. However, the grub installer kept saying there was no mapping for /dev/mapper/lvmroot or something, so I decided to make two partitions: one boot and one rest, which was meant as physical volume for the LVM. The advantage of linux software raid (when you store the superblock at the end of the partition, at least), is that grub can access it like a normal disk; it doesn’t need to know RAID).

After the array was made using something like:

mdadm --create /dev/md0 -l 1 -n 2 -x 0 -e 1.0 /dev/sda1 /dev/sdb1
mdadm --create /dev/md1 -l 1 -n 2 -x 0 -e 1.0 /dev/sda2 /dev/sdb2

It was time to create the LVM. So, I ran (don’t know the exact syntax, so this is an abstraction):

pvcreate /dev/md1
 
# In my research for my initial lvm problem, I found people who had 
# problems with dashes in the volume group name, so I don't 
# use those anymore...
vgcreate lvmonraid /dev/md1
 
lvcreate -n root -l [wanted size/extentsize] lvmonraid
lvcreate -n home -l [wanted size/extentsize] lvmonraid
lvcreate -n swap -l [wanted size/extentsize] lvmonraid

Extent size is normally 4 MB, so a 40MB partition would have “-l 10”. You can also supply sizes in bytes, but that is not only inprecise because it gets rounded to the extent size, but I also noticed bugs in what metric and binary units were supposed to be; it seemed like the command line options don’t differentiate between G and g, for instance, and they’re all GiBi, whereas the –units option does.

When this is done, you can configure the block devices in arch to assign the purpose.

When the installation is almost done, it asks to modify some configuration files. This is important, otherwise the initramfs won’t load the LVM. You need to:

  • Make an mdadm.conf in /etc (of the live CD) with “mdadm –examine –scan > /etc/mdadm.conf”.
  • Add the raid1 and dm_mod module to the MODULES list in /etc/mkinitcpio.conf.
  • Add the mdadm and lvm2 hook to the HOOKS list in /etc/mkinitcpio.conf, before ‘filesystems’
  • Edit your /etc/rc.conf, and set the USELVM parameter to “yes”

Then it will create the ramdisk. The next thing is installing Grub. The config file it makes is fine, except you need to add (hd0,0) after the empty “root” directive, twice. Installing grub fails because of the RAID, so you have to do that by hand:

# grub
grub> root (hd0,0)
grub> setup(hd0)
grub> root (hd1,0)
grub> setup (hd1)

That should be it, basically. I actually did a lot more because of my new Western Digital WD15EARS disk with 4 kB sectors, but I’ll write about that soon.

Disabling Intellipark on the WD15EARS

I just got two Western Digital 1.5TB WD15EARS disks. This drive has a feature called intellipark, which parks the head after the disk is not used for a while. This is supposedly a power saving feature. But, as someone explains, it can also severely decrease the lifetime of your drive.

To disable, download wdidle and disable it. This needs to be done from a dos environment. Dos bootdisks should be available for download.

USAGE:
WDIDLE3 [/S[<Timer>]] [/D] [/R] [/?]
where:
/S[<Timer>] Set timer, units in seconds. Default=8.0 (8.0 seconds).
Resolution is 0.1 seconds from 0.1 to 12.7 seconds.
Resolution is 30 seconds from 30 seconds to 300000 seconds.
Note, times between 12.8 and 30 seconds will be set to 30 seconds.
/D          Disable timer.
/R          Report current timer.
/?          This help info.

Disabling it actually causes it to go even more beserk. In a few hours, SMART logged 5000 load_cycles, and the drive was making very funny noises all the time. Instead, I set it to 300 seconds, which effectively disables it.

Someone also made a boot CD with the tool available (wgetting it works, clicking doesn’t). I don’t think the link will be there forever though. (can I attach zips to a blog post?)

The forum post I linked to also has info about TLER, which I’ll get back to.

Aihato WordPress development notes

I’m collaborating with YTEC on a new website for Aihato. I’ve picked WordPress to do most of the heavy lifting for this project. So far, I’ve spent most of my time on this project to get a good development environment in working order, with WordPress living in its own directory and some deployment recipes managed from a Makefile.

Now that I’m well-settled in the YTEC office with everything set-up and running, I hope to make some actual progress on this project next time that I’m here. 😉

Awesome window manager

I’m officially a convert. I finally went from a floating-only window manager to a tiling window manager. And it does floating too! Awesome seems to be everything that Window Maker just couldn’t be for me.

For a very long time I’ve known that a tiling WM would probably be nicer for me, but there were quite a few to choose from. After looking at the likes of Ion, I ended up looking at Ratpoison when I noticed that the successor to Ratpoison, StumpWM, was based on LISP. Since I never could get the hang of Emacs, this looked like another excellent opportunity to learn LISP.

Sadly, StumpWM is quite a piece of crap with only a very limited feature set and some initial stumbling blocks I just couldn’t get over. My first enthusiasm was tempered by some random errors and my inability to configure it in such a way that I could use my Windows key (Mod4) instead of the GNU Screen like Ctrl-f prefix. It turned out that I couldjust the Mod4 modifier. StumpWM seemed to insist on me using a kind of prefix made of any number of modifiers combined with a regular key.

Luckily, I came across Awesome, which, until now, really seems awesome.

The default configuration comes with a lot of niceness right away.

One thing I particularly like are its default key bindings, mostly because they all use some combination of the Windows/Mod4 key. Some defaults are even exactly the same as I had configured them in Window Maker, such as Mod4-r to type the name of a program to execute and Mod-1 through Mod-9 to switch between Workspaces called tags in Awesome. For as far as the key bindings are different, I actually like them more than what I’ve used before. Most of the key bindings, however, are of course new because they simply weren’t available in Window Maker (or other tiling window managers), often much to my chagrin.

I thought that when switching to a tiling window manager, I’d probably have to get something like Gkrellm for my system monitors and system tray and such, but Awesome actually sports many of these. The Gentoo default configuration even has the system tray already enabled in the statusbar. This is particularly nice because of the crappyness of the available systray DockApps for Window Maker that I had gotten used to.

I’m not yet done playing with Awesome. I like that I probably will never stop tuning it to my preferences and the Lua configuration format means I don’t have to. It’s a modern window manager which supports the latest FreeDesktop standards and it is infinitely lean, mean and flexible. What’s not to like? I’ll comment when I find out. 😉

Upgrading Samba from Lenny-backports

For some reason, after upgrading to the Samba version from Lenny-backports I needed to support Windows 7 profiles, the workstations suffered from severe problems. The entire profile seemed to be read-only, even though they weren’t on disk. I couldn’t change any setting and reverting profile configuration from backups didn’t help. In the end, the only thing that fixed it was recreating the user profile, both server and client side. This was an upgrade from 3.2.5 to 3.4.7.

Another issue I had is that the user database got a new backend and all the users were gone. You can import your existing smbpasswd file with pdbedit.

So, when doing this again, be sure to make workstation and server backups.

Adding a virtual network interface on Debian

When clustering machines, you make it possible for a failover node to be accessible on the same address as the primary node by having a virtual network interface. In Debian, you can add one like this:

iface eth0:0 inet static
    address 192.168.1.75
    network 192.168.1.0
    broadcast 192.168.1.255
    netmask 255.255.255.0
    gateway 192.168.1.251

By leaving out the auto eth0:0, I prevent the interface from becoming active automatically. I can do “ifup eth0:0” to enable it. This can also be left to clustering software, but clustering software can also get in the way, so often you just want to do it by hand.

Preventing the creation of $RECYCLE.BIN on Samba shares by Windows 7

Windows 7 kept creating a $RECYCLE.BIN dir on the network share. This in itself is merely annoying, but there were also errors resulting from it. Whenever a file would be deleted, this message would appear (translated from dutch): “The recycle bin is damaged, do you want to delete the contents?” Everything froze until that question was answered.

Samba has an option “veto files” which can be used to stop the creation of that directory. Put this in each share’s section in your smb.conf:

veto files = /*$RECYCLE.BIN/ 

The slashes are not directory separators in this case. Also, I don’t know if the preceeding * is necessary, but it does no harm.

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑