Changing disk partitions on current setup

General support questions
Post Reply
hardikandhardik
Posts: 2
Joined: 2018/08/13 04:22:11

Changing disk partitions on current setup

Post by hardikandhardik » 2018/08/13 05:04:33

Is there a way to change my disk partitions on my current set-up? I am running out of space on my backup partition and want to take some (or all) from my root partition.

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda6 121G 35G 80G 31% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda3 296G 268G 13G 96% /backup
/dev/sda1 1008M 59M 898M 7% /boot
/dev/sda2 493G 340G 128G 73% /data
[root@ ~]# fdisk -l

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0x0002d415

Device Boot Start End Blocks Id System
/dev/sda1 * 1 131 1048576 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 131 65402 524288000 83 Linux
/dev/sda3 65402 104565 314572800 83 Linux
/dev/sda4 104565 121602 136852184 5 Extended
/dev/sda5 104565 105609 8388608 82 Linux swap / Solaris
/dev/sda6 105609 121602 128460800 83 Linux

User avatar
jlehtone
Posts: 2017
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Changing disk partitions on current setup

Post by jlehtone » 2018/08/13 10:05:37

First, "partition" and "filesystem" are related but not the same. You have shown only the partitions.

There are additional commands for gathering info:

Code: Select all

lsblk
blkid
findmnt
The size of partitions hints that they were created manually, rather than by installer.

You have "backup" on the same physical disk as the "data". While backups can protect
against logical (user) errors, there is no protection against physical disk failure.

You have MBR partition table in use. You don't have LVM in use.
LVM would be more flexible, but one cannot (trivially) inject it into existing system.


gparted should be able to resize/relocate filesystems and partitions.
The gparted you can boot/run from USB stick.


The /dev/sda5 and /dev/sda6 are logical drives within the /dev/sda4 extended partition.
I've totally messed up (but did recover) a shuffle of logical drives once.

The point is: have a backup on separate disk. If your resize fails, you will need it.

hardikandhardik
Posts: 2
Joined: 2018/08/13 04:22:11

Re: Changing disk partitions on current setup

Post by hardikandhardik » 2018/08/17 12:35:19

# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 500G 0 part /data
├─sda3 8:3 0 300G 0 part /backup
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 8G 0 part [SWAP]
└─sda6 8:6 0 122.5G 0 part /
[ ~]# blkid
/dev/sda6: UUID="13d2d4b9-2a70-4b31-899b-11b0c6b00e27" TYPE="ext4"
/dev/sda1: UUID="1f4ed10c-e56a-444e-914b-2a6cecfaff9a" TYPE="ext2"
/dev/sda2: UUID="4d462d27-45e5-4568-8fcb-9a9a3f4446b5" TYPE="ext4"
/dev/sda3: UUID="f7381ad9-e90c-499e-8572-04041bbe36d8" TYPE="ext4"
/dev/sda5: UUID="7d4de32c-2da8-436f-a748-8aeb07d78087" TYPE="swap"
[ ~]# findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda6 ext4 rw,relatime,barrier=1,data=o
├─/proc proc proc rw,relatime
│ ├─/proc/bus/usb /proc/bus/usb usbfs rw,relatime
│ └─/proc/sys/fs/binfmt_misc binfmt_m rw,relatime
├─/sys sysfs sysfs rw,relatime
├─/dev devtmpfs devtmpfs rw,relatime,size=3997932k,nr
│ ├─/dev/pts devpts devpts rw,relatime,gid=5,mode=620,p
│ └─/dev/shm tmpfs tmpfs rw,relatime
├─/backup /dev/sda3 ext4 rw,relatime,barrier=1,data=o
├─/boot /dev/sda1 ext2 rw,relatime,errors=continue
└─/data /dev/sda2 ext4 rw,relatime,barrier=1,data=o

User avatar
TrevorH
Forum Moderator
Posts: 23863
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Changing disk partitions on current setup

Post by TrevorH » 2018/08/17 12:49:19

Given that this is for backups and it's pointless having backups on the same physical disk as the originals, why not just buy and install a new disk, format it, mount it and copy your existing backups onto it and then mount the new one in its place.

That still doesn't make your backup safe as lots of other stuff could go wrong that might result in the total loss of the entire thing. Think fire, lightning, flood, theft etc. Or even just fat fingers on a command resulting in the deletion of the data ...

If you had used LVM when setting the original up then that would have made it easier to shrink/grow things. Plain partitions, especially when the one you want to resize is sandwiched in the middle of the others, are much more difficult to resize.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

Post Reply