Pages

Showing posts with label bootloader. Show all posts
Showing posts with label bootloader. Show all posts

2013-05-28

Fsarhiver, moving OS

And also backing up all shit, of course.
Links of backing up  and to get SystemRescueCD (has fsarchiver and partimage). Especially first link gives nice overview what happens and so on. Also link to fsarchiver itself.
The following is not so much of backing up, but of moving your (backed-up) distro to entirely different partition.
I chose Fsarchiver because it can write to a partition of different size of original... PartImage can not. Other option could be Remastersys, of course. Somehow it seemed more difficult to me... might be - for no reason.
Anyway, it's an AAR of moving installed distro to another partition, AND making it also a master of multibooting Grub2. Yes-yes, finally I am going to remove my Openboxed Xubuntu from this exalted position and elevate freshly-cooked Wheezy Openbox to be the new boot-boss.

What I did:
Dramatis personae: sdb/MBR - bootloader from sdb6 Xubuntu, sdb8 Vsido, sdb9 Wheezy, sdc2 is a backup partition.
Vsido has fsarchiver out of box - if you don't (have Vsido or fsarchiver), install it.
I started in Vsido, opened terminal and:

# mount a partition to put an archive on
sudo mkdir /mnt/back 
sudo mount /dev/sdc2 /mnt/back 
# make backup
sudo fsarchiver -j2 savefs /mnt/back/backup-sdb9-deb.fsa /dev/sdb9
# last command creates a file from whole sdb9 and puts it to sdc2. 3G was compressed to one and it took 4 minutes. -j2 means that my old AMD X2 can use both cores for this task.
If curious what's in there:
sudo fsarchiver archinfo /mnt/back/backup-sdb9-deb.fsa
# Shows you some information about the file.
sudo umount /mnt/back


Then I rebooted and logged into Wheezy - thinking that then I wouldn't have problems with different grub versions... As I realized afterwards: there is no difference - when chrooted in, you download proper grub anyway.
And another afterthought: it might have been really wiser to make that bloody live usb and do the thing from there - less problems with uuids.
Opened Gparted and formatted sdb6 to ext4. Xubuntu died - and together with it, booting Grub. No going back now...
Then I restored previously created archive to sdb6 (and id=0 means that there is only one file-system in archive):

sudo mkdir /mnt/back 
sudo mount /dev/sdc2 /mnt/back
sudo fsarchiver -j2 restfs /mnt/back/backup-sdb9-deb.fsa id=0,dest=/dev/sdb6
sudo umount /mnt/back 
TWO important things to do now:
1. Fix /etc/fstab of your new 'installation'. Because uuid remained the same for both Wheezys, I couldn't mount the other one. @#%$#@@ and shit! So I opened fstab of old one and replaced uuid with /dev/sdb9. After that I could mount and fix fstab of the new Wheezy: I also replaced this uuid - in this case with /dev/sdb6 (as root partition) and that was that.
2. Harder part. Fsarchiver writes things back, BUT it doesn't put them into exactly the same place. So, you have to reinstall your Grub. Even if the partition is the same you started with.
In my case, it was different and I also needed already installed root-grub to be replaced by new mbr-grub.
Mount-chroot-purge-install-update:

sudo mount /dev/sdb6 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
apt-get purge grub-common
# 4 packages get removed
apt-get install grub-pc
# 4 comes. AND it asks WHERE to install. Do NOT answer wrong!
update-grub
# Somehow, it missed Vsido. (But I got it after reboot.)
exit
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys
sudo umount /mnt
sudo reboot
If someone wants to play with uuids, then blkid shows uuids of all partitions, and uuidgen can produce new random uuids. Then do:
sudo tune2fs /dev/sdb6 -U number-you-generated. And your sdb6 partition has a new uuid.

My new 'bootmaster' booted without problems, and additional fast 'update-grub' found, yes, everything that was bootable.
I am not sure if installing from remastersys-backup is not a better way. But doing it with fsarchiver was certainly educating... though somewhat scary.

2013-02-22

1. Foreplay before install


2012, spring
Being somewhat suspicious in nature and averse to continuous fixing-and-reinstalling, I did some careful reading on topic. And remember, I am a noob, I couldn't make difference between ext4 and ntfs – not that I knew the first one existed.

Linux partitioning:
No simple letters are used for drives (c:, d: and so on). Your hard disk is hd or sd, the first one is sda, then comes sdb. The first partition on first drive is sda1, then comes sda2 … and so on. By the way - on your desktop you do not see those anymore. They will be renamed for your convenience or, as it really is, for a convenience and/or by whim of your distro maker. You can look them up with some disk tool like Gparted.
TIP. Partitions:
a) Wise and old-fashioned operator makes a separate boot partition – and 300 kB is enough,
b) Then root partition, known as /, should be at least 10 GB – despite what you see when googling. I made 7GB partition and was hit by disk-full warning in second day. And without any special efforts. When experimenting and installing, it is very easy to fill up the root.
c) Swap partition, 2 gigas if the computer has less or equal to 2 GB of real memory. If there is more, reduce it to 1 GB and let it be – no need to philosophy if it's really needed in modern times. Some distros wouldn't even install without it.
d) ~home partition, with size according to needs. 10 gigas or more, maybe?
e) As a noob, don't bother to make separate /etc, /bin and whatnot partitions.

Making a bootable USB stick:
For making bootable USB-stick - Unetbootin is your friend. NB! Not every distro likes Unetbootin – some even have warning about it (Mageia comes to mind).
Hybrid iso image is needed, pure CD-one fits for CD only. (Times have moved on (as of 2013), and most of 'easy distro' images are hybrid (and live)).
It's handy to know which type processor you have – not that it's not handy knowledge when using Windows as well. Means, 64bit system can use 32bit operational system and soft, but not the vice versa.
Then there are many more intriquing questions to ask, like: Where to install my bootloader. How to avoid overwriting my dear Windows's MBR. What to do if I did. Whole multiboot epic – with very practical question: should I read tips more than 3 hours, or should I commit before it gets totally confusing.
TIP: What did I do to avoid such a tearful situation (fuck-up of MBR):
Requires two hard disks!
Make room at the beginning of the second (EASUSE Partition Master is OK, and free). 25 Gigas is a good number, and more doesn't hurt. By 'making room' I mean creating unallocated space; resizing your windows partition by amount you need for Linux.
When booting to start Linux installation (boot-ready USB inserted), in BIOS switch your hdd's boot order to this second hdd – it should be next after the 'removable device'=USB, which will be the first, of course. When already installing/partitioning, put your grub (bootloader) into MBR of the second device (which should be labeled as hdb or sdb. Do NOT put it into volume – which is hdb2 or some other number.
If your install is successful, and you reboot your machine – without USB-stick and probably no need to visit BIOS (no stick detected and boot default goes to next device), you will be greeted with bootloader menu – which also contains your windows startup option. Now, in future - if you happen to fuck up your grub conf (not so difficult to do) and your booloader refuses to boot, you can go to BIOS, swap your Windows drive back as a first boot drive – and you can start you old pal Windows and contemplate over the sad fate that have befallen on you... and you still have a working operating system and can google for help.
(General info: Google: 'Linux partitions'. Or look here, the page has also strong, suggestive colors, as a bonus.)

Then I tried to understand what 'distro' means and what desktop environment (DE) means.
I read some reviews and comparisons of distros. And came to somewhat fuzzy and unsure conclusion that good point to start is Ubuntu family... No, not really – it was probably a fluke that I started with Linux Mint. Or that Mint's home page is pleasantly info-rich. I mean it actually contains info, tutorials and has lively forum. As opposed to many pages that seem to be a poetry-like lines of laconic statements of releases. Shit, some of them doesn't have even md5 sum to check... Which is the number that tells you if your downloaded ISO is exactly the same that you started with (no errors).
In Windows command line: md5sum.exe yourISOname.iso. Wait. Number appears. If it's the same as the one you copied from download page for checking, you are golden.
Windows version you have to download. In Linux, md5sum is – it is told – already included in most distros. Usage is the same. But do 'man md5sum' if sillily curious.
Oh, and there are 'live' images' and there are 'normals' for stright installation. The first one boots to live environment so the victim can take a look how the environment will look and work. Live loads all stuff into memory, and does not touch your precious hard drives.
DE – Desktop Environment (overview, and another one): Well, bunch of things that make colorful and usable (in idea at least) desktop for us to play on. There are 4 bigger (more users) ones – Gnome, KDE, XFCE and LXDE. And several lesser ones: newcomers Razor-qt, Cinnamon and Mate, then nerdy boxen (Fluxbox, Openbox), freaky Enlightenment, and almost dead old ones. Google for whole zoo... there was somewhere big sad table of the past and present.
Ah, yes, almost forgot – distros – distributions, really – are all those different names and flavors that inhabit Linux ecosystem. Like Linux Mint, Mageia Linux, Red HatEnterprise Linux, SolusOs, Ubuntu and so on.
There are hundreds of them. Choice and freedom? Yes – but for developers only in many cases. Most of distros are marginal for different reasons – they lack support, documentation, real development... they install and work only occasionally and through huge effort... and bagful of bugs are quaranteed. Not so much choice for a dumbuser who wants just to use operational system. When googling about things-Linux I found several times opinions that Linux is not meant for feebleminded normal users. Fortunately for us morons, there also are distros that have fallen to that shameful 'user' level.
So, installing it will be in next chapter.