Friday, January 13, 2017

linux - How can I add space to a partition which is not the last?

I have an Ubuntu Server virtualized (version
Linux server 3.2.0-58-generic #88-Ubuntu SMP x86_64 GNU/Linux) in a VMWare, like this:


hard Disk1 SCSI(0:0) --> 11 Gb /dev/sda1
hard disk2 SCSI(0:1) --> 30 Gb /dev/sdb1


This machine has this occupation:


fdiks-l


Disk /dev/sda: 11.8 GB, 11811160064 bytes
255 heads, 63 sectors/track, 1435 cylinders, total 23068672 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: 0x0001ce75
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 15958015 7977984 83 Linux
/dev/sda2 15960062 16775167 407553 5 Extended
/dev/sda5 15960064 16775167 407552 82 Linux swap / Solaris
Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 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: 0x2666a626
Device Boot Start End Blocks Id System
/dev/sdb1 63 41961779 20980858+ 83 Linux
/dev/sdb2 41961780 62910539 10474380 83 Linux

So, my objective is:



  1. Create spce in Vmware to HD2 (SCSI(0:1))

  2. Give that space to /var (/dev/sdb1)


My free space is:
df -k


Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1 8,1G 6,7G 944M 88% /
udev 3,2G 4,1k 3,2G 1% /dev
tmpfs 1,3G 500k 1,3G 1% /run
none 5,3M 0 5,3M 0% /run/lock
none 3,2G 0 3,2G 0% /run/shm
/dev/sdb1 22G 19G 1,3G 94% /var
/dev/sdb2 11G 7,4G 2,8G 73% /home

I'm reading things like this, but I guess that I can't resize /dev/sdb1 (/var) if I had /dev/sdb2 (/home) just next door, the last block of sdb1 is the next in sdb2.. What are my options? I thinking in:



  1. Merge sdb1 and sdb2

  2. Add space to this new partition

  3. Split again /var and /home, but leave the maximum space to /var


But I don't know... All of this, without loss any data... any ideas?

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...