Author Archive

LVM Root Disk

Posted on Saturday, September 22, 2012 at 4:50 pm

Computers need disks to store their operating system, programs and data. Good old disk partition management has not changed much over time. Using either MBR (created in 1983) or modern GPT paritions you are still using statically allocated partitions and filesystems. It can be challenging to deal with static partitions because initial choices can not be changed easily.

Unfortunately it is more complex to use Logical Volume Manager for Linux (wikipedia). Most factory installed computers use traditional partitioning. The added complexity is not usually needed but when it is needed it is really needed. The benefits of using LVM include the ability to more easily resize partitions and backup via snapshots. Server hardware can even replace disks using hot swapping. LVM is commonly used along with virtualization via LXC, Eucalyptus, OpenStack or other similar systems. Here are the steps needed to convert a root partition to LVM and mirror it on a redhat system.

1. Create a tar backup of your filesystem.

# tar czpf /root/redhat.tar --exclude=/var/tmp/portage/* --exclude=/root/* --exclude=/usr/portage/* --exclude=*.deb --exclude=/tmp/* --exclude=*.rpm --exclude=/sys/* --exclude=/proc/* --exclude=/dev/* --exclude=/mnt/* --exclude=/media/* --exclude=/home/*  --exclude=/var/lib/libvirt/images/* --exclude=/oracle/*  --exclude=redhat.tar

2. Use fdisk to create /boot  and 1 LVM partition on the new disk.

/dev/sda1   *   1    100      803218+  83  Linux
/dev/sda2 101121601  975956782+ 8e Linux LVM

3. Set /dev/sda1 to be bootable.

# parted /dev/sda set 1 boot on

4.  Create the new LVM partition.

# pvcreate /dev/sda2
# vgcreate vg /dev/sda2
# lvcreate -L 200G /dev/vg -n root
# mkfs /dev/vg/root
# mkfs /dev/sda1
# mount /dev/vg/root /mnt
# mount /dev/sda1 /mnt/boot

5. Extract the tar file to /mnt

# tar xpf /root/redhat.tar -C /mnt/

6. Modify the following files:


Modify the kernel line to support LVM by adding the following LVM details:

rd_LVM_VG=vg rd_LVM_LV=root

Also ensure that initrd and kernel does not have /boot/ in the location.


kernel /vmlinuz-2.6.32-279.2.1.el6.x86_64 ro root=/dev/mapper/vg-root LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=128M  rd_LVM_VG=vg rd_LVM_LV=root rhgb quiet
initrd /initramfs-2.6.32-279.2.1.el6.x86_64.img


Change the /boot and / entries to LVM:

/dev/sda1 /boot ext4 defaults 0 0
/dev/mapper/vg-root /      ext4    defaults        1 1

7. Mount and configure the new environment:

# mount /dev/vg/root /mnt
# mount /dev/sda1 /mnt/boot
# mount -o bind /sys /mnt/sys
# mount -o bind /dev /mnt/dev
# mount -o bind /proc /mnt/proc
# grep -v rootfs /proc/mounts  > /mnt/etc/mtab

Modify /mnt/etc/mtab and add:

/dev/sda1 /boot ext4 rw 0 0

Change the apparent root directory for the current running process and its children:

# chroot /mnt

8. Install GRUB and reconfigure the ram disk image:

# grub-install --recheck /dev/sda
# dracut --force

9. Unmount and reboot:

Type exit to exit the chroot environment

# cd /
# umount /mnt/*
# umount /mnt
# reboot

Set your system to boot from the disk known as /dev/sda

10. Initialize and format your original boot disk.

Just like we did for /dev/sda.

 Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1       100      803218+  83  Linux
/dev/sdc2             101    121601   975956782+  8e  Linux LVM

11. Add /dev/sdc to the volume group.

# vgextend /dev/vg /dev/sdc2

12. Format the boot partition on the drive and set it bootable:

# mkfs /dev/sdc1
# parted /dev/sdc set 1 boot on

13. Mirror the boot disk:

# lvconvert -m1 /dev/vg/root

We hope this helps you with your disks. Berkeley LUG meetings continue every second and fourth Sunday each month at Bobby Gs Pizzeria from noon to three in Berkeley. Please join us.

Compiling the new responsive kernel from scratch.

Posted on Wednesday, November 24, 2010 at 4:11 pm

The new “200 lines of code” that makes the system more responsive is finally out! It is included in Kernel 2.6.37-rc3. This guide will explain how to install it on your system!

If you have Ubuntu, you can download the Debian packages:

First, download the latest patch and sources from

#Extract and apply the patch:

tar xvf linux-2.6.37-rc3.tar.bz2
mv patch-2.6.37-rc3.bz2 linux-2.6.37-rc3/
cd linux-2.6.37-rc3
bunzip2 -d patch-2.6.37-rc3.bz2 | patch -p1

#Start the build process:

make clean
make menuconfig
make -j3 all
make -j3 modules_install

#Install and update GRUB:

make install
mkinitramfs -k 2.6.37-rc3 -o /boot/initrd.img-2.6.37-rc3

Enterprise 6 on your desktop?

Posted on Wednesday, June 2, 2010 at 7:40 pm

RedHat Enterprise Linux is known for it’s security and stability on servers. Later this year, Redhat will release Enterprise Linux 6.0 and CentOS will release their version shortly after. CentOS is built entirely from RedHat’s sources. They are basically the same thing minus the RedHat artwork and support. What do you think about using it on your home desktop?

I came close to using CentOS 5.5 100% at home. The downfall

