Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 874  / 1 Year ago, wed, january 4, 2023, 11:35:23

This question is asked many times but I haven't got the right answer.



What I want is to create a partition where I backup my current Ubuntu partition that appears in the GRUB menu. If one day my Ubuntu won't to start I lunch the backup partition and voila my system is restored.



Currently I use CloneZilla but the problem is I must have always on me a usb key that contains CloneZilla.



EDIT:



df -h
/dev/sda5 55G 39G 14G 74% /
none 4,0K 0 4,0K 0% /sys/fs/cgroup
udev 997M 4,0K 997M 1% /dev
tmpfs 202M 1,2M 200M 1% /run
none 5,0M 0 5,0M 0% /run/lock
none 1006M 8,0K 1006M 1% /run/shm
none 100M 36K 100M 1% /run/user
parted -l
nothing

More From » grub2

 Answers
6

Just for note. There is many good methods that provide backing up your system, some of them also provide incremental backups.



Answering exactly what you want step by step



As I can see from your df -h output, you do not distribute your /boot, /usr, /var and other folder to a different partitions. So



1.
First of all you should create your Live CD or bootable USB stick with Ubuntu. Here is guide for Live CD and for USB stick.



2.
Now boot Ubuntu from CD or USB, you should see a menu with "Try Ubuntu without any change to your computer" at the top. In loaded Ubuntu open gnome-terminal (Ctrl + Alt + T), and run sudo gparted. Create new 55Gb ext4 partition using this tutorial. Remember this new partition name, it should something like /dev/sda6.



3.
Now you should mount your new successfully created partition (Lets say /dev/sda6) and your previous partition /dev/sda5. And copy all your files and folders hierarchy. Open gnome-terminal and do this line by line:



sudo mkdir /media/old_partition
sudo mkdir /media/new_partition
sudo mount /dev/sda5 /media/old_partition
sudo mount /dev/sda6 /media/new_partition
sudo cp -ax /media/old_partition /media/new_partition


This last command can work very long. Do not interrupt it. It should output nothing at the end if everything is ok.



Little quote from this guide.



cp -ax / /new-disk



This is the simplest method, but will only work if your original Linux system is on a single disk partition.
The -a option preserves the original system as much as possible. The -x option limits cp to a single file system; this is necessary to avoid copying the /new-disk and /proc directories.



4.
Now you need to update fstab in your new backup partition.



Find UUID of /dev/sda6 (new partition):



sudo blkid /dev/sda6


Find UUID of /dev/sda5 (old partition):



sudo blkid /dev/sda6


Then edit /media/new_partition/etc/fstab:



sudo gedit /media/new_partition/etc/fstab


And substitute UUID of /dev/sda5 to UUID of /dev/sda6. Be carefully, substitute only UUID.



5.
Now adding new entry to grub menu. Open /media/old_partition/etc/grub.d/40_custom using gedit and add this at the
end of the file:



menuentry "Boot backup Ubuntu" {
set root=UUID=XXXX-YYYY
linux /vmlinuz root=UUID=XXXX-YYYY ro quiet splash
initrd /initrd.img
}


Where XXXX-YYYY is UUID of new partition (/dev/sda6).



6.
Unmount everything and reboot. Before do this close everything what you have opened (gparted, gnome-terminal, gedit, others).



sudo umount /dev/sda5
sudo umount /dev/sda6
sudo reboot


Remove your LIVE bootable device.



Now you should see new entry in your grub boot menu.



Notice that this method do not backing up other than / mount points, such as /home, /var, /usr others, if they distributed between partitions. In such situation you should do steps 2-4 for each partition.


[#27349] Wednesday, January 4, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
njuash

Total Points: 402
Total Questions: 125
Total Answers: 98

Location: Jersey
Member since Sun, Dec 4, 2022
1 Year ago
njuash questions
Wed, Jun 8, 22, 11:53, 2 Years ago
Wed, Nov 30, 22, 11:42, 1 Year ago
Mon, May 30, 22, 04:33, 2 Years ago
Mon, Apr 10, 23, 03:40, 1 Year ago
;