cloning partitions (windows 8) with gpt table from linux kubuntu acronis


 

WARNING
I DO NOT TAKE ANY RESPONSIBILITY FOR LOSS OF DATA AND PARTITIONS. THIS ARTICLE IS PUBBLIC BUT IT’S MADE FOR MY OWN USE ONLY.

IF YOU LOST DATAS AND PARTITIONS IT’S NOT MY FAULT, THIS ARTICLE IS NOT FOR NOOBS, PLEASE BE CAREFULL WITH DD .

All the article it’s just based on these commands :

BACKUP

sudo dd if="/dev/sdXY_INPUT_DEVICE" of="OUTPUTFILE" bs=4096 conv=notrunc,noerror

RESTORE

sudo dd  if="INPUT_FILE_NAME" of="/dev/sdXY_OUTPUT_DEVICE"

so for example if you don’t trust my code do :

BACKUP sdb1 partition

sudo dd if="/dev/sdb1" of="$HOME/sdb1_image.img" bs=4096 conv=notrunc,noerror

RESTORE sdb1 partition

sudo dd  if="$HOME/sdb1_image.img" of="/dev/sdb1"

NOWARDEV BASHRC RESTORE AND BACKUP FUNCTIONS

now i am lazy so i have created my own bashrc with nice progress bar (that require pv program )

backup_partitions

THIS IS MY OWN EXPERIENCE SO IF YOU ARE DOING THE SAME STUFF I AM NO RESPONSIBLE OF ANY DATA LOST

i have created 2 bashrc functions to help me to backup and restore

backup_partition
restore_partition

to use these functions you need of :

pv
dd

pv it’s only to monitor dd work and to print % but probably you are missing it so :

sudo apt-get install pv

1)put this code on ~/.bashrc file that it’s in your home

backup_partition(){

#Copyright (C) 2015 nowardev nowardev@gmail.com

#This file is part of kde-peace-settings.

#kde-peace-settings is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

if [[ "$1" == -* ]]; then
	case "$1" in
		-h) echo "backup_partition input_dev ouput_dev" ; return ;;
	esac
fi
echo
if [[ ! -z $(ls /dev | grep "${1##*/}") &&  -d  "$2"  ]] ; then
	if [[ ! -z $(grep "$1" /proc/mounts) ]]; then
		echo $"$1 it's mounted please umount it before."
		return
	else
		date="$(date +"%d-%m-%y")"
		outname="$2/${1##*/}_$date.img"
		outname=${outname/\/\//\/} #remove potential // problem
		echo $"do you want execute \"sudo dd if=\"$1\" of=\"$outname\" bs=4096 conv=notrunc,noerror\" (y\n) ?"
		read
		echo "$REPLY"
		case "$REPLY" in
			[yY]|[yY][eE][sS])

				sudo pv -p -t "$1" | dd  of="$outname" bs=4096 conv=notrunc,noerror

			;;

			[nN]|[nN][oO])
				echo $"user exit"
				return
			;;
		esac

	fi
else
	echo $"$1 it's a valid partition ? and $2 it's really folder ?"

fi
}

restore_partition(){
#Copyright (C) 2015 nowardev nowardev@gmail.com

#This file is part of kde-peace-settings.

#kde-peace-settings is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

if [[ "$1" == -* ]]; then
	case "$1" in
		-h) echo "restore_partition  output_device  INPUT_FILE" ; return ;;
	esac
fi

if [[ ! -z $(ls /dev | grep "${1##*/}") &&  -e  "$2"  ]] ; then
	if [[ ! -z $(grep "$1" /proc/mounts) ]]; then
		echo $"$1 it's mounted please umount it before."
		return
	else
		echo $"doing sudo dd of="$1" if="$2" ?  (y\n) "
		read   

		echo $REPLY
		case "$REPLY" in

		[yY]|[yY][eE][sS])

		sudo pv -p -t "$2" | dd   of="$1"  

		;;

		[nN]|[nN][oO])
		echo $"user exit"
		return
		;;
		esac

	fi
else
	echo $"$1 it's a valid partition ? and $2 it's really a file ?"

fi

}

2)do , in a terminal , where you will perform every commands:

source ~/.bashrc 

ok now you are ready to clone yours partitions in files :

if you type

backup_partition -h

or

