Slackware 13.37 - Shrink reiserfs filesystem without losing data ================================================================ Public domain ******************************************************************************** ### Check partitions status root@uranus:~# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/root reiserfs 49G 48G 1.3G 98% / /dev/sda3 reiserfs 416G 2.0G 414G 1% /storage tmpfs tmpfs 986M 0 986M 0% /dev/shm ******************************************************************************** ### un-mount partition root@uranus:~# umount /dev/sda3 ******************************************************************************** ### Check reiserfs filesystem root@uranus:~# reiserfsck --check /dev/sda3 reiserfsck 3.6.21 (2009 www.namesys.com) ************************************************************* ** If you are using the latest reiserfsprogs and it fails ** ** please email bug reports to reiserfs-list@namesys.com, ** ** providing as much information as possible -- your ** ** hardware, kernel, patches, settings, all reiserfsck ** ** messages (including version), the reiserfsck logfile, ** ** check the syslog file for any related information. ** ** If you would like advice on using this program, support ** ** is available for $25 at www.namesys.com/support.html. ** ************************************************************* Will read-only check consistency of the filesystem on /dev/sda3 Will put log info to 'stdout' Do you want to run this program?[N/Yes] (note need to type Yes if you do):Yes ########### reiserfsck --check started at Thu Apr 5 18:01:14 2012 ########### Replaying journal: Done. Reiserfs journal '/dev/sda3' in blocks [18..8211]: 0 transactions replayed Checking internal tree.. finished Comparing bitmaps..finished Checking Semantic tree: finished No corruptions found There are on the filesystem: Leaves 499 Internal nodes 4 Directories 4 Other files 56 Data block pointers 501231 (0 of them are zero) Safe links 0 ########### reiserfsck finished at Thu Apr 5 18:01:38 2012 ########### ******************************************************************************** ### shrink reiserfs filesystem root@uranus:~# resize_reiserfs -s 50G /dev/sda3 resize_reiserfs 3.6.21 (2009 www.namesys.com) You are running BETA version of reiserfs shrinker. This version is only for testing or VERY CAREFUL use. Backup of you data is recommended. Do you want to continue? [y/N]:y Processing the tree: 0%....20%....40%....60%....80%....100% left 0, 9837 /sec nodes processed (moved): int 4 (4), leaves 499 (481), unfm 501231 (486441), total 501734 (486926). check for used blocks in truncated region ReiserFS report: blocksize 4096 block count 13107200 (109034240) free blocks 12596856 (108520968) bitmap block count 400 (3328) Syncing..done resize_reiserfs: Resizing finished successfully. ******************************************************************************** ### Shrink partition size root@uranus:~# fdisk /dev/sda Command (m for help): p Disk /dev/sda: 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: 0x33683367 Device Boot Start End Blocks Id System /dev/sda1 2048 2099199 1048576 82 Linux swap /dev/sda2 2099200 104499199 51200000 83 Linux /dev/sda3 104499200 976773167 436136984 83 Linux Command (m for help): d Partition number (1-4): 3 Command (m for help): p Disk /dev/sda: 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: 0x33683367 Device Boot Start End Blocks Id System /dev/sda1 2048 2099199 1048576 82 Linux swap /dev/sda2 2099200 104499199 51200000 83 Linux Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4, default 3): 3 First sector (104499200-976773167, default 104499200): Using default value 104499200 Last sector, +sectors or +size{K,M,G} (104499200-976773167, default 976773167): +50G Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. ******************************************************************************** ### Reboot the system reboot ******************************************************************************** _BY: Pejman Moghadam_ _TAG: partitioning, reiserfs, shrink, resize, fdisk_ _DATE: 2012-04-07 16:21:54_