1

Sorry for my poor English, I hope you will understand me.

A month ago I set up a Ubuntu server with a 500GB HDD, while installing the system I created regular, non-LVM, partitions - here's their layout.

root@skysquad:~# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000c9f61

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       10942    87891583+  83  Linux
/dev/sda2           10943       60801   400492417+   5  Extended
/dev/sda5           12159       60801   390724866   83  Linux
/dev/sda6           10943       12158     9767457   82  Linux swap / Solaris

Partition table entries are not in disk order

Basically it's;

sda1 (90GB) for OS (ext4)
sda5 (~370GB) for /home (I will explain later) (ext4)
sda6 (10GB) for SWAP

Later I realised that when sda5 (385GB for /home) will be full I would like to increase its size by adding a new HDD, so I made sda5 an LVM partition like so;

root@skysquad:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda5
  VG Name               vg1
  PV Size               372.62 GB / not usable 3.25 MB
  Allocatable           yes (but full)
  PE Size (KByte)       4096
  Total PE              95391
  Free PE               0
  Allocated PE          95391
  PV UUID               lewQnp-NdvK-Ac0N-sCgE-NGOH-K2cX-WxJ2tL

root@skysquad:~# vgdisplay
  --- Volume group ---
  VG Name               vg1
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               372.62 GB
  PE Size               4.00 MB
  Total PE              95391
  Alloc PE / Size       95391 / 372.62 GB
  Free  PE / Size       0 / 0
  VG UUID               yRkcP7-zvZ0-DjIR-xDWS-Ia6V-InSu-6Hwvpe

root@skysquad:~# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg1/home
  VG Name                vg1
  LV UUID                jXCi37-iWmp-xVd7-9TsL-56pg-6x9m-73flLT
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                372.62 GB
  Current LE             95391
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

Now my sda5 (LVM) is full (see below), but my wallet is not, and I can't just buy another HDD.

root@skysquad:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             86511612   3829536  78287500   5% /
tmpfs                  1677788         0   1677788   0% /lib/init/rw
varrun                 1677788       520   1677268   1% /var/run
varlock                1677788         0   1677788   0% /var/lock
udev                   1677788       144   1677644   1% /dev
tmpfs                  1677788        84   1677704   1% /dev/shm
lrm                    1677788      2192   1675596   1% /lib/modules/2.6.28-15-generic/volatile
/dev/mapper/vg1-home 384590900 332537772  32517052  92% /home

As you can see I'm only using 5% of / (sda1) (I don't know what I had in mind when I was setting 90GB for /).

So finally my question - is there any SAFE way to resize non-LVM partitions (i.e. decrease sda1 size by 60GB, from 90GB to 30GB, and increase sda5 with this 60GB from ~370GB to ~430GB) and then increase LVM at sda5 with those 60GB?

Thank you,
Lulaz

3
  • Where are you in the world Lulaz, and what type of disk do you need (SATA I assume)?
    – Chopper3
    Sep 23, 2009 at 14:43
  • Im from Poland. Yes, I need SATA disk. This 500GB is WD Caviar Black Series (becouse it has 5y warranty), and I want to buy exactly the same, but 1TB.
    – user21006
    Sep 23, 2009 at 15:07
  • The real trick in all this is you cannot decrease the size of a volume while it is mounted. This may not be true in ext4, my knowledge there is a bit vague.
    – Kyle Smith
    Jun 9, 2011 at 14:22

4 Answers 4

4

In theory, you could reduce the size of sda1, increase the size of the extended partition, shift the contents of the extended partition down, then increase the size of the PV on the extended partition and you'd have the extra room. However, the number of possible things that can go wrong there is just astronomical, so I'd recommend either buying a second hard drive (and possibly transferring everything onto it in a more sensible layout, then repartitioning your current drive better) or just making some bind mounts of various bits and pieces out of /home into / to free up a bit more space.

0

Easy shortcut:

If you're root on the box, and it seems like you are, build a directory on '/', which is sda1. For this example, let's call it '/data/overflow'. Then in your home directory, take some directory that's excessively large, move the data to /data/overflow, and use a symbolic link to point to it.

Sample commands:

# make directory on empty partition
mkdir -p /data/overflow
chown username /data/overflow

# move data to empty disk
cd /home/username
mv bigdir /data/overflow

# put the link in, so your old names match
ln -s /data/overflow/bigdir bigdir
0

GParted Live will let you resize non-LVM partitions, theoretically without losing data, but 1. you wouldn't be able to use your server during this time and 2. like womble said, it's highly likely something could go wrong.

0

Create a Ubuntu Live USB stick, boot to it, and run GParted to accomplish your re-configuration. I've found it to operate flawlessly to create, move, copy, and resize conventional partitions.

You must log in to answer this question.