Recently Added

Notes & Bookmarks

  1. Quasars; power and metrics beyond all comprehension. Staggeringly beautiful information... and very well written.
  2. "I'm sorry. I can't come in today. Religious holiday. The feast of...Maximum Occupancy."pic.twitter.com/mkgxPWfNj2
  3. Verifying myself: I am sgnls on Keybase.io. UJa01G4v3YRJYB1LFjDRSf1Nh0bh1sOykCbq / https://keybase.io/sgnls/sigs/UJa01G4v3YRJYB1LFjDRSf1Nh0bh1sOykCbq
  4. Be sure to take care of your own infrastructure(s); purge dumps, tunnel and lock-down egress transit, encrypt and permission CORRECTLY!
  5. It really doesn't matter what else gets released; Sikth's 'The Future in Whose Eyes?' is THE album of 2017. #albumoftheyear @SikthOfficialpic.twitter.com/P5houdf1yx

Partitioning with LVM

Updated : 16:02:07pm, 21st Jul 2015

The other day, I had all sorts of unexpected grief attempting to re-install CrunchBang using LVM across two physical volumes. That I am using a Dell FX170 for the purpose, which has both an on-board NAND and a generic HP 16GB USB flash drive attached, seemed to be a prickly combination for the BusyBox installer (not least of all that one of the physical volumes contained a legacy LVM partition). Despite dropping out of the installer TTY (strangely on TTY4) and using fdisk to manually remove stale partitions and making further progress, only dd was going to provide the cleanest baseline...

The long and short of my initial woes was that attempts to get it all done in one go wasn't working; that I was running the installer from a Live USB meant attempts to span LVM across the two volumes was a task (essentially, it would always use /dev/sdc1 to build the physical-cluster but this would soon be /dev/sdb1 once the installer media was removed).

Anyway, I ended up doing it the 'proper' way and just put a fresh OS installation as an LVM volume on the on-board 4GB NAND (for a change, I also went for 'everything' in one partition as opposed to separates for /boot, /swap and /usr etc.). Once I had the base-line, it was much easier to extend across to the additional storage;

Confirm Current Resources
nivek@kiln:~$ df -h
Filesystem             Size  Used Avail Use% Mounted on
rootfs                 3.5G  2.6G  668M  80% /
udev                    10M     0   10M   0% /dev
tmpfs                  202M  552K  202M   1% /run
/dev/mapper/kiln-root  3.5G  2.6G  668M  80% /
tmpfs                  5.0M     0  5.0M   0% /run/lock
tmpfs                  404M     0  404M   0% /run/shm
/dev/sda1              228M   17M  199M   8% /boot

nivek@kiln:~$ sudo fdisk -l
Disk /dev/sda: 4204 MB, 4204118016 bytes
255 heads, 63 sectors/track, 511 cylinders, total 8211168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004c93f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758     8210431     3854337    5  Extended
/dev/sda5          501760     8210431     3854336   8e  Linux LVM

Disk /dev/mapper/kiln-root: 3724 MB, 3724541952 bytes
255 heads, 63 sectors/track, 452 cylinders, total 7274496 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/kiln-root doesn't contain a valid partition table

Disk /dev/sdb: 16.0 GB, 16043212800 bytes
64 heads, 32 sectors/track, 15300 cylinders, total 31334400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00054279

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/mapper/kiln-swap_1: 218 MB, 218103808 bytes
255 heads, 63 sectors/track, 26 cylinders, total 425984 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/kiln-swap_1 doesn't contain a valid partition table


Create Required LVM Partition on Spare Drive
nivek@kiln:~$ sudo fdisk /dev/sdb

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-31334399, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-31334399, default 31334399): 
Using default value 31334399

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

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

Calling ioctl() to re-read partition table.
Syncing disks.

nivek@kiln:~$ sudo fdisk -l

Disk /dev/sda: 4204 MB, 4204118016 bytes
255 heads, 63 sectors/track, 511 cylinders, total 8211168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004c93f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758     8210431     3854337    5  Extended
/dev/sda5          501760     8210431     3854336   8e  Linux LVM

Disk /dev/mapper/kiln-root: 3724 MB, 3724541952 bytes
255 heads, 63 sectors/track, 452 cylinders, total 7274496 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/kiln-root doesn't contain a valid partition table

Disk /dev/sdb: 16.0 GB, 16043212800 bytes
64 heads, 32 sectors/track, 15300 cylinders, total 31334400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00054279

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    31334399    15666176   8e  Linux LVM

Disk /dev/mapper/kiln-swap_1: 218 MB, 218103808 bytes
255 heads, 63 sectors/track, 26 cylinders, total 425984 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/kiln-swap_1 doesn't contain a valid partition table


Create Physical Volume on New LVM Partition (Attempt #1)
nivek@kiln:~$ sudo pvcreate /dev/sdb1
  Couldn't find device with uuid kDQ1oG-3dXY-0wMV-DELW-qoYN-3JSI-6exzQ6.
  Can't initialize physical volume "/dev/sdb1" of volume group "rutger" without -ff

Note that I STILL have legacy references to the old VG; I should have used DD after all...
nivek@kiln:~$ sudo pvscan
  Couldn't find device with uuid kDQ1oG-3dXY-0wMV-DELW-qoYN-3JSI-6exzQ6.
  PV unknown device   VG rutger   lvm2 [3.67 GiB / 3.67 GiB free]
  PV /dev/sdb1        VG rutger   lvm2 [14.94 GiB / 14.94 GiB free]
  PV /dev/sda5        VG kiln     lvm2 [3.67 GiB / 0    free]
  Total: 3 [22.28 GiB] / in use: 3 [22.28 GiB] / in no VG: 0 [0   ]

nivek@kiln:~$ sudo pvdisplay 
  Couldn't find device with uuid kDQ1oG-3dXY-0wMV-DELW-qoYN-3JSI-6exzQ6.
  --- Physical volume ---
  PV Name               unknown device
  VG Name               rutger
  PV Size               3.68 GiB / not usable 4.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              940
  Free PE               940
  Allocated PE          0
  PV UUID               kDQ1oG-3dXY-0wMV-DELW-qoYN-3JSI-6exzQ6
   
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               rutger
  PV Size               14.94 GiB / not usable 2.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              3824
  Free PE               3824
  Allocated PE          0
  PV UUID               kbvGic-eyhl-0eUl-ir0F-DXpl-5qsb-Zqd84s
   
  --- Physical volume ---
  PV Name               /dev/sda5
  VG Name               kiln
  PV Size               3.68 GiB / not usable 4.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              940
  Free PE               0
  Allocated PE          940
  PV UUID               lDuiCv-BY0I-zNLi-qUBP-1Ngh-GoJa-apLxeS
   
nivek@kiln:~$ sudo vgdisplay 
  Couldn't find device with uuid kDQ1oG-3dXY-0wMV-DELW-qoYN-3JSI-6exzQ6.
  --- Volume group ---
  VG Name               rutger
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                1
  VG Size               18.61 GiB
  PE Size               4.00 MiB
  Total PE              4764
  Alloc PE / Size       0 / 0   
  Free  PE / Size       4764 / 18.61 GiB
  VG UUID               x987eB-ht3t-Meui-pMCP-F5X1-jxaI-bCGAKK
   
  --- Volume group ---
  VG Name               kiln
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               3.67 GiB
  PE Size               4.00 MiB
  Total PE              940
  Alloc PE / Size       940 / 3.67 GiB
  Free  PE / Size       0 / 0   
  VG UUID               PMBwJo-oaLZ-IDuN-U46I-0mqQ-yX3B-lV19Kn
   
Let's remove this accursed reference...
nivek@kiln:~$ sudo vgreduce --removemissing --force rutger
  Couldn't find device with uuid kDQ1oG-3dXY-0wMV-DELW-qoYN-3JSI-6exzQ6.
  Wrote out consistent volume group rutger

nivek@kiln:~$ sudo vgdisplay 
  --- Volume group ---
  VG Name               rutger
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               14.94 GiB
  PE Size               4.00 MiB
  Total PE              3824
  Alloc PE / Size       0 / 0   
  Free  PE / Size       3824 / 14.94 GiB
  VG UUID               x987eB-ht3t-Meui-pMCP-F5X1-jxaI-bCGAKK
   
  --- Volume group ---
  VG Name               kiln
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               3.67 GiB
  PE Size               4.00 MiB
  Total PE              940
  Alloc PE / Size       940 / 3.67 GiB
  Free  PE / Size       0 / 0   
  VG UUID               PMBwJo-oaLZ-IDuN-U46I-0mqQ-yX3B-lV19Kn
   
nivek@kiln:~$ sudo vgremove rutger 
  Volume group "rutger" successfully removed

Now that's more like what we want to see...
nivek@kiln:~$ sudo vgdisplay 
  --- Volume group ---
  VG Name               kiln
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               3.67 GiB
  PE Size               4.00 MiB
  Total PE              940
  Alloc PE / Size       940 / 3.67 GiB
  Free  PE / Size       0 / 0   
  VG UUID               PMBwJo-oaLZ-IDuN-U46I-0mqQ-yX3B-lV19Kn
   

Create Physical Volume on New LVM Partition (Attempt #2)
nivek@kiln:~$ sudo pvcreate /dev/sdb1
  Writing physical volume data to disk "/dev/sdb1"
  Physical volume "/dev/sdb1" successfully created

nivek@kiln:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               kiln
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               3.67 GiB
  PE Size               4.00 MiB
  Total PE              940
  Alloc PE / Size       940 / 3.67 GiB
  Free  PE / Size       0 / 0   
  VG UUID               PMBwJo-oaLZ-IDuN-U46I-0mqQ-yX3B-lV19Kn
   
nivek@kiln:~$ sudo vgextend kiln /dev/sdb1
  Volume group "kiln" successfully extended

nivek@kiln:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               kiln
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               18.61 GiB
  PE Size               4.00 MiB
  Total PE              4764
  Alloc PE / Size       940 / 3.67 GiB
  Free  PE / Size       3824 / 14.94 GiB
  VG UUID               PMBwJo-oaLZ-IDuN-U46I-0mqQ-yX3B-lV19Kn

nivek@kiln:~$ sudo pvscan
  PV /dev/sda5   VG kiln   lvm2 [3.67 GiB / 0    free]
  PV /dev/sdb1   VG kiln   lvm2 [14.94 GiB / 14.94 GiB free]
  Total: 2 [18.61 GiB] / in use: 2 [18.61 GiB] / in no VG: 0 [0   ]

nivek@kiln:~$ sudo lvdisplay 
  --- Logical volume ---
  LV Path                /dev/kiln/root
  LV Name                root
  VG Name                kiln
  LV UUID                k2h49T-Gi8P-b2oU-sxh0-32d3-K0YH-xh02iM
  LV Write Access        read/write
  LV Creation host, time kiln, 2015-02-22 00:53:44 +0000
  LV Status              available
  # open                 1
  LV Size                3.47 GiB
  Current LE             888
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0
   
  --- Logical volume ---
  LV Path                /dev/kiln/swap_1
  LV Name                swap_1
  VG Name                kiln
  LV UUID                Hd57yp-RrWl-vTZa-zzTq-DeWJ-c4V4-Et69U9
  LV Write Access        read/write
  LV Creation host, time kiln, 2015-02-22 00:53:45 +0000
  LV Status              available
  # open                 2
  LV Size                208.00 MiB
  Current LE             52
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1

nivek@kiln:~$ sudo lvextend /dev/kiln/root /dev/sdb1
  Extending logical volume root to 18.41 GiB
  Logical volume root successfully resized

nivek@kiln:~$ sudo lvdisplay 
  --- Logical volume ---
  LV Path                /dev/kiln/root
  LV Name                root
  VG Name                kiln
  LV UUID                k2h49T-Gi8P-b2oU-sxh0-32d3-K0YH-xh02iM
  LV Write Access        read/write
  LV Creation host, time kiln, 2015-02-22 00:53:44 +0000
  LV Status              available
  # open                 1
  LV Size                18.41 GiB
  Current LE             4712
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0
   
  --- Logical volume ---
  LV Path                /dev/kiln/swap_1
  LV Name                swap_1
  VG Name                kiln
  LV UUID                Hd57yp-RrWl-vTZa-zzTq-DeWJ-c4V4-Et69U9
  LV Write Access        read/write
  LV Creation host, time kiln, 2015-02-22 00:53:45 +0000
  LV Status              available
  # open                 2
  LV Size                208.00 MiB
  Current LE             52
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1
  
nivek@kiln:~$ sudo vgdisplay 
  --- Volume group ---
  VG Name               kiln
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               18.61 GiB
  PE Size               4.00 MiB
  Total PE              4764
  Alloc PE / Size       4764 / 18.61 GiB
  Free  PE / Size       0 / 0   
  VG UUID               PMBwJo-oaLZ-IDuN-U46I-0mqQ-yX3B-lV19Kn


Resize Filesystem Across LVM
nivek@kiln:~$ sudo resize2fs /dev/kiln/root
resize2fs 1.42.5 (29-Jul-2012)
Filesystem at /dev/kiln/root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/kiln/root to 4825088 (4k) blocks.
The filesystem on /dev/kiln/root is now 4825088 blocks long.


Confirm New Resourcing
nivek@kiln:~$ df -h
Filesystem             Size  Used Avail Use% Mounted on
rootfs                  19G  2.6G   15G  16% /
udev                    10M     0   10M   0% /dev
tmpfs                  202M  556K  202M   1% /run
/dev/mapper/kiln-root   19G  2.6G   15G  16% /
tmpfs                  5.0M     0  5.0M   0% /run/lock
tmpfs                  404M     0  404M   0% /run/shm
/dev/sda1              228M   17M  199M   8% /boot

SGNLS.net © 2006-2017

Comments, submissions and errors to desk[at]sgnls.net.

Material and content adheres to the Creative Commons (NC-SA 4.0) license.

v12.01151