You are not logged in.

#1 2011-05-27 08:34:50

poltak
Member
From: Hong Kong
Registered: 2010-11-05
Posts: 32

Possible to "image" current Arch install to avoid re-installing?

Hi guys.

Introduction:
Well, currently I have a netbook with Arch installed and highly customized and configured to work with ideally netbook (which took me quite a while). Anyway, recently I purchased an 128GB SSD and have been using it now with a fresh install of Arch for about a month. And only in the last week did I properly realise how an SSD should be configured and used to prolong it's life and boost it's performance... silly me. Anyway, one of the main configurations people are talking about (along with the Arch Wiki SSD page) is proper partition alignment.

Actual Question:
So yeah, I want to know if there is any easy way to create an "image" of my current Arch install/partitions, partition the SSD and then "re-image" it back to how it was before? Is there a piece of software that can do this easily? Also, my partitions are currently:
/dev/sda1      4GB swap (currently not mounted in fstab, and not planning to use again as my 2GB RAM is sufficient)
/dev/sda2     10GB ext4 (/)
/dev/sda3    114GB ext4 (/home)

I'm going to get rid of my swap and instead, take a few GB out of my /home partition to make an extra 15-20GB partition for Joli OS or Chromium OS. But other than this, my partitions will remain pretty much the same. I just thought this would be important to tell me whether or not imaging is possible if I change my partitions a bit.

Also, the data on the partitions is no where near 100%. According to disk usage analyzer, I'm only using ~5.8GB on / and ~1.5GB on /home (I should've bought a 64GB SSD =.=).

Anyway, thanks a lot for your time. Hope you can help.


I like Arch

Offline

#2 2011-05-27 08:45:40

yell!
Member
Registered: 2011-05-16
Posts: 48

Re: Possible to "image" current Arch install to avoid re-installing?

In my opinion (I'm newbie):

you can clone the partition images with Clonezilla or PING (Partimage Is Not Ghost) and do all you need to reconfigure your partition table.
But, if you use olny linux distros on your netbook, I suggest you to use LVM: it is the best way to have a flexible installation.

Offline

#3 2011-05-27 09:57:30

lukaszan
Member
Registered: 2011-05-05
Posts: 117

Re: Possible to "image" current Arch install to avoid re-installing?

You can simply tar the whole filesystem:

tar cvpfJ arch.tar.xz --one-file-system /root-partition

Then just untar it to a new partition. I'd suggest running it on 'inactive' arch (say from live CD), althugh you can do it on a running system if you exclude /proc /sys /tmp and /dev

Offline

#4 2011-05-27 10:59:09

poltak
Member
From: Hong Kong
Registered: 2010-11-05
Posts: 32

Re: Possible to "image" current Arch install to avoid re-installing?

Thanks for the fast replies smile

lukaszan wrote:

You can simply tar the whole filesystem:

tar cvpfJ arch.tar.xz --one-file-system /root-partition

This actually works? It seems so simple. And it will work properly even if I resize partitions? What about currently installed applications and all that? Will my whole system run exactly the same as it was after I untar everything back into place?

Even after using Linux for a long time, I still feel like such a newbie with this stuff tongue I'll have a look at those apps as well yell!. The tar method seems the easiest to me so far, but LVM keeps popping up everywhere I look now in Linux that it seems like something I should make myself aware of. Thanks again, guys.


I like Arch

Offline

#5 2011-05-27 11:36:56

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: Possible to "image" current Arch install to avoid re-installing?

The tar definitely works, if you can plug in both drives at the same time (maybe in your desktop) a regular "cp -a" is even simpler.
I've done this multiple times in the past to migrate an install to another hdd and it has always worked flawlessly.

Just make sure you:
* Reinstall grub to the mbr (or whatever bootloading method you use)
* Double check /etc/fstab: - if you use UUIDs, those will change
                                           - if you use labels make sure to label your new partitions correctly
                                           - if you use raw device nodes (/dev/sda) read this wiki article
* Have a backup in place, you never know what might happen (e.g. a power outage)

Offline

#6 2011-05-27 11:40:42

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: Possible to "image" current Arch install to avoid re-installing?

lukaszan wrote:

You can simply tar the whole filesystem:

tar cvpfJ arch.tar.xz --one-file-system /root-partition

Then just untar it to a new partition. I'd suggest running it on 'inactive' arch (say from live CD), althugh you can do it on a running system if you exclude /proc /sys /tmp and /dev

There are some files in /dev/ that are statically created at install time, you need to copy those too!
I think you need these:

/dev/console
/dev/initctl
/dev/zero
/dev/null

The safest way is to just copy the whole / while the system is not running, as you mentioned before.

Offline

#7 2011-05-27 11:50:04

poltak
Member
From: Hong Kong
Registered: 2010-11-05
Posts: 32

Re: Possible to "image" current Arch install to avoid re-installing?

Alright, lovely. I might try this tar method now. So it's better to do it from live CD and just copy (or tar) it to an external drive (my netbook's a real bother to take apart to get the disk)?

So with my partitions in mind, would you recommend making two tar archives, one for the / directory and the other for /home?
Like:
tar cvpfJ archHome.tar.xz --one-file-system /home
and
tar cvpfJ archRoot.tar.xz --one-file-system /

Is the proper way to do it? Then when I have a core system installed again I'd just tar xvf it back into place (and overwrite/merge existing folders), right? And I suppose reboot...


I like Arch

Offline

#8 2011-05-27 12:29:15

lukaszan
Member
Registered: 2011-05-05
Posts: 117

Re: Possible to "image" current Arch install to avoid re-installing?

About the /dev, I think you are right. In Slackware there was a package called 'dev' which had all the essential files, I'm sure there is something similar in Arch (sorry, new to Arch).

Actualy now that I think of it, if you do it from live CD, you may skip --one-file-systems bit and do 2 archives, 1 for each partition.

And yes, it IS that simple.

Offline

#9 2011-05-27 13:08:51

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: Possible to "image" current Arch install to avoid re-installing?

poltak wrote:

Then when I have a core system installed again I'd just tar xvf it back into place (and overwrite/merge existing folders), right? And I suppose reboot...

No, no, don't install a core system! Just repartition your drive and put all data back onto the empty partition. You then have your exact same install again, just with the partitions aligned differently.

Offline

#10 2011-05-27 13:19:26

poltak
Member
From: Hong Kong
Registered: 2010-11-05
Posts: 32

Re: Possible to "image" current Arch install to avoid re-installing?

Ramses de Norre wrote:

Just repartition your drive and put all data back onto the empty partition. You then have your exact same install again, just with the partitions aligned differently.

Even more simple now tongue Alright, but just another newbie question I thought of about this:
What happens if I do:
tar cvpfJ archRoot.tar.xz /

Won't that also recursively include all the subdirectories of /, including /home (which I want to be seperate)? Or will some lovely magic happen here, and it will miss out /home since it's not on the same partition?

EDIT: and that is the correct command I want to use to backup my root partition, right? (and just substitute / for /home for the home partition?)

Last edited by poltak (2011-05-27 13:20:26)


I like Arch

Offline

#11 2011-05-27 13:25:30

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: Possible to "image" current Arch install to avoid re-installing?

I guess, the tar manpage can tell you that for sure. BTW, if you do this from a live disc, as I suggested before, then /home isn't mounted.

Personally, I'd just do a cp -a or rsync to an external disc or an sshfs mount and then copy it back afterwards. I once had a corrupted tar archive and don't trust tar for backup purposes anymore.

Offline

#12 2011-05-27 13:33:30

poltak
Member
From: Hong Kong
Registered: 2010-11-05
Posts: 32

Re: Possible to "image" current Arch install to avoid re-installing?

Ramses de Norre wrote:

Personally, I'd just do a cp -a or rsync to an external disc or an sshfs mount and then copy it back afterwards.

Didn't even think of that... this is going to be simple now smile And sorry, but why shouldn't /home be mounted in a Live environment when doing this? But seeing as I'll just do this over ssh (non-live), I shouldn't need to worry.

Anyway, I'll do this tomorrow morning (it's late now). And get back with the results and/or any problems that I'll (most likely) get into...

Thanks a lot everyone smile If anyone's got anything additional to mention, please do.


I like Arch

Offline

#13 2011-05-27 13:42:47

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: Possible to "image" current Arch install to avoid re-installing?

poltak wrote:

And sorry, but why shouldn't /home be mounted in a Live environment when doing this? But seeing as I'll just do this over ssh (non-live), I shouldn't need to worry.

I meant that your home partition wont be mounted on the /home direction of your root, of course you should manually mount it somewhere in order to access its data.

Be very careful when doing this from a running system, you don't want to copy stuff like /proc, /sys, /tmp and udev-created nodes in /dev .

Last edited by Ramses de Norre (2011-05-27 13:43:33)

Offline

#14 2011-05-30 02:52:20

poltak
Member
From: Hong Kong
Registered: 2010-11-05
Posts: 32

Re: Possible to "image" current Arch install to avoid re-installing?

Alright... back after a few days. After spending over 12 hours straight yesterday on trying to get a GPT configured on my SSD, I've given up as I could not get grub2 working with it at all. Very frustrating weekend involving many SSD partitions (goodbye SSD long-life). Not really recommended if you're a computer newbie such as myself.
Plus at one point I thought I was sshfs'd into my main computer's /home/USER/test/ directory when it was actually /home/USER/ and managed to delete half my home directory with "rm -r"... yes, I'm a dumbass smile

Anyway, back to the issue of this thread:
So I gave up and went back just to a standard MBR table with:

sda1    /boot     100MiB
sda2    /                 20GiB
sda3    /home ~100GiB

So as you can see, the only thing different is the /boot partition (which I configured correctly and got it working perfectly with grub-legacy) and the deletion of swap. And yes, I did configure my /etc/fstab properly to accomodate the changes.
Anyway, the thing is now, when I try to log into my user (/home/poltak) in gnome-shell, it doesn't like it returning an error box saying

Could not update ICEauthority file /home/poltak/.ICEauthority

and only gives me the option to log back out to GDM. I also found out that I can't log in as user in any virtual-terminal/tty session.

After a bit more investigation from logging in as root, I realised there is nothing in my /home directory, as if /dev/sda3 isn't being mounted properly. I try

# mount /dev/sda3 /home/

but get

mount: /dev/sda3 already mounted or /home/ busy
mount: according to mtab, /dev/sda3 is already mounted on /home

Does anyone know what's going on here?


UPDATE: Alright, was just playing around on it and realised if I unmounted /dev/sda3 (my supposed /home partition), the folder "poltak" showed up in my /home directory and I could log in as my user again smile But that means something else is up... I think my /home partition is empty and the user in now on the / partition under the /home directory (I hope that made sense). Is this what you think? I don't want to move folders and partitions around just yet without a second (or more knowledgeable) opinion, as to be honest, I'm quite sick of messing with my SSD and almost regret buying the cursed thing now...

Anyway, the tar method worked, so I thank you lot a great deal for showing me this smile It will prove to be a good way to backup in the future.

Oh also, some feedback on the "cp -a" method:
It didn't work for me (or phrased better: I didn't do it properly). I got a stream of permissions errors as I tried to cp -a my / partition onto a remote directory using sshfs. I didn't bother with /home partition, I just went to the tar method and it worked. Any advice on the permissions errors? And yes, it was from the live CD.

Last edited by poltak (2011-05-30 03:01:46)


I like Arch

Offline

#15 2011-05-31 05:23:11

wetpaste
Member
Registered: 2011-02-14
Posts: 4

Re: Possible to "image" current Arch install to avoid re-installing?

I just wanted to add that the easiest way to make a carbon copy of your partition table for future use: you can just use "sfdisk -d /dev/sda > ptable-backup"  and to restore it you just do "sfdisk /dev/sda < ptable-backup"

Offline

#16 2011-05-31 08:04:59

poltak
Member
From: Hong Kong
Registered: 2010-11-05
Posts: 32

Re: Possible to "image" current Arch install to avoid re-installing?

wetpaste wrote:

I just wanted to add that the easiest way to make a carbon copy of your partition table for future use: you can just use "sfdisk -d /dev/sda > ptable-backup"  and to restore it you just do "sfdisk /dev/sda < ptable-backup"

Ah lovely smile Another useful command. Thanks for the addition.

And update on my previous post:
I managed to get my system working by mounting my /home partition to a temp location (say, /mnt), and then moving my user's home folder off the / partition and onto the /home partition. Then, of course, unmounting the /home from /mnt and back onto /home. It now works perfectly as before. Thanks a lot for all the help!


I like Arch

Offline

#17 2011-05-31 10:42:33

jeroenh
Member
Registered: 2010-02-11
Posts: 9

Re: Possible to "image" current Arch install to avoid re-installing?

You might also be interested in ReaR. It creates a rescue ramdisk for your system with layout parameters (including LVM, MD, LUKS). It can also create backups (tar,rsync,bacula,...) You can write the result to USB or to a network share.

Recent trunk builds support Arch, PKGBUILD in the contrib/ folder.

Offline

Board footer

Powered by FluxBB