was multimedia applications such as k9copy and Kdenlive. CentOS/RedHat 5 is based off Fedora 6, which is very old. However, version 6 will be based off Fedora 12 which was just surpassed by Fedora 13. Fedora 12 was a great release in my opinion because it was stable and had recent versions of all the applications that I needed. After trying the RedHat 6.0 beta, I was able to install all of my modern applications and be 100% productive at home and work.

My question to all of you out there is would you use CentOS/RedHat on your home desktop? What are your thoughts? Do the non-bleeding edge packages matter to you? My opinion now is that release 6 may be good on the desktop for a year or so before the age of the packages starts to show. How long do you think you can use enterprise Linux for?   Would you feel that you are missing out on the new desktop Linux features?

New Mephisto Backup v1.10.4 released and looking for devs!

Posted on Wednesday, June 2, 2010 at 7:17 pm

The fourth update to the Mephisto 1.10 series has been released. New features were back-ported from v11 to increase stability because the 1.10 branch is going for stability. This project is also looking for developers for new features and stronger development. If interested, please email Documentation engineers are also appreciated.

This program can do simple backups and syncs over a network or locally. Mephisto Backup was made with the Java programming language. The key feature of this program is the ability to backup your system to an image and copy it to a Linux Live DVD for future restoration. The user can then take that cd and move his or her system to any PC.


Also, test out the v1.11 beta and submit feedback =)

Upgrading Fedora and retaining your existing programs.

Posted on Wednesday, June 2, 2010 at 8:27 am

I had an idea on how to make the upgrade process easier for my Fedora installation. I had Fedora 12 installed and wanted to upgrade to Fedora 13 with the same programs installed. The same concept can be applied to most distributions.


1. On my Fedora 12 box:
rpm -qa | cut -d – -f 1 > packages.txt

This command will print all the installed packages and remove the version information and architecture.

2. Install Fedora 13.

3. Copy packages.txt from Fedora 12 to Fedora 13.

4. Copy .repo files in /etc/yum.repos.d from Fedora 12 to Fedora 13.

5. yum install -y –skip-broken `cat packages.txt`

6. Done. =)

SSD and system logs.

Posted on Wednesday, June 2, 2010 at 8:22 am

My backup web server has a 8GB CF card. I want to reduce the number of writes to it as much as possible to save money and keep my server healthy. I added the following to my /etc/rc.local so that the logs files are created in RAM every time the server boots. The only downfall to this is that you will not have any logs if the system crashes to diagnose the problem, oh well =)

How it works:

1. Create the ram disk directory.
2. Mount the ram file system.
3. Erase old logs.
4. Use touch to create an empty log file in the ram disk directory.
5. Link the log file in the ram disk directory to /var/log

[ /etc/rc.local ]
#Creates a tmpfs RAM disk and mount it
mkdir /ramfs;mount -t tmpfs /dev/ram0 /ramfs;mkdir /ramfs/httpd



for ((c=0;c<=15;c++))
rm -f /var/log/${LOG[c]};touch /ramfs/${LOG[c]};ln -s /ramfs/${LOG[c]} /var/log/${LOG[c]}
done Rocks

Posted on Wednesday, June 2, 2010 at 8:21 am offers members of the community to contribute to open source projects even if your not a programmer.

“OpenHatch was founded in May 2009 by three alumni of the free culture and free software movements. The company was part of startup incubator Shotput Ventures‘ inaugural class.

Our core product is an open source software involvement engine. For developers, we provide tools to demonstrate and broaden their experience and expertise in the open source community. Our vision is to make the open source community better connected, more productive, and ultimately well rewarded for its expertise.”

NILFS: An interesting new file system.

Posted on Wednesday, June 3, 2009 at 5:55 am

“NILFS2 (New Implementation of a Log-Structured File System Version 2) is a very promising new log-structured file system that has continuous snapshots and versioning of the entire file system. This means that you can recover files that were deleted or unintentionally modified as well as perform backups at any time from a snapshot without a performance penalty normally associated with creating snapshots. In addition, there is evidence that NILFS has extremely good performance on SSD drives.”


Simple firewall script tutorial for the command line.

Posted on Wednesday, May 20, 2009 at 9:17 am

Firewalls are a critical component of keeping your machine safe on the Internet.

This tutorial will show you how to create firewall rules from the command line.

Details of the script actions are commented in the script.

Read the rest of this entry »

How to reconfigure your display the easy way!

Posted on Monday, May 18, 2009 at 7:56 pm

Believe it or not, sometimes the display will die on your Linux operating system. You probably have no control over this…..Time to move on and fix the issue without spending hours on Google searching for a half-baked how-to.

If you are in the process of implementing this article on a broken system, chances are that you see a black screen with text. Please follow these steps so that you can get the pretty colors back!

Step 1: Login.

Step 2: Ensure the graphical daemons are not running.

service gdm stop

service kdm stop

Step 3: Run this command:   X -configure

(This will create the following file in your directory:

Step 4: Copy the configuration file to the right place.

mv /etc/X11/xorg.conf

Step 5: Restart the display.

service gdm start (for GNOME users.)


service kdm start (for KDE users)


startx (for everyone else, the elite)

Step 6: If you are still having problems……

Repeat Steps 1 – 4.

We will change the driver to vesa. Vesa is a generic display driver that will work on any video card. I usually use this driver on all my machines because it is stable and never fails.

Use your favorite text editor and open /etc/X11/xorg.conf

Look for a line that says  something like the following :

Driver      “nv”

Driver      “ati”

Driver      “nvidia”

Driver      “intel”
Change the name from what is in quotes to “vesa”.

Example of how it should be after the change:  Driver      “vea”

Save and exit the file and follow step 5.

Recent Entries

Popular Posts