theducks.org

In my previous post on the subject, I expanded Filesystems on LVM without rebooting, by adding more partitions. As pointed out by Zanchey, there is a much cleaner way to do this, by just resizing existing partitions being used by LVM.

# fdisk /dev/sda

The number of cylinders for this disk is set to 9790.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 80.5 GB, 80530636800 bytes
255 heads, 63 sectors/track, 9790 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 14 104391 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 14 4178 33450007+ 8e Linux LVM
/dev/sda3 4178 8354 33549073+ 8e Linux LVM
/dev/sda4 8355 9137 6289447+ 8e Linux LVM

Command (m for help): q

###
### Extend the VMDK in vCenter
###

# fdisk /dev/sda

The number of cylinders for this disk is set to 9790.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 80.5 GB, 80530636800 bytes
255 heads, 63 sectors/track, 9790 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 14 104391 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 14 4178 33450007+ 8e Linux LVM
/dev/sda3 4178 8354 33549073+ 8e Linux LVM
/dev/sda4 8355 9137 6289447+ 8e Linux LVM

Command (m for help): q

###
### Whuuuuuut? I can't see the extra space!
###

# echo '1' > /sys/class/scsi_disk/0\:0\:0\:0/device/rescan

###
### Rescan device geometry
###

# fdisk /dev/sda

The number of cylinders for this disk is set to 11096.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 91.2 GB, 91268055040 bytes
255 heads, 63 sectors/track, 11096 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 14 104391 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 14 4178 33450007+ 8e Linux LVM
/dev/sda3 4178 8354 33549073+ 8e Linux LVM
/dev/sda4 8355 9137 6289447+ 8e Linux LVM

###
### Ok, that's much better.
###

Command (m for help): d
Partition number (1-4): 4

###
### Delete partition 4
###

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Selected partition 4

###
### Now recreate it, so it starts in the same place, and ends at the end of the disk
###

First cylinder (8355-11096, default 8355):
Using default value 8355
Last cylinder or +size or +sizeM or +sizeK (8355-11096, default 11096):
Using default value 11096

Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)

###
### Remember to change the partition type of Linux LVM. Or you'll be in trouble.
###

Command (m for help): p

Disk /dev/sda: 91.2 GB, 91268055040 bytes
255 heads, 63 sectors/track, 11096 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 14 104391 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 14 4178 33450007+ 8e Linux LVM
/dev/sda3 4178 8354 33549073+ 8e Linux LVM
/dev/sda4 8355 11096 22025115 8e Linux LVM

Command (m for help): w
The partition table has been altered!

###
### Write to disk and away we go
###

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
# partprobe -s
/dev/sda: msdos partitions 1 2 3 4

###
### Reprobe partition table
###

# pvresize /dev/sda4
Physical volume "/dev/sda4" changed
1 physical volume(s) resized / 0 physical volume(s) not resized

###
### Resize the "filesystem" of the LVM partition we've just extended in fdisk,
### Think of this kind of like resize2fs for LVM, but we'll still have to do that on the logical disks later
###

# vgdisplay
--- Volume group ---
VG Name VGroot
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 84.84 GB
PE Size 32.00 MB
Total PE 2715
Alloc PE / Size 1660 / 51.88 GB
Free PE / Size 1055 / 32.97 GB
VG UUID tSuI0o-Z3mu-mldY-n4pS-qfSZ-g5UP-tXPZlR

###
### Confirm we can now see the extra space in the LVM group
###

# lvdisplay
--- Logical volume ---
LV Name /dev/VGroot/LVroot
VG Name VGroot
LV UUID HYQp9x-yA5H-RLJw-f033-pmEY-Lohg-loRhXa
LV Write Access read/write
LV Status available
# open 1
LV Size 7.88 GB
Current LE 252
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Name /dev/VGroot/LVswap
VG Name VGroot
LV UUID ZXCxs3-nZd4-jR5S-mkCf-zTJP-yVgp-dpq7Mg
LV Write Access read/write
LV Status available
# open 1
LV Size 4.00 GB
Current LE 128
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