restore_partition -h

you will get help :

backup_partition input_dev ouput_dev
restore_partition output_device INPUT_FILE

so let me show you my miserable partitions table with lsblk , i know my partition table and i know that 605GB it’s the folder where i store my files and the 54GB it’s the windows partition , instead sdb1 it’s the uefi stuff .

sdb      8:16   0 698,7G  0 disk
├─sdb1   8:17   0   260M  0 part
├─sdb2   8:18   0   1,5G  0 part
├─sdb3   8:19   0   260M  0 part
├─sdb4   8:20   0   128M  0 part
├─sdb5   8:21   0  54,6G  0 part
├─sdb6   8:22   0 605,4G  0 part
└─sdb7   8:23   0  27,1G  0 part

BACKUP A PARTITION WITH MY BASHRC FUNCTIONS

so now i will use sdb6 to store every sdb1 sdb2 …. etc partitions . i will mount the partition sdb6 into a folder so :

sudo mkdir /media/sem/myownbackuppart

now my sdb6 it’s formated into ntfs so i will use :

sudo mount -t ntfs-3g /dev/sdb6 /media/sem/myownbackuppart

now i will backup the partition with this : MAKE SURE TO SET LIKE FIRT ARGUMENT THE DEVICE !

backup_partition /dev/sdb1 /media/sem/myownbackuppart/

this command will generate a file called sdb1_31-12-14.img here /media/sem/myownbackuppart/

now we will do the same thing for every partition

RESTORE THE PARTITION

restore_partition /dev/sdb1 /media/sem/myownbackuppart/sdb1_31-12-14.img

and you have done , i have tested this method in my computer and it works i hope it will work for you too .

now the bashrc functions that lets you to clone a partition in an img file :

Here i will save the informations to bakcup and restore the partition table

BACKUP PARTITION TABLE GPT

sgdisk -b - /dev/sdb > /mnt/sdb6/gpt-table-windows_hdd

RESTORE PARTITION TABLE GPT

sgdisk -l - Gg /dev/sdb < /mnt/sdb6/gpt-table-windows_hdd

startkde $DISPLAY is not set or cannot connect to the X server


if you are not be able to login and you are stuck in kdm lightdm sddm window this can be helpfull for you :

there are a lots of issues that can develop this situation in your machine so i will list them here :

these are really funny but i had even these situations 😀

-no space left in /var

-no space left in /

-no space left in /home

-no plasma-desktop or plasmashell installed

these instead are really normal

-bad video driver installed

-bad xorg manually configurated

-bad init file

i guess these are the most frequent issues so let’s try to find out which one is your issue, if you are skilled you could just read this

fgrep '(EE)' /var/log/Xorg.0.log

but if you are not a skilled user… 🙂 we will start with some weird errors l

FIRST STEP PREPARE THE TERMINAL TO TEST YOUR MACHINE

Try to start another terminal session being freezed on kdm window pressing these keys : (NOTE TO GET BACK CTRL ALT F7 it’s the normal session … so if you need to go back just do that.)

CTRL ALT F4

Now you have to login with your password after that :

CHECK IF PLASMA-DESKTOP IS INSTALLED

sometime plasma-desktop is not installed so …

run this command kde4 first command kde5 if you have the latest:

type plasma-desktop #kde4
type plasmashell #kde5

if both are empty then you have not plasma installed 😀 , so … if you have not plasma-desktop or shell installed well install it 🙂

