Can I resize "/" partition?

General support questions
hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Can I resize "/" partition?

Post by hack3rcon » 2019/01/05 08:50:27

Hello.
Is it possible to resize the Linux partition without losing data?

Thank you.

scottro
Forum Moderator
Posts: 2556
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Re: Can I resize "/" partition?

Post by scottro » 2019/01/05 11:24:03

Yes. This will depend upon what partitioning scheme you used when first installing. It's probably easiest with LVM. If you're not familiar with disk resizing, the safest way is to boot off a gparted disk and use its GUI interface to do it.
https://gparted.org/
New users should check the FAQ and Read Me First pages

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Can I resize "/" partition?

Post by TrevorH » 2019/01/05 12:51:29

It's possible to _increase_ it's size online while it's mounted and running. To shrink it requires that it be done offline via a separate boot disk and can only be done if it's using ext2/3 or ext4. The xfs filesystem cannot be shrunk at all.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Can I resize "/" partition?

Post by hack3rcon » 2019/01/05 12:54:58

scottro wrote:
2019/01/05 11:24:03
Yes. This will depend upon what partitioning scheme you used when first installing. It's probably easiest with LVM. If you're not familiar with disk resizing, the safest way is to boot off a gparted disk and use its GUI interface to do it.
https://gparted.org/
Thank you but I want to do it by command line. I want to merge "sdb1" and "sdb2" :

Code: Select all

# fdisk -l
Disk /dev/sdb: 100 GiB, 107374182400 bytes, 209715200 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
Disklabel type: gpt
Disk identifier: E58FA36C-9B1D-4EDA-8C7A-4BA352780D49

Device         Start       End   Sectors Size Type
/dev/sdb1       2048 104859647 104857600  50G Linux filesystem
/dev/sdb2  104859648 209715166 104855519  50G Linux filesystem

mashiro2004
Posts: 68
Joined: 2018/12/08 21:46:22
Location: Italy

Re: Can I resize "/" partition?

Post by mashiro2004 » 2019/01/05 13:46:27

Hi, can you post also result of: lsblk and df -h

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Can I resize "/" partition?

Post by hack3rcon » 2019/01/06 06:19:43

mashiro2004 wrote:
2019/01/05 13:46:27
Hi, can you post also result of: lsblk and df -h
Hi.
Sure:

Code: Select all

# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   35G  0 disk 
├─sda1   8:1    0 33.5G  0 part /
├─sda2   8:2    0    1K  0 part 
└─sda5   8:5    0  1.5G  0 part [SWAP]
sdb      8:16   0  100G  0 disk 
├─sdb1   8:17   0   50G  0 part 
└─sdb2   8:18   0   50G  0 part 

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        33G 1009M   31G   4% /
udev             10M     0   10M   0% /dev
tmpfs           201M  3.0M  198M   2% /run
tmpfs           501M     0  501M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           501M     0  501M   0% /sys/fs/cgroup
tmpfs           101M     0  101M   0% /run/user/1001
I have two partitions and I want to merge them.

mashiro2004
Posts: 68
Joined: 2018/12/08 21:46:22
Location: Italy

Re: Can I resize "/" partition?

Post by mashiro2004 » 2019/01/06 09:55:35

On sdb2 have you data?
The Better way Is destroy sdb2 and enlarging sdb1 on free space.

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Can I resize "/" partition?

Post by hack3rcon » 2019/01/06 10:05:08

mashiro2004 wrote:
2019/01/06 09:55:35
On sdb2 have you data?
The Better way Is destroy sdb2 and enlarging sdb1 on free space.
Without destroy, is it impossible?

mashiro2004
Posts: 68
Joined: 2018/12/08 21:46:22
Location: Italy

Re: Can I resize "/" partition?

Post by mashiro2004 » 2019/01/06 10:44:13

It Is possibile to extend partition in unallocated space only. If you have enought space you Can shrink sdb2, extend sdb1 move data fronte sdb2 in sdb1 destroy sdb2 and extend sdb1. With lvm volume is more flexible, because you Can add phisical disk to volume move data and the remove....

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Can I resize "/" partition?

Post by hack3rcon » 2019/01/06 11:30:32

mashiro2004 wrote:
2019/01/06 10:44:13
It Is possibile to extend partition in unallocated space only. If you have enought space you Can shrink sdb2, extend sdb1 move data fronte sdb2 in sdb1 destroy sdb2 and extend sdb1. With lvm volume is more flexible, because you Can add phisical disk to volume move data and the remove....
Can you write properly commands here?
Thank you.

Post Reply