--- Logical volume ---
LV Name /dev/VGroot/LVut01
VG Name VGroot
LV UUID VUv17I-QbdC-pkyr-bE25-f4MC-gLXq-2QKGr0
LV Write Access read/write
LV Status available
# open 1
LV Size 40.00 GB
Current LE 1280
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2

###
### Confirm how big our logical volumes are within our LVM pool
###

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VGroot-LVroot
7.7G 3.3G 4.0G 45% /
/dev/sda1 99M 24M 71M 26% /boot
tmpfs 1014M 0 1014M 0% /dev/shm
/dev/mapper/VGroot-LVut01
40G 177M 38G 1% /ut01

###
### Confirm amount of space seen on filesystems within the LVM Logical Volumes
###

# lvextend -L+5G /dev/VGroot/LVut01
Extending logical volume LVut01 to 45.00 GB
Logical volume LVut01 successfully resized

###
### Added 5Gb onto our Logical Volume, LVut01
###

# lvdisplay
--- Logical volume ---
LV Name /dev/VGroot/LVroot
VG Name VGroot
LV UUID HYQp9x-yA5H-RLJw-f033-pmEY-Lohg-loRhXa
LV Write Access read/write
LV Status available
# open 1
LV Size 7.88 GB
Current LE 252
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Name /dev/VGroot/LVswap
VG Name VGroot
LV UUID ZXCxs3-nZd4-jR5S-mkCf-zTJP-yVgp-dpq7Mg
LV Write Access read/write
LV Status available
# open 1
LV Size 4.00 GB
Current LE 128
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

--- Logical volume ---
LV Name /dev/VGroot/LVut01
VG Name VGroot
LV UUID VUv17I-QbdC-pkyr-bE25-f4MC-gLXq-2QKGr0
LV Write Access read/write
LV Status available
# open 1
LV Size 45.00 GB
Current LE 1440
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VGroot-LVroot
7.7G 3.3G 4.0G 45% /
/dev/sda1 99M 24M 71M 26% /boot
tmpfs 1014M 0 1014M 0% /dev/shm
/dev/mapper/VGroot-LVut01
40G 177M 38G 1% /ut01

###
### So the space is added to the Logical Volume, but the filesystem in the logical volume is not extended
###

# resize2fs /dev/VGroot/LVut01
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VGroot/LVut01 is mounted on /ut01; on-line resizing required
Performing an on-line resize of /dev/VGroot/LVut01 to 11796480 (4k) blocks.
The filesystem on /dev/VGroot/LVut01 is now 11796480 blocks long.

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VGroot-LVroot
7.7G 3.3G 4.0G 45% /
/dev/sda1 99M 24M 71M 26% /boot
tmpfs 1014M 0 1014M 0% /dev/shm
/dev/mapper/VGroot-LVut01
45G 181M 42G 1% /ut01

###
### TADA! All done.
###

This will also work if your root filesystems (“/”) is on LVM, since most of the important stuff is loaded into memory.

Edit 2009-11-16: Use these instructions instead – much cleaner way of doing it

In my day job, I help look after a pretty big VMware cluster (20 blades running 350+ servers, mix of Linux and Windows). On Linux, we use LVM for flexibility.

Conventional wisdom on the subject of growing seems to have said that after resizing your virtual disk, you had to reboot to see the extra space. This is probably not a bad idea, but sometimes you’re just a bit too impatient for that. Or I am anyway.

Let’s follow this through our layers of misdirection between the actual filesystem people can store files on, and the physical disks underneath it.

At the lowest level, we run a NetApp filer pair (well, several) with spinning disks, assembled into aggregates, then split into raid sets, then presented as virtual file systems over NFS to our VMware ESX boxes. Virtual Center stores the vmdks associated with VMs on there. These virtual file systems automatically grow, waffle, backup, etc, transparent to the VMs. It’s very cool.

Ok, growing the file system. The first step is to grow the size of the virtual disk in vCenter (Edit Settings -> Hard Drive 1 -> Resize). Wait for that to finish.

On your Linux VM, rescan the SCSI device:

# echo 1 > /sys/class/scsi_device/0\:0\:0\:0/device/rescan

Run fdisk, and verify that the disk is now seen as its new size:

# fdisk /dev/sda

The number of cylinders for this disk is set to 9137.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 14 104391 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 14 4178 33450007+ 8e Linux LVM
/dev/sda3 4178 8354 33549073+ 8e Linux LVM

Create your new LVM partition in the free space:


Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Selected partition 4
First cylinder (8355-9137, default 8355):
Using default value 8355
Last cylinder or +size or +sizeM or +sizeK (8355-9137, default 9137):
Using default value 9137

Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e

Print out the partition table (p) then write to disk (w) and exit (q).

FDISK will ominously warn:

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

And if you try to use this new partition, it won’t be seen.


# pvcreate /dev/sda4
Device /dev/sda4 not found (or ignored by filtering).

The step that every one of the otherwise fine sets of instructions I found online missed out was to rescan the partition table again:


# partprobe -s
/dev/sda: msdos partitions 1 2 3 4

And it works!


# pvcreate /dev/sda4
Physical volume "/dev/sda4" successfully created

And we can extend onto it..


# vgextend -v VGroot /dev/sda4
Checking for volume group "VGroot"
Archiving volume group "VGroot" metadata (seqno 6).
Wiping cache of LVM-capable devices
Adding physical volume '/dev/sda4' to volume group 'VGroot'
Volume group "VGroot" will be extended by 1 new physical volumes
Creating volume group backup "/etc/lvm/backup/VGroot" (seqno 7).
Volume group "VGroot" successfully extended

And create new filesystems, resize filesystems into it, etc. So there you go.

12 Nov, 2009

The secret life of ships

Posted by: alex in: Gibbering

Following the armistice of 1918, the German Navy was moved to Scapa Flow, and moored there with their German crews while the greedy allies decided who would get what ships.

Ze Germans however, wanted nothing of this, so despite the armistice, scuttled the ships, an act of war in and of its own. Some of the ships were saved and scuttled as target practice in the 1920s, but most went to the bottom. Some were refloated, but again, most are still there. There’s a wikipedia article, but don’t read it right now..

Fast forward to the 1940s. The somewhat unfair settlement against the germans has lead (in part) to another world war, and the americans develop a massive weapon, the likes of which have never been seen before. The war in Europe finishes, and this new weapon brings about the end to the war in Asia. More of these mighty weapons are tested, and from the fallout, the world’s background radiation increases just a bit. So much so that most of the world’s steel refineries produce steel that contains trace levels of radiation (in some cases, not so trace..)

Anyway, this produces a problem. How do you compare radiation levels when everything is now radioactive, to a degree? Well, the easy way is to compare it to something you know is mostly non radioactive. So they grab steel that’s been under water since the 1920s, and thus shielded from most radiation. Remember the Kaiser’s ships? Yup, them.

The circle of life continues.

07 Nov, 2009

upgraded pc

Posted by: alex in: Gibbering

A few weeks ago, I bought a Acer Aspire X1301 + LCD, since it was a great deal.. C$399 + tax + enviro fees.

I then sold the LCD for $50, leaving me with a C$349 computer.

The plucky little Acer had some problems.. its power for gaming was.. limited, to say the least, and it only took half height cards, which meant it would be difficult to actually get a good card in there. Then I opened it to check something and the power switch stopped working..

So being me, I bought a new case, PSU and a Radeon 4890 1GB graphics card, and .. erm.. upgraded it. I swapped in the motherboard + drives from the Acer, which meant Windows 7 didn’t need to reactivate, and then plugged in this grunty ATI giant of a card. And it works, I get 100+ fps in everything I’ve tried so far ;)

The only problem is that the graphic card doesn’t have HDMI (despite the box saying in big letters that it does have HDMI, and then having a small weasel statement about requiring an adapter), which means right now.. no sound or use VGA. But I have the adapter on its way, courtesy of eBay.

22 Oct, 2009

Mike Neville

Posted by: alex in: Gibbering

I received news that my former boss at UWA Arts, Mike Neville, passed away sometime last night.

