LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-08-2014, 12:32 PM   #1
pedrofleck
LQ Newbie
 
Registered: Nov 2014
Posts: 10

Rep: Reputation: Disabled
Unhappy Wrongly resized btrfs partition


Hey, I tried to resize a btrfs (almost 550gb used) from 1tb to 800gb, but I accidentally used "btrfs filesystem resize -800g" instead of "btrfs filesystem resize 800g", now "btrfs filesystem show" says "devid 1 size 131.51GiB used 552.03GiB", all (I hope) my files are there, but I can't resize it anymore. What can I do?
 
Old 11-08-2014, 01:40 PM   #2
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Back up your drive entierly (yes, it's a lot of time, but it's have to be done)
Run testdisk. It has an option to recreate partition table.
 
Old 11-08-2014, 02:23 PM   #3
pedrofleck
LQ Newbie
 
Registered: Nov 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
Teufel: I can't open some folders without root, will I have problems if I use "sudo cp"? Is there a chance I lost some files because of that resize? Can I use gparted to recreate the partition table? Thanks!
 
Old 11-08-2014, 02:45 PM   #4
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
It isn't a right way to create backup with cp, tar, rsync or any other utilities that relies on underlying tools. You will get wrong result due to underlying structures (partition table) are wrong
You have to create image. Exact copy of your drive. As it exists right now. If you'll fail for some reason to restore partition table you will be able to reload your current drive state from backup image and try again.
You need tool that works with drive at low level, e.g. dd that creates raw drive image.
And you have to have enough free space outside your drive to save backup image there.

Last edited by Teufel; 11-08-2014 at 02:46 PM.
 
1 members found this post helpful.
Old 11-08-2014, 02:53 PM   #5
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Regarding gparted - I do not know, can it be used to restore partition table or not.
I did it with testdisk (I accidentally erased partition table)
 
Old 11-08-2014, 02:54 PM   #6
pedrofleck
LQ Newbie
 
Registered: Nov 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
Can I use an USB external HDD? Which dd options I should use? And to restore it I use dd again then?
 
Old 11-08-2014, 03:03 PM   #7
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
You can use any storage to save backup image there. The only limitation - it should be larger than your drive (i.e. it should have more that 1Tb of free space) to fit 1Tb file.
To create a backup copy:
dd if=/dev/sdX of=/path/to/save/copy/backup.img bs=4M
If you'll fail with restoring partition table you can apply image back to your drive:
dd if=/path/to/save/copy/backup.img of=/dev/sdX bs=4M

sdX is your drive. Without trailing digit
Take in to account - it will be very long operation.

Last edited by Teufel; 11-08-2014 at 03:05 PM.
 
1 members found this post helpful.
Old 11-08-2014, 03:08 PM   #8
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Take a look here
http://www.cyberciti.biz/open-source...ging-software/
 
Old 11-08-2014, 03:23 PM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
The btrfs command doesn't alter physical partitions - no need to fret over that.
Do not use a 1T drive as backup - it may (will) be a different size to the original. Get a 2 or 4T just in case.
Personally, after dd has finished (that may be days on USB), I would also take a filesystem copy with something like rsync or cp. You can never have too many backups - as I hope the OP has learned.

Btrfs has some interesting notions of (used) space, but this is certainly unusual. May be worth raising a bug, even if only to get an explanation. After you've finished recovery of course.
 
1 members found this post helpful.
Old 11-08-2014, 07:05 PM   #10
pedrofleck
LQ Newbie
 
Registered: Nov 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
Ok, thank you for the answers, I just bought a 2tb external HDD (1 week to arrive, I'm fucked).
But you guys sure it's okay to just use dd and not something more "sophisticated" (like the tools in Teufel's link)? I'm afraid that this doesn't work because of btrfs is screwed up. And what will happen with the "root only" folders after the dd restore? (I don't even know why they are root only)
Another question: which partition you recommend to format the external HDD?
And syg00, I'll try to do a rsync or cp too, but I think it can't be done to the external HDD. And I will bug report it after this!
 
Old 11-08-2014, 09:45 PM   #11
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
Quote:
Originally Posted by pedrofleck View Post
But you guys sure it's okay to just use dd and not something more "sophisticated"
Normaly you'd be right, but for recovery you need an exact copy, errors and all. There's a big chance you'll have to re-do the recovery attempt - you need that exact image.
Note I am not advising using "dd" for normal backups, just recovery/forensic scenarios.
Quote:
Another question: which partition you recommend to format the external HDD?
Shouldn't matter, but something more stable like ext4 may be an idea.
Quote:
I'll try to do a rsync or cp too, but I think it can't be done to the external HDD.
Where did you get that idea - in *nix, it's just a device node, internal or external.
 
Old 11-09-2014, 08:58 AM   #12
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Quote:
Originally Posted by pedrofleck View Post
But you guys sure it's okay to just use dd and not something more "sophisticated" (like the tools in Teufel's link)? I'm afraid that this doesn't work because of btrfs is screwed up. And what will happen with the "root only" folders after the dd restore? (I don't even know why they are root only)
The thing is dd doesn't work with btrfs or ext or ntfs. dd works with hard drive. It reads/writes data directly from drive sector-by-sector regardless what that sectors actually contains. No matter does you filesystem screwed up or not - dd doesn't rely on filesystem information. It is the best way to create exact copy of your hdd, including mbr, partitions table and partitions as is, with damaged partition table and partitions.

Regarding "root folders":
At first: dd does nothing with your folders.
At second: dd doesn't restore. dd just creates exact copy of current drive state.

For restoration there are another tools, like testdisk. If something will go wrong on restoration you will be able to re-apply your backup image to harddrive and try to restore it again.

Last edited by Teufel; 11-09-2014 at 09:07 AM.
 
Old 11-14-2014, 11:53 AM   #13
pedrofleck
LQ Newbie
 
Registered: Nov 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
My external HDD finally arrived. And I was thinking about the "rsync or cp" backup: can I create 2 partitions (like 1.3 and 0.7) and use dd to one and cp to the other? I won't have anything else to use cp if dd finish using the entire disk
EDIT: forget it, I didn't see the .img output, already backing up (2 hours estimated, using pv and USB3)

Last edited by pedrofleck; 11-14-2014 at 03:10 PM.
 
Old 11-14-2014, 08:10 PM   #14
pedrofleck
LQ Newbie
 
Registered: Nov 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
Well, rsync and dd backups are done, and looks like everything is okay in the rsync backup, will be safe to wipe everything in my HD, recreate partition table and new partitions (I'll take the opportunity and use Bcache) and then use rsync to move the files back?

Last edited by pedrofleck; 11-14-2014 at 08:53 PM.
 
Old 11-14-2014, 10:45 PM   #15
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
No. Backup image you created with dd is not for dragging files from there. Rsync backup is useless.
Do not wipe your hdd. You have to restore damaged partition table at hdd, not to wipe it.
For restoration there are few different tools/ways. I would start with testdisk. Another alternative is gparted, but I had a fault with gparted in past, so I wouldn't use it right now. Other alternatives can be googled (as well as how to deal with restoration tools).
Run testdisk on your damaged drive and analize your partition structures.
Testdisk may show few partition that may overlap each other. This case one partitioning schema is wrong and other is correct. You have to chose which one is correct and instruct testdisk to write it to disk. After that check you hdd (partitions, directories, files).

Anyway, do not make any changes on your backup! It's for reading only! If new partition schema created by testdisk will be wrong, you will need to copy you backup to hdd and try to restore it once more. In fact you do not need to copy all the dd image back to hdd, it's enough to copy copy the beginning of the disk that contains partition table.

Last edited by Teufel; 11-14-2014 at 10:48 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I resized a ntfs partition using QtParted... trist007 Linux - Newbie 2 03-23-2009 12:57 AM
Ext4 partition corrupted by resized NTFS Vista C:\ partition? graviton-boson Linux - Newbie 2 03-16-2009 01:26 PM
Recover Data after wrongly Re-create partition mongkokcactus Linux - General 7 12-19-2006 02:02 PM
Root (/) partition resized, but I can't used the additional space. dickgregory Linux - General 2 03-26-2006 09:24 AM
HELP resized partition and lost all data wolfbeast2 Linux - Newbie 15 08-14-2004 07:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration