4

So here I just installed Timeshift on my ubuntu 20.04 LTS. As I was trying to set up the backup of my entire system using timeshift, it shows that I can only save backup data on my primary partition. (Mind you that my system is dual-booted with windows 11)

I connected my external hard drive to my system to backup data on it using timeshift, but it shows that "The external hard drive does not have a linux partition" and hence I am unable to backup my data using timeshift.

Currently I have backed up my files normally using the "backups" option, on my external hard drive.

I am a newbie to linux, so I wanted to ask as to how can I create a Linux Partition on an external hard drive?

Also, is "Backup" enough to restore my files if my system somehow breaks down ?

The file system which my external hard drive shows is ExFat

Parth Rajawat
  • 153
  • 2
  • 7
  • What is the file system type on the external hard drive? NTFS ex4 or what? – David Mar 16 '22 at 13:37
  • it is exfat David – Parth Rajawat Mar 16 '22 at 13:41
  • 2
    Format the external drive to ext4 using gparted or "disks". This will cause the loss of all data on the drive. I have several pc's set up where I use timeshift to back up to a 64G USB thumb drive, it works fine. – Organic Marble Mar 16 '22 at 13:53
  • If you have data on the external drive you might want to shrink the partition first before adding a second partition which should be formatted to ext4 – PonJar Mar 16 '22 at 14:00
  • @PonJar Yeah, I am confused as to how do i shrink my external hard drive, I don't know how to do that in linux. – Parth Rajawat Mar 16 '22 at 14:02
  • @OrganicMarble I mean, I can do that but the size of my external Hard Drive is 1 TB, and I don't want to use my ENTIRE hard drive for linux timeshift. I wish to convert a particular amount of space of my hard drive to ext4 and save the rest for windows. – Parth Rajawat Mar 16 '22 at 14:05
  • Use gparted to shrink the partition and then make a ext4 part on that drive. BACK UP ALL DATA FIRST. Yes I had a typo before. – David Mar 16 '22 at 14:12
  • @David Yeah gparted is not allowing me to do that even after unmounting the disk. I click on resize option, then a new box opens and when i try to enter numbers to resize.... it does not work. Do i need to format it first to ext4 ? how do I specify the amount of size I want to convert to ext4 ? – Parth Rajawat Mar 16 '22 at 14:17
  • Search this site for questions on how to use gparted. – David Mar 16 '22 at 14:21
  • Maybe just get a 64G USB thumb drive and dedicate it to timeshift. – Organic Marble Mar 16 '22 at 14:28
  • 2
    @OrganicMarble Okay so I managed to do it, I dedicated 370 GB to Linux ext4 and the remaining 600+ GB to windows in ExFat format. I suppose, it will not harm my hard drive. Also, if i boot ubuntu without connecting this hard drive, will timeshift backup data on primary partition or wait for me to connect the hard drive to backup the data ? – Parth Rajawat Mar 16 '22 at 14:37
  • Nice job! Consider posting an answer, it may help others. It's perfectly OK to answer your own question here. – Organic Marble Mar 16 '22 at 14:38
  • @OrganicMarble Alright, I'll do that, thank you for all your help :) – Parth Rajawat Mar 16 '22 at 14:51

2 Answers2

2

Timeshift requires the external drive to be of type ext4.

Lets say /dev/sdb1 is the path to the external drive (adjust accordingly to your path with lsblk | grep sdb or check gparted)

You can use

sudo umount -lf /dev/sdb1 
mkfs.ext4 /dev/sdb1

to achieve that.

After this you are able to select your drive in Timeshift.

OuttaSpaceTime
  • 238
  • 2
  • 9
1

Another option, although maybe less friendly, is to use dd to perform any backups. It requires a HDD with enough space to store a partition/drive the same size as the one being backed up. dd creates an exact copy of your drive (including free space & deleted files) which makes it perfect for backups as you can literally just switch the hard drives out or copy it over to a new partition.

First you need to boot from live usb. Then run sudo fdisk -l which will list all connected drives and partitions. This will list all sorts of useful information. Take not of the /dev/nvme* or /dev/sd* as this is the drive/partition path. Take note of your block size. The output should look something like this:

Disk /dev/nvme0n1: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors
    Disk model: Samsung SSD 980 1TB                     
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 16384 bytes / 131072 bytes
    Disklabel type: gpt

Device              Start        End   Sectors   Size Type
/dev/nvme0n1p1       2048     206847    204800   100M EFI System
/dev/nvme0n1p2     206848     239615     32768    16M Microsoft reserved
/dev/nvme0n1p3     239616  773042175 772802560 368.5G Microsoft basic data

Then you can use gparted to make a partition on the external hard drive the appropriate size.

Once that is done open your terminal and type sudo fdisk -l. From the out put of this you should be able to tell which partition you have created (helps to compare the command before and after creating the partition to identify any differences although that is not entirely necessary).

Then use the following command

dd if=/dev/sdX of=/dev/sdX bs=XXXX conv=noerror,sync status=progress

It takes a bit of time to copy but because it creates an exact copy (including free space) it's perfect for backing up your hdd. Just make sure to do it regularly or backups will get outdated. For larger drives you may need to leave it running overnight - or automate it into a background task using cron. It can be sped up by increasing the blocksize to bs=16M or something similar but this can lead to error propagation if there are errors in your data.

This method is cumbersome can't be done as an automated backup but it is reliable and the drive that you backup can be immediately switched out.

theYnot
  • 629
  • 5
  • 12
  • I get some part of it and I would actually have to do it to understand. But doesn't Timeshift do the exact same things ? It creates the exact copy of the system, albeit at a particular time ? – Parth Rajawat Mar 17 '22 at 10:28
  • 1
    TimeShift is far more space efficient and simpler to restore. It provides multiple restore points and is designed for system restoration. dd will work but it’s not as convenient for the task TimeShift is designed for – PonJar Mar 17 '22 at 12:17
  • @PonJar - Thank you, I did offer it as an alternative.. Once I worked with `dd` and had to do a few drive recoveries I never needed to look any further. I've had drives fail and it's nice to be able to just swap it out and carry on. Is TimeShift suitable for that or does it then make it a multi-step process where you need to re-install your os and then restore? – theYnot Mar 18 '22 at 23:06
  • TimeShift is designed to restore your system files (not data) to a previous working state when you have done something that breaks it, typically before a system upgrade. I don’t think it’s intended to restore after a drive failure but I think you could do that with a bit of extra work and a data backup. `dd` is better in that case if you have taken the time to create the image. Have you tried clonezilla? – PonJar Mar 19 '22 at 08:40