resize btrfs partition

I wanna resize too btrfs partition shrink home and then move it ( change the cylinder positions) so I can enlarge root parition (/home partition si right after /root physicaly in HDD). And what’s the main problem/question is that physical moving, if it’s possible and how to achieve that?

btrfs is the file system not a partition. Partitions are just containers that contain file system. Thus any partition tools can be used to move and resize. The trick would be the extending of the btrfs file system in a larger partition You will have to dig into the btrfs tools to find out about that.

btrfs filesystem resize -500m to shrink orbtrfs filesystem resize +500m to expand

Yeah I know that command, but I mean like if I shrink (2) could I enlarge the 1, - will the 2 move it’s postition physicaly from cylinder e.g 50000 to 55000 , cause now 1 is : e.g 30000-40000 and 2 is:40000 - 50000 ? so I can be after this op\eration 40000-55000 , you know what i mean. i.e wont it do that 2 will shnrik but from 50000-60000 it’l shrink to 50000-55000 so I can’t enlarge the 1

That is still just the files system you need to first change the partition size and locations. Remember partitions are containers of file system Partitions and file systems are NOT the same thing.

SO first you need to reduce the file system in a partition you are going to reduce. then you need to expand any file system for any partition you make larger.

you can try using GParted

just an FYI, I am pretty sure GParted will work
BUT be VERY VERY VERY careful not to touch any partitions involved in boot process.
also you will need to get the gparted CD and boot from it.

what I think your steps would be (and I tried this in a VM but not with /home as I do not have one):

  1. boot from gparted CD
  2. identify your “/” “/boot” “/home” partitions
  3. shrink your /home partition to desired size
  4. move your home partition as needed
  5. expand / partition as need

do each steps 3,4,5 in order applying changes after each steps so if something go wrong all is not lost
and as always BACKUP FIRST BACKUP FIRST BACKUP FIRST :slight_smile:

PS>> not sure if it applies to you but it is not recommended to move any windows partitions as it will affect the boot process

thats what I thought , so if I boot from /boot parittion so don’t move in any way, but can I move /root then? I mean partitions are recognized in grub by id (whole filesys is on that partition)

I am not sure about /root.
everywhere I looked it is not recommended to move any windows partition and any partition used in boot. as I am not proficient with Linux File system much I personally would not try it, but I am pretty sure you can recover using emergency boot CD or something and re-point grub to the /root partition as needed.

actually my situation changed alittle bit, enough said I’ll rater post this

 df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6        26G   13G   13G  51% /
devtmpfs        1.9G   44K  1.9G   1% /dev
tmpfs           1.9G  2.1M  1.9G   1% /dev/shm
tmpfs           1.9G  5.2M  1.9G   1% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
tmpfs           1.9G  5.2M  1.9G   1% /var/lock
tmpfs           1.9G  5.2M  1.9G   1% /var/run
/dev/sda7        28G   22G  4.4G  83% /home
/dev/sda12      585M  246M  297M  46% /boot
/dev/sda1       197G   99G   88G  53% /run/media/robert/data


so I want/need to move /boot partition and then resize /home (to ease pain in the future put the /boot before /home so I can easily enlarge the /home in the future) and then use Live CD to locate grub to find that /boot parition. I suppose that’d be like proper solution

so I did everything I needed (resized, moved my partitions), but now I’m getting error at grub : no such partition. I tried grub rescue but also with no sucess http://karuppuswamy.com/wordpress/2011/09/09/how-to-fix-grub-rescue-prompt-without-live-cd-for-grub2/

here’s my grub.cfg

 cat grub.cfg#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#


### BEGIN /etc/grub.d/00_header ###
if  -s $prefix/grubenv ]; then
  load_env
fi
if  "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi


if  x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi


export menuentry_id_option


if  "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi


function savedefault {
  if  -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}


function load_video {
  if  x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}


if  x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_msdos
insmod btrfs
set root='hd0,msdos6'
if  x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  7b9d027c-1093-466c-8be4-aea8f94863bc
else
  search --no-floppy --fs-uuid --set=root 7b9d027c-1093-466c-8be4-aea8f94863bc
fi
    font="/usr/share/grub2/unicode.pf2"
fi


if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=POSIX
  insmod gettext
fi
terminal_output gfxterm
insmod part_msdos
insmod ext2
set root='hd0,msdos12'
if  x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos12 --hint-efi=hd0,msdos12 --hint-baremetal=ahci0,msdos12 --hint='hd0,msdos12'  fc017ea6-21ae-4dd9-ac23-53756ffeb8f0
else
  search --no-floppy --fs-uuid --set=root fc017ea6-21ae-4dd9-ac23-53756ffeb8f0
fi
insmod gfxmenu
loadfont ($root)/grub2/themes/openSUSE/DejaVuSans-Bold14.pf2
loadfont ($root)/grub2/themes/openSUSE/DejaVuSans10.pf2
loadfont ($root)/grub2/themes/openSUSE/DejaVuSans12.pf2
loadfont ($root)/grub2/themes/openSUSE/ascii.pf2
insmod png
set theme=($root)/grub2/themes/openSUSE/theme.txt
export theme
if  x${boot_once} = xtrue ]; then
  set timeout=0
elif sleep --interruptible 0 ; then
  set timeout=8
fi
### END /etc/grub.d/00_header ###


### BEGIN /etc/grub.d/10_linux ###
menuentry 'openSUSE 13.1' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-7b9d027c-1093-466c-8be4-aea8f94863bc' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos12'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos12 --hint-efi=hd0,msdos12 --hint-baremetal=ahci0,msdos12 --hint='hd0,msdos12'  fc017ea6-21ae-4dd9-ac23-53756ffeb8f0
        else
          search --no-floppy --fs-uuid --set=root fc017ea6-21ae-4dd9-ac23-53756ffeb8f0
        fi
        echo    'Loading Linux 3.14.0-23.gfa168d7-desktop ...'
        linux   /vmlinuz-3.14.0-23.gfa168d7-desktop root=UUID=7b9d027c-1093-466c-8be4-aea8f94863bc   quiet quiet liveinstall resume=/dev/disk/by-id/ata-WDC_WD7500BPKT-00PK4T0_WD-WXF1E32MVUC9-part5 splash=silent quiet showopts
        echo    'Loading initial ramdisk ...'
        initrd  /initrd-3.14.0-23.gfa168d7-desktop
}
submenu 'Advanced options for openSUSE 13.1' $menuentry_id_option 'gnulinux-advanced-7b9d027c-1093-466c-8be4-aea8f94863bc' {
        menuentry 'openSUSE 13.1, with Linux 3.14.0-23.gfa168d7-desktop' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.14.0-23.gfa168d7-desktop-advanced-7b9d027c-1093-466c-8be4-aea8f94863bc' {
                load_video
                set gfxpayload=keep
                insmod gzio
                insmod part_msdos
                insmod ext2
                set root='hd0,msdos12'
                if  x$feature_platform_search_hint = xy ]; then
                  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos12 --hint-efi=hd0,msdos12 --hint-baremetal=ahci0,msdos12 --hint='hd0,msdos12'  fc017ea6-21ae-4dd9-ac23-53756ffeb8f0
                else
                  search --no-floppy --fs-uuid --set=root fc017ea6-21ae-4dd9-ac23-53756ffeb8f0
                fi
                echo    'Loading Linux 3.14.0-23.gfa168d7-desktop ...'
                linux   /vmlinuz-3.14.0-23.gfa168d7-desktop root=UUID=7b9d027c-1093-466c-8be4-aea8f94863bc   quiet quiet liveinstall resume=/dev/disk/by-id/ata-WDC_WD7500BPKT-00PK4T0_WD-WXF1E32MVUC9-part5 splash=silent quiet showopts
                echo    'Loading initial ramdisk ...'
                initrd  /initrd-3.14.0-23.gfa168d7-desktop
        }
         
### END /etc/grub.d/10_linux ###


### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###


### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry 'openSUSE 13.1 Memtest' --class opensuse --class memtest86 --class gnu --class tools $menuentry_id_option 'memtest-fc017ea6-21ae-4dd9-ac23-53756ffeb8f0' {
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos12'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos12 --hint-efi=hd0,msdos12 --hint-baremetal=ahci0,msdos12 --hint='hd0,msdos12'  fc017ea6-21ae-4dd9-ac23-53756ffeb8f0
        else
          search --no-floppy --fs-uuid --set=root fc017ea6-21ae-4dd9-ac23-53756ffeb8f0
        fi
        echo    'Loading memtest ...'
        linux16 /memtest.bin
}
### END /etc/grub.d/20_memtest86+ ###


### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ###


### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###


### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###


### BEGIN /etc/grub.d/41_custom ###
if  -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif  -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###


### BEGIN /etc/grub.d/90_persistent ###
### END /etc/grub.d/90_persistent ###


 

I try to chroot from live DVD and then do grub2-mkconfig -o /dev/sda7/grub2/grub.cfg path path /boot/grub2 si not readable by grub on boot … I mounted both partition (roo and boot, binded /sys /proc but still no sucess

and I forget here’s my boot paritiion (/dev/sda7)

 cd ../ && ls -la                                                                                                                                                                                   total 239840                                                                                                                                                                                                                                 
drwxr-xr-x  5 root root     4096 Apr  6 08:25 .                                                                                                                                                                                              
drwxr-x---+ 3 root root       60 Apr 14 13:13 ..                                                                                                                                                                                             
-rw-r--r--  1 root root  2681728 Feb  3 23:08 System.map-3.11.10-7-desktop                                                                                                                                                                   
-rw-r--r--  1 root root  2764530 Mar 18 03:39 System.map-3.13.6-19.g4727218-desktop                                                                                                                                                          
-rw-r--r--  1 root root  2764530 Mar 24 12:48 System.map-3.13.6-20.g0509ce5-desktop                                                                                                                                                          
-rw-r--r--  1 root root  2764949 Mar 27 23:58 System.map-3.13.7-21.ga68bc7c-desktop                                                                                                                                                          
-rw-r--r--  1 root root  2798246 Apr  2 00:16 System.map-3.14.0-22.g79de0a7-desktop                                                                                                                                                          
-rw-r--r--  1 root root  2798178 Apr  5 13:29 System.map-3.14.0-23.gfa168d7-desktop                                                                                                                                                          
-rw-r--r--  1 root root      512 Feb 13 09:57 backup_mbr                                                                                                                                                                                     
lrwxrwxrwx  1 root root        1 Nov  6 15:36 boot -> .                                                                                                                                                                                      
-rw-r--r--  1 root root     1484 Oct 18 06:48 boot.readme                                                                                                                                                                                    
-rw-r--r--  1 root root   140316 Feb  3 22:11 config-3.11.10-7-desktop                                                                                                                                                                       
-rw-r--r--  1 root root   143734 Mar 18 02:43 config-3.13.6-19.g4727218-desktop                                                                                                                                                              
-rw-r--r--  1 root root   143723 Mar 24 11:54 config-3.13.6-20.g0509ce5-desktop                                                                                                                                                              
-rw-r--r--  1 root root   143723 Mar 27 22:11 config-3.13.7-21.ga68bc7c-desktop                                                                                                                                                              
-rw-r--r--  1 root root   145895 Apr  1 22:17 config-3.14.0-22.g79de0a7-desktop                                                                                                                                                              
-rw-r--r--  1 root root   145895 Apr  5 11:20 config-3.14.0-23.gfa168d7-desktop                                                                                                                                                              
drwxr-xr-x  2 root root     4096 Nov  6 15:36 grub                                                                                                                                                                                           
drwxr-xr-x  7 root root     4096 Apr  6 07:44 grub2                                                                                                                                                                                          
lrwxrwxrwx  1 root root       33 Apr  6 07:43 initrd -> initrd-3.14.0-23.gfa168d7-desktop                                                                                                                                                    
-rw-------  1 root root 25952424 Apr  6 07:43 initrd-3.11.10-7-desktop
-rw-------  1 root root 26035874 Apr  6 07:43 initrd-3.13.6-19.g4727218-desktop
-rw-------  1 root root 26035513 Apr  6 07:43 initrd-3.13.6-20.g0509ce5-desktop
-rw-------  1 root root 26037137 Apr  6 07:43 initrd-3.13.7-21.ga68bc7c-desktop
-rw-------  1 root root 26028091 Apr  6 07:43 initrd-3.14.0-22.g79de0a7-desktop
-rw-------  1 root root 26028030 Apr  6 07:43 initrd-3.14.0-23.gfa168d7-desktop
drwx------  2 root root    16384 Feb 13 09:51 lost+found
-rw-r--r--  1 root root   176760 Sep 21  2013 memtest.bin
-rw-r--r--  1 root root   620544 Apr  6 07:41 message
-rw-r--r--  1 root root   262119 Feb  3 23:20 symvers-3.11.10-7-desktop.gz
-rw-r--r--  1 root root   299529 Mar 18 03:51 symvers-3.13.6-19.g4727218-desktop.gz
-rw-r--r--  1 root root   299526 Mar 24 13:02 symvers-3.13.6-20.g0509ce5-desktop.gz
-rw-r--r--  1 root root   299515 Mar 28 00:18 symvers-3.13.7-21.ga68bc7c-desktop.gz
-rw-r--r--  1 root root   301247 Apr  2 00:39 symvers-3.14.0-22.g79de0a7-desktop.gz
-rw-r--r--  1 root root   301247 Apr  5 13:50 symvers-3.14.0-23.gfa168d7-desktop.gz
-rw-r--r--  1 root root      516 Feb  3 23:19 sysctl.conf-3.11.10-7-desktop
-rw-r--r--  1 root root      516 Mar 18 03:51 sysctl.conf-3.13.6-19.g4727218-desktop
-rw-r--r--  1 root root      516 Mar 24 13:02 sysctl.conf-3.13.6-20.g0509ce5-desktop
-rw-r--r--  1 root root      516 Mar 28 00:17 sysctl.conf-3.13.7-21.ga68bc7c-desktop
-rw-r--r--  1 root root      516 Apr  2 00:38 sysctl.conf-3.14.0-22.g79de0a7-desktop
-rw-r--r--  1 root root      516 Apr  5 13:50 sysctl.conf-3.14.0-23.gfa168d7-desktop
-rw-r--r--  1 root root  6039636 Feb  3 23:19 vmlinux-3.11.10-7-desktop.gz
-rw-r--r--  1 root root  6253161 Mar 18 03:51 vmlinux-3.13.6-19.g4727218-desktop.gz
-rw-r--r--  1 root root  6253012 Mar 24 13:01 vmlinux-3.13.6-20.g0509ce5-desktop.gz
-rw-r--r--  1 root root  6253098 Mar 28 00:17 vmlinux-3.13.7-21.ga68bc7c-desktop.gz
-rw-r--r--  1 root root  6306740 Apr  2 00:38 vmlinux-3.14.0-22.g79de0a7-desktop.gz
-rw-r--r--  1 root root  6307237 Apr  5 13:50 vmlinux-3.14.0-23.gfa168d7-desktop.gz
lrwxrwxrwx  1 root root       34 Apr  6 07:42 vmlinuz -> vmlinuz-3.14.0-23.gfa168d7-desktop
-rw-r--r--  1 root root  5179304 Feb  4 00:52 vmlinuz-3.11.10-7-desktop
-rw-r--r--  1 root root  5330736 Mar 18 05:22 vmlinuz-3.13.6-19.g4727218-desktop
-rw-r--r--  1 root root  5330800 Mar 24 16:58 vmlinuz-3.13.6-20.g0509ce5-desktop
-rw-r--r--  1 root root  5330928 Mar 28 02:57 vmlinuz-3.13.7-21.ga68bc7c-desktop
-rw-r--r--  1 root root  5375008 Apr  2 02:50 vmlinuz-3.14.0-22.g79de0a7-desktop
-rw-r--r--  1 root root  5375424 Apr  5 17:17 vmlinuz-3.14.0-23.gfa168d7-desktop


 

On 2014-04-14 16:06, roberto68 wrote:
>
> so I did everything I needed (resized, moved my partitions), but now I’m
> getting error at grub : no such partition. I tried grub rescue but also
> with no sucess http://tinyurl.com/82jr76n

Forget it, and waste no more time: reinstall.

I assume that you did a full backup before doing such a dangerous
procedure as resizing partitions, so just reformat it all, reinstall,
and recover your files from that backup.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

No you don’t, because the only reason someone might spend all that time trying is because they do not have a backup. :wink:

On 2014-04-15 13:16, consused wrote:
>
> robin_listas;2637019 Wrote:
>>
>> I assume that you did a full backup before doing such a dangerous
>> procedure as resizing partitions…
>>
> No you don’t, because the only reason someone might spend all that time
> trying is because they do not have a backup. :wink:

Oh, you are naughty! :wink: :-))


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

I didn’t do backup cause I only resize (enlarge) home and move boot and whole root remained untouched (but no problem copying it from live CD session). But tas I explore it via Live session these parititons & files in them are just fine. so there must be a way to recover that grub that’s all I need - respectively what to type at that grub rescue prompt. I tried to install another suse to create another “clean” grub but installation stucked somewhere at copaying root filesys, maybe I’ll burn that live image on that dvd again

This won’t work. grub2-mkconfig cannot write to a device directly.
Use something like this:

grub2-mkconfig -o /wherever_you_mounted_boot_to/grub2/grub.cfg

Then run “grub2-install /dev/sda”. And maybe try to specify the “–force” option:

grub2-install --force /dev/sda

Anytime you do anything to a partitions you have the potential of messing it all up. Power fails you take the wrong option any number of things can go wrong and you can lose it all. Always backup before doing any brain surgery

On 2014-04-15 15:36, roberto68 wrote:
>
> I didn’t do backup cause I only resize (enlarge) home and move boot and

Only!!!? That’s a terrible death danger!

> whole root remained untouched (but no problem copying it from live CD
> session). But tas I explore it via Live session these parititons & files
> in them are just fine. so there must be a way to recover that grub
> that’s all I need - respectively what to type at that grub rescue
> prompt.

You can chroot your system from another, then try to run yast boot manager.

You can download this script:

bootinfoscript

which will find a lot of information about your current boot system.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

when i’m adding menuentry in grub manually should set root be set to boot partition? i.e.

set root =hd0,msdos7 

msdos7 - is my /boot paritition ; msdos6 - is /root