Updates from November, 2011 Toggle Comment Threads | Keyboard Shortcuts

  • tuxdna 9:20 am on November 29, 2011 Permalink | Reply  

    How to resize a VM and its partitions? 

    In this post I am going to list the steps to resize a Virtual Machine image created using virt-install

    There are three steps:

    • Resize the VM image
    • Resize the LVM volume inside the VM ( both physical volume and logical volume )
    • Resize the filesystem on the LVM volume

    First locate where the image for your VM is stored.

    # virsh dumpxml vm2 | xpath /domain/devices/disk/source
    Found 1 nodes:
    -- NODE --
    <source file="/export/vmimgs/vm2.img" />

    Mine is stored at /export/vmimgs/vm2.img

    It is 5GB VM which I want to resize to 10GB. And then, I basically want more space for root partition ( mount point / ).

    Step 1: Resize the VM image

    Shutdown the VM and take a backup;

    # virsh shutdown vm2
    # cd /export/vmimgs
    # cp vm2.img vm2.img.backup

    First lets find the disk devices within our VM:

    # virt-filesystems --long -h -a  /export/vmimgs/vm2.img
    Name                   Type        VFS   Label  Size
    /dev/sda1              filesystem  ext4  -      500M
    /dev/VolGroup/lv_root  filesystem  ext4  -      1.5G
    # virt-filesystems --long --parts --blkdevs -h -a  /export/vmimgs/vm2.img
    Name       Type       MBR  Size  Parent
    /dev/sda1  partition  83   500M  /dev/sda
    /dev/sda2  partition  8e   1.5G  /dev/sda
    /dev/sda   device     -    5G    -

    Now we resize our VM image ( +5GB ):

    # cd /export/vmimgs
    # truncate -r vm2.img vm2.img.new
    # truncate -s +5G vm2.img.new 
    # virt-resize --expand /dev/sda2 vm2.img vm2.img.new
    Examining vm2.img ...
    Summary of changes:
    /dev/sda1: This partition will be left alone.
    /dev/sda2: This partition will be resized from 4.5G to 9.5G.  The LVM 
        PV on /dev/sda2 will be expanded using the 'pvresize' method.
    Setting up initial partition table on vm2.img.new ...
    Copying /dev/sda1 ...
     100% ⟦▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓⟧ 00:00
    Copying /dev/sda2 ...
     100% ⟦▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓⟧ 00:00
     100% ⟦▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓⟧ --:--
    Expanding /dev/sda2 using the 'pvresize' method ...
    Resize operation completed with no errors.  Before deleting the old 
    disk, carefully check that the resized disk boots and works correctly.

    Did you notice that /dev/sda2 was resized using ‘pvresize’. Thats because
    its a LVM physical volume.

    Now we move the new image vm2.img.new to the actuall image, taking backup for safety:

    # chmod +x vm2.img.new
    # mv vm2.img vm2.img.original
    # mv vm2.img.new vm2.img

    Step 2: Resize the LVM volume inside the VM – logical volume

    Login into guest and resize the logical volume:

    [root@localhost ~]# lvresize -L +5G /dev/VolGroup/lv_root

    Step 3: Resize the filesystem on the LVM volume.

    Resize the ext4 partition:

    [root@localhost ~]# resize2fs /dev/VolGroup/lv_root
    resize2fs 1.41.12 (17-May-2010)
    Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
    old desc_blocks = 1, new_desc_blocks = 1
    Performing an on-line resize of /dev/VolGroup/lv_root to 1708032 (4k) blocks.
    The filesystem on /dev/VolGroup/lv_root is now 1708032 blocks long.
    [root@localhost ~]# df -h
    Filesystem                    Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root  6.5G  1.4G  4.8G  23% /
    tmpfs                        1004M     0 1004M   0% /dev/shm
    /dev/vda1                     485M   31M  429M   7% /boot

    Thats it. I hope that helps.


    • rich 5:59 pm on November 29, 2011 Permalink | Reply

      Rather than using the separate lvresize step, you can add this option to virt-resize:
      --lv-expand /dev/VolGroup/lv_root. This option requires virt-resize > 1.2 IIRC.

      • rich 6:00 pm on November 29, 2011 Permalink | Reply

        .. which resizes the filesystem in the LV too.

        • tuxdna 6:50 pm on November 29, 2011 Permalink

          @rich: Thanks for the tip 🙂

    • Cletus 6:10 pm on April 5, 2012 Permalink | Reply

      I have a question if I may: When I use the virt-filesystems command I get /dev/VolGroup00/LogVol00 instead of /dev/VolGroup/lv_root. When I get to the section on using lvresize I put what virt-filesystems coughed up in the command line. (#lvresize -L +10G /dev/VolGroup00/LogVol00) and I get “VolGroup00 not found”. I then figure I should try the syntax as you have it written. I get a similar error message. What am I doing wrong? Thanks. 🙂

    • rich 6:22 pm on April 5, 2012 Permalink | Reply

      virt-filesystems will print out different things depending on what’s in the guest / disk image. On RHEL 5, the root LV used to be called /dev/VolGroup00/LogVol00, so if the guest is RHEL 5, this is normal.

      The question is, are you running lvresize inside the guest or somewhere else (eg on the host — a bad idea).

      In any case, see my comment above. Don’t use lvresize at all. Use the virt-resize --lv-expand option.

  • tuxdna 3:46 pm on November 28, 2011 Permalink | Reply  

    zif critical errors 

    Every once in a while I get these errors when installing a package using zif:

    Downloading        [==================================================================] (59%)
     packages/glusterfs-server-3.2.4-2.fc16.x86_64.rpm [2.9 MB/s] om 64 to 52 on 0x1fb60b0!
    5) zif-main.c:2590 (5/6)
    4) zif-main.c:2401 (3/5)
    3) zif-transaction.c:3989 (1/3)
    2) zif-package-array.c:243 (0/1)
    1) zif-package-remote.c:416 (2/3)
    0) zif-store-remote.c:505 (1/2)
    (zif:18671): Zif-CRITICAL **: percentage should not go down from 60 to 19 on 0x78e6410!
    4) zif-main.c:2590 (5/6)
    3) zif-main.c:2401 (3/5)
    2) zif-transaction.c:3989 (1/3)
    1) zif-package-array.c:243 (0/1)
    0) zif-package-remote.c:416 (2/3)
    (zif:18671): Zif-CRITICAL **: percentage should not go down from 64 to 27 on 0x7f5f4c0!
    3) zif-main.c:2590 (5/6)
    2) zif-main.c:2401 (3/5)
    1) zif-transaction.c:3989 (1/3)
    0) zif-package-array.c:243 (0/1)
    (zif:18671): Zif-CRITICAL **: percentage should not go down from 64 to 27 on 0x1fb63e0!
    2) zif-main.c:2590 (5/6)
    1) zif-main.c:2401 (3/5)
    0) zif-transaction.c:3989 (1/3)
    (zif:18671): Zif-CRITICAL **: percentage should not go down from 61 to 31 on 0x7909ae0!
    1) zif-main.c:2590 (5/6)
    0) zif-main.c:2401 (3/5)
    (zif:18671): Zif-CRITICAL **: percentage should not go down from 49 to 40 on 0x1fb62d0!
    0) zif-main.c:2590 (5/6)
    Completed          [==================================================================] (100%)
                                                                   m 59 to 52 on 0x1fb60b0!
    Transaction success!

    Although the packages get installed, this is makes me uncomfortable.

    And how are these stack-traces generated for C code ?

  • tuxdna 12:42 pm on November 24, 2011 Permalink | Reply  

    zif – Package management done faster 

    On Fedora 16, I used zif. zif is an alternative to yum and its fast!

    How to setup zif?
    So easy: sudo yum install zif zif-tools

    All set!

    Search for packages using zif:
    sudo zif search mongodb

    Do a offline serach ( like cached -C in yum ):
    sudo zif search -o mongodb

    Install packages using zif:
    sudo zif install mongodb-server mysql-server

    Update all packages:
    sudo zif update

    And if you feel like canceling the operation using Ctrl+C, it happens almost instantaneously!

    I like it.

    • Michael 9:57 am on November 27, 2011 Permalink | Reply

      Thanks for sharing.
      Any idea why this is not the default package manager for Fedora? If it has all the mentioned benefits including all of the functionality of yum, this would make sense (to me).?

      • Mike Manilone 10:11 am on June 23, 2012 Permalink | Reply

        I guess, the Fedora Project, even Red Hat, preferred Python much! Another reason is that zif is not well-tested and do not have a big developer group just like yum’s.

    • tuxdna 3:43 pm on November 28, 2011 Permalink | Reply

      No idea!

    • rich 6:03 pm on November 29, 2011 Permalink | Reply

      I’d love to see faster and more intelligent depsolving, either in yum or some alternative (zif, zypper?)

      There was a rather extensive argument on fedora-devel-list a few months ago about this, if you can stomach it:

  • tuxdna 5:49 am on November 17, 2011 Permalink | Reply  

    How to setup multiple monitors on Xfce desktop? 

    How to setup multiple monitors on Xfce desktop?

    I just followed the instructionson Xorg RandR 1.2 wiki

    Lets find out how many monitors we have connected?

    $ xrandr -q
    Screen 0: minimum 320 x 200, current 1280 x 800, maximum 8192 x 8192
    LVDS1 connected 1280x800+0+0 (normal left inverted right x axis y axis) 261mm x 163mm
       1280x800       60.0*+   50.0  
       1024x768       60.0  
       800x600        60.3     56.2  
       640x480        59.9  
    VGA1 connected (normal left inverted right x axis y axis)
       1680x1050      60.0 +
       1280x1024      75.0     60.0  
       1152x864       75.0  
       1024x768       75.1     60.0  
       800x600        75.0     60.3  
       640x480        75.0     60.0  
       720x400        70.1  
    HDMI1 disconnected (normal left inverted right x axis y axis)
    DP1 disconnected (normal left inverted right x axis y axis)
    HDMI2 disconnected (normal left inverted right x axis y axis)
    DP2 disconnected (normal left inverted right x axis y axis)
    DP3 disconnected (normal left inverted right x axis y axis)

    Now ask Xrandr to configure them:

    $ xrandr --output LVDS1 --auto --output VGA1 --auto --right-of LVDS1

    Now thats simply cool!

    • Siddhesh 2:25 pm on November 17, 2011 Permalink | Reply

      Here’s a script I’ve written to do this with any external display (monitor, projector, etc.). Execute it after connecting the display to your box:


      typeset -a resx
      typeset -a resy
      typeset -a screen
      typeset -i name=1
      typeset -i count=0

      cmd=”xrandr –fb ”

      xrandr | grep -A 1 ” connected ” | grep -v “^–$” | awk ‘{print $1}’ > $tmpfile

      for line in $(cat $tmpfile); do
      if [ $name -eq 1 ]; then
      line=$(echo $line|sed ‘s/[Xx]/ /g’)
      resx[$count]=$(echo $line | awk ‘{print $1}’)
      resy[$count]=$(echo $line | awk ‘{print $2}’)

      for i in $(seq 0 $((count-1))); do
      if [ $max_height -lt ${resy[$i]} ]; then

      cmd_ext=”$cmd_ext –output ${screen[$i]} –mode ${resx[$i]}x${resy[$i]}”
      if [ -n “$prev_scr” ]; then
      cmd_ext=”$cmd_ext –right-of $prev_scr”


      cmd=”xrandr –fb ${total_width}x${max_height} $cmd_ext”

      echo “Running command: $cmd”
      eval $cmd

      rm -f tmpfile

    • tuxdna 2:36 pm on November 17, 2011 Permalink | Reply

      Thanks for sharing. I have created a gist for the same:

    • easoncxz 10:42 am on July 7, 2013 Permalink | Reply

      Consider using the “Settings > Settings Editor” to change the “Position” property according to the method mentioned in ArchLinux’s wiki post on Xfce: https://wiki.archlinux.org/index.php/Xfce#Multiple_Monitors

    • Tarik 9:58 am on March 19, 2014 Permalink | Reply

      Thanks for Sharing

  • tuxdna 5:40 am on November 15, 2011 Permalink | Reply  

    Emacs key binding Ctrl+Space not working on Fedora 16 GNOME or XFCE 

    I installed Fedora 16 x86_64 and then installed Emacs. Then I logged in into (XFCE or GNOME) desktop and started Emacs.
    For text selection in Emacs I use Ctrl+Space ( which is the default in Emacs ), and is no longer working. So I cannot select text using Ctr+Space.

    However, if I login into virtual terminal ( Ctrl+Alt+F3 ), then login and start Emacs, the key-binding (Ctrl+Space) for text selection works fine. Therefore there is no problem in Emacs itself.

    I suspect that the Ctrl+Space key strokes are intercepted by something in between i.e. either GDM or IBus but I am not sure which one. How can I fix it?

    • tuxdna 6:01 am on November 15, 2011 Permalink | Reply

    • wks 12:24 pm on November 15, 2011 Permalink | Reply

      As for me, ctrl+space has been for toggling between Chinese (and other languages) and English since I was using M$ Windows. I was using ctrl+@ to select text in Emacs because I was so comfortable to have ctrl+space as a language switcher that I could not change my habit. And ctrl+@ is not as easy to use as ctrl+space (and this is partially why I ended up using VIM). After I began using GNOME3, this combo fails to work from time to time. That should be Gnome Shell’s bug. Now I am training myself to use right-alt to switch languages, instead.

  • tuxdna 1:10 pm on November 13, 2011 Permalink | Reply  

    Autocomplete and colorize your Ruby shell ( irb ) with wirble 

    Lets first install wirble

    sudo gem install wirble

    Add following lines to ~/.irbrc

    require 'irb/completion'
    require 'rubygems'
    require 'wirble'

    Now invoke irb.

    $ irb
    >>  1.m # press TAB here to auto complete
    1.method   1.methods  1.modulo
    >>  1.methods # press ENTER and the output will be colorized 🙂
    => ["%", "odd?", "inspect", "prec_i", "<<", "tap", "div", "&", "pretty_print", "po", "clone", ">>", "public_methods", "__send__", "object_id", "instance_var
    iable_defined?", "equal?", "freeze", "to_sym", "*", "ord", "+", "extend", "next", "pretty_print_cycle", "send", "round", "methods", "prec_f", "-", "even?",s
    ingleton_method_added", "divmod", "hash", "/", "integer?", "downto", "poc", "dup", "to_enum", "instance_variables", "|", "eql?", "size", "id", "instance_eva
    l", "truncate", "~", "to_i", "singleton_methods", "modulo", "taint", "zero?", "times", "instance_variable_get", "frozen?", "enum_for", "display", "instance_
    of?", "^", "method", "to_a", "+@", "pretty_print_inspect", "-@", "quo", "instance_exec", "type", "**", "upto", "to_f", "<", "step", "protected_methods", "<=
    >", "between?", "==", "remainder", ">", "===", "ri", "to_int", "nonzero?", "pred", "instance_variable_set", "coerce", "respond_to?", "kind_of?", "floor", "s
    ucc", ">=", "prec", "to_s", "<=", "pretty_inspect", "fdiv", "class", "private_methods", "=~", "tainted?", "__id__", "abs", "untaint", "nil?", "chr", "pretty
    _print_instance_variables", "id2name", "is_a?", "ceil", "[]"]
  • tuxdna 5:58 pm on November 12, 2011 Permalink | Reply  

    How to setup mock quickly? 

    How to setup mock quickly?

    yum install mock

    The default configuration is already set for you:
    ls -l /etc/mock/default.cfg

    If not then this will do:
    sudo ln -s /etc/mock/fedora-15-x86_64.cfg /etc/mock/default.cfg

    As is clearly stated in mock(1) man page, you need to add the relevant user to mock group:
    sudo /usr/sbin/usermod -a -G mock $USER

    Thats all for the setup.

    Now lets use it:

    mock --init # this populates the build root with the required pacakges and repositories
    mock --rebuild hello-2.7-1.fc15.src.rpm # this will do the actuall build with all the build dependencies resolved
    mock --shell # enter the mock's chroot shell

    For more read here

    ( it covers many caveats related to mock )

    You can build the hello source rpm as described here.

  • tuxdna 3:35 pm on November 12, 2011 Permalink | Reply  

    Fast alternative to yum whatprovides 

    If yum whatprovides /path/to/file is slow for you, try a faster alternative:

    rpm -q --whatprovides /path/to/file

    For example:

    $ rpm -q --whatprovides /usr/bin/clibrary

    rpm is quite fast and yum is too slow. Get back to basics!

    • hansvon 4:51 pm on November 12, 2011 Permalink | Reply

      The obvious difference:

      rpm -q –whatprovides /usr/bin/clibrary
      error: file /usr/bin/clibrary: No such file or directory

      yum whatprovides /usr/bin/clibrary
      Loaded plugins: langpacks, presto, refresh-packagekit
      speech-dispatcher-0.7.1-6.fc16.i686 : To provide a high-level device independent layer for speech synthesis
      Repo : fedora
      Matched from:
      Filename : /usr/bin/clibrary

      speech-dispatcher-0.7.1-6.fc16.x86_64 : To provide a high-level device independent layer for speech synthesis
      Repo : fedora
      Matched from:
      Filename : /usr/bin/clibrary

      • tuxdna 5:06 pm on November 12, 2011 Permalink | Reply

        Thats a good catch. In my case I was only searching the packages that are already installed. i.e. rpm would work only if the package is already installed.

        I agree that yum does find the it in all the repositories ( which includes the packages that aren’t yet installed ). Instead of always hitting the repositories ( i.e. connecting to the servers ), yum should first do a local rpm search, display the results and then search for repositories.

        That way it would be faster with local search and give complete results. Can we configure yum to do so?

    • mether 6:59 pm on November 12, 2011 Permalink | Reply

      That would be a RFE?

    • Juanjo 8:19 pm on November 12, 2011 Permalink | Reply

      Running “time sudo yum -C whatprovides /usr/bin/clibrary” it’s just 0.608 seconds here.

      Running “time sudo rpm -q –whatprovides /usr/bin/clibrary” it’s 0.048 seconds here.

      I can see the difference, but… either case is less than a second!

      • Juanjo 8:21 pm on November 12, 2011 Permalink | Reply

        I totally forgot! You might want to use -C to avoid the slowest part of yum: the networks bits to update and download headers!

      • tuxdna 6:29 am on November 13, 2011 Permalink | Reply

        Apparently yum is many times slower for this particular operation ( 12.67 times in this case ), as compared to rpm.

        Anyways, thanks for -C switch 🙂

    • pingou 9:28 pm on November 12, 2011 Permalink | Reply

      For rpm which are installed I normally use:
      $ rpm -qf /path/to/file

      If you want to see all the file of a given rpm easy:
      $ rpm -ql /path/to/file

      They both go really easy.

      Also to speed up the yum whatprovides, you can try to use the yum’s cache
      yum -C whatprovide “*/part/of/path/file”

  • tuxdna 9:06 am on November 12, 2011 Permalink | Reply  

    Turbocharge your Emacs for Ruby on Rails with rinari and rails-reloaded 

    Rinari is an Emacs minor mode that is aimed towards making Emacs into a top-notch Ruby and Rails development environment.

    Rails reloaded is the minor mode for editing Ruby On Rails code with Emacs. This
    minor mode makes your work much easier and user friendly.

    Lets first install rinari:

    cd ~/.emacs.d/
    git clone git://github.com/eschulte/rinari.git
    cd rinari
    git submodule init
    git submodule update

    ( Curious about git submodules? Read here http://book.git-scm.com/5_submodules.html )

    And why not do yum install emacs-rinari? Because it gives me an error:
    Symbol's value as variable is void: inflection-uncountables

    Next, install rails-reloaded:

    cd ~/.emacs.d/
    git clone git://github.com/dima-exe/emacs-rails-reloaded.git rails-reloaded

    Edit ~/.emacs file now to add these modules.
    This is how how my .emacs file looks now:

    ;; START: Ruby / Rails setup
    ;; Interactively Do Things (highly recommended, but not strictly required)
    (require 'ido)
    (ido-mode t)
    ;; Rinari
    (setq load-path (cons (expand-file-name "~/.emacs.d/rinari") load-path))
    ;; (add-to-list 'load-path "~/.emacs/rinari")
    (require 'rinari)
    ;; rails reloaded plugin
    (setq load-path (cons (expand-file-name "~/.emacs.d/emacs-rails-reloaded") load-path))
    (require 'rails-autoload)
    ;; END: Ruby / Rails setup

    Next bytecompile, press [M-x] and type rails/bytecompile.

    Thats it!

    Screen cast of rinari in action: http://vimeo.com/2854412

    Rinari Screencast (Ruby on Rails development with Emacs) from Eric Schulte on Vimeo.

    Read the documentation for more:

  • tuxdna 9:24 pm on November 10, 2011 Permalink | Reply  

    fudcon.in – online face of FUDCon Pune 2011 

    My involvement with FUDCon Pune 2011 started since the initial days of its planning. I wasn’t much involved until I took the task of managing a website for the event. My idea was to have a fully dynamic website where users could login, submit talks, vote for talks and we could manage the content all in a single website. The plan is available here.

    After a few initial discussion about FUDCon websites here and there, Rahul arranged for a domain fudcon.fedoraproject.org and commit access for me, so that I could add content to that website myself. Tatica was already working on a static website for FUDCon Milan by then. It took time for me to understand how is this going to work out for our purpose. I converted those static pages to genshi templates and pushed them fedora-web. To make the context clearer, all the code for Fedora websites can be viewed using this git repository. In the meantime I wasn’t able to help with the updates on FUDCon website for a month, so Shreyank took up the responsibility. Anyways, genshi templates sounded a bit ancient to me. The setup generated HTML pages only ( of course they are localized etc. ). But it was not solving the problem we had started with – no dynamic content, no databases ? So, anyways, I thought and discussed with our FUDCon Pune team here. Since we were very near the event we didn’t have much time. It would have taken long to get the website up on Fedora Infrastructure as it has it own guidelines and process. Finally I decided to pull up a COD based installation for the website on a separate domain and hosting space so I bought one.

    Vaidik came up as a volunteer during that time and took charge of a lot of tasks. His efforts deserve immense appreciation. We had another volunteer Harvish Sekar for the website. ( all the open and closed tasks can be found here ).

    Thats how FUDCon Pune 2011 Website is in existence today.

    Things that don’t work at present:

    It has been a journey with many surprises and roadblocks. Thanks to all the people in order of involvement over time. Rahul Sundaram for giving a nod for this website our way when it was getting tough to do it the Fedora Infrastructure way. Tatica for providing intial designs for the website. Suchakra for graphics and artwork for FUDCon Pune 2011 ( you’ve done an amazing job! ). Amit Shah for valuable suggestions and counter-suggestions that helped in refining our plans. Shreyank for interim responsibility with updates and fixes to the earlier website – fudcon.fedoraproject.org. Vaidik for large amount of contributions with themeing and many other enancements to COD installation for fudcon.in. Harvish Sekar for configuring the countdown timer. Siddhesh for helping me with scheduling sesions and making sure that we are doing it in the right order – i.e. constraint based scheduling. And many more people who were involved in this effort.

    Needles to say we have made avaialble all the source code on github. Just checkout the wiki ( link at the end ) for all the information you would need to setup.

    Where is all the information:

    • Siddhesh 10:57 am on November 11, 2011 Permalink | Reply

      Also the fact that we can’t upload tarballs in the talk content.

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc