How can I resize my root partition in Debian?

59,542

If done carefully, you can use gparted to resize your partitions safely.

You should boot to a live image since you can't resize mounted partitions, and make sure you have a valid back up of your data!!

Share:
59,542

Related videos on Youtube

phimath
Author by

phimath

Updated on September 18, 2022

Comments

  • phimath
    phimath over 1 year

    I am trying to add space to my root partition and am really not sure the safest way to go about it. I have read this thread, Can I resize the root partition without uninstalling and reinstalling Linux (or losing data)? but I don't think the information lines up with my system.

    Any help would be througholy appreciated. Also, in that post, F1234K asked for recommendations on good reading to learn this stuff, but no one replied to it. I would also be very interested in some learning material on the subject.

    Thanks!

    edit: I should add that my goal is to take 20 gb from sdb6 and put it in sdb1. sdb6 is a logical volume of sdb2.

    sudo fdisk -l

    Disk /dev/sdb: 750.2 GB, 750156374016 bytes
    255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 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: 0x0000babf   
    Device     Boot      Start         End      Blocks   Id  System
    /dev/sdb1   *        2048    19531775     9764864   83  Linux
    /dev/sdb2        19533822  1465147391   722806785    5  Extended
    /dev/sdb5        19533824    76765183    28615680   82  Linux swap / Solaris
    /dev/sdb6        76767232  1465147391   694190080   83  Linux
    
    Disk /dev/sda: 1000.2 GB, 1000200658432 bytes
    255 heads, 63 sectors/track, 121600 cylinders, total 1953516911 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: 0x000a9997
    
    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            2048  1953515519   976756736   83  Linux
    
    Disk /dev/sdc: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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: 0x927a1713
    
    Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1   *        2048      206847      102400    7  HPFS/NTFS/exFAT
    /dev/sdc2          206848   976771071   488282112    7  HPFS/NTFS/exFAT
    
    WARNING: GPT (GUID Partition Table) detected on '/dev/sdd'! The util fdisk doesn't support GPT. Use GNU Parted.
    
    
    Disk /dev/sdd: 999.5 GB, 999501594624 bytes
    256 heads, 63 sectors/track, 121041 cylinders, total 1952151552 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: 0x809da6bc
    
    Device Boot      Start         End      Blocks   Id  System
    /dev/sdd1               1  4294967295  2147483647+  ee  GPT
    

    df -h

    Filesystem                                              Size  Used Avail Use% Mounted on
    rootfs                                                  9.2G  8.8G     0 100% /
    udev                                                     10M     0   10M   0% /dev
    tmpfs                                                   2.4G  896K  2.4G   1% /run
    /dev/disk/by-uuid/d7968f08-4108-4382-a585-0b4a3850ec63  9.2G  8.8G     0 100% /
    tmpfs                                                   5.0M     0  5.0M   0% /run/lock
    tmpfs                                                    11G  692K   11G   1% /run/shm
    /dev/sdb6                                               652G  581G   39G  94% /home
    /dev/sr0                                                4.4G  4.4G     0 100% /media/cdrom0
    /dev/sr1                                                354M  354M     0 100% /media/cdrom1
    /dev/sdd2                                               931G  759G  173G  82% /media/zacharydimaria
    

    mount

    sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
    proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
    udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=3091362,mode=755)
    devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
    tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=2474360k,mode=755)
    /dev/disk/by-uuid/d7968f08-4108-4382-a585-0b4a3850ec63 on / type ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
    tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
    tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=10671840k)
    /dev/sdb6 on /home type ext4 (rw,relatime,user_xattr,barrier=1,data=ordered)
    rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
    binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
    /dev/sr0 on /media/cdrom0 type udf (ro,nosuid,nodev,noexec,relatime,utf8,user=zachary)
    /dev/sr1 on /media/cdrom1 type udf (ro,nosuid,nodev,noexec,relatime,utf8,user=zachary)
    /dev/sdd2 on /media/zacharydimaria type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
    

    pvdisplay does not return anything.

    edit: cat etc/fstab

    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    # / was on /dev/sdb1 during installation
    UUID=d7968f08-4108-4382-a585-0b4a3850ec63 /               ext4    errors=remount-ro 0       1
    # /home was on /dev/sdb6 during installation
    UUID=ec5e593e-a36f-4b88-b210-8666128b4bf1 /home           ext4    defaults        0       2
    # swap was on /dev/sdb5 during installation
    UUID=4525d76b-dd14-48e4-b60d-dffee5b08245 none            swap    sw              0       0
    /dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0
    /dev/sr1        /media/cdrom1   udf,iso9660 user,noauto     0       0
    
    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' over 11 years
      Do you want to add more space to /dev/sdb? It's fully partitioned, so you'll have to shrink at least one other partition. What sizes do you want to have?
    • phimath
      phimath over 11 years
      I would like to take 20 gb from sdb6 and put it in sdb1. sdb6 is a logical volume on sdb2.
    • haziz
      haziz over 11 years
      Also for safety, what is currently on sdb1?
    • haziz
      haziz over 11 years
      From what I can see from your fdisk -l output I suspect sdb1 is your root partition already. Can you printout the contents of your /etc/fstab file?
    • phimath
      phimath over 11 years
      sdb1 is my root partition. I added fstab file.
  • Shadur
    Shadur over 11 years
    Concur. I've been using gparted off and on to resize partitions in a virtual server environment, and it works like a charm.
  • Santropedro
    Santropedro over 8 years
    What makes a backup valid?