There’s so much that could be said. I know he pretty seriously pissed off some people doing his job at UWA, but in the end he was a force for doing things right, and he was still there after they left. He was also a geek at heart, and we often chatted about the esoterics of computer and electronics hardware.

On a more personal level, I thought he was a great guy, both in and out of work. My heart goes out thinking of his wife, delightfully nutty daughter and son. He was also a great friend and mentor to so many of us, but I think none more so than my former co-worker Dan.

I’ll really miss the guy when I am next in Perth.

18 Oct, 2009

Autumn at UBC

Posted by: alex in: Gibbering




Autumn at UBC

Originally uploaded by theducks

Don’t the hours grow shorter as the days go by? It’s starting to be dark when I wake up, and when I leave for work. But the colours are pretty.

Oh for a camera with the dynamic range of the human eye.

13 Oct, 2009

roadtrips

Posted by: alex in: Gibbering

We had a fun roadtrip down to Seattle and Portland last weekend. About 1200kms round trip. No tickets, but we did have something fall off a truck and scratch our car. Will wait to see if Avis wants my kidneys for that.

US Customs were nice and quick. Seattle was great, but a short visit (but it’s a quick drive, so maybe we’ll head down another weekend). We arrived late, had breakfast at Pike Place markets. Lots of character. Went to the Museum of Flight and saw the first 727, 737, 747 and 757, as well as a Concorde. Very nice.

Portland was also great. Caught up with Perth-friend Jen S-B, and long time online friend Kristal. Had many yummy foods, before doing the drive back to Vancouver directly in one afternoon. All good.

Work has been fun. Really getting my teeth into it.

16 Sep, 2009

Updates

Posted by: alex in: Gibbering

It seems I never posted about this.. we both have jobs now, and an awesome 17th floor apartment in Richmond BC. I’m working for a Big University, looking after operations for their VMWare environment (299 VMs and counting). Elizabeth is working for a small software company that does something like cpanel, but for IIS. We both passed our Canadian driving tests, so can legally drive here after the 24th of this month.

Which is coming up quite rapidly, much like the 28th of this month. Also an important date, for those following at home.

16 Sep, 2009

Good morning Vancouver

Posted by: alex in: Gibbering




Good morning Vancouver

Originally uploaded by theducks

Sure, I could avoid 3 hours of commuting per day (and transfer that task to elizabeth..) but we wouldn’t have these spectacular views. What a country.

16 Sep, 2009

Truth is not universal

Posted by: alex in: Gibbering

Working at a University, as I for some reason continue to do so, you are exposed to a large amount of political material from various student (and staff) groups. I also know some people who are pretty interested in Canadian politics.

I remember that at one point, I’d see this political speech and think “wow, the ruling party suck, how could they do these things!”. But as I’ve started thinking more critically, I’ve started to notice how sometimes these hot topics are mutually exclusive.

One example:
- BC Liberals have cut millions from student support loans etc!
- BC Liberals are predicting a deficit of over $400 million next year!
- BC Liberals introducing HST – tax increase!
- BC Liberals won’t raise minimum wage!

.. so which would you like guys? you can’t spend money you don’t have without going into deficit. You can’t have the money to spend without cutting programs or raising taxes. You can’t provide services without taxing, etc.

Another example, Federal Liberal blogger friend made a tweet about how the Conservative Party were spending into deficit. But the thing is, stimulating economies during depressions/recessions is best done by government spending.. so spending money in and of itself isn’t bad. At the same time, the Conservative Party (the ones in government) are running attack ads against the head of the federal Liberal party, talking about how terrible it is that he used to live in the US..

Which brings me to the conclusion that as a politician, EVERYTHING you do is going to piss SOMEONE off, and pissed off people ranting sells newspapers and gets viewers on TV. Which is another factor.. newspapers in particular are in a lot of financial trouble these days, and so are fanning the flames of discontent.

I think the trick in being a politician is to make sure you don’t do things that will piss off too many people at once.


About

After years of doing theducks.org manually, I've finally given in and moved to Wordpress. Just in time to move overseas, because I haven't got anything else to do with my time...