Debian disk full, How to increase size?

8,592

Solution 1

Since you are running a virtual machine and adding new disk is easy task, I would suggest you to add a new virtual disk instead of shrinking /home because it might be difficult for you.

Depends on your VM host, add a new virtual disk to your VM.

Then, check the device name for your new disk by:

# fdisk -l

You will get something similar to below:

Disk /dev/sdb: 70.9 GB, 70866960384 bytes
255 heads, 63 sectors/track, 8615 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Next, you need to either partition your disk or simply make use of whole disk:

To partition your disk (assume you have disk with label /dev/sdb) added:

# fdisk /dev/sdb
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-8615, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-8615, default 8615):
Using default value 8615

Next, you need to format the disk the become a Physical Volume of LVM:

# pvcreate /dev/sdb1

From your information, you have a volume group deb-web138. So you can add new space by:

# vgextend deb-web138 /dev/sdb1

You will now have new space added to volume group, resize your logical volume root by 70G for example:

# lvresize -L+70G /dev/deb-web138/root
# resize2fs /dev/deb-web138/root

When the resizing operation completes, you will have new free space and can be checked by the command:

# df -h

When you need to add new space again, you can add new virtual disk and follow the procedure as mentioned above.

Solution 2

First of all you need to unmount /home partition which you are going to shrink and get root access. Now your /dev/deb-web138/home has 143G. For example we want to leave it with 100G and add 43G to /dev/deb-web138/root
1. Reduce /dev/deb-web138/home
lvreduce -L 100g -r /dev/deb-web138/home
2. Add freed space to /dev/deb-web138/root
lvextend -L +43G /dev/deb-web138/root
Thats it, just mount your /home back. Note that -r arg implies resize2fs so you don't need to run it explicitly

Share:
8,592

Related videos on Youtube

Timo77
Author by

Timo77

Updated on September 18, 2022

Comments

  • Timo77
    Timo77 almost 2 years

    I have a small web server running Debian 7. If I run command df -h, I can see that I have /dev/mapper/deb--webxxx-root/ allmost full, 17 megabytes of free space.

    How can I allocate more free space? /dev/mapper/deb--webxxx-home/ has 130 gigabytes of free space. Can I some how move some of that free space to another mapper? Debian is a virtual machine so I could add more disk space quite easily too, but how?

    I 'am newbaby on these debian server things...

    pvdisplay:

    --- Physical volume ---
      PV Name               /dev/sda5
      VG Name               deb-web138
      PV Size               159,76 GiB / not usable 2,00 MiB
      Allocatable           yes (but full)
      PE Size               4,00 MiB
      Total PE              40898
      Free PE               0
      Allocated PE          40898
      PV UUID               3rsJgY-I7KJ-Mv7H-xQ3Z-jNGn-z4bE-eKTUmH
    

    Vgdisplay

      --- Volume group ---
      VG Name               deb-web138
      System ID
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  7
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                6
      Open LV               6
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               159,76 GiB
      PE Size               4,00 MiB
      Total PE              40898
      Alloc PE / Size       40898 / 159,76 GiB
      Free  PE / Size       0 / 0
      VG UUID               90CrJD-xtBB-DaZB-UD1R-Lzxj-90w2-kZROya
    

    lvdisplay

      LV Path                /dev/deb-web138/tmp
      LV Name                tmp
      VG Name                deb-web138
      LV UUID                IKNzaW-t55g-FiIK-lP8L-3OFe-Lg8z-hg910U
      LV Write Access        read/write
      LV Creation host, time deb-web138, 2014-12-15 16:18:55 +0200
      LV Status              available
      # open                 1
      LV Size                380,00 MiB
      Current LE             95
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           254:4
    

    lvscan

      ACTIVE            '/dev/deb-web138/root' [332,00 MiB] inherit
      ACTIVE            '/dev/deb-web138/usr' [8,38 GiB] inherit
      ACTIVE            '/dev/deb-web138/var' [2,79 GiB] inherit
      ACTIVE            '/dev/deb-web138/swap_1' [4,00 GiB] inherit
      ACTIVE            '/dev/deb-web138/tmp' [380,00 MiB] inherit
      ACTIVE            '/dev/deb-web138/home' [143,89 GiB] inherit
    
    • user1700494
      user1700494 almost 8 years
      Pls attach to your post output of the following commands: pvdisplay, vgdisplay, lvdisplay
    • Timo77
      Timo77 almost 8 years
      No idea what those are, but just edited results of those...
    • user1700494
      user1700494 almost 8 years
      It is strange that lvdisplay shows only one logical volume. Pls attach output of lvcan as well.