Sep 182011
 

I had a development desktop fail and had to extract the data from the LVM managed hard drive. Easy, right? Pull out the drive, hook it up to an enclosure, plug into a laptop USB port and suck all the data down. And typically, it wasn’t that simple. The following error message appeared:

   # mount /dev/sdb1 /mnt
unknown filesystem type lvm2_member

Blast. Turns out, this disk has been part of an LVM volume group and the laptop didn’t know anything about this configuration. The solution, fortunately, is simple.

Install LVM, if it isn’t already:

   # apt-get install lvm2

List physical volumes, and their labelled volume groups:

   # pvs
  PV         VG         Fmt  Attr PSize  PFree
  /dev/sdb1  VolGroup01 lvm2 a-   27.95g 22.95g

There’s a volume group, VolGroup01, which I do vaguely remember configuring. So, scan for this, make active, scan for logical volumes and mount. That’s it, like so:

   # vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup01" using metadata type lvm2

   # vgchange -a y VolGroup01
  1 logical volume(s) in volume group "VolGroup01" now active

   # lvscan
  ACTIVE            '/dev/VolGroup01/dataVol00' [5.00 GiB] inherit

   # mount /dev/VolGroup01/dataVol00 /mnt

And now the data on the stray disk is available, mounted under /mnt. Do with it what you will.


Matt Parsons is a freelance Linux specialist who has designed, built and supported Unix and Linux systems in the finance, telecommunications and media industries.

He lives and works in London.

Sep 162011
 

I’ve got a nice GRUB dual-boot going on my laptop with multiple partitions and Ubuntu and Windows 7. Like it or not, I tend to use Windows 7 more, being an iPhone and vSphere user which gives me know option.

Trouble struck when I had to reinstall Windows 7 and it ruined my boot partition. I Googled around and found several manual solutions, until I discovered that this problem seems so common that someone has a tool to fix it immediately – Boot-Repair. Totally automatic, it scans all partitions and rebuilds GRUB automatically. It worked first time, so I didn’t even bother to work out how it did it.

Here’s the quick-and-dirty:

  • Boot into Ubuntu, using a Live CD.
  • Enable the network connection
  • Install and run Boot-Repair:
  •    # sudo add-apt-repository ppa:yannubuntu/boot-repair
       # sudo apt-get update && sudo apt-get install -y boot-repair && boot-repair
    

    After Boot-Repair finishes, reboot. The GRUB menu should magically reappear, just as it was.


    Matt Parsons is a freelance Linux specialist who has designed, built and supported Unix and Linux systems in the finance, telecommunications and media industries.

    He lives and works in London.

    Sep 082011
     

    The bane of every Unix admin’s life is the network department, because almost every connectivity problem is their fault – which we’ve already verified with a quick snoop, tcpdump or netcat – but they claim it isn’t, and then stop answering the phone. Once in a while, you end up with a couple of switches of your very own, and wonder where to start. How hard could it be? None hard, that’s how.

    Here’s the rudiments of using my Dell PowerConnect 5324: the commands I use most frequently. This will get you started, and remember to just press “?” after commands to find out what the available options are.

    Login and get privilege on the Dell Switch

    SSH or telnet (if you’re primitive and insecure) on, getting a prompt. It’s probably “admin”:

       User Name:  admin
       Password:  *******
    

    This mode gives only limited functionality, like viewing configs. You can’t change anything. To make edits:

       dev-switch#  conf
    

    Prompt changes:

      dev-switch(config)#
    

    Display Interfaces

    First awesome thing about network gear that Unix command line doesn’t have: you can be lazy and just type enough of commands and switches to be unambigious. Thus the command “show interface status” can be rendered as “sh int stat”. Display interface information:

      dev-switch#  show int status
      dev-switch#  show int desc
    

    Display information about specific switchport (g3):

      dev-switch# show int switchport eth g3
    

    Create a VLAN

    Get your head around VLANs quick, and why you trunk them. You’ve got a VMWare server and you want a management network to the server, but different networks to the virtual machines, then you trunk your VLANs on the switch, and send them all down the same NIC.

      dev-switch# show vlan
      dev-switch(config)# vlan database
      dev-switch(config)# vlan 173
      dev-switch(config)# int vlan 173
      dev-switch(config)# name DEV-TEST
      dev-switch(config)# exit
      dev-switch# show vlan
    
    Vlan       Name                   Ports                Type     Authorization
    ---- ----------------- --------------------------- ------------ -------------
     1           1                     g(1,24)             other     Required 
    173      DEV-TEST                                   permanent     Required 
    

    Add Interfaces to VLAN

    The way to aggregate interfaces is to give them permission to use a VLAN. Also, there are several different modes of aggregation that can be used. As far as I can work out, if the switchport is taking a connection from a router or firewall (that is, upstream), then use “trunk” mode. If it’s connecting to a server, then use “general” mode. “access” mode is just a plain old vanilla single-VLAN interface. I can’t tell you how long it took to work this out.

    Set switchport mode:

      dev-switch(config)# int eth g16
      dev-switch(config-if)# swi mode general
    

    Add VLAN to switchport, after first setting the “native” (non-trunk VLAN) to VLAN 3 (for example):

      dev-switch(config-if)# swi general pvid 3
      dev-switch(config-if)# swi general allow vlan add 173
      dev-switch(config-if)# end
      dev-switch# show vlan
    
    Vlan       Name                   Ports                Type     Authorization
    ---- ----------------- --------------------------- ------------ -------------
     1           1           g(1-24)      other       Required 
    173      DEV-TEST                  g16              permanent     Required 
    

    Save Running Config

    Switches have two configurations – one saved in a file “startup-config” which gets loaded on startup, and one running in memory “running-config”. If you don’t periodically copy the running config to disk, then a sudden reboot will result in a reversion to the filesystem config. So do this:

       dev-switch# copy running-config startup-config
    

    Ideally, also save this file to a backup server, but that will be a subject for another post. Or Google it. Probably Google it. It involves setting up a TFTP server and typing “write net”.


    Matt Parsons is a freelance Linux specialist who has designed, built and supported Unix and Linux systems in the finance, telecommunications and media industries.

    He lives and works in London.