Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Copying /var from another system : possible ?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Tue Dec 11, 2018 4:46 pm    Post subject: Copying /var from another system : possible ? Reply with quote

Hi,

I have a BananaPI to crontrol my home.
The system is on an SD card but /var is on an hard disk ... that just died :( And obviously, no-backup.
Thanks to this SD card, the system is booting but obviously with an empty /var.

I have a "twin" system on which I'm testing upgrades which is still perfectly running.
Is it possible to copy this machine's content to replace lost data ?

If I do so, I'm pretty sure portage will be confused about installed software version : any why to correct that as well ?

Thanks

Laurent
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9679
Location: almost Mile High in the USA

PostPosted: Tue Dec 11, 2018 6:42 pm    Post subject: Reply with quote

As a stop gap, might well copy, but it really has no value to the actual setup. And yeah, losing /var/db/pkg would suck bad. If your mirror is identical with the same packages and versions installed, you may be in luck; but if you made changes to either, you'll have trouble down the road with just a simple copy.

Reinstall might be your best bet if you want to keep that machine up to date, unfortunately /var/lib/portage/world also got lost ...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Tue Dec 11, 2018 7:07 pm    Post subject: Reply with quote

I need to ask the inevitable: You're running Gentoo or something else?

Not trying to shoo you out the door if you're not running Gentoo but clearly this changes how we answer questions.

/var is a bag of cats. Some subdirectories it would be safe if nonsensical to copy over, like /var/log. You would be transferring information from your other system which would cause your destination system to lose its mind somewhat. /var/lib and the like might work if you have exactly or almost exactly the same components in the two machines, I might do that to make your broken system functional long enough to get a backup of lost data. Data directories for system processes would be pretty useless IMO, like DHCP leases and such.

One of the things I feel is most valuable to back up is a list of "human-installed" packages as a text file suitable to be used by the package manager, preferably in order of being installed. The last part doesn't usually matter but in the case of some laser printer driver components I've found that it does.

I don't backup binaries because a single system update trashes all the viability of your backup. When it comes to /var I am very selective about what gets backed up and what doesn't. Often as not copying an alien system's /var across will break your system rather than fixing it.
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Tue Dec 11, 2018 8:35 pm    Post subject: Reply with quote

Thanks for your replies.

1clue wrote:
I need to ask the inevitable: You're running Gentoo or something else?

It's Gentoo :)

eccerr0r wrote:
If your mirror is identical with the same packages and versions installed, you may be in luck; but if you made changes to either, you'll have trouble down the road with just a simple copy.

Unfortunately, the "source" environment will be a bit ahead : it's the binhost of the dead one and I was on way to upgrade.

eccerr0r wrote:
And yeah, losing /var/db/pkg would suck bad. [...] Reinstall might be your best bet if you want to keep that machine up to date, unfortunately /var/lib/portage/world also got lost ...

If I'm able to resuscitate the disk for some minutes, which are all the minimal files to recovers from /var ? /usr, /etc, ... are on the SD and still good.

1clue wrote:
One of the things I feel is most valuable to back up is a list of "human-installed" packages as a text file suitable to be used by the package manager, preferably in order of being installed.

/home is lost as on the same disk (2To of movies into the trashcan :( but I don't care). All priceless files like personal photos or videos are safe on 2 other backup systems, as well as configuration files.

Bye
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Tue Dec 11, 2018 8:51 pm    Post subject: Reply with quote

Congratulations and condolences. I installed Gentoo onto a Raspberry Pi b+ and got a running system, then decided to scrap it because a kernel took 12 hours to build. Updates and building the updates literally took the entire system time.

I won't rant about backups. You clearly know the pros and cons.

If the broken system is a binhost off your "source" system then this might not be terrible. Copying files from /var and other places will give nonsensical info in places, but since you're going to copy much of that over anyway, maybe just pretend it's an update but copy the entire directories for the parts you lost? Before you try that be aware I've never done a binhost setup.

I've managed to trash a stack of irreplaceable family photos, that's the worst. And it wasn't a disk error, it was me being stupid.
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Tue Dec 11, 2018 9:17 pm    Post subject: Reply with quote

1clue wrote:
Congratulations and condolences. I installed Gentoo onto a Raspberry Pi b+ and got a running system, then decided to scrap it because a kernel took 12 hours to build. Updates and building the updates literally took the entire system time.

I'm stick on the 3.14 kernel as I can't find a DTS for the 3'5 LCD screen I'm using : so I did it once on a PC.
For upgrading, having 2 Bananas + an i7 on my distcc farm, compile time are quite decent ... but for Gcc obviously. For this particular case, I don't care if it took 5 or 6 hours to compile nightly :)

1clue wrote:
I won't rant about backups. You clearly know the pros and cons.

Probably, we have to establish a list of "must to be saved" files :)
I thought I was safe by backing up configuration files ... but it wasn't enough.

1clue wrote:
If the broken system is a binhost off your "source" system then this might not be terrible.

It's the revers, it's the target that died.

1clue wrote:
I've managed to trash a stack of irreplaceable family photos, that's the worst. And it wasn't a disk error, it was me being stupid.

A common mistake :) I did the same by reformating my gopro : a full ski photos gone :(
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9679
Location: almost Mile High in the USA

PostPosted: Wed Dec 12, 2018 4:46 am    Post subject: Reply with quote

If you have a chance to recover the disk, recover your irreplaceable files first in /home. Don't worry about /var : it's mostly configuration and metadata. You can always reinstall which will rebuild all those files in /var. The only exceptions I can think of perhaps is to save mysql and libvirt data which I don't understand why their data lives there.

/var/cache - junk
/var/db - metadata
/var/log - logfiles... you may or may not want to save these, perhaps for forensics.
/var/spool - may contain new mail and queued stuff, perhaps mbox mail should be saved from this directory.
/var/lib - miscellaneous configuration and state files. At least on my system, again, app-emulation/libvirt and dev-db/mysql data should be saved. You might want to save iptables, and portage/world file to know what you had installed before.
/var/www - another wtf why this lives here, if you have www-servers/apache the base webpages are here by default.

This is just a partial list based on stuff on my machine, so it may not be enough for yours.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Wed Dec 12, 2018 11:51 am    Post subject: Reply with quote

So, this is the content of my "twin" system :

Code:
torchwood /var # du -hs * | sort -n
0   lock
0   mail
0   run
0   tmp
4,0K   empty
7,9M   cache
16K   www -> don't care, my real websites are elsewhere
32K   bind -> [b]YES[/b] : named configuration
48K   spool
65M   db -> [b]YES[/b] : containing my valuable (and late) portage stuffs
109M   log
449M   lib


In lib : all because I duno exactly what is inside but :
Code:

torchwood /var # du -hs lib/* | sort -n
4,0K   lib/arpd
4,0K   lib/dav
4,0K   lib/dbus
4,0K   lib/deluge
4,0K   lib/iptables
4,0K   lib/mediatomb
8,0K   lib/eselect-php
8,0K   lib/lock
8,0K   lib/ntp
12K   lib/misc
12K   lib/owfs
20K   lib/dhcp
20K   lib/gentoo
20K   lib/portage
20K   lib/syslog-ng
24K   lib/alsa
24K   lib/pulse
44M   lib/layman
140K   lib/mosquitto : I think it's its internal DB for on flight ... don't care but [b]YES[/b] ?
405M   lib/postgresql : [b]NO[/b] but configuration files


Do you agree with that ?
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9679
Location: almost Mile High in the USA

PostPosted: Wed Dec 12, 2018 5:15 pm    Post subject: Reply with quote

Seems reasonable, but it's kind of hard knowing in advance what to and what not to back up. I end up simply backing up all of /var as even metadata is valuable, plus all those sneaky software that saves important data there...

Technically speaking, if it comes down to it, /var/db/pkg does not get backed up if I also don't care about /usr/lib, /bin, et cetera... either both or neither get backed up...

I had to type out et cetera because /etc is definitely something that should get backed up :)
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Wed Dec 12, 2018 5:35 pm    Post subject: Reply with quote

ok, but in my case, I don't care as /usr, /etc are not in the same disk (an SDcard).
If this SD died, I have no other choice than a full system reinstall.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Wed Dec 12, 2018 8:58 pm    Post subject: Reply with quote

destroyedlolo,

See if you can image the dead HDD with ddrescue then work on the image.
If the electronics has failed, its dead. If its the mechanics, you might get one last read.

You must create the log file. ddrescue will use it to resume, if you run it several times. You will.

Going with its a mechanical failure, run ddrescue with the drive in its normal operating position.
Now run it 5 more times, with the drive on each face and edge. If you get bored, try other random positions too.
The aim is to use gravity to help align things.

If possible, do not operate the drive in a USB enclosure while you rescue it. Read errors will cause bus resets and some commands that ddrescue may want to use may not be supported by the USB to HDD chipset.

ddrescue can be quite aggressive in sneaking up on the data to get one more read. The more aggressive you tell it to be the longer it will take, so see how much you can get 'easily'.
Don't power the drive down, it may never power up again.

I've had to do some of this myself. I had two drives drop out of a raid5 15 minutes apart, so I didn't have much choice.
I've had other HDD failures too.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Mon Dec 17, 2018 10:21 am    Post subject: Reply with quote

Hi,

The disk is continually stopping / restarting ... so my guess is an electronic failure.

I will try :
* to put it on a PC on which the power supply is far more powerful and probably stable vs the phone adapter I'm using on my bPI
* if it still failing, I'll try to put it on a fridge for some minutes before another try : I've been able to save lot of valuable data from another dying disk using that.

Related to that : are SATA disk hotplugable ?
My try will be to first start the PC and then plug the disk to reduce it's "working" time. But will it be detected by my Gentoo ?

And, I'll cross my finger at each attempt that will probably help too :roll: :roll:

Bye
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Mon Dec 17, 2018 3:15 pm    Post subject: Reply with quote

destroyedlolo wrote:
Hi,

The disk is continually stopping / restarting ... so my guess is an electronic failure.

I will try :
* to put it on a PC on which the power supply is far more powerful and probably stable vs the phone adapter I'm using on my bPI
* if it still failing, I'll try to put it on a fridge for some minutes before another try : I've been able to save lot of valuable data from another dying disk using that.

Related to that : are SATA disk hotplugable ?
My try will be to first start the PC and then plug the disk to reduce it's "working" time. But will it be detected by my Gentoo ?

And, I'll cross my finger at each attempt that will probably help too :roll: :roll:

Bye


You're not using an external power supply for the disk drive? That's your problem right there then, unless by repetition you've done enough damage to something else (electronics or surface or ??) that there might be two problems now.

Re: SATA hot-pluggable. Yes and no. A USB drive enclosure containing a SATA drive can be plugged in while the system is running, and it can be unmounted and then removed while the system is running. There are extra considerations for server-grade hotpluggable hardware.
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Mon Dec 17, 2018 3:40 pm    Post subject: Reply with quote

1clue wrote:
You're not using an external power supply for the disk drive? That's your problem right there then, unless by repetition you've done enough damage to something else (electronics or surface or ??) that there might be two problems now.

It is designed for that : there is a "way thru" from the bPI alimentation to a connector on wish we can power a 2''5 disk, 5v only. And it worked like a charm for 4+ years before my disk decided to pass away.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Mon Dec 17, 2018 3:44 pm    Post subject: Reply with quote

destroyedlolo,

The bPi PSU will not power a HDD of any sort. It might manage a USB stick, if you are lucky.
You need a USB Y cable to make this work, where one branch of the Y is data only and connects to the bPi and the other branch is power only and provides power to the HDD.
I made my own by cutting up two USB cables and doing a little soldering.

SATA is designed to be hot pluggable. That's why the pins in the connectors are different lengths.
However, in some some chipsets, the hot plug is badly implemented, so it may not work.
Its harmless to try.

I suspect that the continual PSU 'brownout' situation has damaged the filesystem rather than the drive, in which case the ddrescue operation will work but the filesystem in the image will be a faithful copy of the damaged original.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Tue Dec 18, 2018 1:39 pm    Post subject: Reply with quote

Well well well : putting the disk in a "normal" PC make it working like a charm, so I'm able to recover everything.
It makes some mechanical noise so I suspect there is too much loss in the power path or the PSU is dying facing load.

Or it's because it is flat (I duno if it's the correct wording) and not vertical, I need to make more test.

Anyway, if it's again the PSU, it seems they are only crap and works only for 2 or 3 years 24/24 before starting to die, so I'll improve the way I power my stuffs : I'll use a 12V PSU with a DC-DC step down like this one, with a direct disk powering.
As the amperage will be lower, I hope a better life duration AND will be able to use a 3.5'' disk if needed.

As I already bought another disk, I'll use it to put in place another backup place, for large video this time (before, I didn't care but kids challenged me about this loss :) ).
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Tue Dec 18, 2018 3:07 pm    Post subject: Reply with quote

@destroyedlolo,

It's not about a crap power supply. These hobby boards are designed to be inexpensive, and part of that means they are not designed to have a USB hard drive powered from the board while getting full utilization of the rest of the board. If you want something that can power the USB drive directly, then get a regular consumer device and pay full price for it.

I have several Raspberry Pi's. I've reviewed the specs of many other hobby boards. I'm a member of multiple forums/groups for the pi. One disturbing tendency is that people buy a $35 computer (or in your case $100, or whatever) and believe there are no weaknesses in the product. They fully expect them to keep up with a $1000 laptop, and can't understand why they wouldn't.

These boards are not designed to be a regular desktop computer. They're designed to control a robot or a smart home, and to tolerate an amateur with a soldering iron and an imperfect understanding of electronics.

Edit: The thing to make sure of is that when you put a bigger supply on your board, you don't allow too much current to pass through the board itself. Remember you're running Gentoo on this. Your CPU will be pulling max current during compilation. You're also powering a USB drive through the port, which is beyond the intended design, especially when both high-current situations have been combined. To date you've been using a marginal power supply (proved by the drive working correctly on standard pc hardware) so your system hasn't had the opportunity to draw too much current for the board to handle. By putting in a larger supply you risk the possibility of burning out your board.
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Wed Dec 19, 2018 8:55 pm    Post subject: Reply with quote

Well well, I had a look on what I did 2 years back when the previous PSU died and ... the disk is directly connected to the power supply.
So, definitively, it's a PSU issue :(

I'll try with a 12v PSU with the converter mentioned above, hopping it can have a longer life.

1clue wrote:
I'm a member of multiple forums/groups for the pi. One disturbing tendency is that people buy a $35 computer (or in your case $100, or whatever) and believe there are no weaknesses in the product. They fully expect them to keep up with a $1000 laptop, and can't understand why they wouldn't. These boards are not designed to be a regular desktop computer.

Totally agree ...

1clue wrote:
They're designed to control a robot or a smart home, and to tolerate an amateur with a soldering iron and an imperfect understanding of electronics.

Exactly the role of mine : smart home automation + various network services (web, dlna, ...). And it suites perfectly my needs and has lot of free resources for other duties.
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2569

PostPosted: Wed Dec 19, 2018 9:27 pm    Post subject: Reply with quote

...directly to what PSU? Are you running both the pi and the hdd from the same supply? Is the PSU rated for continuous current in the rage you're using?

There's a difference between a PSU running at full capacity part of the time with long stretches of lower output, and a PSU running flat out for hours straight. If you're running Gentoo on any sort of hobby board and a spinning USB disk as well, then you're running flat out for hours for compilations, and you're running the disk at the same time you're running your CPU flat out. That's something I'd never expect a wall wart to handle, unless you have like a laptop PSU or something.

I can say with significant certainty that the builders of the Banana Pi did not anticipate it to compile a source-based operating system every time you get an update. That constitutes heavy use of resources. I can also say that their typical use case does not include a USB hdd, especially not with both the board and the hdd driven from the same power supplly.

Personally I would use a separate supply for the USB drive, and make sure it handles the full load of the drive. And then another separate supply for the hobby board, and make sure you're giving it the full current capacity specified by the board.
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Thu Dec 20, 2018 8:35 pm    Post subject: Reply with quote

It's a 3A. I did a full check of the chain.
  • the PSU started to drop voltage when facing load, about 1A
  • there is also a drop in cable itself (despite a used 75mm2 cables !)
  • the drive itself consumes a but more than at the begging.

So, all in all, the voltage drop makes the disk to restart when it had lot of I/O and a consequent CPU load.

So :
  • I switched to a 12v PSU + the converter above : the PSU is less loaded and the cable drop reduced dramatically.
  • I've put a 2200uF capacitor to level pic load (decoupling)


You're right, it's not an ideal solution but a PC power supply is consuming a lot for itself.

Quote:
I can say with significant certainty that the builders of the Banana Pi did not anticipate it to compile a source-based operating system every time you get an update.

In fact, I compile on another bPI powered with a recycled PC PSU and use it as a binhost. To speed up things, some PCs are participating to a distcc "compile farm".
The only compilation that stands for hours is for GCC update (so, on by binhost). Otherwise, upgrades remains decents :)

So ... my smart home automation is back, I didn't loose films it seems but I have to rethink my backup procedure to ensure I can restore my system if the OS memory card is safe but /var gone.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum