Partition fuckup

David Beveridge bevhost at gmail.com
Fri Jul 26 07:47:16 UTC 2013


On Fri, Jul 26, 2013 at 3:50 PM, Martin Skjöldebrand
<shieldfire at gmail.com> wrote:

> I want them the other way round really.
> What would be the best way of trying to achieve this?

You can do it with Logical Volume Manager,
assuming LVM was used to create the partitions.

This is a procedure I use to remove the /home partition completely and
grow the root partition into the available space.
 /home should be empty / or backed up..

In this example I want to remove the /home partition and reallocate
the space to the / partiton to increase it's size.

root at db3 ~#  df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_db3-lv_root
                       50G   17G   31G  35% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1             485M   64M  396M  14% /boot

root at db3 ~ # lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg_db3/lv_root
  VG Name                vg_db3
  LV UUID                eOnC1Q-9Iv7-FiNg-eveh-HVN3-XXz0-Tp1Xer
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/vg_db3/lv_home
  VG Name                vg_db3
  LV UUID                fzWyrF-8X8F-3d89-VMbO-cN66-MGZw-cgvQpS
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                63.63 GiB
  Current LE             16290
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Name                /dev/vg_db3/lv_swap
  VG Name                vg_db3
  LV UUID                4JVuin-Jm6F-OtO7-qyw8-Dakr-KcSI-A8M3D4
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                5.88 GiB
  Current LE             1504
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1


# umount /home
remove it from /etc/fstab

# vi /etc/fstab

delete the line that referers to the /home paritition

root at db3 ~ # lvm

deactivate the volume

lvm> lvchange -a n /dev/vg_db3/lv_home

remove it.

lvm> lvremove /dev/vg_db3/lv_home
 Logical volume "lv_home" successfully removed


lvm> lvscan
  ACTIVE            '/dev/vg_db3/lv_root' [50.00 GiB] inherit
  ACTIVE            '/dev/vg_db3/lv_swap' [5.88 GiB] inherit

lvm> pvscan
  PV /dev/sda2   VG vg_db3   lvm2 [119.51 GiB / 63.63 GiB free]
  Total: 1 [119.51 GiB] / in use: 1 [119.51 GiB] / in no VG: 0 [0   ]

lvm> lvextend -l +100%FREE /dev/vg_db3/lv_root /dev/sda2
  Extending logical volume lv_root to 113.63 GiB
  Logical volume lv_root successfully resized

lvm> quit
  Exiting.
root at db3 ~ # resize2fs /dev/vg_db3/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_db3/lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 8
Performing an on-line resize of /dev/vg_db3/lv_root to 29788160 (4k) blocks.
The filesystem on /dev/vg_db3/lv_root is now 29788160 blocks long.


root at db3 ~ # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_db3-lv_root
                      112G   17G   91G  16% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1             485M   64M  396M  14% /boot


More information about the users mailing list