(sudo apt-get install plasma-desktop # or similar )

try to login from the console and try to start kde with thi command:

startkde

if nothing happen and you get stuck just do again CTRL ALT F4 or just use again the terminal

CHECK IF YOUR KDE CONFIGURATION HAS SOMETHING OF STRANGE

this code will start kwin without 3d effects … and start system settigns … so you can disable desktop effects … this is not a good stuff i mean it should work and it could be a problem with your video drivers …or it could be just a wrong configuration that you have tried not compatible with your drivers .

KDE4 VERSION

DISPLAY=:0 && KWIN_COMPOSE=N kwin --replace & systemsettings & echo

KDE5 VERSION

DISPLAY=:0 && KWIN_COMPOSE=N kwin_x11 --replace & systemsettings & echo

another test that you could try it’s to rename or maybe mv the kde configs folder

Maybe you don’t remember but you could have done something to kde configs so try to rename your ~/.kde , in some distro ~/.kde4 , in new kde5 you have ~/.config and~/.local   and now try again

KDE5 VERSION

mv ~/.config ~/.configOLD
mv ~/.local ~/.localOLD

KDE4 VERSION

mv ~/.kde ~/.kdeOLD

or

mv ~/.kde4 ~/.kdeOLD

again

try to login from the console and try to start kde with:

startkde

if even with a new configs it doesn’t start … you have system bad configs or bad driver … if says

$DISPLAY is not set or cannot connect to the X server

try to set DISPLAY:0.0 in this way :

export DISPLAY=:0.0 ; startx

if it fails

CHECK XINITRC FILE

in my case i had a bad xinitrc so i have edited this file :

sudo nano /etc/X11/xinit/xinitrc

added this line

exec startkde

pressed CRTL X and saved …

to the terminal :

startx

If it fails :

CHECK IF X CAN STARTS ITSELF PROPERLY WITHOUT KDE

make sure you have twm installed xterm and xclock

if kde doesn’t start try to see if at least X can run with another stuff , disable exec startkde putting # before put this shit on xinitrc

# exec startkde
# start some nice programs

twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66+0+0 -name login

you should see something like this , it’s not the same but it looks like this

xclock

if you can see xterm and xclock just type exit and press enter to exit. X is installed properly and the video driver should work fine.

CHECK IF YOU HAVE INSTALLED PROPERLY YOUR VIDEO DRIVER

here i can’t help you because it depends on your video card . To get your video card you can try this

lspci | grep -i vga

i got an ati so i need to :

ATI

sudo apt-get install --reinstall xserver-xorg-video-ati xserver-xorg-core xserver-xorg

if you have another video card you need to replace xserver-xorg-video-ati with one of these :

xserver-xorg-video-nouveau

xserver-xorg-video-intel

xserver-xorg-video-sis

SPACE LEFT SITUATION

as i said before you could have some problem of space , yeah! if you have not enough space in your haddrive kde could even not start … so …

to check this funny stuff you need to use this command line i have excluded HOME because normally it’s the biggest folder in my partition table but anyway if you have 1 partition only you can just remove that option from this command line

cd /; du --block-size=M --max-depth=1 --exclude=home --exclude=archivio --exclude=proc 2>/dev/null | sort -n

it will print a list like this :

2M ./.kde

3M ./oldkde

4M ./Lightworks

5M ./logs

111M ./.mozilla

111M ./.thumbnails

146M ./.q3a

390M ./.config

556M ./.local

1034M ./bin

1389M ./.cache

1404M ./VirtualBox VMs

5159M .

check the biggest folder and remove your stuff tipically you can remove safely /var/tmp/stuff or maybe you can just try to it to another harddrive just to be sure to not lose datas… but they should be only temp-files i had this issue one time for example for a bug in kde …

hope it will help you to start kde again 🙂

trick

start kwin without compisition KDE 4 COMMAND

KWIN_COMPOSE=N kwin --replace

start kwin without compisition KDE 5 COMMAND

KWIN_COMPOSE=N kwin_x11 --replace

Darik’s Boot And Nuke , After dban unable to boot linux or any os


i have used Darik’s Boot And Nuke , to delete my 2 laptop’s hd , so … after that i have installed without problems linux and everything was ok.

but they did not boot…. but i have fixed thank to irc guys again

so why ? i dunno anyway i have followed these tutorial to fix mbr :

1 i have done this but i don’t believe that it’s necessary : (note i had only linux so i have installed in the first partition that is called sda in my system you need to change the code if yours it’s different , sudo fdisk -l will help you to understand where is windows if you have , or the first partition anyway.)

sudo fdisk -l ; sudo ms-sys -w /dev/sdxxx

then

i have just restored grub2

note that fdisk should tell you where is installed kubuntu , if you don’t know just try to see where is installed with a live cd .

so i will use sda1 cuz my system was installed on sda… change the code if you need it

sudo fdisk -l ; sudo mount /dev/sda1 /mnt ; sudo mount --bind /dev /mnt/dev; sudo mount --bind /proc /mnt/proc; sudo mount --bind /sys /mnt/sys ; sudo chroot /mnt ; grub-install /dev/sda ;  update-grub2